Changeset 749

Show
Ignore:
Timestamp:
07/08/09 19:43:40 (14 months ago)
Author:
lordlamer
Message:

- update prototypejs to version 1.6.1rc3 (Closes: #112)

Location:
branches/knowledgeroot-0.9.9
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/knowledgeroot-0.9.9/doc/CHANGELOG

    r745 r749  
    39439420090707 - fhabermann 
    395395- fixed mistake with filehandling 
     396 
     39720090708 - 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_rc2 
     1/*  Prototype JavaScript framework, version 1.6.1_rc3 
    22 *  (c) 2005-2009 Sam Stephenson 
    33 * 
     
    88 
    99var 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  })(), 
    2123 
    2224  BrowserFeatures: { 
     
    2426    SelectorsAPI: !!document.querySelector, 
    2527    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); 
    3030    })(), 
    3131    SpecificElementExtensions: (function() { 
     
    3434 
    3535      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; 
    4246    })() 
    4347  }, 
     
    7680 
    7781var Class = (function() { 
     82  function subclass() {}; 
    7883  function create() { 
    7984    var parent = null, properties = $A(arguments); 
     
    9095 
    9196    if (parent) { 
    92       var subclass = function() {}; 
    9397      subclass.prototype = parent.prototype; 
    9498      klass.prototype = new subclass; 
     
    477481 
    478482  function stripTags() { 
    479     return this.replace(/<\/?[^>]+>/gi, ''); 
     483    return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, ''); 
    480484  } 
    481485 
     
    508512      div.childNodes[0].nodeValue) : ''; 
    509513  } 
     514 
    510515 
    511516  function toQueryParams(separator) { 
     
    630635    scan:           scan, 
    631636    truncate:       truncate, 
    632     strip:          strip, 
     637    strip:          String.prototype.trim ? String.prototype.trim : strip, 
    633638    stripTags:      stripTags, 
    634639    stripScripts:   stripScripts, 
     
    670675  String.prototype.escapeHTML = function() { 
    671676    return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); 
    672   } 
     677  }; 
    673678} 
    674679 
     
    676681  String.prototype.unescapeHTML = function() { 
    677682    return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&'); 
    678   } 
     683  }; 
    679684} 
    680685var Template = Class.create({ 
     
    685690 
    686691  evaluate: function(object) { 
    687     if (Object.isFunction(object.toTemplateReplacements)) 
     692    if (object && Object.isFunction(object.toTemplateReplacements)) 
    688693      object = object.toTemplateReplacements(); 
    689694 
    690695    return this.template.gsub(this.pattern, function(match) { 
    691       if (object == null) return ''; 
     696      if (object == null) return (match[1] + ''); 
    692697 
    693698      var before = match[1] || ''; 
     
    962967function $A(iterable) { 
    963968  if (!iterable) return []; 
    964   if ('toArray' in iterable) return iterable.toArray(); 
     969  if ('toArray' in Object(iterable)) return iterable.toArray(); 
    965970  var length = iterable.length || 0, results = new Array(length); 
    966971  while (length--) results[length] = iterable[length]; 
     
    18951900      if (SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY) { 
    18961901        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          } 
    19001905          Element._getContentFromAnonymousElement(tagName, content.stripScripts()) 
    19011906            .each(function(node) { 
     
    20012006 
    20022007  ancestors: function(element) { 
    2003     return $(element).recursivelyCollect('parentNode'); 
     2008    return Element.recursivelyCollect(element, 'parentNode'); 
    20042009  }, 
    20052010 
     
    20222027 
    20232028  previousSiblings: function(element) { 
    2024     return $(element).recursivelyCollect('previousSibling'); 
     2029    return Element.recursivelyCollect(element, 'previousSibling'); 
    20252030  }, 
    20262031 
    20272032  nextSiblings: function(element) { 
    2028     return $(element).recursivelyCollect('nextSibling'); 
     2033    return Element.recursivelyCollect(element, 'nextSibling'); 
    20292034  }, 
    20302035 
    20312036  siblings: function(element) { 
    20322037    element = $(element); 
    2033     return element.previousSiblings().reverse().concat(element.nextSiblings()); 
     2038    return Element.previousSiblings(element).reverse() 
     2039      .concat(Element.nextSiblings(element)); 
    20342040  }, 
    20352041 
     
    20432049    element = $(element); 
    20442050    if (arguments.length == 1) return $(element.parentNode); 
    2045     var ancestors = element.ancestors(); 
     2051    var ancestors = Element.ancestors(element); 
    20462052    return Object.isNumber(expression) ? ancestors[expression] : 
    20472053      Selector.findElement(ancestors, expression, index); 
     
    20502056  down: function(element, expression, index) { 
    20512057    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] : 
    20542060      Element.select(element, expression)[index || 0]; 
    20552061  }, 
     
    20582064    element = $(element); 
    20592065    if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); 
    2060     var previousSiblings = element.previousSiblings(); 
     2066    var previousSiblings = Element.previousSiblings(element); 
    20612067    return Object.isNumber(expression) ? previousSiblings[expression] : 
    20622068      Selector.findElement(previousSiblings, expression, index); 
     
    20662072    element = $(element); 
    20672073    if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); 
    2068     var nextSiblings = element.nextSiblings(); 
     2074    var nextSiblings = Element.nextSiblings(element); 
    20692075    return Object.isNumber(expression) ? nextSiblings[expression] : 
    20702076      Selector.findElement(nextSiblings, expression, index); 
     
    20722078 
    20732079 
    2074   select: function() { 
    2075     var args = $A(arguments), element = $(args.shift()); 
     2080  select: function(element) { 
     2081    var args = Array.prototype.slice.call(arguments, 1); 
    20762082    return Selector.findChildElements(element, args); 
    20772083  }, 
    20782084 
    2079   adjacent: function() { 
    2080     var args = $A(arguments), element = $(args.shift()); 
     2085  adjacent: function(element) { 
     2086    var args = Array.prototype.slice.call(arguments, 1); 
    20812087    return Selector.findChildElements(element.parentNode, args).without(element); 
    20822088  }, 
     
    20842090  identify: function(element) { 
    20852091    element = $(element); 
    2086     var id = element.readAttribute('id'); 
     2092    var id = Element.readAttribute(element, 'id'); 
    20872093    if (id) return id; 
    20882094    do { id = 'anonymous_element_' + Element.idCounter++ } while ($(id)); 
    2089     element.writeAttribute('id', id); 
     2095    Element.writeAttribute(element, 'id', id); 
    20902096    return id; 
    20912097  }, 
     
    21492155 
    21502156  getHeight: function(element) { 
    2151     return $(element).getDimensions().height; 
     2157    return Element.getDimensions(element).height; 
    21522158  }, 
    21532159 
    21542160  getWidth: function(element) { 
    2155     return $(element).getDimensions().width; 
     2161    return Element.getDimensions(element).width; 
    21562162  }, 
    21572163 
     
    21692175  addClassName: function(element, className) { 
    21702176    if (!(element = $(element))) return; 
    2171     if (!element.hasClassName(className)) 
     2177    if (!Element.hasClassName(element, className)) 
    21722178      element.className += (element.className ? ' ' : '') + className; 
    21732179    return element; 
     
    21832189  toggleClassName: function(element, className) { 
    21842190    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); 
    21872193  }, 
    21882194 
     
    22202226  scrollTo: function(element) { 
    22212227    element = $(element); 
    2222     var pos = element.cumulativeOffset(); 
     2228    var pos = Element.cumulativeOffset(element); 
    22232229    window.scrollTo(pos[0], pos[1]); 
    22242230    return element; 
     
    22682274  getDimensions: function(element) { 
    22692275    element = $(element); 
    2270     var display = element.getStyle('display'); 
     2276    var display = Element.getStyle(element, 'display'); 
    22712277    if (display != 'none' && display != null) // Safari bug 
    22722278      return {width: element.offsetWidth, height: element.offsetHeight}; 
     
    23592365  absolutize: function(element) { 
    23602366    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); 
    23642370    var top     = offsets[1]; 
    23652371    var left    = offsets[0]; 
     
    23822388  relativize: function(element) { 
    23832389    element = $(element); 
    2384     if (element.getStyle('position') == 'relative') return element; 
     2390    if (Element.getStyle(element, 'position') == 'relative') return element; 
    23852391 
    23862392    element.style.position = 'relative'; 
     
    24512457 
    24522458    source = $(source); 
    2453     var p = source.viewportOffset(); 
     2459    var p = Element.viewportOffset(source); 
    24542460 
    24552461    element = $(element); 
     
    24572463    var parent = null; 
    24582464    if (Element.getStyle(element, 'position') == 'absolute') { 
    2459       parent = element.getOffsetParent(); 
    2460       delta = parent.viewportOffset(); 
     2465      parent = Element.getOffsetParent(element); 
     2466      delta = Element.viewportOffset(parent); 
    24612467    } 
    24622468 
     
    28832889 
    28842890(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 
    28892896  }); 
    2890 }).call(Element._insertionTranslations); 
     2897})(); 
    28912898 
    28922899Element.Methods.Simulated = { 
     
    29472954        HTMLAPPLETELEMENT_PROTOTYPE_BUGGY) { 
    29482955      return function(element) { 
    2949         if (element && element.tagName) { 
    2950           var tagName = element.tagName.toUpperCase(); 
    2951           if (tagName === 'OBJECT' || tagName === 'APPLET') { 
     2956        if (element && typeof element._extendedByPrototype == 'undefined') { 
     2957          var t = element.tagName; 
     2958          if (t && (/^(?:object|applet|embed)$/i.test(t))) { 
    29522959            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()]); 
    29592962          } 
    29602963        } 
     
    31593162 
    31603163    if (arguments.length === 2) { 
    3161       element.getStorage().update(key); 
     3164      Element.getStorage(element).update(key); 
    31623165    } else { 
    3163       element.getStorage().set(key, value); 
     3166      Element.getStorage(element).set(key, value); 
    31643167    } 
    31653168 
     
    35813584    }, 
    35823585 
    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    })(), 
    35883611 
    35893612    index: function(parentNode, reverse, ofType) { 
     
    39273950        if (node.tagName !== "!") a.push(node); 
    39283951      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; 
    39353952    } 
    39363953  }); 
     
    40294046 
    40304047    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); 
    40324049    }); 
    40334050  }, 
     
    41154132      element.focus(); 
    41164133      if (element.select && (element.tagName.toLowerCase() != 'input' || 
    4117           !['button', 'reset', 'submit'].include(element.type))) 
     4134          !(/^(?:button|reset|submit)$/i.test(element.type)))) 
    41184135        element.select(); 
    41194136    } catch (e) { } 
     
    43094326  }; 
    43104327 
     4328  var docEl = document.documentElement; 
     4329  var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl 
     4330    && 'onmouseleave' in docEl; 
     4331 
    43114332  var _isButton; 
    43124333  if (Prototype.Browser.IE) { 
     
    44614482 
    44624483    var respondersForEvent = registry.get(eventName); 
    4463     if (Object.isUndefined()) { 
     4484    if (Object.isUndefined(respondersForEvent)) { 
    44644485      respondersForEvent = []; 
    44654486      registry.set(eventName, respondersForEvent); 
     
    44814502      }; 
    44824503    } else { 
    4483       if (!Prototype.Browser.IE && 
     4504      if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED && 
    44844505       (eventName === "mouseenter" || eventName === "mouseleave")) { 
    44854506        if (eventName === "mouseenter" || eventName === "mouseleave") { 
     
    45294550  var _getDOMEventName = Prototype.K; 
    45304551 
    4531   if (!Prototype.Browser.IE) { 
     4552  if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) { 
    45324553    _getDOMEventName = function(eventName) { 
    45334554      var translations = { mouseenter: "mouseover", mouseleave: "mouseout" };