You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2005/12/22 22:30:21 UTC

svn commit: r358637 [2/2] - in /myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/prototype/resource: dragdrop.js effects.js prototype.js

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/prototype/resource/prototype.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/prototype/resource/prototype.js?rev=358637&r1=358636&r2=358637&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/prototype/resource/prototype.js (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/prototype/resource/prototype.js Thu Dec 22 13:30:13 2005
@@ -1,4 +1,4 @@
-/*  Prototype JavaScript framework, version 1.4.0
+/*  Prototype JavaScript framework, version 1.4.0_rc2
  *  (c) 2005 Sam Stephenson <sa...@conio.net>
  *
  *  THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
@@ -11,8 +11,7 @@
 /*--------------------------------------------------------------------------*/
 
 var Prototype = {
-  Version: '1.4.0',
-  ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
+  Version: '1.4.0_rc2',
 
   emptyFunction: function() {},
   K: function(x) {return x}
@@ -46,10 +45,10 @@
   }
 }
 
-Function.prototype.bind = function() {
-  var __method = this, args = $A(arguments), object = args.shift();
+Function.prototype.bind = function(object) {
+  var __method = this;
   return function() {
-    return __method.apply(object, args.concat($A(arguments)));
+    return __method.apply(object, arguments);
   }
 }
 
@@ -144,22 +143,6 @@
     return this.replace(/<\/?[^>]+>/gi, '');
   },
 
-  stripScripts: function() {
-    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
-  },
-
-  extractScripts: function() {
-    var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
-    var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
-    return (this.match(matchAll) || []).map(function(scriptTag) {
-      return (scriptTag.match(matchOne) || ['', ''])[1];
-    });
-  },
-
-  evalScripts: function() {
-    return this.extractScripts().map(eval);
-  },
-
   escapeHTML: function() {
     var div = document.createElement('div');
     var text = document.createTextNode(this);
@@ -231,8 +214,8 @@
   all: function(iterator) {
     var result = true;
     this.each(function(value, index) {
-      result = result && !!(iterator || Prototype.K)(value, index);
-      if (!result) throw $break;
+      if (!(result &= (iterator || Prototype.K)(value, index)))
+        throw $break;
     });
     return result;
   },
@@ -240,7 +223,7 @@
   any: function(iterator) {
     var result = true;
     this.each(function(value, index) {
-      if (result = !!(iterator || Prototype.K)(value, index))
+      if (result &= (iterator || Prototype.K)(value, index))
         throw $break;
     });
     return result;
@@ -393,7 +376,6 @@
   entries: Enumerable.toArray
 });
 var $A = Array.from = function(iterable) {
-  if (!iterable) return [];
   if (iterable.toArray) {
     return iterable.toArray();
   } else {
@@ -406,19 +388,12 @@
 
 Object.extend(Array.prototype, Enumerable);
 
-Array.prototype._reverse = Array.prototype.reverse;
-
 Object.extend(Array.prototype, {
   _each: function(iterator) {
     for (var i = 0; i < this.length; i++)
       iterator(this[i]);
   },
 
-  clear: function() {
-    this.length = 0;
-    return this;
-  },
-
   first: function() {
     return this[0];
   },
@@ -450,18 +425,13 @@
   indexOf: function(object) {
     for (var i = 0; i < this.length; i++)
       if (this[i] == object) return i;
-    return -1;
-  },
-
-  reverse: function(inline) {
-    return (inline !== false ? this : this.toArray())._reverse();
+    return false;
   },
 
-  shift: function() {
-    var result = this[0];
-    for (var i = 0; i < this.length - 1; i++)
-      this[i] = this[i + 1];
-    this.length--;
+  reverse: function() {
+    var result = [];
+    for (var i = this.length; i > 0; i--)
+      result.push(this[i-1]);
     return result;
   },
 
@@ -516,9 +486,9 @@
   Object.extend(hash, Hash);
   return hash;
 }
-ObjectRange = Class.create();
-Object.extend(ObjectRange.prototype, Enumerable);
-Object.extend(ObjectRange.prototype, {
+var Range = Class.create();
+Object.extend(Range.prototype, Enumerable);
+Object.extend(Range.prototype, {
   initialize: function(start, end, exclusive) {
     this.start = start;
     this.end = end;
@@ -543,7 +513,7 @@
 });
 
 var $R = function(start, end, exclusive) {
-  return new ObjectRange(start, end, exclusive);
+  return new Range(start, end, exclusive);
 }
 
 var Ajax = {
@@ -579,7 +549,8 @@
       if (responder[callback] && typeof responder[callback] == 'function') {
         try {
           responder[callback].apply(responder, [request, transport, json]);
-        } catch (e) {}
+        } catch (e) {
+        }
       }
     });
   }
@@ -655,7 +626,8 @@
       this.transport.send(this.options.method == 'post' ? body : null);
 
     } catch (e) {
-      this.dispatchException(e);
+      (this.options.onException || Prototype.emptyFunction)(this, e);
+      Ajax.Responders.dispatch('onException', this, e);
     }
   },
 
@@ -689,23 +661,12 @@
       this.respondToReadyState(this.transport.readyState);
   },
 
-  header: function(name) {
-    try {
-      return this.transport.getResponseHeader(name);
-    } catch (e) {}
-  },
-
   evalJSON: function() {
     try {
-      return eval(this.header('X-JSON'));
-    } catch (e) {}
-  },
-
-  evalResponse: function() {
-    try {
-      return eval(this.transport.responseText);
+      var json = this.transport.getResponseHeader('X-JSON'), object;
+      object = eval(json);
+      return object;
     } catch (e) {
-      this.dispatchException(e);
     }
   },
 
@@ -713,38 +674,22 @@
     var event = Ajax.Request.Events[readyState];
     var transport = this.transport, json = this.evalJSON();
 
-    if (event == 'Complete') {
-      try {
-        (this.options['on' + this.transport.status]
-         || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
-         || Prototype.emptyFunction)(transport, json);
-      } catch (e) {
-        this.dispatchException(e);
-      }
-
-      if ((this.header('Content-type') || '').match(/^text\/javascript/i))
-        this.evalResponse();
-    }
+    if (event == 'Complete')
+      (this.options['on' + this.transport.status]
+       || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
+       || Prototype.emptyFunction)(transport, json);
 
-    try {
-      (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
-      Ajax.Responders.dispatch('on' + event, this, transport, json);
-    } catch (e) {
-      this.dispatchException(e);
-    }
+    (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
+    Ajax.Responders.dispatch('on' + event, this, transport, json);
 
     /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
     if (event == 'Complete')
       this.transport.onreadystatechange = Prototype.emptyFunction;
-  },
-
-  dispatchException: function(exception) {
-    (this.options.onException || Prototype.emptyFunction)(this, exception);
-    Ajax.Responders.dispatch('onException', this, exception);
   }
 });
 
 Ajax.Updater = Class.create();
+Ajax.Updater.ScriptFragment = '(?:<script.*?>)((\n|.)*?)(?:<\/script>)';
 
 Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
   initialize: function(container, url, options) {
@@ -769,16 +714,16 @@
   updateContent: function() {
     var receiver = this.responseIsSuccess() ?
       this.containers.success : this.containers.failure;
-    var response = this.transport.responseText;
 
-    if (!this.options.evalScripts)
-      response = response.stripScripts();
+    var match    = new RegExp(Ajax.Updater.ScriptFragment, 'img');
+    var response = this.transport.responseText.replace(match, '');
+    var scripts  = this.transport.responseText.match(match);
 
     if (receiver) {
       if (this.options.insertion) {
         new this.options.insertion(receiver, response);
       } else {
-        Element.update(receiver, response);
+        receiver.innerHTML = response;
       }
     }
 
@@ -786,6 +731,14 @@
       if (this.onComplete)
         setTimeout(this.onComplete.bind(this), 10);
     }
+
+    if (this.options.evalScripts && scripts) {
+      match = new RegExp(Ajax.Updater.ScriptFragment, 'im');
+      setTimeout((function() {
+        for (var i = 0; i < scripts.length; i++)
+          eval(scripts[i].match(match)[1]);
+      }).bind(this), 10);
+    }
   }
 });
 
@@ -877,11 +830,6 @@
     element.parentNode.removeChild(element);
   },
 
-  update: function(element, html) {
-    $(element).innerHTML = html.stripScripts();
-    setTimeout(function() {html.evalScripts()}, 10);
-  },
-
   getHeight: function(element) {
     element = $(element);
     return element.offsetHeight;
@@ -945,12 +893,6 @@
     return value == 'auto' ? null : value;
   },
 
-  setStyle: function(element, style) {
-    element = $(element);
-    for (name in style)
-      element.style[name.camelize()] = style[name];
-  },
-
   getDimensions: function(element) {
     element = $(element);
     if (Element.getStyle(element, 'display') != 'none')
@@ -1027,7 +969,7 @@
 Abstract.Insertion.prototype = {
   initialize: function(element, content) {
     this.element = $(element);
-    this.content = content.stripScripts();
+    this.content = content;
 
     if (this.adjacency && this.element.insertAdjacentHTML) {
       try {
@@ -1044,8 +986,6 @@
       if (this.initializeRange) this.initializeRange();
       this.insertContent([this.range.createContextualFragment(this.content)]);
     }
-
-    setTimeout(function() {content.evalScripts()}, 10);
   },
 
   contentFromAnonymousTable: function() {
@@ -1078,7 +1018,7 @@
   },
 
   insertContent: function(fragments) {
-    fragments.reverse(false).each((function(fragment) {
+    fragments.reverse().each((function(fragment) {
       this.element.insertBefore(fragment, this.element.firstChild);
     }).bind(this));
   }
@@ -1139,7 +1079,7 @@
     if (!this.include(classNameToRemove)) return;
     this.set(this.select(function(className) {
       return className != classNameToRemove;
-    }).join(' '));
+    }));
   },
 
   toString: function() {
@@ -1169,10 +1109,8 @@
   },
 
   activate: function(element) {
-    element = $(element);
-    element.focus();
-    if (element.select)
-      element.select();
+    $(element).focus();
+    $(element).select();
   }
 }
 
@@ -1240,15 +1178,16 @@
     }
   },
 
-  findFirstElement: function(form) {
-    return Form.getElements(form).find(function(element) {
-      return element.type != 'hidden' && !element.disabled &&
-        ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
-    });
-  },
-
   focusFirstElement: function(form) {
-    Field.activate(Form.findFirstElement(form));
+    form = $(form);
+    var elements = Form.getElements(form);
+    for (var i = 0; i < elements.length; i++) {
+      var element = elements[i];
+      if (element.type != 'hidden' && !element.disabled) {
+        Field.activate(element);
+        break;
+      }
+    }
   },
 
   reset: function(form) {
@@ -1262,17 +1201,9 @@
     var method = element.tagName.toLowerCase();
     var parameter = Form.Element.Serializers[method](element);
 
-    if (parameter) {
-      var key = encodeURIComponent(parameter[0]);
-      if (key.length == 0) return;
-
-      if (parameter[1].constructor != Array)
-        parameter[1] = [parameter[1]];
-
-      return parameter[1].map(function(value) {
-        return key + '=' + encodeURIComponent(value);
-      }).join('&');
-    }
+    if (parameter)
+      return encodeURIComponent(parameter[0]) + '=' +
+        encodeURIComponent(parameter[1]);
   },
 
   getValue: function(element) {
@@ -1418,14 +1349,24 @@
       switch (element.type.toLowerCase()) {
         case 'checkbox':
         case 'radio':
-          Event.observe(element, 'click', this.onElementEvent.bind(this));
+          element.target = this;
+          element.prev_onclick = element.onclick || Prototype.emptyFunction;
+          element.onclick = function() {
+            this.prev_onclick();
+            this.target.onElementEvent();
+          }
           break;
         case 'password':
         case 'text':
         case 'textarea':
         case 'select-one':
         case 'select-multiple':
-          Event.observe(element, 'change', this.onElementEvent.bind(this));
+          element.target = this;
+          element.prev_onchange = element.onchange || Prototype.emptyFunction;
+          element.onchange = function() {
+            this.prev_onchange();
+            this.target.onElementEvent();
+          }
           break;
       }
     }