Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10966: improved_versioncheck_noloaderclashing.diff

File improved_versioncheck_noloaderclashing.diff, 2.5 kB (added by staaky, 7 months ago)
  • C:/svn/scriptaculous/src/scriptaculous.js

    old new  
    1 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     1// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    22//  
    33// Permission is hereby granted, free of charge, to any person obtaining 
    44// a copy of this software and associated documentation files (the 
     
    2727    // inserting via DOM fails in Safari 2.0, so brute force approach 
    2828    document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>'); 
    2929  }, 
    30   REQUIRED_PROTOTYPE: '1.6.0', 
     30  REQUIRED_PROTOTYPE: '1.6.0.2', 
    3131  load: function() { 
    32     function convertVersionString(versionString){ 
    33       var r = versionString.split('.'); 
    34       return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]); 
     32    function convertVersionString(versionString) { 
     33      var v = versionString.replace(/_.*|\./g, ''); 
     34      v = parseInt(v + '0'.times(4-v.length)); 
     35      return versionString.indexOf('_') > -1 ? v-1 : v; 
    3536    } 
    36   
    37     if((typeof Prototype=='undefined') ||  
    38        (typeof Element == 'undefined') ||  
     37 
     38    if((typeof Prototype=='undefined') || 
     39       (typeof Element == 'undefined') || 
    3940       (typeof Element.Methods=='undefined') || 
    40        (convertVersionString(Prototype.Version) <  
     41       (convertVersionString(Prototype.Version) < 
    4142        convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE))) 
    4243       throw("script.aculo.us requires the Prototype JavaScript framework >= " + 
    4344        Scriptaculous.REQUIRED_PROTOTYPE); 
    44      
    45     $A(document.getElementsByTagName("script")).findAll( function(s) { 
    46       return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/)) 
    47     }).each( function(s) { 
    48       var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,''); 
     45 
     46    var js = /scriptaculous\.js(\?.*)?$/; 
     47    $$('head script[src]').findAll(function(s) { 
     48      return s.src.match(js); 
     49    }).each(function(s) { 
     50      var path = s.src.replace(js,''); 
    4951      var includes = s.src.match(/\?.*load=([a-z,]*)/); 
    5052      (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each( 
    5153       function(include) { Scriptaculous.require(path+include+'.js') });