Skip to content

Instantly share code, notes, and snippets.

@pmorch
Created February 1, 2012 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmorch/1715924 to your computer and use it in GitHub Desktop.
Save pmorch/1715924 to your computer and use it in GitHub Desktop.
Working bugfix for "ThemeRoller Bookmarklet not working" http://bugs.jqueryui.com/ticket/7195

This is a bugfix for #7195 (ThemeRoller Bookmarklet not working) – jQuery UI

To use it, put the contents of the patched bookmarklet in the bookmarklet instead of what you got from the original bookmarklet. To do this, right-click on the bookmarklet, select Properties, and replace the "Location" field with the contents of the patched bookmarklet link above.

Look at the git history of the gist history (not available in githubs user interface it seems) to see the diffs for the bookmarklet and developertool.js(.php?)

But basically I just implemented the patch referenced by the bug report and made it easy for others to use.

Beware, though, that apparently the source for ThemeRoller is currently not available. So a real upstream bugfix may not be easy.

javascript:(function(){if%20(!/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){alert('Sorry,%20due%20to%20security%20restrictions,%20this%20tool%20only%20works%20in%20Firefox');%20return%20false;%20};%20if(window.jquitr){%20jquitr.addThemeRoller();%20}%20else{%20jquitr%20=%20{};%20jquitr.s%20=%20document.createElement('script');%20jquitr.s.src%20=%20'https://raw.github.com/gist/1715924/developertool.js';%20document.getElementsByTagName('head')[0].appendChild(jquitr.s);}%20})();
if (!window.jquitr) {
var jquitr = {};
}
jquitr.trString = '';
jquitr.s1 = document.createElement('script');
jquitr.s2 = document.createElement('script');
jquitr.s1.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
jquitr.s2.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js');
document.getElementsByTagName('head')[0].appendChild(jquitr.s1);
document.getElementsByTagName('head')[0].appendChild(jquitr.s2);
//once jq and ui are loaded...
jquitr.s1.onload = function () {
jquitr.s2.onload = function () {
(function ($) {
//add dev tool to page
jquitr.addThemeRoller = function(){
if($('#inline_themeroller').size() > 0){
$('#inline_themeroller').fadeIn();
}
else {
$('<div id="inline_themeroller" style="display: none; position: fixed; background: #111; top: 25px; right: 25px; padding: 22px 0 15px 4px;width: 245px;height:400px; -webkit-border-radius: 6px; -moz-border-radius: 6px; z-index: 9999999;">'+
'<a href="#" class="closeTR" style="font-family: Verdana, sans-serif; font-size: 10px; display: block; position: absolute; right: 0; top: 2px; text-align: right; background: url(http://jqueryui.com/themeroller/developertool/icon_bookmarklet_close.gif) 0 2px no-repeat; width: 16px;height: 16px; color: #fff; text-decoration: none;" title="Close ThemeRoller"></a>'+
'<iframe name="trApp" src="http://jqueryui.com/themeroller/developertool/appinterface.php" style="background: transparent; overflow: auto; width: 240px;height:100%;border: 0;" frameborder="0" ></iframe>'+
'</div>')
.appendTo('body')
.draggable({
start: function(){
$('<div id="div_cover" />').appendTo('#inline_themeroller').css({width: $(this).width(), height: $(this).height(), position: 'absolute', top: 0, left:0});
},
stop: function(){
$('#div_cover').remove();
},
opacity: 0.6,
cursor: 'move'
})
.resizable({
start: function(){
$(this).find('iframe').hide();
},
stop: function(){
$(this).find('iframe').show();
},
handles: 's'
})
.find('a.closeTR').click(function(){
jquitr.closeThemeRoller();
})
.end()
.find('.ui-resizable-s').css({
background: 'url(http://jqueryui.com/themeroller/developertool/icon_bookmarklet_dragger.gif) 50% 50% no-repeat',
border: 'none',
height: '14px',
dipslay: 'block',
cursor: 'resize-s',
bottom: '-3px'
})
.end()
.css('cursor', 'move')
.fadeIn();
}
jquitr.reloadCSS();
};
//close dev tool
jquitr.closeThemeRoller = function () {
$('#inline_themeroller').fadeOut();
};
//get current url hash
jquitr.getHash = function () {
var currSrc = window.location.hash;
if (currSrc.indexOf('#') > -1) {
currSrc = currSrc.split('#')[1];
}
return currSrc;
};
//recursive reload call
jquitr.reloadCSS = function(){
var currSrc = jquitr.getHash(), cssLink;
if(jquitr.trString !== currSrc && currSrc !== ''){
jquitr.trString = currSrc;
cssLink = '<link href="http://jqueryui.com/themeroller/css/parseTheme.css.php?'+ currSrc +'" type="text/css" rel="Stylesheet" />';
//works for both 1.6 final and early rc's
if( $("link[href*='parseTheme.css.php'], link[href='ui.theme.css']").size() > 0){
$("link[href*='parseTheme.css.php']:last, link[href='ui.theme.css']:last").eq(0).after(cssLink);
} else {
$("head").append(cssLink);
}
if( $("link[href*='parseTheme.css.php']").size() > 3){
$("link[href*='parseTheme.css.php']:first").remove();
}
}
window.setTimeout(jquitr.reloadCSS, 1000);
};
// Actually add the roller
jquitr.addThemeRoller();
}(jQuery.noConflict(true)));
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment