diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dbf0821 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/* \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..0f80c3f --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,32 @@ +module.exports = function(grunt){ + + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + jshint:{ + options:{ + asi:true, + laxcomma:true, + laxbreak:true + }, + all:['flexibleWapHelper.js'] + }, + uglify: { + options: { + banner: '/*!\n' + + ' * author:jieyou\n' + + ' * contacts:baidu hi->youyo1122\n' + + ' * see https://github.com/jieyou/flexibleWapHelper\n' + + ' */\n' + }, + build: { + src:'flexibleWapHelper.js', + dest:'flexibleWapHelper.min.js' + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + + grunt.registerTask('default', ['jshint','uglify']); +} \ No newline at end of file diff --git a/flexibleWapHelper.js b/flexibleWapHelper.js index a7aab01..507ed73 100644 --- a/flexibleWapHelper.js +++ b/flexibleWapHelper.js @@ -1,6 +1,6 @@ /*! * author:jieyou - * contacts:百度hi->youyo1122 + * contacts:baidu hi->youyo1122 * see https://github.com/jieyou/flexibleWapHelper */ ;(function($){ @@ -109,7 +109,8 @@ }) this.each(function(j,k){ var $k = that.eq(j), - curStyle = $k.attr('style') + // curStyle = $k.attr('style') // in zepto will return [object CSSStyleDeclaration] + curStyle = $k[0].getAttribute('style') // all style has the same key -- `display`, so can not use .css({}) directly $k.attr('style',curStyle?(curStyle + boxFlexCssStr):boxFlexCssStr) }) diff --git a/flexibleWapHelper.min.js b/flexibleWapHelper.min.js index 5fd047f..7124a02 100644 --- a/flexibleWapHelper.min.js +++ b/flexibleWapHelper.min.js @@ -1,6 +1,6 @@ /*! * author:jieyou - * contacts:百度hi->youyo1122 + * contacts:baidu hi->youyo1122 * see https://github.com/jieyou/flexibleWapHelper */ -!function(a){function k(a){return parseFloat(a.$dom.offset().width||a.$dom.css("width"))/a.originalWidth*a.originalHeight}function l(b){var c={};a.each(b,function(a,b){var d,f,e=b.sameKey;e?(f=c[e],f&&f.originalWidth*b.originalHeight==f.originalHeight*b.originalWidth?d=f.height:(d=k(b),c[b.sameKey]={height:d,originalWidth:b.originalWidth,originalHeight:b.originalHeight})):d=k(b),b.$dom.css("height",d)})}function m(a,b,c,d){a.css("background-image")&&a.css(e),c||b.push({$dom:a,originalWidth:parseFloat(a.data("original-width")),originalHeight:parseFloat(a.data("original-height")),sameKey:d||null})}var j,b=a(window),c="background-size",d="100% 100%",e={},f="display",g="box",h="box-flex",i=[];e["-webkit-"+c]=e["-moz-"+c]=e["-ms-"+c]=e[c]=d,i.push(";",f,":",g,";",f,":","-webkit-",g,";",f,":","-moz-",g,";",f,":","-ms-",g,";"),j=i.join(""),a.fn.fullWidth=function(a){var c=[],d=this;return this.each(function(b){m(d.eq(b),c,!!a)}),this.css("width","100%"),a?this.css("height",a):c.length>0&&(l(c),b.on("resize",function(){l(c)})),this},a.fn.prorate=function(a){var c=this.children(),d=[],e=this;return c.each(function(b){var i,f=c.eq(b),g=parseInt(f.data("box-flex"));isNaN(g)||(g+="",i={},i["-webkit-"+h]=i["-moz-"+h]=i["-ms-"+h]=i[h]=g,f.css("display","block").css(i),a&&f.css("height",a),m(f,d,!!a,"SK"+g))}),this.each(function(a){var c=e.eq(a),d=c.attr("style");c.attr("style",d?d+j:j)}),a?this.css("height",a):d.length>0&&(l(d),b.on("resize",function(){l(d)})),this}}($); \ No newline at end of file +!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}}($); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..bd48586 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "remember.js", + "version": "0.1.0", + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-uglify" : "*", + "grunt-contrib-jshint" : "*" + } +} \ No newline at end of file