NIHVIVO-1511: Used a different supersleight.js version to fix the problem.
This commit is contained in:
parent
ae5de265d8
commit
68ef7ff400
1 changed files with 97 additions and 41 deletions
124
webapp/web/js/jquery_plugins/supersleight.js
vendored
124
webapp/web/js/jquery_plugins/supersleight.js
vendored
|
@ -1,41 +1,97 @@
|
||||||
//Fix Transparent PNGs in IE6
|
// SuperSleight, version 1.1.0
|
||||||
jQuery.fn.supersleight = function(settings) {
|
// version 1.1.0 by Jeffrey Barke <http://themechanism.com/> 20071218
|
||||||
settings = jQuery.extend({
|
// Essential (99% of the) code by Drew McLellan <http://24ways.org/2007/supersleight-transparent-png-in-ie6>
|
||||||
imgs: true,
|
var supersleight = function() {
|
||||||
backgrounds: true,
|
|
||||||
shim: 'x.gif',
|
|
||||||
apply_positioning: true
|
|
||||||
}, settings);
|
|
||||||
|
|
||||||
return this.each(function(){
|
// local vars
|
||||||
if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
|
var root = false;
|
||||||
jQuery(this).find('*').andSelf().each(function(i,obj) {
|
var applyPositioning = true;
|
||||||
var self = jQuery(obj);
|
// path to a transparent GIF image
|
||||||
|
var shim = '../images/x.gif';
|
||||||
|
|
||||||
|
var fnLoadPngs = function() {
|
||||||
|
// if supersleight.limitTo called, limit to specified id
|
||||||
|
if (root) { root = document.getElementById(root); } else { root = document; }
|
||||||
|
// loop
|
||||||
|
for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
|
||||||
// background pngs
|
// background pngs
|
||||||
if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
|
if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
|
||||||
var bg = self.css('background-image');
|
bg_fnFixPng(obj);
|
||||||
var src = bg.substring(5,bg.length-2);
|
}
|
||||||
var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
|
|
||||||
var styles = {
|
|
||||||
'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
|
|
||||||
'background-image': 'url('+settings.shim+')'
|
|
||||||
};
|
|
||||||
self.css(styles);
|
|
||||||
};
|
|
||||||
// image elements
|
// image elements
|
||||||
if (settings.imgs && self.is('img[src$=png]')){
|
if (obj.tagName == 'IMG' && obj.src.match(/\.png$/i) !== null) {
|
||||||
var styles = {
|
el_fnFixPng(obj);
|
||||||
'width': self.width() + 'px',
|
}
|
||||||
'height': self.height() + 'px',
|
|
||||||
'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
|
|
||||||
};
|
|
||||||
self.css(styles).attr('src', settings.shim);
|
|
||||||
};
|
|
||||||
// apply position to 'active' elements
|
// apply position to 'active' elements
|
||||||
if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
|
if (applyPositioning && (obj.tagName == 'A' || obj.tagName == 'INPUT') && obj.style.position === '') {
|
||||||
self.css('position', 'relative');
|
obj.style.position = 'relative';
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
var bg_fnFixPng = function(obj) {
|
||||||
|
var mode = 'scale';
|
||||||
|
var bg = obj.currentStyle.backgroundImage;
|
||||||
|
var src = bg.substring(5,bg.length-2);
|
||||||
|
if (obj.currentStyle.backgroundRepeat == 'no-repeat') {
|
||||||
|
mode = 'crop';
|
||||||
|
}
|
||||||
|
obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
|
||||||
|
obj.style.backgroundImage = 'url(' + shim + ')';
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
var el_fnFixPng = function(img) {
|
||||||
|
var src = img.src;
|
||||||
|
img.style.width = img.width + 'px';
|
||||||
|
img.style.height = img.height + 'px';
|
||||||
|
img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
|
||||||
|
img.src = shim;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var addLoadEvent = function(func) {
|
||||||
|
var oldonload = window.onload;
|
||||||
|
if (typeof window.onload != 'function') {
|
||||||
|
window.onload = func;
|
||||||
|
} else {
|
||||||
|
window.onload = function() {
|
||||||
|
if (oldonload) {
|
||||||
|
oldonload();
|
||||||
|
}
|
||||||
|
func();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// supersleight object
|
||||||
|
return {
|
||||||
|
init: function(strPath, blnPos, strId) {
|
||||||
|
if (document.getElementById) {
|
||||||
|
if (typeof(strPath) != 'undefined' && null !== strPath) { shim = strPath; }
|
||||||
|
if (typeof(blnPos) != 'undefined' && null !== blnPos) { applyPositioning = blnPos; }
|
||||||
|
if (typeof(strId) != 'undefined' && null !== strId) { root = strId; }
|
||||||
|
addLoadEvent(fnLoadPngs);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
limitTo: function(el) {
|
||||||
|
root = el;
|
||||||
|
},
|
||||||
|
run: function(strPath, blnPos, strId) {
|
||||||
|
if (document.getElementById) {
|
||||||
|
if (typeof(strPath) != 'undefined' && null !== strPath) { shim = strPath; }
|
||||||
|
if (typeof(blnPos) != 'undefined' && null !== blnPos) { applyPositioning = blnPos; }
|
||||||
|
if (typeof(strId) != 'undefined' && null !== strId) { root = strId; }
|
||||||
|
fnLoadPngs();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}();
|
||||||
|
|
||||||
|
// limit to part of the page ... pass an ID to limitTo:
|
||||||
|
// supersleight.limitTo('top');
|
||||||
|
// optional path to a transparent GIF image, apply positioning, limitTo
|
||||||
|
supersleight.init();
|
Loading…
Add table
Add a link
Reference in a new issue