Created
August 15, 2012 12:40
-
-
Save Leftium/3359813 to your computer and use it in GitHub Desktop.
Add Dojo to any website with a single click of this bookmarklet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet | |
// | |
(function() { | |
var el=document.createElement('div'), | |
b=document.getElementsByTagName('body')[0], | |
msg=''; | |
el.style.position='fixed'; | |
el.style.height='20px'; | |
el.style.width='100%'; | |
el.style.marginLeft='0px'; | |
el.style.top='0'; | |
el.style.left='0px'; | |
el.style.padding='5px 10px'; | |
el.style.zIndex = 1001; | |
el.style.fontSize='20px'; | |
el.style.color='#FFF'; | |
el.style.backgroundColor='#0092C9'; | |
el.style.textAlign='center'; | |
el.onmouseover = function() { | |
this.parentNode.removeChild(this); | |
}; | |
if(typeof dojo != 'undefined') { | |
msg='This page already using Dojo v'+ dojo.version ; | |
return showMsg(); | |
} | |
// more or less stolen form jquery core and adapted by paul irish | |
function getScript(url,success){ | |
var script=document.createElement('script'); | |
script.src=url; | |
var head=document.getElementsByTagName('head')[0], | |
done=false; | |
// Attach handlers for all browsers | |
script.onload=script.onreadystatechange = function(){ | |
if ( !done && (!this.readyState | |
|| this.readyState == 'loaded' | |
|| this.readyState == 'complete') ) { | |
done=true; | |
success(); | |
script.onload = script.onreadystatechange = null; | |
head.removeChild(script); | |
} | |
}; | |
head.appendChild(script); | |
} | |
djConfig={afterOnLoad:true}; | |
getScript('//ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js',function() { | |
if (typeof dojo=='undefined') { | |
msg='Sorry, but Dojo wasn\'t able to load'; | |
} else { | |
msg='This page is now Dojo-fied with v' + dojo.version; | |
} | |
return showMsg(); | |
}); | |
function showMsg() { | |
el.innerHTML=msg; | |
b.appendChild(el); | |
window.setTimeout(function() { | |
if (typeof dojo=='undefined') { | |
b.removeChild(el); | |
} else { | |
dojo.fadeOut({ | |
node: el, duration: 2500, | |
onEnd: function() { | |
dojo.query(this).orphan(); | |
} | |
}).play(); | |
} | |
}, 2500); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works great. I changed to the latest version by changing the url to