diff --git a/Copyright b/Copyright new file mode 100644 index 0000000..06f88b9 --- /dev/null +++ b/Copyright @@ -0,0 +1,11 @@ +/*! + * Midnight.js <%= version %> + * jQuery plugin to switch between multiple fixed header designs on the fly, so it looks in line with the content below it. + * http://aerolab.github.io/midnight.js/ + * + * Copyright (c) 2014 Aerolab + * + * Released under the MIT license + * http://aerolab.github.io/midnight.js/LICENSE.txt + */ + \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..0e53e13 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,24 @@ +var gulp = require('gulp') +, fs = require('fs') +, uglify = require("gulp-uglify") +, concat = require("gulp-concat") +, header = require("gulp-header"); + +var getVersion = function () { + info = require("./package.json"); + return info.version; +}; +var getCopyright = function () { + return fs.readFileSync('Copyright'); +}; + +// task +gulp.task('minifyjs', function () { + gulp.src('./midnight.jquery.js') + .pipe(uglify()) + .pipe(header(getCopyright(), {version: getVersion()})) + .pipe(concat('midnight.jquery.min.js')) + .pipe(gulp.dest('')); +}); + +gulp.task('default', ['minifyjs']); \ No newline at end of file diff --git a/midnight.jquery.min.js b/midnight.jquery.min.js new file mode 100644 index 0000000..f702e11 --- /dev/null +++ b/midnight.jquery.min.js @@ -0,0 +1,11 @@ +/*! + * Midnight.js 1.0.0 + * jQuery plugin to switch between multiple fixed header designs on the fly, so it looks in line with the content below it. + * http://aerolab.github.io/midnight.js/ + * + * Copyright (c) 2014 Aerolab + * + * Released under the MIT license + * http://aerolab.github.io/midnight.js/LICENSE.txt + */ + !function(e){e.fn.midnight=function(s){return"object"!=typeof s&&(s={}),this.each(function(){var t={headerClass:"midnightHeader",innerClass:"midnightInner",defaultClass:"default"};e.extend(t,s);var a=window.pageYOffset||document.documentElement.scrollTop,n=e(this),r={},o={top:0,height:n.outerHeight()},l=e("[data-midnight]"),d=[],f=function(){for(var e="transform WebkitTransform MozTransform OTransform msTransform".split(" "),s=0;s ."+t.headerClass),a=0,r=0;return s.length?s.each(function(){var s=e(this),n=s.find("> ."+t.innerClass);n.length?(n.css("bottom","auto"),r=n.outerHeight(),n.css("bottom","0")):(s.css("bottom","auto"),r=s.outerHeight(),s.css("bottom","0")),a=r>a?r:a}):a=r=n.outerHeight(),a},c=function(){o.height=m(),n.css("height",o.height+"px")},u=function(){r["default"]={},l.each(function(){var s=e(this),t=s.data("midnight");"string"==typeof t&&(t=t.trim(),""!==t&&(r[t]={}))});({top:n.css("padding-top"),right:n.css("padding-right"),bottom:n.css("padding-bottom"),left:n.css("padding-left")});n.css({position:"fixed",top:0,left:0,right:0,overflow:"hidden"}),c();var s=n.find("> ."+t.headerClass);s.length?s.filter("."+t.defaultClass).length||s.filter("."+t.headerClass+":first").clone(!0,!0).attr("class",t.headerClass+" "+t.defaultClass):n.wrapInner('
');var s=n.find("> ."+t.headerClass),a=s.filter("."+t.defaultClass).clone(!0,!0);for(headerClass in r)if("undefined"==typeof r[headerClass].element){var i=s.filter("."+headerClass);r[headerClass].element=i.length?i:a.clone(!0,!0).removeClass(t.defaultClass).addClass(headerClass).appendTo(n);var o={position:"absolute",overflow:"hidden",top:0,left:0,right:0,bottom:0};r[headerClass].element.css(o),h!==!1&&r[headerClass].element.css(h,"translateZ(0)"),r[headerClass].element.find("> ."+t.innerClass).length||r[headerClass].element.wrapInner('
'),r[headerClass].inner=r[headerClass].element.find("> ."+t.innerClass),r[headerClass].inner.css(o),h!==!1&&r[headerClass].inner.css(h,"translateZ(0)"),r[headerClass].from="",r[headerClass].progress=0}s.each(function(){var s=e(this),a=!1;for(headerClass in r)s.hasClass(headerClass)&&(a=!0);s.find("> ."+t.innerClass).length||s.wrapInner('
'),a||s.hide()})};u();var p=function(){for(d=[],i=0;i=d[ix].start&&s<=d[ix].end&&(r[d[ix].class].visible=!0,s>=d[ix].start&&t<=d[ix].end?(r[d[ix].class].from="top",r[d[ix].class].progress+=1):t>d[ix].end&&sd[ix].start&&se&&(""===r[t.defaultClass].from?(r[t.defaultClass].from="top"===r[s].from?"bottom":"top",r[t.defaultClass].progress=1-e):r[t.defaultClass].progress+=1-e);for(ix in r)if(""!==!r[ix].from){var a=100*(1-r[ix].progress);"top"===r[ix].from?h!==!1?(r[ix].element[0].style[h]="translateY(-"+a+"%) translateZ(0)",r[ix].inner[0].style[h]="translateY(+"+a+"%) translateZ(0)"):(r[ix].element[0].style.top="-"+a+"%",r[ix].inner[0].style.top="+"+a+"%"):h!==!1?(r[ix].element[0].style[h]="translateY(+"+a+"%) translateZ(0)",r[ix].inner[0].style[h]="translateY(-"+a+"%) translateZ(0)"):(r[ix].element.style.top="+"+a+"%",r[ix].inner.style.top="-"+a+"%")}};e(window).resize(function(){p(),c(),g(),C()}).trigger("resize"),requestAnimationFrame=window.requestAnimationFrame||function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}();var x=function(){requestAnimationFrame(x),g(),C()};x()}})}}(jQuery); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..2908725 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "Midnight.JS", + "version": "1.0.0", + "description": "A jQuery plugin to switch fixed headers on the fly", + "devDependencies": { + "gulp": "^3.8.8", + "gulp-concat": "^2.4.1", + "gulp-header": "^1.1.1", + "gulp-uglify": "^1.0.1" + }, + "repository": { + "type": "git", + "url": "https://github.com/Aerolab/midnight.js" + }, + "author": "Aerolab", + "license": "MIT", + "bugs": { + "url": "https://github.com/Aerolab/midnight.js/issues" + }, + "homepage": "http://aerolab.github.io/midnight.js/" +} \ No newline at end of file