Skip to content

Commit

Permalink
Update Prototype version check so all version can be required and use…
Browse files Browse the repository at this point in the history
… $$ in the loader instead of getElementsByTagName. Closes #9032, #10966 [Nick Stakenburg]
  • Loading branch information
staaky committed Apr 21, 2008
1 parent 5ffc019 commit 951f483
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
@@ -1,3 +1,7 @@
* Update version check so all Prototype versions can be required, not just x.x.x. Closes #10966. [Nick Stakenburg]

* Using $$ in the loader instead of getElementsByTagName to prevent limitations. Closes #9032. [Nick Stakenburg]

* Fix some missing semicolons. [jdalton]

* Update to Prototype 1.6.0.2 final
Expand Down
30 changes: 16 additions & 14 deletions src/scriptaculous.js
Expand Up @@ -27,26 +27,28 @@ var Scriptaculous = {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
},
REQUIRED_PROTOTYPE: '1.6.0',
REQUIRED_PROTOTYPE: '1.6.0.2',
load: function() {
function convertVersionString(versionString){
var r = versionString.split('.');
return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
function convertVersionString(versionString) {
var v = versionString.replace(/_.*|\./g, '');
v = parseInt(v + '0'.times(4-v.length));
return versionString.indexOf('_') > -1 ? v-1 : v;
}
if((typeof Prototype=='undefined') ||
(typeof Element == 'undefined') ||

if((typeof Prototype=='undefined') ||
(typeof Element == 'undefined') ||
(typeof Element.Methods=='undefined') ||
(convertVersionString(Prototype.Version) <
(convertVersionString(Prototype.Version) <
convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
throw("script.aculo.us requires the Prototype JavaScript framework >= " +
Scriptaculous.REQUIRED_PROTOTYPE);

$A(document.getElementsByTagName("script")).findAll( function(s) {
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
}).each( function(s) {
var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
var includes = s.src.match(/\?.*load=([a-z,]*)/);

var js = /scriptaculous\.js(\?.*)?$/;
$$('head script[src]').findAll(function(s) {
return s.src.match(js);
}).each(function(s) {
var path = s.src.replace(js, ''),
includes = s.src.match(/\?.*load=([a-z,]*)/);
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') });
});
Expand Down

0 comments on commit 951f483

Please sign in to comment.