It is quite few changes:
/*
* Shim jQuery Plug-in jqRevision: 3 jq
* <https://sourceforge.net/projects/jqueryshim>
*
* Copyright (c) 2010 Dave Willkomm
* Licensed under the MIT License
* <http://www.opensource.org/licenses/mit-license.php>
*
* Patched to work in Chrome 5.0 and FF 3.6.8 by Jesper Hansson, Grontmij | Carl Bro
*/
(function(jq) {
jq.fn.shim = function()
{
this.each(function()
{
var bgc = (jq.browser.mozilla) ? 'white' : 'none';
var element = jq(this),
offset = element.offset(),
html = '<iframe class="shim" frameborder="0" style="' +
'display: block;'+
'background-color: ' + bgc + ';' +
'position: absolute;' +
'top:' + offset.top + 'px;' +
'left:' + offset.left + 'px;' +
'width:' + element.outerWidth() + 'px;' +
'height:' + element.outerHeight() + 'px;' +
'z-index:' + (Number(element.css('z-index')) - 1) + ';' +
'"/>';
element.before(html);
});
return this;
};
jq.fn.unshim = function()
{
this.each(function()
{
jq(this).prev("iframe.shim").remove();
});
return this;
};
})(jQuery);
/*
* Shim jQuery Plug-in jqRevision: 3 jq
* <https://sourceforge.net/projects/jqueryshim>
*
* Copyright (c) 2010 Dave Willkomm
* Licensed under the MIT License
* <http://www.opensource.org/licenses/mit-license.php>
*
* Patched 12/8-2010 to work in Chrome 5.0 and FF 3.6.8 by Jesper Hansson, Grontmij | Carl Bro
* Also resolved problems with shimming inside nested divs.
* Only one shimmer per element will be inserted.
*/
(function(jq) {
jq.fn.shim = function()
{
this.each(function()
{
var element = jq(this),
id = (element.attr('id') == '') ? 'shimGenId' + Math.floor(Math.random()*4294967296) : element.attr('id');
if (jq('#shimmer_' + jq(this).attr('id')).size() == 0) {
var bgc = (jq.browser.mozilla) ? 'white' : 'none',
offset = element.offset(),
html = '<iframe class="shim" frameborder="0" id="shimmer_' + id + '"style="' +
'display: block;'+
'background-color: ' + bgc + ';' +
'position: absolute;' +
'top:' + offset.top + 'px;' +
'left:' + offset.left + 'px;' +
'width:' + element.outerWidth() + 'px;' +
'height:' + element.outerHeight() + 'px;' +
'z-index:' + (Number(element.css('z-index')) - 1) + ';' +
'"/>';
element.attr('id', id);
jq('body').append(html);
}
});
return this;
};
jq.fn.unshim = function()
{
this.each(function()
{
jq('#shimmer_' + jq(this).attr('id') ).remove() ;
});
return this;
};
})(jQuery);
in a file
Now with reshim when calling shim. Very convinient when resizing window.
/*
* Shim jQuery Plug-in jqRevision: 3 jq
* <https://sourceforge.net/projects/jqueryshim>
*
* Copyright (c) 2010 Dave Willkomm
* Licensed under the MIT License
* <http://www.opensource.org/licenses/mit-license.php>
*
* Patched 12/8-2010 to work in Chrome 5.0 and FF 3.6.8 by Jesper Hansson, Grontmij | Carl Bro
* Also resolved problems with shimming inside nested divs.
* Max one shimmer per element will be inserted - otherwise it will be reshimmed.
*/
(function(jq) {
jq.fn.shim = function()
{
this.each(function()
{
var element = jq(this),
id = (element.attr('id') == '') ? 'shimGenId' + Math.floor(Math.random()*4294967296) : element.attr('id');
if (jq('#shimmer_' + jq(this).attr('id')).size() > 0)
jq('#shimmer_' + jq(this).attr('id') ).remove() ;
var bgc = (jq.browser.mozilla) ? 'white' : 'none',
offset = element.offset(),
html = '<iframe class="shim" frameborder="0" id="shimmer_' + id + '"style="' +
'display: block;'+
'background-color: ' + bgc + ';' +
'position: absolute;' +
'top:' + offset.top + 'px;' +
'left:' + offset.left + 'px;' +
'width:' + element.outerWidth() + 'px;' +
'height:' + element.outerHeight() + 'px;' +
'z-index:' + (Number(element.css('z-index')) - 1) + ';' +
'"/>';
element.attr('id', id);
jq('body').append(html);
});
return this;
};
jq.fn.unshim = function()
{
this.each(function()
{
jq('#shimmer_' + jq(this).attr('id') ).remove() ;
});
return this;
};
})(jQuery);