Changeset 749
- Timestamp:
- 07/08/09 19:43:40 (14 months ago)
- Location:
- branches/knowledgeroot-0.9.9
- Files:
-
- 2 modified
-
doc/CHANGELOG (modified) (1 diff)
-
system/javascript/prototype.js (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/knowledgeroot-0.9.9/doc/CHANGELOG
r745 r749 394 394 20090707 - fhabermann 395 395 - fixed mistake with filehandling 396 397 20090708 - fhabermann 398 - update prototypejs to version 1.6.1rc3 (Closes: #112) -
branches/knowledgeroot-0.9.9/system/javascript/prototype.js
r681 r749 1 /* Prototype JavaScript framework, version 1.6.1_rc 21 /* Prototype JavaScript framework, version 1.6.1_rc3 2 2 * (c) 2005-2009 Sam Stephenson 3 3 * … … 8 8 9 9 var Prototype = { 10 Version: '1.6.1_rc2', 11 12 Browser: { 13 IE: !!(window.attachEvent && 14 navigator.userAgent.indexOf('Opera') === -1), 15 Opera: navigator.userAgent.indexOf('Opera') > -1, 16 WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, 17 Gecko: navigator.userAgent.indexOf('Gecko') > -1 && 18 navigator.userAgent.indexOf('KHTML') === -1, 19 MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) 20 }, 10 Version: '1.6.1_rc3', 11 12 Browser: (function(){ 13 var ua = navigator.userAgent; 14 var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]'; 15 return { 16 IE: !!window.attachEvent && !isOpera, 17 Opera: isOpera, 18 WebKit: ua.indexOf('AppleWebKit/') > -1, 19 Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1, 20 MobileSafari: /Apple.*Mobile.*Safari/.test(ua) 21 } 22 })(), 21 23 22 24 BrowserFeatures: { … … 24 26 SelectorsAPI: !!document.querySelector, 25 27 ElementExtensions: (function() { 26 if (window.HTMLElement && window.HTMLElement.prototype) 27 return true; 28 if (window.Element && window.Element.prototype) 29 return true; 28 var constructor = window.Element || window.HTMLElement; 29 return !!(constructor && constructor.prototype); 30 30 })(), 31 31 SpecificElementExtensions: (function() { … … 34 34 35 35 var div = document.createElement('div'); 36 if (div['__proto__'] && div['__proto__'] !== 37 document.createElement('form')['__proto__']) { 38 return true; 39 } 40 41 return false; 36 var form = document.createElement('form'); 37 var isSupported = false; 38 39 if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) { 40 isSupported = true; 41 } 42 43 div = form = null; 44 45 return isSupported; 42 46 })() 43 47 }, … … 76 80 77 81 var Class = (function() { 82 function subclass() {}; 78 83 function create() { 79 84 var parent = null, properties = $A(arguments); … … 90 95 91 96 if (parent) { 92 var subclass = function() {};93 97 subclass.prototype = parent.prototype; 94 98 klass.prototype = new subclass; … … 477 481 478 482 function stripTags() { 479 return this.replace(/<\ /?[^>]+>/gi, '');483 return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, ''); 480 484 } 481 485 … … 508 512 div.childNodes[0].nodeValue) : ''; 509 513 } 514 510 515 511 516 function toQueryParams(separator) { … … 630 635 scan: scan, 631 636 truncate: truncate, 632 strip: strip,637 strip: String.prototype.trim ? String.prototype.trim : strip, 633 638 stripTags: stripTags, 634 639 stripScripts: stripScripts, … … 670 675 String.prototype.escapeHTML = function() { 671 676 return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); 672 } 677 }; 673 678 } 674 679 … … 676 681 String.prototype.unescapeHTML = function() { 677 682 return this.stripTags().replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&'); 678 } 683 }; 679 684 } 680 685 var Template = Class.create({ … … 685 690 686 691 evaluate: function(object) { 687 if ( Object.isFunction(object.toTemplateReplacements))692 if (object && Object.isFunction(object.toTemplateReplacements)) 688 693 object = object.toTemplateReplacements(); 689 694 690 695 return this.template.gsub(this.pattern, function(match) { 691 if (object == null) return '';696 if (object == null) return (match[1] + ''); 692 697 693 698 var before = match[1] || ''; … … 962 967 function $A(iterable) { 963 968 if (!iterable) return []; 964 if ('toArray' in iterable) return iterable.toArray();969 if ('toArray' in Object(iterable)) return iterable.toArray(); 965 970 var length = iterable.length || 0, results = new Array(length); 966 971 while (length--) results[length] = iterable[length]; … … 1895 1900 if (SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY) { 1896 1901 if (tagName in Element._insertionTranslations.tags) { 1897 $A(element.childNodes).each(function(node) {1898 element.removeChild( node);1899 } );1902 while (element.firstChild) { 1903 element.removeChild(element.firstChild); 1904 } 1900 1905 Element._getContentFromAnonymousElement(tagName, content.stripScripts()) 1901 1906 .each(function(node) { … … 2001 2006 2002 2007 ancestors: function(element) { 2003 return $(element).recursivelyCollect('parentNode');2008 return Element.recursivelyCollect(element, 'parentNode'); 2004 2009 }, 2005 2010 … … 2022 2027 2023 2028 previousSiblings: function(element) { 2024 return $(element).recursivelyCollect('previousSibling');2029 return Element.recursivelyCollect(element, 'previousSibling'); 2025 2030 }, 2026 2031 2027 2032 nextSiblings: function(element) { 2028 return $(element).recursivelyCollect('nextSibling');2033 return Element.recursivelyCollect(element, 'nextSibling'); 2029 2034 }, 2030 2035 2031 2036 siblings: function(element) { 2032 2037 element = $(element); 2033 return element.previousSiblings().reverse().concat(element.nextSiblings()); 2038 return Element.previousSiblings(element).reverse() 2039 .concat(Element.nextSiblings(element)); 2034 2040 }, 2035 2041 … … 2043 2049 element = $(element); 2044 2050 if (arguments.length == 1) return $(element.parentNode); 2045 var ancestors = element.ancestors();2051 var ancestors = Element.ancestors(element); 2046 2052 return Object.isNumber(expression) ? ancestors[expression] : 2047 2053 Selector.findElement(ancestors, expression, index); … … 2050 2056 down: function(element, expression, index) { 2051 2057 element = $(element); 2052 if (arguments.length == 1) return element.firstDescendant();2053 return Object.isNumber(expression) ? element.descendants()[expression] :2058 if (arguments.length == 1) return Element.firstDescendant(element); 2059 return Object.isNumber(expression) ? Element.descendants(element)[expression] : 2054 2060 Element.select(element, expression)[index || 0]; 2055 2061 }, … … 2058 2064 element = $(element); 2059 2065 if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); 2060 var previousSiblings = element.previousSiblings();2066 var previousSiblings = Element.previousSiblings(element); 2061 2067 return Object.isNumber(expression) ? previousSiblings[expression] : 2062 2068 Selector.findElement(previousSiblings, expression, index); … … 2066 2072 element = $(element); 2067 2073 if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); 2068 var nextSiblings = element.nextSiblings();2074 var nextSiblings = Element.nextSiblings(element); 2069 2075 return Object.isNumber(expression) ? nextSiblings[expression] : 2070 2076 Selector.findElement(nextSiblings, expression, index); … … 2072 2078 2073 2079 2074 select: function( ) {2075 var args = $A(arguments), element = $(args.shift());2080 select: function(element) { 2081 var args = Array.prototype.slice.call(arguments, 1); 2076 2082 return Selector.findChildElements(element, args); 2077 2083 }, 2078 2084 2079 adjacent: function( ) {2080 var args = $A(arguments), element = $(args.shift());2085 adjacent: function(element) { 2086 var args = Array.prototype.slice.call(arguments, 1); 2081 2087 return Selector.findChildElements(element.parentNode, args).without(element); 2082 2088 }, … … 2084 2090 identify: function(element) { 2085 2091 element = $(element); 2086 var id = element.readAttribute('id');2092 var id = Element.readAttribute(element, 'id'); 2087 2093 if (id) return id; 2088 2094 do { id = 'anonymous_element_' + Element.idCounter++ } while ($(id)); 2089 element.writeAttribute('id', id);2095 Element.writeAttribute(element, 'id', id); 2090 2096 return id; 2091 2097 }, … … 2149 2155 2150 2156 getHeight: function(element) { 2151 return $(element).getDimensions().height;2157 return Element.getDimensions(element).height; 2152 2158 }, 2153 2159 2154 2160 getWidth: function(element) { 2155 return $(element).getDimensions().width;2161 return Element.getDimensions(element).width; 2156 2162 }, 2157 2163 … … 2169 2175 addClassName: function(element, className) { 2170 2176 if (!(element = $(element))) return; 2171 if (! element.hasClassName(className))2177 if (!Element.hasClassName(element, className)) 2172 2178 element.className += (element.className ? ' ' : '') + className; 2173 2179 return element; … … 2183 2189 toggleClassName: function(element, className) { 2184 2190 if (!(element = $(element))) return; 2185 return element[element.hasClassName(className) ?2186 'removeClassName' : 'addClassName']( className);2191 return Element[Element.hasClassName(element, className) ? 2192 'removeClassName' : 'addClassName'](element, className); 2187 2193 }, 2188 2194 … … 2220 2226 scrollTo: function(element) { 2221 2227 element = $(element); 2222 var pos = element.cumulativeOffset();2228 var pos = Element.cumulativeOffset(element); 2223 2229 window.scrollTo(pos[0], pos[1]); 2224 2230 return element; … … 2268 2274 getDimensions: function(element) { 2269 2275 element = $(element); 2270 var display = element.getStyle('display');2276 var display = Element.getStyle(element, 'display'); 2271 2277 if (display != 'none' && display != null) // Safari bug 2272 2278 return {width: element.offsetWidth, height: element.offsetHeight}; … … 2359 2365 absolutize: function(element) { 2360 2366 element = $(element); 2361 if ( element.getStyle('position') == 'absolute') return element;2362 2363 var offsets = element.positionedOffset();2367 if (Element.getStyle(element, 'position') == 'absolute') return element; 2368 2369 var offsets = Element.positionedOffset(element); 2364 2370 var top = offsets[1]; 2365 2371 var left = offsets[0]; … … 2382 2388 relativize: function(element) { 2383 2389 element = $(element); 2384 if ( element.getStyle('position') == 'relative') return element;2390 if (Element.getStyle(element, 'position') == 'relative') return element; 2385 2391 2386 2392 element.style.position = 'relative'; … … 2451 2457 2452 2458 source = $(source); 2453 var p = source.viewportOffset();2459 var p = Element.viewportOffset(source); 2454 2460 2455 2461 element = $(element); … … 2457 2463 var parent = null; 2458 2464 if (Element.getStyle(element, 'position') == 'absolute') { 2459 parent = element.getOffsetParent();2460 delta = parent.viewportOffset();2465 parent = Element.getOffsetParent(element); 2466 delta = Element.viewportOffset(parent); 2461 2467 } 2462 2468 … … 2883 2889 2884 2890 (function() { 2885 Object.extend(this.tags, { 2886 THEAD: this.tags.TBODY, 2887 TFOOT: this.tags.TBODY, 2888 TH: this.tags.TD 2891 var tags = Element._insertionTranslations.tags; 2892 Object.extend(tags, { 2893 THEAD: tags.TBODY, 2894 TFOOT: tags.TBODY, 2895 TH: tags.TD 2889 2896 }); 2890 }) .call(Element._insertionTranslations);2897 })(); 2891 2898 2892 2899 Element.Methods.Simulated = { … … 2947 2954 HTMLAPPLETELEMENT_PROTOTYPE_BUGGY) { 2948 2955 return function(element) { 2949 if (element && element.tagName) {2950 var t agName = element.tagName.toUpperCase();2951 if (t agName === 'OBJECT' || tagName === 'APPLET') {2956 if (element && typeof element._extendedByPrototype == 'undefined') { 2957 var t = element.tagName; 2958 if (t && (/^(?:object|applet|embed)$/i.test(t))) { 2952 2959 extendElementWith(element, Element.Methods); 2953 if (tagName === 'OBJECT') { 2954 extendElementWith(element, Element.Methods.ByTag.OBJECT) 2955 } 2956 else if (tagName === 'APPLET') { 2957 extendElementWith(element, Element.Methods.ByTag.APPLET) 2958 } 2960 extendElementWith(element, Element.Methods.Simulated); 2961 extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]); 2959 2962 } 2960 2963 } … … 3159 3162 3160 3163 if (arguments.length === 2) { 3161 element.getStorage().update(key);3164 Element.getStorage(element).update(key); 3162 3165 } else { 3163 element.getStorage().set(key, value);3166 Element.getStorage(element).set(key, value); 3164 3167 } 3165 3168 … … 3581 3584 }, 3582 3585 3583 unmark: function(nodes) { 3584 for (var i = 0, node; node = nodes[i]; i++) 3585 node._countedByPrototype = undefined; 3586 return nodes; 3587 }, 3586 unmark: (function(){ 3587 3588 var PROPERTIES_ATTRIBUTES_MAP = (function(){ 3589 var el = document.createElement('div'), 3590 isBuggy = false, 3591 propName = '_countedByPrototype', 3592 value = 'x' 3593 el[propName] = value; 3594 isBuggy = (el.getAttribute(propName) === value); 3595 el = null; 3596 return isBuggy; 3597 })(); 3598 3599 return PROPERTIES_ATTRIBUTES_MAP ? 3600 function(nodes) { 3601 for (var i = 0, node; node = nodes[i]; i++) 3602 node.removeAttribute('_countedByPrototype'); 3603 return nodes; 3604 } : 3605 function(nodes) { 3606 for (var i = 0, node; node = nodes[i]; i++) 3607 node._countedByPrototype = void 0; 3608 return nodes; 3609 } 3610 })(), 3588 3611 3589 3612 index: function(parentNode, reverse, ofType) { … … 3927 3950 if (node.tagName !== "!") a.push(node); 3928 3951 return a; 3929 },3930 3931 unmark: function(nodes) {3932 for (var i = 0, node; node = nodes[i]; i++)3933 node.removeAttribute('_countedByPrototype');3934 return nodes;3935 3952 } 3936 3953 }); … … 4029 4046 4030 4047 return firstByIndex ? firstByIndex : elements.find(function(element) { 4031 return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());4048 return /^(?:input|select|textarea)$/i.test(element.tagName); 4032 4049 }); 4033 4050 }, … … 4115 4132 element.focus(); 4116 4133 if (element.select && (element.tagName.toLowerCase() != 'input' || 4117 ! ['button', 'reset', 'submit'].include(element.type)))4134 !(/^(?:button|reset|submit)$/i.test(element.type)))) 4118 4135 element.select(); 4119 4136 } catch (e) { } … … 4309 4326 }; 4310 4327 4328 var docEl = document.documentElement; 4329 var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl 4330 && 'onmouseleave' in docEl; 4331 4311 4332 var _isButton; 4312 4333 if (Prototype.Browser.IE) { … … 4461 4482 4462 4483 var respondersForEvent = registry.get(eventName); 4463 if (Object.isUndefined( )) {4484 if (Object.isUndefined(respondersForEvent)) { 4464 4485 respondersForEvent = []; 4465 4486 registry.set(eventName, respondersForEvent); … … 4481 4502 }; 4482 4503 } else { 4483 if (! Prototype.Browser.IE&&4504 if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED && 4484 4505 (eventName === "mouseenter" || eventName === "mouseleave")) { 4485 4506 if (eventName === "mouseenter" || eventName === "mouseleave") { … … 4529 4550 var _getDOMEventName = Prototype.K; 4530 4551 4531 if (! Prototype.Browser.IE) {4552 if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) { 4532 4553 _getDOMEventName = function(eventName) { 4533 4554 var translations = { mouseenter: "mouseover", mouseleave: "mouseout" };
