-
Notifications
You must be signed in to change notification settings - Fork 2
/
flexibleWapHelper.min.js
6 lines (6 loc) · 1.56 KB
/
flexibleWapHelper.min.js
1
2
3
4
5
6
/*!
* author:jieyou
* contacts:baidu hi->youyo1122
* see https://github.com/jieyou/flexibleWapHelper
*/
!function(a){function b(a){return parseFloat(a.$dom.offset().width||a.$dom.css("width"))/a.originalWidth*a.originalHeight}function c(c){var d={};a.each(c,function(a,c){var e,f,g=c.sameKey;g?(f=d[g],f&&f.originalWidth*c.originalHeight==f.originalHeight*c.originalWidth?e=f.height:(e=b(c),d[c.sameKey]={height:e,originalWidth:c.originalWidth,originalHeight:c.originalHeight})):e=b(c),c.$dom.css("height",e)})}function d(a,b,c,d){a.css("background-image")&&a.css(i),c||b.push({$dom:a,originalWidth:parseFloat(a.data("original-width")),originalHeight:parseFloat(a.data("original-height")),sameKey:d||null})}var e,f=a(window),g="background-size",h="100% 100%",i={},j="display",k="box",l="box-flex",m=[];i["-webkit-"+g]=i["-moz-"+g]=i["-ms-"+g]=i[g]=h,m.push(";",j,":",k,";",j,":","-webkit-",k,";",j,":","-moz-",k,";",j,":","-ms-",k,";"),e=m.join(""),a.fn.fullWidth=function(a){var b=[],e=this;return this.each(function(c){d(e.eq(c),b,!!a)}),this.css("width","100%"),a?this.css("height",a):b.length>0&&(c(b),f.on("resize",function(){c(b)})),this},a.fn.prorate=function(a){var b=this.children(),g=[],h=this;return b.each(function(c){var e,f=b.eq(c),h=parseInt(f.data("box-flex"));isNaN(h)||(h+="",e={},e["-webkit-"+l]=e["-moz-"+l]=e["-ms-"+l]=e[l]=h,f.css("display","block").css(e),a&&f.css("height",a),d(f,g,!!a,"SK"+h))}),this.each(function(a){var b=h.eq(a),c=b[0].getAttribute("style");b.attr("style",c?c+e:e)}),a?this.css("height",a):g.length>0&&(c(g),f.on("resize",function(){c(g)})),this}}($);