Skip to content
This repository
Browse code

Update to Prototype 1.2.0

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1198 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit d547c3f5ecd0318d9d3ddb95778867d4c43273c2 1 parent c11cc30
Sam Stephenson authored April 18, 2005
279  actionpack/lib/action_view/helpers/javascripts/prototype.js
... ...
@@ -1,12 +1,17 @@
1  
-/*  Prototype: an object-oriented Javascript library, version 1.1.0
  1
+/*  Prototype: an object-oriented Javascript library, version 1.2.0
2 2
  *  (c) 2005 Sam Stephenson <sam@conio.net>
3 3
  *
4  
- *  Prototype is freely distributable under the terms of an MIT-style license. 
5  
- *  For details, see http://prototype.conio.net/
6  
- */
  4
+ *  THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
  5
+ *  against the source tree, available from the Prototype darcs repository. 
  6
+ *
  7
+ *  Prototype is freely distributable under the terms of an MIT-style license.
  8
+ *
  9
+ *  For details, see the Prototype web site: http://prototype.conio.net/
  10
+ *
  11
+/*--------------------------------------------------------------------------*/
7 12
 
8 13
 var Prototype = {
9  
-  Version: '1.1.0'
  14
+  Version: '1.2.0'
10 15
 }
11 16
 
12 17
 var Class = {
@@ -62,28 +67,33 @@ var Try = {
62 67
   }
63 68
 }
64 69
 
65  
-// Deprecated accessor for Element.toggle
66  
-var Toggle = { display: function() { Element.toggle(arguments); } }
  70
+/*--------------------------------------------------------------------------*/
67 71
 
68  
-var Element = {
69  
-  toggle: function() {
70  
-    for (var i = 0; i < arguments.length; i++) {
71  
-      var element = $(arguments[i]);
72  
-      element.style.display = 
73  
-        (element.style.display == 'none' ? '' : 'none');
74  
-    }
75  
-  }
76  
-  hide: function() {
77  
-    for (var i = 0; i < arguments.length; i++) {
78  
-      var element = $(arguments[i]);
79  
-      element.style.display = 'none';
80  
-    }
81  
-  }
82  
-  show: function() {
83  
-    for (var i = 0; i < arguments.length; i++) {
84  
-      var element = $(arguments[i]);
85  
-      element.style.display = '';
  72
+var PeriodicalExecuter = Class.create();
  73
+PeriodicalExecuter.prototype = {
  74
+  initialize: function(callback, frequency) {
  75
+    this.callback = callback;
  76
+    this.frequency = frequency;
  77
+    this.currentlyExecuting = false;
  78
+    
  79
+    this.registerCallback();
  80
+  },
  81
+  
  82
+  registerCallback: function() {
  83
+    setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
  84
+  },
  85
+  
  86
+  onTimerEvent: function() {
  87
+    if (!this.currentlyExecuting) {
  88
+      try { 
  89
+        this.currentlyExecuting = true;
  90
+        this.callback(); 
  91
+      } finally { 
  92
+        this.currentlyExecuting = false;
  93
+      }
86 94
     }
  95
+    
  96
+    this.registerCallback();
87 97
   }
88 98
 }
89 99
 
@@ -106,22 +116,34 @@ function $() {
106 116
   return elements;
107 117
 }
108 118
 
109  
-function getElementsByClassName(className) {
110  
-  var children = document.getElementsByTagName('*') || document.all;
111  
-  var elements = new Array();
112  
-  
113  
-  for (var i = 0; i < children.length; i++) {
114  
-    var child = children[i];
115  
-    var classNames = child.className.split(' ');
116  
-    for (var j = 0; j < classNames.length; j++) {
117  
-      if (classNames[j] == className) {
118  
-        elements.push(child);
119  
-        break;
120  
-      }
121  
-    }
  119
+/*--------------------------------------------------------------------------*/
  120
+
  121
+if (!Array.prototype.push) {
  122
+  Array.prototype.push = function() {
  123
+		var startLength = this.length;
  124
+		for (var i = 0; i < arguments.length; i++)
  125
+      this[startLength + i] = arguments[i];
  126
+	  return this.length;
  127
+  }
  128
+}
  129
+
  130
+if (!Function.prototype.apply) {
  131
+  // Based on code from http://www.youngpup.net/
  132
+  Function.prototype.apply = function(object, parameters) {
  133
+    var parameterStrings = new Array();
  134
+    if (!object)     object = window;
  135
+    if (!parameters) parameters = new Array();
  136
+    
  137
+    for (var i = 0; i < parameters.length; i++)
  138
+      parameterStrings[i] = 'x[' + i + ']';
  139
+    
  140
+    object.__apply__ = this;
  141
+    var result = eval('obj.__apply__(' + 
  142
+      parameterStrings[i].join(', ') + ')');
  143
+    object.__apply__ = null;
  144
+    
  145
+    return result;
122 146
   }
123  
-  
124  
-  return elements;
125 147
 }
126 148
 
127 149
 /*--------------------------------------------------------------------------*/
@@ -169,6 +191,9 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
169 191
         setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
170 192
       }
171 193
               
  194
+      this.transport.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  195
+      this.transport.setRequestHeader('X-Prototype-Version', Prototype.Version);
  196
+
172 197
       if (this.options.method == 'post') {
173 198
         this.transport.setRequestHeader('Connection', 'close');
174 199
         this.transport.setRequestHeader('Content-type',
@@ -212,11 +237,11 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
212 237
   },
213 238
   
214 239
   updateContent: function() {
215  
-    if (!this.options.insertion) {
216  
-      this.container.innerHTML = this.request.transport.responseText;
217  
-    } else {
  240
+    if (this.options.insertion) {
218 241
       new this.options.insertion(this.container,
219 242
         this.request.transport.responseText);
  243
+    } else {
  244
+      this.container.innerHTML = this.request.transport.responseText;
220 245
     }
221 246
 
222 247
     if (this.onComplete) {
@@ -241,6 +266,15 @@ var Field = {
241 266
     for (var i = 0; i < arguments.length; i++)
242 267
       if ($(arguments[i]).value == '') return false;
243 268
     return true;
  269
+  },
  270
+  
  271
+  select: function(element) {
  272
+    $(element).select();
  273
+  },
  274
+   
  275
+  activate: function(element) {
  276
+    $(element).focus();
  277
+    $(element).select();
244 278
   }
245 279
 }
246 280
 
@@ -270,6 +304,31 @@ var Form = {
270 304
         elements.push(tagElements[j]);
271 305
     }
272 306
     return elements;
  307
+  },
  308
+  
  309
+  disable: function(form) {
  310
+    var elements = Form.getElements(form);
  311
+    for (var i = 0; i < elements.length; i++) {
  312
+      var element = elements[i];
  313
+      element.blur();
  314
+      element.disable = 'true';
  315
+    }
  316
+  },
  317
+
  318
+  focusFirstElement: function(form) {
  319
+    form = $(form);
  320
+    var elements = Form.getElements(form);
  321
+    for (var i = 0; i < elements.length; i++) {
  322
+      var element = elements[i];
  323
+      if (element.type != 'hidden' && !element.disabled) {
  324
+        Field.activate(element);
  325
+        break;
  326
+      }
  327
+    }
  328
+  },
  329
+
  330
+  reset: function(form) {
  331
+    $(form).reset();
273 332
   }
274 333
 }
275 334
 
@@ -319,12 +378,17 @@ Form.Element.Serializers = {
319 378
 
320 379
   select: function(element) {
321 380
     var index = element.selectedIndex;
322  
-    return [element.name, (index >= 0) ? element.options[index].value : ''];
  381
+    var value = element.options[index].value || element.options[index].text;
  382
+    return [element.name, (index >= 0) ? value : ''];
323 383
   }
324 384
 }
325 385
 
326 386
 /*--------------------------------------------------------------------------*/
327 387
 
  388
+var $F = Form.Element.getValue;
  389
+
  390
+/*--------------------------------------------------------------------------*/
  391
+
328 392
 Abstract.TimedObserver = function() {}
329 393
 Abstract.TimedObserver.prototype = {
330 394
   initialize: function(element, frequency, callback) {
@@ -368,6 +432,65 @@ Form.Observer.prototype = (new Abstract.TimedObserver()).extend({
368 432
 
369 433
 /*--------------------------------------------------------------------------*/
370 434
 
  435
+document.getElementsByClassName = function(className) {
  436
+  var children = document.getElementsByTagName('*') || document.all;
  437
+  var elements = new Array();
  438
+  
  439
+  for (var i = 0; i < children.length; i++) {
  440
+    var child = children[i];
  441
+    var classNames = child.className.split(' ');
  442
+    for (var j = 0; j < classNames.length; j++) {
  443
+      if (classNames[j] == className) {
  444
+        elements.push(child);
  445
+        break;
  446
+      }
  447
+    }
  448
+  }
  449
+  
  450
+  return elements;
  451
+}
  452
+
  453
+/*--------------------------------------------------------------------------*/
  454
+
  455
+var Element = {
  456
+  toggle: function() {
  457
+    for (var i = 0; i < arguments.length; i++) {
  458
+      var element = $(arguments[i]);
  459
+      element.style.display = 
  460
+        (element.style.display == 'none' ? '' : 'none');
  461
+    }
  462
+  },
  463
+
  464
+  hide: function() {
  465
+    for (var i = 0; i < arguments.length; i++) {
  466
+      var element = $(arguments[i]);
  467
+      element.style.display = 'none';
  468
+    }
  469
+  },
  470
+
  471
+  show: function() {
  472
+    for (var i = 0; i < arguments.length; i++) {
  473
+      var element = $(arguments[i]);
  474
+      element.style.display = '';
  475
+    }
  476
+  },
  477
+
  478
+  remove: function(element) {
  479
+    element = $(element);
  480
+    element.parentNode.removeChild(element);
  481
+  },
  482
+   
  483
+  getHeight: function(element) {
  484
+    element = $(element);
  485
+    return element.offsetHeight; 
  486
+  }
  487
+}
  488
+
  489
+var Toggle = new Object();
  490
+Toggle.display = Element.toggle;
  491
+
  492
+/*--------------------------------------------------------------------------*/
  493
+
371 494
 Abstract.Insertion = function(adjacency) {
372 495
   this.adjacency = adjacency;
373 496
 }
@@ -484,7 +607,7 @@ Effect.Fade.prototype = {
484 607
     if (this.timer) clearTimeout(this.timer);
485 608
     this.setOpacity(this.element, this.current);
486 609
     this.current -= 10;
487  
-    this.timer = setTimeout(this.fade.bind(this), 100);
  610
+    this.timer = setTimeout(this.fade.bind(this), 50);
488 611
   },
489 612
   
490 613
   isFinished: function() {
@@ -494,7 +617,7 @@ Effect.Fade.prototype = {
494 617
   setOpacity: function(element, opacity) {
495 618
     opacity = (opacity == 100) ? 99.999 : opacity;
496 619
     element.style.filter = "alpha(opacity:"+opacity+")";
497  
-    element.style.opacity = opacity/100;
  620
+    element.style.opacity = opacity/100 /*//*/;
498 621
   }
499 622
 }
500 623
 
@@ -503,13 +626,13 @@ Effect.Scale.prototype = {
503 626
   initialize: function(element, percent) {
504 627
     this.element = $(element);
505 628
     this.startScale    = 1.0;
506  
-    this.startHeight   = this.element.height || this.element.offsetHeight;
507  
-    this.startWidth    = this.element.width || this.element.offsetWidth;
  629
+    this.startHeight   = this.element.offsetHeight;
  630
+    this.startWidth    = this.element.offsetWidth;
508 631
     this.currentHeight = this.startHeight;
509 632
     this.currentWidth  = this.startWidth;
510  
-    this.finishScale   = (percent/100);
  633
+    this.finishScale   = (percent/100) /*//*/;
511 634
     if (this.element.style.fontSize=="") this.sizeEm = 1.0;
512  
-    if (this.element.style.fontSize && this.element.style.fontSize.indexOf("em")>0)
  635
+    if (this.element.style.fontSize.indexOf("em")>0)
513 636
        this.sizeEm      = parseFloat(this.element.style.fontSize);
514 637
     if(this.element.effect_scale) {
515 638
       clearTimeout(this.element.effect_scale.timer);
@@ -537,7 +660,7 @@ Effect.Scale.prototype = {
537 660
     if (this.options.step) this.options.step(this);
538 661
     this.setDimensions(this.element, this.currentWidth, this.currentHeight);
539 662
     if(this.sizeEm) this.element.style.fontSize = this.sizeEm*this.currentScale + "em";
540  
-    this.currentScale += (this.factor/10);
  663
+    this.currentScale += (this.factor/10) /*//*/;
541 664
     this.currentWidth = this.startWidth * this.currentScale;
542 665
     this.currentHeight = this.startHeight * this.currentScale;
543 666
     this.timer = setTimeout(this.scale.bind(this), 50);
@@ -577,13 +700,9 @@ Effect.Puff.prototype = {
577 700
   fade: function(effect) {
578 701
     topd    = (((effect.currentScale)*effect.startHeight) - effect.startHeight)/2;
579 702
     leftd   = (((effect.currentScale)*effect.startWidth) - effect.startWidth)/2;
580  
-    if(this.element.style.position='absolute') {
581  
-      this.element.style.top = this.startTop-topd + "px";
582  
-      this.element.style.left = this.startLeft-leftd + "px";
583  
-    } else {
584  
-      this.element.style.top = -topd + "px";
585  
-      this.element.style.left = -leftd + "px";
586  
-    }
  703
+    this.element.style.position='absolute';
  704
+    this.element.style.top = this.startTop-topd + "px";
  705
+    this.element.style.left = this.startLeft-leftd + "px";
587 706
     this.opacity -= 10;
588 707
     this.setOpacity(this.element, this.opacity); 
589 708
     if(navigator.appVersion.indexOf('AppleWebKit')>0) this.element.innerHTML += ''; //force redraw on safari
@@ -594,7 +713,7 @@ Effect.Puff.prototype = {
594 713
   setOpacity: function(element, opacity) {
595 714
     opacity = (opacity == 100) ? 99.999 : opacity;
596 715
     element.style.filter = "alpha(opacity:"+opacity+")";
597  
-    element.style.opacity = opacity/100;
  716
+    element.style.opacity = opacity/100 /*//*/;
598 717
   }
599 718
 }
600 719
 
@@ -613,7 +732,7 @@ Effect.Appear.prototype = {
613 732
     if (this.timer) clearTimeout(this.timer);
614 733
     this.setOpacity(this.element, this.current);
615 734
     this.current += 10;
616  
-    this.timer = setTimeout(this.fade.bind(this), 100);
  735
+    this.timer = setTimeout(this.fade.bind(this), 50);
617 736
   },
618 737
   
619 738
   isFinished: function() {
@@ -623,37 +742,23 @@ Effect.Appear.prototype = {
623 742
   setOpacity: function(element, opacity) {
624 743
     opacity = (opacity == 100) ? 99.999 : opacity;
625 744
     element.style.filter = "alpha(opacity:"+opacity+")";
626  
-    element.style.opacity = opacity/100;
  745
+    element.style.opacity = opacity/100 /*//*/;
627 746
     element.style.display = '';
628 747
   }
629 748
 }
630 749
 
631  
-/*--------------------------------------------------------------------------*/
632  
-
633  
-PeriodicalExecuter = Class.create();
634  
-PeriodicalExecuter.prototype = {
635  
-  initialize: function(what, frequency) {
636  
-    this.what = what;
637  
-    this.frequency = frequency;
638  
-    this.currentlyExecuting = false;
639  
-    
640  
-    this.registerCallback();
641  
-  },
642  
-  
643  
-  registerCallback: function() {
644  
-    setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
645  
-  },
646  
-  
647  
-  onTimerEvent: function() {
648  
-    if (!this.currentlyExecuting) {
649  
-      try { 
650  
-        this.currentlyExecuting = true;
651  
-        this.what(); 
652  
-      } finally { 
653  
-        this.currentlyExecuting = false;
654  
-      }
  750
+Effect.ContentZoom = Class.create();
  751
+Effect.ContentZoom.prototype = {
  752
+  initialize: function(element, percent) {
  753
+    this.element = $(element);
  754
+    if (this.element.style.fontSize=="") this.sizeEm = 1.0;
  755
+    if (this.element.style.fontSize.indexOf("em")>0)
  756
+       this.sizeEm = parseFloat(this.element.style.fontSize);
  757
+    if(this.element.effect_contentzoom) {
  758
+      this.sizeEm = this.element.effect_contentzoom.sizeEm;
655 759
     }
656  
-    
657  
-    this.registerCallback();
  760
+    this.element.effect_contentzoom = this;
  761
+    this.element.style.fontSize = this.sizeEm*(percent/100) + "em" /*//*/;
  762
+    if(navigator.appVersion.indexOf('AppleWebKit')>0) { this.element.scrollTop -= 1; };
658 763
   }
659 764
 }
279  railties/html/javascripts/prototype.js
... ...
@@ -1,12 +1,17 @@
1  
-/*  Prototype: an object-oriented Javascript library, version 1.1.0
  1
+/*  Prototype: an object-oriented Javascript library, version 1.2.0
2 2
  *  (c) 2005 Sam Stephenson <sam@conio.net>
3 3
  *
4  
- *  Prototype is freely distributable under the terms of an MIT-style license. 
5  
- *  For details, see http://prototype.conio.net/
6  
- */
  4
+ *  THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
  5
+ *  against the source tree, available from the Prototype darcs repository. 
  6
+ *
  7
+ *  Prototype is freely distributable under the terms of an MIT-style license.
  8
+ *
  9
+ *  For details, see the Prototype web site: http://prototype.conio.net/
  10
+ *
  11
+/*--------------------------------------------------------------------------*/
7 12
 
8 13
 var Prototype = {
9  
-  Version: '1.1.0'
  14
+  Version: '1.2.0'
10 15
 }
11 16
 
12 17
 var Class = {
@@ -62,28 +67,33 @@ var Try = {
62 67
   }
63 68
 }
64 69
 
65  
-// Deprecated accessor for Element.toggle
66  
-var Toggle = { display: function() { Element.toggle(arguments); } }
  70
+/*--------------------------------------------------------------------------*/
67 71
 
68  
-var Element = {
69  
-  toggle: function() {
70  
-    for (var i = 0; i < arguments.length; i++) {
71  
-      var element = $(arguments[i]);
72  
-      element.style.display = 
73  
-        (element.style.display == 'none' ? '' : 'none');
74  
-    }
75  
-  }
76  
-  hide: function() {
77  
-    for (var i = 0; i < arguments.length; i++) {
78  
-      var element = $(arguments[i]);
79  
-      element.style.display = 'none';
80  
-    }
81  
-  }
82  
-  show: function() {
83  
-    for (var i = 0; i < arguments.length; i++) {
84  
-      var element = $(arguments[i]);
85  
-      element.style.display = '';
  72
+var PeriodicalExecuter = Class.create();
  73
+PeriodicalExecuter.prototype = {
  74
+  initialize: function(callback, frequency) {
  75
+    this.callback = callback;
  76
+    this.frequency = frequency;
  77
+    this.currentlyExecuting = false;
  78
+    
  79
+    this.registerCallback();
  80
+  },
  81
+  
  82
+  registerCallback: function() {
  83
+    setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
  84
+  },
  85
+  
  86
+  onTimerEvent: function() {
  87
+    if (!this.currentlyExecuting) {
  88
+      try { 
  89
+        this.currentlyExecuting = true;
  90
+        this.callback(); 
  91
+      } finally { 
  92
+        this.currentlyExecuting = false;
  93
+      }
86 94
     }
  95
+    
  96
+    this.registerCallback();
87 97
   }
88 98
 }
89 99
 
@@ -106,22 +116,34 @@ function $() {
106 116
   return elements;
107 117
 }
108 118
 
109  
-function getElementsByClassName(className) {
110  
-  var children = document.getElementsByTagName('*') || document.all;
111  
-  var elements = new Array();
112  
-  
113  
-  for (var i = 0; i < children.length; i++) {
114  
-    var child = children[i];
115  
-    var classNames = child.className.split(' ');
116  
-    for (var j = 0; j < classNames.length; j++) {
117  
-      if (classNames[j] == className) {
118  
-        elements.push(child);
119  
-        break;
120  
-      }
121  
-    }
  119
+/*--------------------------------------------------------------------------*/
  120
+
  121
+if (!Array.prototype.push) {
  122
+  Array.prototype.push = function() {
  123
+		var startLength = this.length;
  124
+		for (var i = 0; i < arguments.length; i++)
  125
+      this[startLength + i] = arguments[i];
  126
+	  return this.length;
  127
+  }
  128
+}
  129
+
  130
+if (!Function.prototype.apply) {
  131
+  // Based on code from http://www.youngpup.net/
  132
+  Function.prototype.apply = function(object, parameters) {
  133
+    var parameterStrings = new Array();
  134
+    if (!object)     object = window;
  135
+    if (!parameters) parameters = new Array();
  136
+    
  137
+    for (var i = 0; i < parameters.length; i++)
  138
+      parameterStrings[i] = 'x[' + i + ']';
  139
+    
  140
+    object.__apply__ = this;
  141
+    var result = eval('obj.__apply__(' + 
  142
+      parameterStrings[i].join(', ') + ')');
  143
+    object.__apply__ = null;
  144
+    
  145
+    return result;
122 146
   }
123  
-  
124  
-  return elements;
125 147
 }
126 148
 
127 149
 /*--------------------------------------------------------------------------*/
@@ -169,6 +191,9 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
169 191
         setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
170 192
       }
171 193
               
  194
+      this.transport.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  195
+      this.transport.setRequestHeader('X-Prototype-Version', Prototype.Version);
  196
+
172 197
       if (this.options.method == 'post') {
173 198
         this.transport.setRequestHeader('Connection', 'close');
174 199
         this.transport.setRequestHeader('Content-type',
@@ -212,11 +237,11 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
212 237
   },
213 238
   
214 239
   updateContent: function() {
215  
-    if (!this.options.insertion) {
216  
-      this.container.innerHTML = this.request.transport.responseText;
217  
-    } else {
  240
+    if (this.options.insertion) {
218 241
       new this.options.insertion(this.container,
219 242
         this.request.transport.responseText);
  243
+    } else {
  244
+      this.container.innerHTML = this.request.transport.responseText;
220 245
     }
221 246
 
222 247
     if (this.onComplete) {
@@ -241,6 +266,15 @@ var Field = {
241 266
     for (var i = 0; i < arguments.length; i++)
242 267
       if ($(arguments[i]).value == '') return false;
243 268
     return true;
  269
+  },
  270
+  
  271
+  select: function(element) {
  272
+    $(element).select();
  273
+  },
  274
+   
  275
+  activate: function(element) {
  276
+    $(element).focus();
  277
+    $(element).select();
244 278
   }
245 279
 }
246 280
 
@@ -270,6 +304,31 @@ var Form = {
270 304
         elements.push(tagElements[j]);
271 305
     }
272 306
     return elements;
  307
+  },
  308
+  
  309
+  disable: function(form) {
  310
+    var elements = Form.getElements(form);
  311
+    for (var i = 0; i < elements.length; i++) {
  312
+      var element = elements[i];
  313
+      element.blur();
  314
+      element.disable = 'true';
  315
+    }
  316
+  },
  317
+
  318
+  focusFirstElement: function(form) {
  319
+    form = $(form);
  320
+    var elements = Form.getElements(form);
  321
+    for (var i = 0; i < elements.length; i++) {
  322
+      var element = elements[i];
  323
+      if (element.type != 'hidden' && !element.disabled) {
  324
+        Field.activate(element);
  325
+        break;
  326
+      }
  327
+    }
  328
+  },
  329
+
  330
+  reset: function(form) {
  331
+    $(form).reset();
273 332
   }
274 333
 }
275 334
 
@@ -319,12 +378,17 @@ Form.Element.Serializers = {
319 378
 
320 379
   select: function(element) {
321 380
     var index = element.selectedIndex;
322  
-    return [element.name, (index >= 0) ? element.options[index].value : ''];
  381
+    var value = element.options[index].value || element.options[index].text;
  382
+    return [element.name, (index >= 0) ? value : ''];
323 383
   }
324 384
 }
325 385
 
326 386
 /*--------------------------------------------------------------------------*/
327 387
 
  388
+var $F = Form.Element.getValue;
  389
+
  390
+/*--------------------------------------------------------------------------*/
  391
+
328 392
 Abstract.TimedObserver = function() {}
329 393
 Abstract.TimedObserver.prototype = {
330 394
   initialize: function(element, frequency, callback) {
@@ -368,6 +432,65 @@ Form.Observer.prototype = (new Abstract.TimedObserver()).extend({
368 432
 
369 433
 /*--------------------------------------------------------------------------*/
370 434
 
  435
+document.getElementsByClassName = function(className) {
  436
+  var children = document.getElementsByTagName('*') || document.all;
  437
+  var elements = new Array();
  438
+  
  439
+  for (var i = 0; i < children.length; i++) {
  440
+    var child = children[i];
  441
+    var classNames = child.className.split(' ');
  442
+    for (var j = 0; j < classNames.length; j++) {
  443
+      if (classNames[j] == className) {
  444
+        elements.push(child);
  445
+        break;
  446
+      }
  447
+    }
  448
+  }
  449
+  
  450
+  return elements;
  451
+}
  452
+
  453
+/*--------------------------------------------------------------------------*/
  454
+
  455
+var Element = {
  456
+  toggle: function() {
  457
+    for (var i = 0; i < arguments.length; i++) {
  458
+      var element = $(arguments[i]);
  459
+      element.style.display = 
  460
+        (element.style.display == 'none' ? '' : 'none');
  461
+    }
  462
+  },
  463
+
  464
+  hide: function() {
  465
+    for (var i = 0; i < arguments.length; i++) {
  466
+      var element = $(arguments[i]);
  467
+      element.style.display = 'none';
  468
+    }
  469
+  },
  470
+
  471
+  show: function() {
  472
+    for (var i = 0; i < arguments.length; i++) {
  473
+      var element = $(arguments[i]);
  474
+      element.style.display = '';
  475
+    }
  476
+  },
  477
+
  478
+  remove: function(element) {
  479
+    element = $(element);
  480
+    element.parentNode.removeChild(element);
  481
+  },
  482
+   
  483
+  getHeight: function(element) {
  484
+    element = $(element);
  485
+    return element.offsetHeight; 
  486
+  }
  487
+}
  488
+
  489
+var Toggle = new Object();
  490
+Toggle.display = Element.toggle;
  491
+
  492
+/*--------------------------------------------------------------------------*/
  493
+
371 494
 Abstract.Insertion = function(adjacency) {
372 495
   this.adjacency = adjacency;
373 496
 }
@@ -484,7 +607,7 @@ Effect.Fade.prototype = {
484 607
     if (this.timer) clearTimeout(this.timer);
485 608
     this.setOpacity(this.element, this.current);
486 609
     this.current -= 10;
487  
-    this.timer = setTimeout(this.fade.bind(this), 100);
  610
+    this.timer = setTimeout(this.fade.bind(this), 50);
488 611
   },
489 612
   
490 613
   isFinished: function() {
@@ -494,7 +617,7 @@ Effect.Fade.prototype = {
494 617
   setOpacity: function(element, opacity) {
495 618
     opacity = (opacity == 100) ? 99.999 : opacity;
496 619
     element.style.filter = "alpha(opacity:"+opacity+")";
497  
-    element.style.opacity = opacity/100;
  620
+    element.style.opacity = opacity/100 /*//*/;
498 621
   }
499 622
 }
500 623
 
@@ -503,13 +626,13 @@ Effect.Scale.prototype = {
503 626
   initialize: function(element, percent) {
504 627
     this.element = $(element);
505 628
     this.startScale    = 1.0;
506  
-    this.startHeight   = this.element.height || this.element.offsetHeight;
507  
-    this.startWidth    = this.element.width || this.element.offsetWidth;
  629
+    this.startHeight   = this.element.offsetHeight;
  630
+    this.startWidth    = this.element.offsetWidth;
508 631
     this.currentHeight = this.startHeight;
509 632
     this.currentWidth  = this.startWidth;
510  
-    this.finishScale   = (percent/100);
  633
+    this.finishScale   = (percent/100) /*//*/;
511 634
     if (this.element.style.fontSize=="") this.sizeEm = 1.0;
512  
-    if (this.element.style.fontSize && this.element.style.fontSize.indexOf("em")>0)
  635
+    if (this.element.style.fontSize.indexOf("em")>0)
513 636
        this.sizeEm      = parseFloat(this.element.style.fontSize);
514 637
     if(this.element.effect_scale) {
515 638
       clearTimeout(this.element.effect_scale.timer);
@@ -537,7 +660,7 @@ Effect.Scale.prototype = {
537 660
     if (this.options.step) this.options.step(this);
538 661
     this.setDimensions(this.element, this.currentWidth, this.currentHeight);
539 662
     if(this.sizeEm) this.element.style.fontSize = this.sizeEm*this.currentScale + "em";
540  
-    this.currentScale += (this.factor/10);
  663
+    this.currentScale += (this.factor/10) /*//*/;
541 664
     this.currentWidth = this.startWidth * this.currentScale;
542 665
     this.currentHeight = this.startHeight * this.currentScale;
543 666
     this.timer = setTimeout(this.scale.bind(this), 50);
@@ -577,13 +700,9 @@ Effect.Puff.prototype = {
577 700
   fade: function(effect) {
578 701
     topd    = (((effect.currentScale)*effect.startHeight) - effect.startHeight)/2;
579 702
     leftd   = (((effect.currentScale)*effect.startWidth) - effect.startWidth)/2;
580  
-    if(this.element.style.position='absolute') {
581  
-      this.element.style.top = this.startTop-topd + "px";
582  
-      this.element.style.left = this.startLeft-leftd + "px";
583  
-    } else {
584  
-      this.element.style.top = -topd + "px";
585  
-      this.element.style.left = -leftd + "px";
586  
-    }
  703
+    this.element.style.position='absolute';
  704
+    this.element.style.top = this.startTop-topd + "px";
  705
+    this.element.style.left = this.startLeft-leftd + "px";
587 706
     this.opacity -= 10;
588 707
     this.setOpacity(this.element, this.opacity); 
589 708
     if(navigator.appVersion.indexOf('AppleWebKit')>0) this.element.innerHTML += ''; //force redraw on safari
@@ -594,7 +713,7 @@ Effect.Puff.prototype = {
594 713
   setOpacity: function(element, opacity) {
595 714
     opacity = (opacity == 100) ? 99.999 : opacity;
596 715
     element.style.filter = "alpha(opacity:"+opacity+")";
597  
-    element.style.opacity = opacity/100;
  716
+    element.style.opacity = opacity/100 /*//*/;
598 717
   }
599 718
 }
600 719
 
@@ -613,7 +732,7 @@ Effect.Appear.prototype = {
613 732
     if (this.timer) clearTimeout(this.timer);
614 733
     this.setOpacity(this.element, this.current);
615 734
     this.current += 10;
616  
-    this.timer = setTimeout(this.fade.bind(this), 100);
  735
+    this.timer = setTimeout(this.fade.bind(this), 50);
617 736
   },
618 737
   
619 738
   isFinished: function() {
@@ -623,37 +742,23 @@ Effect.Appear.prototype = {
623 742
   setOpacity: function(element, opacity) {
624 743
     opacity = (opacity == 100) ? 99.999 : opacity;
625 744
     element.style.filter = "alpha(opacity:"+opacity+")";
626  
-    element.style.opacity = opacity/100;
  745
+    element.style.opacity = opacity/100 /*//*/;
627 746
     element.style.display = '';
628 747
   }
629 748
 }
630 749
 
631  
-/*--------------------------------------------------------------------------*/
632  
-
633  
-PeriodicalExecuter = Class.create();
634  
-PeriodicalExecuter.prototype = {
635  
-  initialize: function(what, frequency) {
636  
-    this.what = what;
637  
-    this.frequency = frequency;
638  
-    this.currentlyExecuting = false;
639  
-    
640  
-    this.registerCallback();
641  
-  },
642  
-  
643  
-  registerCallback: function() {
644  
-    setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
645  
-  },
646  
-  
647  
-  onTimerEvent: function() {
648  
-    if (!this.currentlyExecuting) {
649  
-      try { 
650  
-        this.currentlyExecuting = true;
651  
-        this.what(); 
652  
-      } finally { 
653  
-        this.currentlyExecuting = false;
654  
-      }
  750
+Effect.ContentZoom = Class.create();
  751
+Effect.ContentZoom.prototype = {
  752
+  initialize: function(element, percent) {
  753
+    this.element = $(element);
  754
+    if (this.element.style.fontSize=="") this.sizeEm = 1.0;
  755
+    if (this.element.style.fontSize.indexOf("em")>0)
  756
+       this.sizeEm = parseFloat(this.element.style.fontSize);
  757
+    if(this.element.effect_contentzoom) {
  758
+      this.sizeEm = this.element.effect_contentzoom.sizeEm;
655 759
     }
656  
-    
657  
-    this.registerCallback();
  760
+    this.element.effect_contentzoom = this;
  761
+    this.element.style.fontSize = this.sizeEm*(percent/100) + "em" /*//*/;
  762
+    if(navigator.appVersion.indexOf('AppleWebKit')>0) { this.element.scrollTop -= 1; };
658 763
   }
659 764
 }

0 notes on commit d547c3f

Please sign in to comment.
Something went wrong with that request. Please try again.