Merge branch 'g5'
This commit is contained in:
44
js/viewimageresize.js
Normal file
44
js/viewimageresize.js
Normal file
@ -0,0 +1,44 @@
|
||||
(function($) {
|
||||
$.fn.viewimageresize = function(selector)
|
||||
{
|
||||
var cfg = {
|
||||
selector: "img"
|
||||
};
|
||||
|
||||
if(typeof selector == "object") {
|
||||
cfg = $.extend(cfg, selector);
|
||||
} else {
|
||||
if(selector) {
|
||||
cfg = $.extend({ selector: selector });
|
||||
}
|
||||
}
|
||||
|
||||
var $img = this.find(cfg.selector);
|
||||
var width = this.width();
|
||||
|
||||
function image_resize()
|
||||
{
|
||||
$img.each(function() {
|
||||
$(this).removeAttr("width")
|
||||
.removeAttr("height")
|
||||
.css("width","")
|
||||
.css("height", "");
|
||||
|
||||
if($(this).data("width") == undefined)
|
||||
$(this).data("width", $(this).width());
|
||||
|
||||
if($(this).data("width") > width) {
|
||||
$(this).css("width", "100%");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(window).on("load", function() {
|
||||
image_resize();
|
||||
});
|
||||
|
||||
$(window).on("resize", function() {
|
||||
image_resize();
|
||||
});
|
||||
}
|
||||
}(jQuery));
|
||||
Reference in New Issue
Block a user