/[drupal]/contributions/sandbox/timcn/soc/generic.patch
ViewVC logotype

Contents of /contributions/sandbox/timcn/soc/generic.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Aug 22 10:49:59 2006 UTC (3 years, 3 months ago) by timcn
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-patch
Forgot the updated patch.
1 Index: includes/common.inc
2 ===================================================================
3 RCS file: /cvs/drupal/drupal/includes/common.inc,v
4 retrieving revision 1.559
5 diff -u -d -F^\s*function -r1.559 common.inc
6 --- includes/common.inc 22 Aug 2006 09:00:30 -0000 1.559
7 +++ includes/common.inc 22 Aug 2006 10:30:18 -0000
8 @@ -1335,6 +1335,7 @@ function drupal_add_js($data = NULL, $ty
9
10 if (empty($javascript['header']['core']['misc/drupal.js'])) {
11 drupal_add_js('misc/drupal.js', 'core');
12 + drupal_add_js('misc/jquery.js', 'core');
13 }
14 }
15
16 Index: includes/menu.inc
17 ===================================================================
18 RCS file: /cvs/drupal/drupal/includes/menu.inc,v
19 retrieving revision 1.133
20 diff -u -d -F^\s*function -r1.133 menu.inc
21 --- includes/menu.inc 20 Aug 2006 05:57:40 -0000 1.133
22 +++ includes/menu.inc 22 Aug 2006 10:30:52 -0000
23 @@ -695,7 +695,9 @@ function theme_menu_item($mid, $children
24 * @ingroup themeable
25 */
26 function theme_menu_item_link($item, $link_item) {
27 - return l($item['title'], $link_item['path'], isset($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
28 + return l(
29 + liveedit_label($item['title'], 'js/menu/item/title', $link_item['path'], array('mid' => (string)$item['mid'])),
30 + $link_item['path'], isset($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL, NULL, FALSE, TRUE);
31 }
32
33 /**
34 @@ -714,6 +716,8 @@ function menu_item_link($mid, $theme = T
35 while ($link_item['type'] & MENU_LINKS_TO_PARENT) {
36 $link_item = menu_get_item($link_item['pid']);
37 }
38 +
39 + $item['mid'] = $mid;
40
41 if ($theme) {
42 $link = theme('menu_item_link', $item, $link_item);
43 Index: misc/autocomplete.js
44 ===================================================================
45 RCS file: /cvs/drupal/drupal/misc/autocomplete.js,v
46 retrieving revision 1.12
47 diff -u -d -F^\s*function -r1.12 autocomplete.js
48 --- misc/autocomplete.js 20 May 2006 07:23:47 -0000 1.12
49 +++ misc/autocomplete.js 22 Aug 2006 10:30:55 -0000
50 @@ -1,76 +1,52 @@
51 // $Id: autocomplete.js,v 1.12 2006/05/20 07:23:47 drumm Exp $
52
53 -// Global Killswitch
54 -if (isJsEnabled()) {
55 - addLoadEvent(autocompleteAutoAttach);
56 -}
57 -
58 /**
59 * Attaches the autocomplete behaviour to all required fields
60 */
61 -function autocompleteAutoAttach() {
62 +Drupal.autocompleteAutoAttach = function () {
63 var acdb = [];
64 - var inputs = document.getElementsByTagName('input');
65 - for (i = 0; input = inputs[i]; i++) {
66 - if (input && hasClass(input, 'autocomplete')) {
67 - uri = input.value;
68 - if (!acdb[uri]) {
69 - acdb[uri] = new ACDB(uri);
70 - }
71 - input = $(input.id.substr(0, input.id.length - 13));
72 - input.setAttribute('autocomplete', 'OFF');
73 - addSubmitEvent(input.form, autocompleteSubmit);
74 - new jsAC(input, acdb[uri]);
75 + $('input.autocomplete').each(function () {
76 + var uri = this.value;
77 + if (!acdb[uri]) {
78 + acdb[uri] = new Drupal.ACDB(uri);
79 }
80 - }
81 + var input = $('#' + this.id.substr(0, this.id.length - 13))
82 + .attr('autocomplete', 'OFF')
83 + .get(0);
84 + $(input.form).submit(Drupal.autocompleteSubmit);
85 + new Drupal.jsAC(input, acdb[uri]);
86 + });
87 }
88
89 /**
90 * Prevents the form from submitting if the suggestions popup is open
91 + * and closes the suggestions popup when doing so.
92 */
93 -function autocompleteSubmit() {
94 - var popup = document.getElementById('autocomplete');
95 - if (popup) {
96 - popup.owner.hidePopup();
97 - return false;
98 - }
99 - return true;
100 +Drupal.autocompleteSubmit = function () {
101 + return $('#autocomplete').each(function () {
102 + this.owner.hidePopup();
103 + }).size() == 0;
104 }
105
106 -
107 /**
108 * An AutoComplete object
109 */
110 -function jsAC(input, db) {
111 +Drupal.jsAC = function (input, db) {
112 var ac = this;
113 this.input = input;
114 this.db = db;
115 - this.input.onkeydown = function (event) { return ac.onkeydown(this, event); };
116 - this.input.onkeyup = function (event) { ac.onkeyup(this, event) };
117 - this.input.onblur = function () { ac.hidePopup(); ac.db.cancel(); };
118 - this.popup = document.createElement('div');
119 - this.popup.id = 'autocomplete';
120 - this.popup.owner = this;
121 -};
122
123 -/**
124 - * Hides the autocomplete suggestions
125 - */
126 -jsAC.prototype.hidePopup = function (keycode) {
127 - if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) {
128 - this.input.value = this.selected.autocompleteValue;
129 - }
130 - if (this.popup.parentNode && this.popup.parentNode.tagName) {
131 - removeNode(this.popup);
132 - }
133 - this.selected = false;
134 -}
135 + $(this.input)
136 + .keydown(function (event) { return ac.onkeydown(this, event); })
137 + .keyup(function (event) { ac.onkeyup(this, event) })
138 + .blur(function () { ac.hidePopup(); ac.db.cancel(); });
139
140 +};
141
142 /**
143 * Handler for the "keydown" event
144 */
145 -jsAC.prototype.onkeydown = function (input, e) {
146 +Drupal.jsAC.prototype.onkeydown = function (input, e) {
147 if (!e) {
148 e = window.event;
149 }
150 @@ -89,7 +65,7 @@ function jsAC(input, db) {
151 /**
152 * Handler for the "keyup" event
153 */
154 -jsAC.prototype.onkeyup = function (input, e) {
155 +Drupal.jsAC.prototype.onkeyup = function (input, e) {
156 if (!e) {
157 e = window.event;
158 }
159 @@ -126,21 +102,21 @@ function jsAC(input, db) {
160 /**
161 * Puts the currently highlighted suggestion into the autocomplete field
162 */
163 -jsAC.prototype.select = function (node) {
164 +Drupal.jsAC.prototype.select = function (node) {
165 this.input.value = node.autocompleteValue;
166 }
167
168 /**
169 * Highlights the next suggestion
170 */
171 -jsAC.prototype.selectDown = function () {
172 +Drupal.jsAC.prototype.selectDown = function () {
173 if (this.selected && this.selected.nextSibling) {
174 this.highlight(this.selected.nextSibling);
175 }
176 else {
177 - var lis = this.popup.getElementsByTagName('li');
178 - if (lis.length > 0) {
179 - this.highlight(lis[0]);
180 + var lis = $('li', this.popup);
181 + if (lis.size() > 0) {
182 + this.highlight(lis.get(0));
183 }
184 }
185 }
186 @@ -148,7 +124,7 @@ function jsAC(input, db) {
187 /**
188 * Highlights the previous suggestion
189 */
190 -jsAC.prototype.selectUp = function () {
191 +Drupal.jsAC.prototype.selectUp = function () {
192 if (this.selected && this.selected.previousSibling) {
193 this.highlight(this.selected.previousSibling);
194 }
195 @@ -157,30 +133,61 @@ function jsAC(input, db) {
196 /**
197 * Highlights a suggestion
198 */
199 -jsAC.prototype.highlight = function (node) {
200 - removeClass(this.selected, 'selected');
201 - addClass(node, 'selected');
202 +Drupal.jsAC.prototype.highlight = function (node) {
203 + if (this.selected) {
204 + $(this.selected).removeClass('selected');
205 + }
206 + $(node).addClass('selected');
207 this.selected = node;
208 }
209
210 /**
211 * Unhighlights a suggestion
212 */
213 -jsAC.prototype.unhighlight = function (node) {
214 - removeClass(node, 'selected');
215 +Drupal.jsAC.prototype.unhighlight = function (node) {
216 + $(node).removeClass('selected');
217 + this.selected = false;
218 +}
219 +
220 +/**
221 + * Hides the autocomplete suggestions
222 + */
223 +Drupal.jsAC.prototype.hidePopup = function (keycode) {
224 + // Select item if the right key or mousebutton was pressed
225 + if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) {
226 + this.input.value = this.selected.autocompleteValue;
227 + }
228 + // Hide popup
229 + var popup = this.popup;
230 + if (popup) {
231 + this.popup = null;
232 + $(popup).fadeOut('fast', function() { $(popup).remove(); });
233 + }
234 this.selected = false;
235 }
236
237 /**
238 * Positions the suggestions popup and starts a search
239 */
240 -jsAC.prototype.populatePopup = function () {
241 - var ac = this;
242 - var pos = absolutePosition(this.input);
243 +Drupal.jsAC.prototype.populatePopup = function () {
244 + // Show popup
245 + if (this.popup) {
246 + $(this.popup).remove();
247 + }
248 + var pos = Drupal.absolutePosition(this.input);
249 this.selected = false;
250 - this.popup.style.top = (pos.y + this.input.offsetHeight) +'px';
251 - this.popup.style.left = pos.x +'px';
252 - this.popup.style.width = (this.input.offsetWidth - 4) +'px';
253 + this.popup = document.createElement('div');
254 + this.popup.id = 'autocomplete';
255 + this.popup.owner = this;
256 + $(this.popup).css({
257 + top: (pos.y + this.input.offsetHeight) +'px',
258 + left: pos.x +'px',
259 + width: (this.input.offsetWidth - 4) +'px',
260 + display: 'none'
261 + });
262 + $('body').append(this.popup);
263 +
264 + // Do search
265 this.db.owner = this;
266 this.db.search(this.input.value);
267 }
268 @@ -188,45 +195,39 @@ function jsAC(input, db) {
269 /**
270 * Fills the suggestion popup with any matches received
271 */
272 -jsAC.prototype.found = function (matches) {
273 - while (this.popup.hasChildNodes()) {
274 - this.popup.removeChild(this.popup.childNodes[0]);
275 - }
276 - if (!this.popup.parentNode || !this.popup.parentNode.tagName) {
277 - document.getElementsByTagName('body')[0].appendChild(this.popup);
278 - }
279 +Drupal.jsAC.prototype.found = function (matches) {
280 + // Prepare matches
281 var ul = document.createElement('ul');
282 var ac = this;
283 -
284 for (key in matches) {
285 var li = document.createElement('li');
286 - var div = document.createElement('div');
287 - div.innerHTML = matches[key];
288 - li.appendChild(div);
289 + $(li)
290 + .html('<div>'+ matches[key] +'</div>')
291 + .mousedown(function () { ac.select(this); })
292 + .mouseover(function () { ac.highlight(this); })
293 + .mouseout(function () { ac.unhighlight(this); });
294 li.autocompleteValue = key;
295 - li.onmousedown = function() { ac.select(this); };
296 - li.onmouseover = function() { ac.highlight(this); };
297 - li.onmouseout = function() { ac.unhighlight(this); };
298 - ul.appendChild(li);
299 + $(ul).append(li);
300 }
301
302 + // Show popup with matches, if any
303 if (ul.childNodes.length > 0) {
304 - this.popup.appendChild(ul);
305 + $(this.popup).empty().append(ul).show();
306 }
307 else {
308 this.hidePopup();
309 }
310 }
311
312 -jsAC.prototype.setStatus = function (status) {
313 +Drupal.jsAC.prototype.setStatus = function (status) {
314 switch (status) {
315 case 'begin':
316 - addClass(this.input, 'throbbing');
317 + $(this.input).addClass('throbbing');
318 break;
319 case 'cancel':
320 case 'error':
321 case 'found':
322 - removeClass(this.input, 'throbbing');
323 + $(this.input).removeClass('throbbing');
324 break;
325 }
326 }
327 @@ -234,7 +235,7 @@ function jsAC(input, db) {
328 /**
329 * An AutoComplete DataBase object
330 */
331 -function ACDB(uri) {
332 +Drupal.ACDB = function (uri) {
333 this.uri = uri;
334 this.delay = 300;
335 this.cache = {};
336 @@ -243,47 +244,55 @@ function ACDB(uri) {
337 /**
338 * Performs a cached and delayed search
339 */
340 -ACDB.prototype.search = function(searchString) {
341 +Drupal.ACDB.prototype.search = function (searchString) {
342 + var db = this;
343 this.searchString = searchString;
344 +
345 + // See if this key has been searched for before
346 if (this.cache[searchString]) {
347 return this.owner.found(this.cache[searchString]);
348 }
349 +
350 + // Initiate delayed search
351 if (this.timer) {
352 clearTimeout(this.timer);
353 }
354 - var db = this;
355 this.timer = setTimeout(function() {
356 db.owner.setStatus('begin');
357 - db.transport = HTTPGet(db.uri +'/'+ encodeURIComponent(searchString), db.receive, db);
358 - }, this.delay);
359 -}
360
361 -/**
362 - * HTTP callback function. Passes suggestions to the autocomplete object
363 - */
364 -ACDB.prototype.receive = function(string, xmlhttp, acdb) {
365 - // Note: Safari returns 'undefined' status if the request returns no data.
366 - if (xmlhttp.status != 200 && typeof xmlhttp.status != 'undefined') {
367 - acdb.owner.setStatus('error');
368 - return alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ acdb.uri);
369 - }
370 - // Parse back result
371 - var matches = parseJson(string);
372 - if (typeof matches['status'] == 'undefined' || matches['status'] != 0) {
373 - acdb.cache[acdb.searchString] = matches;
374 - acdb.owner.found(matches);
375 - acdb.owner.setStatus('found');
376 - }
377 + // Ajax GET request for autocompletion
378 + $.ajax({
379 + type: "GET",
380 + url: db.uri +'/'+ encodeURIComponent(searchString),
381 + success: function (xmlhttp) {
382 + // Parse back result
383 + var matches = Drupal.parseJson(xmlhttp.responseText);
384 + if (typeof matches['status'] == 'undefined' || matches['status'] != 0) {
385 + db.cache[searchString] = matches;
386 + // Verify if these are still the matches the user wants to see
387 + if (db.searchString == searchString) {
388 + db.owner.found(matches);
389 + }
390 + db.owner.setStatus('found');
391 + }
392 + },
393 + error: function (xmlhttp) {
394 + alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ db.uri);
395 + }
396 + });
397 + }, this.delay);
398 }
399
400 /**
401 * Cancels the current autocomplete request
402 */
403 -ACDB.prototype.cancel = function() {
404 +Drupal.ACDB.prototype.cancel = function() {
405 if (this.owner) this.owner.setStatus('cancel');
406 if (this.timer) clearTimeout(this.timer);
407 - if (this.transport) {
408 - this.transport.onreadystatechange = function() {};
409 - this.transport.abort();
410 - }
411 + this.searchString = '';
412 }
413 +
414 +// Global Killswitch
415 +if (Drupal.isJsEnabled()) {
416 + $(document).ready(Drupal.autocompleteAutoAttach);
417 +}
418 \ No newline at end of file
419 Index: misc/collapse.js
420 ===================================================================
421 RCS file: /cvs/drupal/drupal/misc/collapse.js,v
422 retrieving revision 1.6
423 diff -u -d -F^\s*function -r1.6 collapse.js
424 --- misc/collapse.js 14 Apr 2006 13:48:56 -0000 1.6
425 +++ misc/collapse.js 22 Aug 2006 10:30:56 -0000
426 @@ -1,70 +1,99 @@
427 // $Id: collapse.js,v 1.6 2006/04/14 13:48:56 killes Exp $
428
429 -if (isJsEnabled()) {
430 - addLoadEvent(collapseAutoAttach);
431 -}
432 -
433 -function collapseAutoAttach() {
434 - var fieldsets = document.getElementsByTagName('fieldset');
435 - var legend, fieldset;
436 - for (var i = 0; fieldset = fieldsets[i]; i++) {
437 - if (!hasClass(fieldset, 'collapsible')) {
438 - continue;
439 - }
440 - legend = fieldset.getElementsByTagName('legend');
441 - if (legend.length == 0) {
442 - continue;
443 - }
444 - legend = legend[0];
445 +Drupal.collapseAutoAttach = function () {
446 + $('fieldset.collapsible legend').each(function () {
447 + // Turn the legend into clickable link
448 var a = document.createElement('a');
449 a.href = '#';
450 - a.onclick = function() {
451 - toggleClass(this.parentNode.parentNode, 'collapsed');
452 - if (!hasClass(this.parentNode.parentNode, 'collapsed')) {
453 - collapseScrollIntoView(this.parentNode.parentNode);
454 - if (typeof textAreaAutoAttach != 'undefined') {
455 - // Add the grippie to a textarea in a collapsed fieldset.
456 - textAreaAutoAttach(null, this.parentNode.parentNode);
457 + $(a)
458 + .click(function() {
459 + var fieldset = this.parentNode.parentNode;
460 +
461 + // Prevent double animations
462 + if (fieldset.animating) {
463 + return false;
464 }
465 - }
466 - this.blur();
467 - return false;
468 - };
469 - a.innerHTML = legend.innerHTML;
470 - while (legend.hasChildNodes()) {
471 - removeNode(legend.childNodes[0]);
472 + fieldset.animating = true;
473 +
474 + if ($(fieldset).is('.collapsed')) {
475 + // Open fieldset with animation
476 + $(fieldset.contentWrapper).hide();
477 + $(fieldset).removeClass('collapsed');
478 + $(fieldset.contentWrapper).slideDown('medium',
479 + {
480 + // Make sure we open to height auto
481 + complete: function() {
482 + $(fieldset.contentWrapper).css('height', 'auto');
483 + Drupal.collapseScrollIntoView(fieldset);
484 + fieldset.animating = false;
485 + },
486 + // Scroll the fieldset into view
487 + step: function() {
488 + Drupal.collapseScrollIntoView(fieldset);
489 + }
490 + }
491 + );
492 + if (typeof Drupal.textAreaAutoAttach != 'undefined') {
493 + // Initialize resizable textareas that are now revealed
494 + Drupal.textAreaAutoAttach(null, fieldset);
495 + }
496 + }
497 + else {
498 + // Collapse fieldset with animation (reverse of opening)
499 + $(fieldset.contentWrapper)
500 + .slideUp('medium', function () { $(fieldset).addClass('collapsed'); fieldset.animating = false; } )
501 + .show();
502 + }
503 + this.blur();
504 + return false;
505 + })
506 + .html(this.innerHTML);
507 + $(this)
508 + .empty()
509 + .append(a);
510 +
511 + // Wrap fieldsets contents (except for the legend) into wrapper divs for animating.
512 + // div1 is used to avoid margin problems inside fieldsets,
513 + // div2 is the one that is actually animated.
514 + var div1 = document.createElement('div');
515 + var div2 = document.createElement('div');
516 + this.parentNode.contentWrapper = div2;
517 + $(this).after(div1);
518 + $(div1).append(div2);
519 + var el = div1.nextSibling;
520 + while (el != null) {
521 + var next = el.nextSibling;
522 + $(el).remove();
523 + $(div2).append(el);
524 + el = next;
525 }
526 - legend.appendChild(a);
527 - collapseEnsureErrorsVisible(fieldset);
528 - }
529 -}
530 + // Avoid jumping around due to margins collapsing into fieldset border
531 + $(div1).css('overflow', 'hidden');
532
533 -function collapseEnsureErrorsVisible(fieldset) {
534 - if (!hasClass(fieldset, 'collapsed')) {
535 - return;
536 - }
537 - var inputs = [];
538 - inputs = inputs.concat(fieldset.getElementsByTagName('input'));
539 - inputs = inputs.concat(fieldset.getElementsByTagName('textarea'));
540 - inputs = inputs.concat(fieldset.getElementsByTagName('select'));
541 - for (var j = 0; j<3; j++) {
542 - for (var i = 0; i < inputs[j].length; i++) {
543 - if (hasClass(inputs[j][i], 'error')) {
544 - return removeClass(fieldset, 'collapsed');
545 - }
546 + // Expand if there are errors inside
547 + if ($('input.error, textarea.error, select.error', this.parentNode).size() > 0) {
548 + $(fieldset).removeClass('collapsed');
549 }
550 - }
551 + });
552 }
553
554 -function collapseScrollIntoView(node) {
555 +/**
556 + * Scroll a given fieldset into view as much as possible.
557 + */
558 +Drupal.collapseScrollIntoView = function (node) {
559 var h = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
560 var offset = self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
561 - var pos = absolutePosition(node);
562 + var pos = Drupal.absolutePosition(node);
563 if (pos.y + node.scrollHeight > h + offset) {
564 if (node.scrollHeight > h) {
565 window.scrollTo(0, pos.y);
566 } else {
567 - window.scrollTo(0, pos.y + node.scrollHeight - h);
568 + window.scrollTo(0, pos.y + node.scrollHeight - h + 15);
569 }
570 }
571 }
572 +
573 +// Global Killswitch
574 +if (Drupal.isJsEnabled()) {
575 + $(document).ready(Drupal.collapseAutoAttach);
576 +}
577 \ No newline at end of file
578 Index: misc/drupal.js
579 ===================================================================
580 RCS file: /cvs/drupal/drupal/misc/drupal.js,v
581 retrieving revision 1.26
582 diff -u -d -F^\s*function -r1.26 drupal.js
583 --- misc/drupal.js 22 Aug 2006 09:00:31 -0000 1.26
584 +++ misc/drupal.js 22 Aug 2006 10:30:57 -0000
585 @@ -1,377 +1,198 @@
586 // $Id: drupal.js,v 1.26 2006/08/22 09:00:31 dries Exp $
587
588 -/**
589 - * Only enable Javascript functionality if all required features are supported.
590 - */
591 -function isJsEnabled() {
592 - if (typeof document.jsEnabled == 'undefined') {
593 - // Note: ! casts to boolean implicitly.
594 - document.jsEnabled = !(
595 - !document.getElementsByTagName ||
596 - !document.createElement ||
597 - !document.createTextNode ||
598 - !document.documentElement ||
599 - !document.getElementById);
600 - }
601 - return document.jsEnabled;
602 -}
603 -
604 -// Global Killswitch on the <html> element
605 -if (isJsEnabled()) {
606 - document.documentElement.className = 'js';
607 -}
608 -
609 -Drupal = { };
610 -
611 -Drupal.extend = function(obj) {
612 - for (var i in obj) {
613 - if (this[i]) {
614 - Drupal.extend.apply(this[i], [obj[i]]);
615 - }
616 - else {
617 - this[i] = obj[i];
618 - }
619 - }
620 -}
621 -
622 -/**
623 - * Make IE's XMLHTTP object accessible through XMLHttpRequest()
624 - */
625 -if (typeof XMLHttpRequest == 'undefined') {
626 - XMLHttpRequest = function () {
627 - var msxmls = ['MSXML3', 'MSXML2', 'Microsoft']
628 - for (var i=0; i < msxmls.length; i++) {
629 - try {
630 - return new ActiveXObject(msxmls[i]+'.XMLHTTP')
631 - }
632 - catch (e) { }
633 +var Drupal = {
634 + /**
635 + * Only enable Javascript functionality if all required features are supported.
636 + */
637 + isJsEnabled: function () {
638 + if (typeof document.jsEnabled == 'undefined') {
639 + // Note: ! casts to boolean implicitly.
640 + document.jsEnabled = !(
641 + !document.getElementsByTagName ||
642 + !document.createElement ||
643 + !document.createTextNode ||
644 + !document.documentElement ||
645 + !document.getElementById);
646 }
647 - throw new Error("No XML component installed!");
648 - }
649 -}
650 -
651 -/**
652 - * Creates an HTTP GET request and sends the response to the callback function.
653 - *
654 - * Note that dynamic arguments in the URI should be escaped with encodeURIComponent().
655 - */
656 -function HTTPGet(uri, callbackFunction, callbackParameter) {
657 - var xmlHttp = new XMLHttpRequest();
658 - var bAsync = true;
659 - if (!callbackFunction) {
660 - bAsync = false;
661 - }
662 -
663 - xmlHttp.open('GET', uri, bAsync);
664 - xmlHttp.send(null);
665 -
666 - if (bAsync) {
667 - xmlHttp.onreadystatechange = function() {
668 - if (xmlHttp.readyState == 4) {
669 - callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
670 + return document.jsEnabled;
671 + },
672 +
673 + extend: function(obj) {
674 + for (var i in obj) {
675 + if (this[i]) {
676 + Drupal.extend.apply(this[i], [obj[i]]);
677 }
678 - }
679 - return xmlHttp;
680 - }
681 - else {
682 - return xmlHttp.responseText;
683 - }
684 -}
685 -
686 -/**
687 - * Creates an HTTP POST request and sends the response to the callback function
688 - *
689 - * Note: passing null or undefined for 'object' makes the request fail in Opera 8.
690 - * Pass an empty string instead.
691 - */
692 -function HTTPPost(uri, callbackFunction, callbackParameter, object) {
693 - var xmlHttp = new XMLHttpRequest();
694 - var bAsync = true;
695 - if (!callbackFunction) {
696 - bAsync = false;
697 - }
698 - xmlHttp.open('POST', uri, bAsync);
699 -
700 - var toSend = '';
701 - if (typeof object == 'object') {
702 - xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
703 - for (var i in object) {
704 - toSend += (toSend ? '&' : '') + i + '=' + encodeURIComponent(object[i]);
705 - }
706 - }
707 - else {
708 - toSend = object;
709 - }
710 - xmlHttp.send(toSend);
711 -
712 - if (bAsync) {
713 - xmlHttp.onreadystatechange = function() {
714 - if (xmlHttp.readyState == 4) {
715 - callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
716 + else {
717 + this[i] = obj[i];
718 }
719 }
720 - return xmlHttp;
721 - }
722 - else {
723 - return xmlHttp.responseText;
724 - }
725 -}
726 -
727 -/**
728 - * Redirects a button's form submission to a hidden iframe and displays the result
729 - * in a given wrapper. The iframe should contain a call to
730 - * window.parent.iframeHandler() after submission.
731 - */
732 -function redirectFormButton(uri, button, handler) {
733 - // (Re)create an iframe to target.
734 - createIframe();
735 + },
736
737 - // Trap the button
738 - button.onmouseover = button.onfocus = function() {
739 - button.onclick = function() {
740 - // Prepare variables for use in anonymous function.
741 - var button = this;
742 - var action = button.form.action;
743 - var target = button.form.target;
744 + /**
745 + * Redirects a button's form submission to a hidden iframe and displays the result
746 + * in a given wrapper. The iframe should contain a call to
747 + * window.parent.iframeHandler() after submission.
748 + */
749 + redirectFormButton: function (uri, button, handler) {
750 + // Trap the button
751 + button.onmouseover = button.onfocus = function() {
752 + button.onclick = function() {
753 + // Create target iframe
754 + Drupal.createIframe();
755 +
756 + // Prepare variables for use in anonymous function.
757 + var button = this;
758 + var action = button.form.action;
759 + var target = button.form.target;
760
761 - // Redirect form submission
762 - this.form.action = uri;
763 - this.form.target = 'redirect-target';
764 + // Redirect form submission to iframe
765 + this.form.action = uri;
766 + this.form.target = 'redirect-target';
767
768 - handler.onsubmit();
769 + handler.onsubmit();
770
771 - // Set iframe handler for later
772 - window.iframeHandler = function () {
773 - var iframe = $('redirect-target');
774 - // Restore form submission
775 - button.form.action = action;
776 - button.form.target = target;
777 + // Set iframe handler for later
778 + window.iframeHandler = function () {
779 + var iframe = $('#redirect-target').get(0);
780 + // Restore form submission
781 + button.form.action = action;
782 + button.form.target = target;
783
784 - // Get response from iframe body
785 - try {
786 - response = (iframe.contentWindow || iframe.contentDocument || iframe).document.body.innerHTML;
787 - // Firefox 1.0.x hack: Remove (corrupted) control characters
788 - response = response.replace(/[\f\n\r\t]/g, ' ');
789 - if (window.opera) {
790 - // Opera-hack: it returns innerHTML sanitized.
791 - response = response.replace(/&quot;/g, '"');
792 + // Get response from iframe body
793 + try {
794 + response = (iframe.contentWindow || iframe.contentDocument || iframe).document.body.innerHTML;
795 + // Firefox 1.0.x hack: Remove (corrupted) control characters
796 + response = response.replace(/[\f\n\r\t]/g, ' ');
797 + if (window.opera) {
798 + // Opera-hack: it returns innerHTML sanitized.
799 + response = response.replace(/&quot;/g, '"');
800 + }
801 + }
802 + catch (e) {
803 + response = null;
804 }
805 - }
806 - catch (e) {
807 - response = null;
808 - }
809
810 - $('redirect-target').onload = null;
811 - $('redirect-target').src = 'about:blank';
812 + response = Drupal.parseJson(response);
813 + // Check response code
814 + if (response.status == 0) {
815 + handler.onerror(response.data);
816 + return;
817 + }
818 + handler.oncomplete(response.data);
819
820 - response = parseJson(response);
821 - // Check response code
822 - if (response.status == 0) {
823 - handler.onerror(response.data);
824 - return;
825 + return true;
826 }
827 - handler.oncomplete(response.data);
828 - }
829
830 - return true;
831 + return true;
832 + }
833 }
834 - }
835 - button.onmouseout = button.onblur = function() {
836 - button.onclick = null;
837 - }
838 -}
839 -
840 -/**
841 - * Adds a function to the window onload event
842 - */
843 -function addLoadEvent(func) {
844 - var oldOnload = window.onload;
845 - if (typeof window.onload != 'function') {
846 - window.onload = func;
847 - }
848 - else {
849 - window.onload = function() {
850 - oldOnload();
851 - func();
852 + button.onmouseout = button.onblur = function() {
853 + button.onclick = null;
854 }
855 - }
856 -}
857 + },
858
859 -/**
860 - * Adds a function to a given form's submit event
861 - */
862 -function addSubmitEvent(form, func) {
863 - var oldSubmit = form.onsubmit;
864 - if (typeof oldSubmit != 'function') {
865 - form.onsubmit = func;
866 - }
867 - else {
868 - form.onsubmit = function() {
869 - return oldSubmit() && func();
870 + /**
871 + * Retrieves the absolute position of an element on the screen
872 + */
873 + absolutePosition: function (el) {
874 + var sLeft = 0, sTop = 0;
875 + var isDiv = /^div$/i.test(el.tagName);
876 + if (isDiv && el.scrollLeft) {
877 + sLeft = el.scrollLeft;
878 }
879 - }
880 -}
881 -
882 -/**
883 - * Retrieves the absolute position of an element on the screen
884 - */
885 -function absolutePosition(el) {
886 - var sLeft = 0, sTop = 0;
887 - var isDiv = /^div$/i.test(el.tagName);
888 - if (isDiv && el.scrollLeft) {
889 - sLeft = el.scrollLeft;
890 - }
891 - if (isDiv && el.scrollTop) {
892 - sTop = el.scrollTop;
893 - }
894 - var r = { x: el.offsetLeft - sLeft, y: el.offsetTop - sTop };
895 - if (el.offsetParent) {
896 - var tmp = absolutePosition(el.offsetParent);
897 - r.x += tmp.x;
898 - r.y += tmp.y;
899 - }
900 - return r;
901 -};
902 -
903 -function dimensions(el) {
904 - return { width: el.offsetWidth, height: el.offsetHeight };
905 -}
906 -
907 -/**
908 - * Returns true if an element has a specified class name
909 - */
910 -function hasClass(node, className) {
911 - if (node.className == className) {
912 - return true;
913 - }
914 - var reg = new RegExp('(^| )'+ className +'($| )')
915 - if (reg.test(node.className)) {
916 - return true;
917 - }
918 - return false;
919 -}
920 -
921 -/**
922 - * Adds a class name to an element
923 - */
924 -function addClass(node, className) {
925 - if (hasClass(node, className)) {
926 - return false;
927 - }
928 - node.className += ' '+ className;
929 - return true;
930 -}
931 -
932 -/**
933 - * Removes a class name from an element
934 - */
935 -function removeClass(node, className) {
936 - if (!hasClass(node, className)) {
937 - return false;
938 - }
939 - // Replaces words surrounded with whitespace or at a string border with a space. Prevents multiple class names from being glued together.
940 - node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
941 - return true;
942 -}
943 + if (isDiv && el.scrollTop) {
944 + sTop = el.scrollTop;
945 + }
946 + var r = { x: el.offsetLeft - sLeft, y: el.offsetTop - sTop };
947 + if (el.offsetParent) {
948 + var tmp = Drupal.absolutePosition(el.offsetParent);
949 + r.x += tmp.x;
950 + r.y += tmp.y;
951 + }
952 + return r;
953 + },
954
955 -/**
956 - * Toggles a class name on or off for an element
957 - */
958 -function toggleClass(node, className) {
959 - if (!removeClass(node, className) && !addClass(node, className)) {
960 - return false;
961 - }
962 - return true;
963 -}
964 + /**
965 + * Return the dimensions of an element on the screen
966 + */
967 + dimensions: function (el) {
968 + return { width: el.offsetWidth, height: el.offsetHeight };
969 + },
970
971 -/**
972 - * Emulate PHP's ereg_replace function in javascript
973 - */
974 -function eregReplace(search, replace, subject) {
975 - return subject.replace(new RegExp(search,'g'), replace);
976 -}
977 + /**
978 + * Parse a JSON response.
979 + *
980 + * The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
981 + */
982 + parseJson: function (data) {
983 + if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
984 + return { status: 0, data: data.length ? data : 'Unspecified error' };
985 + }
986 + return eval('(' + data + ');');
987 + },
988
989 -/**
990 - * Removes an element from the page
991 - */
992 -function removeNode(node) {
993 - if (typeof node == 'string') {
994 - node = $(node);
995 - }
996 - if (node && node.parentNode) {
997 - return node.parentNode.removeChild(node);
998 - }
999 - else {
1000 - return false;
1001 - }
1002 -}
1003 + /**
1004 + * Create an invisible iframe for form submissions.
1005 + */
1006 + createIframe: function () {
1007 + if ($('#redirect-holder').size()) {
1008 + return;
1009 + }
1010 + // Note: some browsers require the literal name/id attributes on the tag,
1011 + // some want them set through JS. We do both.
1012 + window.iframeHandler = function () {};
1013 + var div = document.createElement('div');
1014 + div.id = 'redirect-holder';
1015 + $(div).html('<iframe name="redirect-target" id="redirect-target" class="redirect" onload="window.iframeHandler();"></iframe>');
1016 + var iframe = div.firstChild;
1017 + $(iframe)
1018 + .set({
1019 + name: 'redirect-target',
1020 + id: 'redirect-target'
1021 + })
1022 + .css({
1023 + position: 'absolute',
1024 + height: '1px',
1025 + width: '1px',
1026 + visibility: 'hidden'
1027 + });
1028 + $('body').append(div);
1029 + },
1030
1031 -/**
1032 - * Prevents an event from propagating.
1033 - */
1034 -function stopEvent(event) {
1035 - if (event.preventDefault) {
1036 - event.preventDefault();
1037 - event.stopPropagation();
1038 - }
1039 - else {
1040 - event.returnValue = false;
1041 - event.cancelBubble = true;
1042 - }
1043 -}
1044 + /**
1045 + * Delete the invisible iframe
1046 + */
1047 + deleteIframe: function () {
1048 + $('#redirect-holder').remove();
1049 + },
1050
1051 -/**
1052 - * Parse a JSON response.
1053 - *
1054 - * The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
1055 - */
1056 -function parseJson(data) {
1057 - if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
1058 - return { status: 0, data: data.length ? data : 'Unspecified error' };
1059 - }
1060 - return eval('(' + data + ');');
1061 -}
1062 + /**
1063 + * Freeze the current body height (as minimum height). Used to prevent
1064 + * unnecessary upwards scrolling when doing DOM manipulations.
1065 + */
1066 + freezeHeight: function () {
1067 + Drupal.unfreezeHeight();
1068 + var div = document.createElement('div');
1069 + $(div).css({
1070 + position: 'absolute',
1071 + top: '0px',
1072 + left: '0px',
1073 + width: '1px',
1074 + height: $('body').css('height') +'px'
1075 + }).set('id', 'freeze-height');
1076 + $('body').append(div);
1077 + },
1078
1079 -/**
1080 - * Create an invisible iframe for form submissions.
1081 - */
1082 -function createIframe() {
1083 - // Delete any previous iframe
1084 - deleteIframe();
1085 - // Note: some browsers require the literal name/id attributes on the tag,
1086 - // some want them set through JS. We do both.
1087 - window.iframeHandler = function () {};
1088 - var div = document.createElement('div');
1089 - div.id = 'redirect-holder';
1090 - div.innerHTML = '<iframe name="redirect-target" id="redirect-target" class="redirect" onload="window.iframeHandler();"></iframe>';
1091 - var iframe = div.firstChild;
1092 - with (iframe) {
1093 - name = 'redirect-target';
1094 - setAttribute('name', 'redirect-target');
1095 - id = 'redirect-target';
1096 - }
1097 - with (iframe.style) {
1098 - position = 'absolute';
1099 - height = '1px';
1100 - width = '1px';
1101 - visibility = 'hidden';
1102 + /**
1103 + * Unfreeze the body height
1104 + */
1105 + unfreezeHeight: function () {
1106 + $('#freeze-height').remove();
1107 }
1108 - document.body.appendChild(div);
1109 }
1110
1111 -/**
1112 - * Delete the invisible iframe for form submissions.
1113 - */
1114 -function deleteIframe() {
1115 - var holder = $('redirect-holder');
1116 - if (holder != null) {
1117 - removeNode(holder);
1118 - }
1119 -}
1120
1121 -/**
1122 - * Wrapper around document.getElementById().
1123 - */
1124 -function $(id) {
1125 - return document.getElementById(id);
1126 -}
1127 +// Global Killswitch on the <html> element
1128 +if (Drupal.isJsEnabled()) {
1129 + document.documentElement.className = 'js';
1130 +}
1131 \ No newline at end of file
1132 Index: misc/progress.js
1133 ===================================================================
1134 RCS file: /cvs/drupal/drupal/misc/progress.js,v
1135 retrieving revision 1.10
1136 diff -u -d -F^\s*function -r1.10 progress.js
1137 --- misc/progress.js 28 Mar 2006 09:29:23 -0000 1.10
1138 +++ misc/progress.js 22 Aug 2006 10:30:57 -0000
1139 @@ -5,45 +5,35 @@
1140 * the DOM afterwards through progressBar.element.
1141 *
1142 * method is the function which will perform the HTTP request to get the
1143 - * progress bar state. Either HTTPGet or HTTPPost.
1144 + * progress bar state. Either "GET" or "POST".
1145 *
1146 * e.g. pb = new progressBar('myProgressBar');
1147 * some_element.appendChild(pb.element);
1148 */
1149 -function progressBar(id, updateCallback, method, errorCallback) {
1150 +Drupal.progressBar = function (id, updateCallback, method, errorCallback) {
1151 var pb = this;
1152 this.id = id;
1153 - this.method = method ? method : HTTPGet;
1154 + this.method = method || "GET";
1155 this.updateCallback = updateCallback;
1156 this.errorCallback = errorCallback;
1157
1158 this.element = document.createElement('div');
1159 this.element.id = id;
1160 this.element.className = 'progress';
1161 - this.element.innerHTML = '<div class="percentage"></div>'+
1162 - '<div class="message">&nbsp;</div>'+
1163 - '<div class="bar"><div class="filled"></div></div>';
1164 + $(this.element).html('<div class="percentage"></div>'+
1165 + '<div class="message">&nbsp;</div>'+
1166 + '<div class="bar"><div class="filled"></div></div>');
1167 }
1168
1169 /**
1170 * Set the percentage and status message for the progressbar.
1171 */
1172 -progressBar.prototype.setProgress = function (percentage, message) {
1173 - var divs = this.element.getElementsByTagName('div');
1174 - var div;
1175 - for (var i = 0; div = divs[i]; ++i) {
1176 - if (percentage >= 0) {
1177 - if (hasClass(divs[i], 'filled')) {
1178 - divs[i].style.width = percentage + '%';
1179 - }
1180 - if (hasClass(divs[i], 'percentage')) {
1181 - divs[i].innerHTML = percentage + '%';
1182 - }
1183 - }
1184 - if (hasClass(divs[i], 'message')) {
1185 - divs[i].innerHTML = message;
1186 - }
1187 +Drupal.progressBar.prototype.setProgress = function (percentage, message) {
1188 + if (percentage >= 0 && percentage <= 100) {
1189 + $('div.filled', this.element).css('width', percentage +'%');
1190 + $('div.percentage', this.element).html(percentage +'%');
1191 }
1192 + $('div.message', this.element).html(message);
1193 if (this.updateCallback) {
1194 this.updateCallback(percentage, message, this);
1195 }
1196 @@ -52,7 +42,7 @@ function progressBar(id, updateCallback,
1197 /**
1198 * Start monitoring progress via Ajax.
1199 */
1200 -progressBar.prototype.startMonitoring = function (uri, delay) {
1201 +Drupal.progressBar.prototype.startMonitoring = function (uri, delay) {
1202 this.delay = delay;
1203 this.uri = uri;
1204 this.sendPing();
1205 @@ -61,7 +51,7 @@ function progressBar(id, updateCallback,
1206 /**
1207 * Stop monitoring progress via Ajax.
1208 */
1209 -progressBar.prototype.stopMonitoring = function () {
1210 +Drupal.progressBar.prototype.stopMonitoring = function () {
1211 clearTimeout(this.timer);
1212 // This allows monitoring to be stopped from within the callback
1213 this.uri = null;
1214 @@ -70,47 +60,44 @@ function progressBar(id, updateCallback,
1215 /**
1216 * Request progress data from server.
1217 */
1218 -progressBar.prototype.sendPing = function () {
1219 +Drupal.progressBar.prototype.sendPing = function () {
1220 if (this.timer) {
1221 clearTimeout(this.timer);
1222 }
1223 if (this.uri) {
1224 - this.method(this.uri, this.receivePing, this, '');
1225 - }
1226 -}
1227 -
1228 -/**
1229 - * HTTP callback function. Passes data back to the progressbar and sets a new
1230 - * timer for the next ping.
1231 - */
1232 -progressBar.prototype.receivePing = function (string, xmlhttp, pb) {
1233 - if (xmlhttp.status != 200) {
1234 - return pb.displayError('An HTTP error '+ xmlhttp.status +' occured.\n'+ pb.uri);
1235 - }
1236 - // Parse response
1237 - var progress = parseJson(string);
1238 - // Display errors
1239 - if (progress.status == 0) {
1240 - pb.displayError(progress.data);
1241 - return;
1242 + var pb = this;
1243 + $.ajax({
1244 + type: this.method,
1245 + url: this.uri,
1246 + success: function (xmlhttp) {
1247 + // Parse response
1248 + var progress = Drupal.parseJson(xmlhttp.responseText);
1249 + // Display errors
1250 + if (progress.status == 0) {
1251 + pb.displayError(progress.data);
1252 + return;
1253 + }
1254 + // Update display
1255 + pb.setProgress(progress.percentage, progress.message);
1256 + // Schedule next timer
1257 + pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
1258 + },
1259 + error: function (xmlhttp) {
1260 + pb.displayError('An HTTP error '+ xmlhttp.status +' occured.\n'+ pb.uri);
1261 + }
1262 + });
1263 }
1264 -
1265 - // Update display
1266 - pb.setProgress(progress.percentage, progress.message);
1267 - // Schedule next timer
1268 - pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
1269 }
1270
1271 /**
1272 * Display errors on the page.
1273 */
1274 -progressBar.prototype.displayError = function (string) {
1275 +Drupal.progressBar.prototype.displayError = function (string) {
1276 var error = document.createElement('div');
1277 error.className = 'error';
1278 error.innerHTML = string;
1279
1280 - this.element.style.display = 'none';
1281 - this.element.parentNode.insertBefore(error, this.element);
1282 + $(this.element).before(error).hide();
1283
1284 if (this.errorCallback) {
1285 this.errorCallback(this);
1286 Index: misc/textarea.js
1287 ===================================================================
1288 RCS file: /cvs/drupal/drupal/misc/textarea.js,v
1289 retrieving revision 1.9
1290 diff -u -d -F^\s*function -r1.9 textarea.js
1291 --- misc/textarea.js 14 Apr 2006 13:48:56 -0000 1.9
1292 +++ misc/textarea.js 22 Aug 2006 10:30:58 -0000
1293 @@ -1,76 +1,67 @@
1294 // $Id: textarea.js,v 1.9 2006/04/14 13:48:56 killes Exp $
1295
1296 -if (isJsEnabled()) {
1297 - addLoadEvent(textAreaAutoAttach);
1298 -}
1299 -
1300 -function textAreaAutoAttach(event, parent) {
1301 - if (typeof parent == 'undefined') {
1302 - // Attach to all visible textareas.
1303 - textareas = document.getElementsByTagName('textarea');
1304 - }
1305 - else {
1306 - // Attach to all visible textareas inside parent.
1307 - textareas = parent.getElementsByTagName('textarea');
1308 - }
1309 - var textarea;
1310 - for (var i = 0; textarea = textareas[i]; ++i) {
1311 - if (hasClass(textarea, 'resizable') && !hasClass(textarea.nextSibling, 'grippie')) {
1312 - if (typeof dimensions(textarea).width != 'undefined' && dimensions(textarea).width != 0) {
1313 - new textArea(textarea);
1314 - }
1315 +Drupal.textAreaAutoAttach = function (event, parent) {
1316 + $('textarea.resizable', parent).each(function() {
1317 + if (!this.resizable
1318 + && typeof Drupal.dimensions(this).width != 'undefined'
1319 + && Drupal.dimensions(this).width != 0) {
1320 + new Drupal.textArea(this);
1321 }
1322 - }
1323 + });
1324 }
1325
1326 -function textArea(element) {
1327 +Drupal.textArea = function (element) {
1328 var ta = this;
1329 this.element = element;
1330 - this.parent = this.element.parentNode;
1331 - this.dimensions = dimensions(element);
1332 + this.element.resizable = true;
1333 + this.dimensions = Drupal.dimensions(element);
1334
1335 // Prepare wrapper
1336 this.wrapper = document.createElement('div');
1337 this.wrapper.className = 'resizable-textarea';
1338 - this.parent.insertBefore(this.wrapper, this.element);
1339 + $(this.element).before(this.wrapper);
1340
1341 // Add grippie and measure it
1342 this.grippie = document.createElement('div');
1343 this.grippie.className = 'grippie';
1344 - this.wrapper.appendChild(this.grippie);
1345 - this.grippie.dimensions = dimensions(this.grippie);
1346 - this.grippie.onmousedown = function (e) { ta.beginDrag(e); };
1347 + $(this.wrapper).append(this.grippie);
1348 + this.grippie.dimensions = Drupal.dimensions(this.grippie);
1349 + $(this.grippie).mousedown(function (e) { ta.beginDrag(e); });
1350
1351 // Set wrapper and textarea dimensions
1352 - this.wrapper.style.height = this.dimensions.height + this.grippie.dimensions.height + 1 +'px';
1353 - this.element.style.marginBottom = '0px';
1354 - this.element.style.width = '100%';
1355 - this.element.style.height = this.dimensions.height +'px';
1356 + $(this.wrapper).css('height', this.dimensions.height + this.grippie.dimensions.height + 1 +'px');
1357 + $(this.element).css({
1358 + marginBottom: '0px',
1359 + width: '100%',
1360 + height: this.dimensions.height +'px'
1361 + });
1362
1363 // Wrap textarea
1364 - removeNode(this.element);
1365 - this.wrapper.insertBefore(this.element, this.grippie);
1366 + $(this.element).remove();
1367 + $(this.grippie).before(this.element);
1368
1369 // Measure difference between desired and actual textarea dimensions to account for padding/borders
1370 - this.widthOffset = dimensions(this.wrapper).width - this.dimensions.width;
1371 + this.widthOffset = Drupal.dimensions(this.wrapper).width - this.dimensions.width;
1372
1373 // Make the grippie line up in various browsers
1374 if (window.opera) {
1375 // Opera
1376 - this.grippie.style.marginRight = '4px';
1377 + $(this.grippie).css('marginRight', '4px');
1378 }
1379 if (document.all && !window.opera) {
1380 // IE
1381 - this.grippie.style.width = '100%';
1382 - this.grippie.style.paddingLeft = '2px';
1383 + $(this.grippie).css({
1384 + width: '100%',
1385 + paddingLeft: '2px'
1386 + });
1387 }
1388 // Mozilla
1389 - this.element.style.MozBoxSizing = 'border-box';
1390 + $(this.element).css('MozBoxSizing', 'border-box');
1391
1392 - this.heightOffset = absolutePosition(this.grippie).y - absolutePosition(this.element).y - this.dimensions.height;
1393 + this.heightOffset = Drupal.absolutePosition(this.grippie).y - Drupal.absolutePosition(this.element).y - this.dimensions.height;
1394 }
1395
1396 -textArea.prototype.beginDrag = function (event) {
1397 +Drupal.textArea.prototype.beginDrag = function (event) {
1398 if (document.isDragging) {
1399 return;
1400 }
1401 @@ -85,20 +76,20 @@ function textArea(element) {
1402 document.onmouseup = function(e) { cp.endDrag(e); };
1403
1404 // Store drag offset from grippie top
1405 - var pos = absolutePosition(this.grippie);
1406 + var pos = Drupal.absolutePosition(this.grippie);
1407 this.dragOffset = event.clientY - pos.y;
1408
1409 // Make transparent
1410 - this.element.style.opacity = 0.5;
1411 + $(this.element).css('opacity', '0.5');
1412
1413 // Process
1414 this.handleDrag(event);
1415 }
1416
1417 -textArea.prototype.handleDrag = function (event) {
1418 +Drupal.textArea.prototype.handleDrag = function (event) {
1419 event = event || window.event;
1420 // Get coordinates relative to text area
1421 - var pos = absolutePosition(this.element);
1422 + var pos = Drupal.absolutePosition(this.element);
1423 var y = event.clientY - pos.y;
1424
1425 // Set new height
1426 @@ -107,16 +98,19 @@ function textArea(element) {
1427 this.element.style.height = height + 'px';
1428
1429 // Avoid text selection
1430 - stopEvent(event);
1431 + return false;
1432 }
1433
1434 -textArea.prototype.endDrag = function (event) {
1435 +Drupal.textArea.prototype.endDrag = function (event) {
1436 // Uncapture mouse
1437 document.onmousemove = this.oldMoveHandler;
1438 document.onmouseup = this.oldUpHandler;
1439
1440 // Restore opacity
1441 - this.element.style.opacity = 1.0;
1442 + $(this.element).css('opacity', '1.0');
1443 document.isDragging = false;
1444 }
1445
1446 +if (Drupal.isJsEnabled()) {
1447 + $(document).ready(Drupal.textAreaAutoAttach);
1448 +}
1449 \ No newline at end of file
1450 Index: misc/update.js
1451 ===================================================================
1452 RCS file: /cvs/drupal/drupal/misc/update.js,v
1453 retrieving revision 1.8
1454 diff -u -d -F^\s*function -r1.8 update.js
1455 --- misc/update.js 28 Mar 2006 09:29:23 -0000 1.8
1456 +++ misc/update.js 22 Aug 2006 10:30:58 -0000
1457 @@ -1,12 +1,11 @@
1458 // $Id: update.js,v 1.8 2006/03/28 09:29:23 killes Exp $
1459
1460 -if (isJsEnabled()) {
1461 - addLoadEvent(function() {
1462 - if ($('edit-has_js')) {
1463 - $('edit-has_js').value = 1;
1464 - }
1465 +if (Drupal.isJsEnabled()) {
1466 + $(document).ready(function() {
1467 + $('#edit-has_js').each(function() { this.value = 1; });
1468 + $('#progress').each(function () {
1469 + var holder = this;
1470
1471 - if ($('progress')) {
1472 // Success: redirect to the summary.
1473 var updateCallback = function (progress, status, pb) {
1474 if (progress == 100) {
1475 @@ -19,15 +18,15 @@
1476 var errorCallback = function (pb) {
1477 var div = document.createElement('p');
1478 div.className = 'error';
1479 - div.innerHTML = 'An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the <a href="update.php?op=error">update summary</a>';
1480 - $('progress').insertBefore(div, $('progress').firstChild);
1481 - $('wait').style.display = 'none';
1482 + $(div).html('An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the <a href="update.php?op=error">update summary</a>');
1483 + $(holder).prepend(div);
1484 + $('#wait').hide();
1485 }
1486
1487 - var progress = new progressBar('updateprogress', updateCallback, HTTPPost, errorCallback);
1488 + var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback);
1489 progress.setProgress(-1, 'Starting updates');
1490 - $('progress').appendChild(progress.element);
1491 + $(holder).append(progress.element);
1492 progress.startMonitoring('update.php?op=do_update', 0);
1493 - }
1494 + });
1495 });
1496 }
1497 Index: misc/upload.js
1498 ===================================================================
1499 RCS file: /cvs/drupal/drupal/misc/upload.js,v
1500 retrieving revision 1.9
1501 diff -u -d -F^\s*function -r1.9 upload.js
1502 --- misc/upload.js 5 May 2006 10:47:20 -0000 1.9
1503 +++ misc/upload.js 22 Aug 2006 10:30:59 -0000
1504 @@ -1,75 +1,119 @@
1505 // $Id: upload.js,v 1.9 2006/05/05 10:47:20 drumm Exp $
1506
1507 -// Global killswitch
1508 -if (isJsEnabled()) {
1509 - addLoadEvent(uploadAutoAttach);
1510 -}
1511 -
1512 /**
1513 * Attaches the upload behaviour to the upload form.
1514 */
1515 -function uploadAutoAttach() {
1516 - var inputs = document.getElementsByTagName('input');
1517 - for (i = 0; input = inputs[i]; i++) {
1518 - if (input && hasClass(input, 'upload')) {
1519 - var uri = input.value;
1520 - // Extract the button ID based on a substring of the input name: edit[foo][bar] -> foo-bar
1521 - var button = input.name.substr(5, input.name.length - 6).replace('][', '-');
1522 - var wrapper = button + '-wrapper';
1523 - var hide = button + '-hide';
1524 - var upload = new jsUpload(uri, button, wrapper, hide);
1525 - }
1526 - }
1527 +Drupal.uploadAutoAttach = function() {
1528 + $('input.upload').each(function () {
1529 + var uri = this.value;
1530 + // Extract the button ID based on a substring of the input name: edit[foo][bar] -> foo-bar
1531 + var button = this.name.substr(5, this.name.length - 6).replace('][', '-');
1532 + var wrapper = button + '-wrapper';
1533 + var hide = button + '-hide';
1534 + var upload = new Drupal.jsUpload(uri, button, wrapper, hide);
1535 + });
1536 }
1537
1538 /**
1539 * JS upload object.
1540 */
1541 -function jsUpload(uri, button, wrapper, hide) {
1542 - this.button = button;
1543 - this.wrapper = wrapper;
1544 - this.hide = hide;
1545 - redirectFormButton(uri, $(button), this);
1546 +Drupal.jsUpload = function(uri, button, wrapper, hide) {
1547 + // Note: these elements are replaced after an upload, so we re-select them
1548 + // everytime they are needed.
1549 + this.button = '#'+ button;
1550 + this.wrapper = '#'+ wrapper;
1551 + this.hide = '#'+ hide;
1552 + Drupal.redirectFormButton(uri, $(this.button).get(0), this);
1553 }
1554
1555 /**
1556 * Handler for the form redirection submission.
1557 */
1558 -jsUpload.prototype.onsubmit = function () {
1559 - var hide = $(this.hide);
1560 +Drupal.jsUpload.prototype.onsubmit = function () {
1561 // Insert progressbar and stretch to take the same space.
1562 - this.progress = new progressBar('uploadprogress');
1563 + this.progress = new Drupal.progressBar('uploadprogress');
1564 this.progress.setProgress(-1, 'Uploading file');
1565 - this.progress.element.style.width = '28em';
1566 - this.progress.element.style.height = hide.offsetHeight +'px';
1567 - hide.parentNode.insertBefore(this.progress.element, hide);
1568 - // Hide file form (cannot use display: none, this mysteriously aborts form
1569 - // submission in Konqueror)
1570 - hide.style.position = 'absolute';
1571 - hide.style.left = '-2000px';
1572 + $(this.progress.element).css({
1573 + width: '28em',
1574 + height: ($(this.hide).get(0).offsetHeight - 10) +'px',
1575 + marginBottom: -$(this.hide).get(0).offsetHeight +'px',
1576 + paddingTop: '10px',
1577 + display: 'none'
1578 + });
1579 +
1580 + // Hide file form and replace by progress bar (cannot use display: none,
1581 + // this mysteriously aborts form submission in Konqueror)
1582 +/* $(this.hide)
1583 + .css({
1584 + position: 'absolute',
1585 + left: '-2000px'
1586 + })
1587 + .before(this.progress.element);
1588 +*/
1589 + $(this.hide).before(this.progress.element).fadeOut('slow');
1590 + $(this.progress.element).fadeIn('slow');
1591 }
1592
1593 /**
1594 * Handler for the form redirection completion.
1595 */
1596 -jsUpload.prototype.oncomplete = function (data) {
1597 - // Remove progressbar
1598 - removeNode(this.progress.element);
1599 - this.progress = null;
1600 - // Replace form and re-attach behaviour
1601 - $(this.wrapper).innerHTML = data;
1602 - uploadAutoAttach();
1603 +Drupal.jsUpload.prototype.oncomplete = function (data) {
1604 + // Remove old form
1605 + Drupal.freezeHeight(); // Avoid unnecessary scrolling
1606 + $(this.wrapper).html('');
1607 +
1608 + // Place HTML into temporary div
1609 + var div = document.createElement('div');
1610 + $(div).html(data);
1611 +
1612 + // If uploading the first attachment fade in everything
1613 + if ($('tr', div).size() == 2) {
1614 + // Replace form and re-attach behaviour
1615 + $(div).hide();
1616 + $(this.wrapper).append(div);
1617 + $(div).fadeIn('slow');
1618 + Drupal.uploadAutoAttach();
1619 + }
1620 + // Else fade in only the last table row
1621 + else {
1622 + // Hide form and last table row
1623 + $('table tr:last-of-type td', div).hide();
1624 +
1625 + // Note: workaround because jQuery's #id selector does not work outside of 'document'
1626 + // Should be: $(this.hide, div).hide();
1627 + var hide = this.hide;
1628 + $('div', div).each(function() {
1629 + if (('#'+ this.id) == hide) {
1630 + this.style.display = 'none';
1631 + }
1632 + });
1633 +
1634 + // Replace form, fade in items and re-attach behaviour
1635 + $(this.wrapper).append(div);
1636 + $('table tr:last-of-type td', div).fadeIn('slow');
1637 + $(this.hide, div).fadeIn('slow');
1638 + Drupal.uploadAutoAttach();
1639 + }
1640 + Drupal.unfreezeHeight();
1641 }
1642
1643 /**
1644 * Handler for the form redirection error.
1645 */
1646 -jsUpload.prototype.onerror = function (error) {
1647 +Drupal.jsUpload.prototype.onerror = function (error) {
1648 alert('An error occurred:\n\n'+ error);
1649 // Remove progressbar
1650 - removeNode(this.progress.element);
1651 + $(this.progress.element).remove();
1652 this.progress = null;
1653 // Undo hide
1654 - $(this.hide).style.position = 'static';
1655 - $(this.hide).style.left = '0px';
1656 + $(this.hide).css({
1657 + position: 'static',
1658 + left: '0px'
1659 + });
1660 +}
1661 +
1662 +
1663 +// Global killswitch
1664 +if (Drupal.isJsEnabled()) {
1665 + $(document).ready(Drupal.uploadAutoAttach);
1666 }
1667 Index: modules/system/system.css
1668 ===================================================================
1669 RCS file: /cvs/drupal/drupal/modules/system/system.css,v
1670 retrieving revision 1.5
1671 diff -u -d -F^\s*function -r1.5 system.css
1672 --- modules/system/system.css 21 Aug 2006 07:33:26 -0000 1.5
1673 +++ modules/system/system.css 22 Aug 2006 10:31:01 -0000
1674 @@ -232,24 +232,29 @@
1675 border-left-width: 0;
1676 border-right-width: 0;
1677 margin-bottom: 0;
1678 + height: 1em;
1679 }
1680 html.js fieldset.collapsed * {
1681 display: none;
1682 }
1683 -html.js fieldset.collapsed table *,
1684 -html.js fieldset.collapsed legend,
1685 -html.js fieldset.collapsed legend * {
1686 - display: inline;
1687 +html.js fieldset.collapsed legend {
1688 + display: block;
1689 }
1690 html.js fieldset.collapsible legend a {
1691 padding-left: 15px;
1692 - background: url(../../misc/menu-expanded.png) 5px 50% no-repeat;
1693 + background: url(../../misc/menu-expanded.png) 5px 75% no-repeat;
1694 }
1695 html.js fieldset.collapsed legend a {
1696 background-image: url(../../misc/menu-collapsed.png);
1697 + background-position: 5px 50%;
1698 }
1699 /* Note: IE-only fix due to '* html' (breaks Konqueror otherwise). */
1700 -* html.js fieldset.collapsible legend a {
1701 +* html.js fieldset.collapsed legend,
1702 +* html.js fieldset.collapsed legend *,
1703 +* html.js fieldset.collapsed table * {
1704 + display: inline;
1705 +}
1706 +html.js fieldset.collapsible legend a {
1707 display: block;
1708 }
1709

  ViewVC Help
Powered by ViewVC 1.1.2