Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched from Goggle Closure to UglifyJS; Now JSHinted; Renamed image file -> might move to data uri to reduce dependencies; Removed console warnings
- Loading branch information
Showing
16 changed files
with
805 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/*global module:false*/ | ||
module.exports = function(grunt) { | ||
|
||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
meta: { | ||
banner: '/* \n' + | ||
' * <%= pkg.name %> v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> \n' + | ||
' * <%= pkg.description %> \n' + | ||
' * <%= pkg.homepage %> \n' + | ||
' * \n' + | ||
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>; <%= pkg.license %> Licensed \n' + | ||
' */ \n\n' | ||
}, | ||
// JS Hint | ||
jshint: { | ||
options: { | ||
globals: { | ||
'jQuery': true, | ||
'$' : true | ||
}, | ||
browser: true, | ||
curly: true, | ||
eqeqeq: true, | ||
forin: true, | ||
freeze: true, | ||
immed: true, | ||
latedef: true, | ||
newcap: true, | ||
noarg: true, | ||
nonew: true, | ||
smarttabs: true, | ||
sub: true, | ||
undef: true, | ||
validthis: true | ||
}, | ||
files: ['src/<%= pkg.codename %>.js'] | ||
}, | ||
// Concat | ||
concat: { | ||
options: { | ||
banner: '<%= meta.banner %>' | ||
}, | ||
js: { | ||
src: 'src/<%= pkg.codename %>.js', | ||
dest: '<%= pkg.codename %>.js' | ||
}, | ||
css: { | ||
src: 'src/<%= pkg.codename %>.css', | ||
dest: '<%= pkg.codename %>.css' | ||
} | ||
}, | ||
// Uglify | ||
uglify: { | ||
options: { | ||
banner: '<%= meta.banner %>', | ||
report: 'min' | ||
}, | ||
target: { | ||
files: { | ||
'<%= pkg.codename %>.min.js': [ '<%= pkg.codename %>.js' ] | ||
} | ||
} | ||
}, | ||
// jQuery Manifest | ||
jquerymanifest: { | ||
options: { | ||
source: grunt.file.readJSON('package.json'), | ||
overrides: { | ||
name: '<%= pkg.id %>', | ||
keywords: '<%= pkg.keywords %>', | ||
homepage: '<%= pkg.homepage %>', | ||
docs: '<%= pkg.homepage %>', | ||
demo: '<%= pkg.homepage %>', | ||
download: '<%= pkg.repository.url %>', | ||
bugs: '<%= pkg.repository.url %>/issues', | ||
dependencies: { | ||
jquery: '>=1.7' | ||
} | ||
} | ||
} | ||
}, | ||
//Bower sync | ||
sync: { | ||
all: { | ||
options: { | ||
sync: [ 'name', 'version', 'description', 'author', 'license', 'homepage' ] | ||
} | ||
} | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-concat'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-jquerymanifest'); | ||
grunt.loadNpmTasks('grunt-npm2bower-sync'); | ||
|
||
// Default task. | ||
grunt.registerTask('default', [ 'jshint', 'concat', 'uglify', 'jquerymanifest', 'sync' ]); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
Shifter | ||
======= | ||
<a href="http://gruntjs.com" target="_blank"><img src="https://cdn.gruntjs.com/builtwith.png" alt="Built with Grunt"></a> | ||
# Shifter | ||
|
||
A jQuery plugin for simple slide-out mobile navigation. Part of the formstone library. | ||
|
||
[Documentation and Examples](http://www.benplum.com/formstone/shifter/) | ||
- [Demo](http://www.benplum.com/components/Shifter/demo/index.html) | ||
- [Documentation](http://www.benplum.com/formstone/shifter/) | ||
|
||
Bower Support: `bower install Shifter` | ||
#### Bower Support | ||
|
||
`bower install Shifter` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
{ | ||
"name": "Shifter", | ||
"version": "1.0.0", | ||
"description": "A jQuery plugin for simple slide-out mobile navigation.", | ||
"keywords": [ | ||
"javascript", | ||
"jquery", | ||
"responsive", | ||
"mobile", | ||
"navigation", | ||
"menu", | ||
"ui", | ||
"formstone", | ||
"benplum" | ||
], | ||
"authors": [ | ||
"Ben Plum" | ||
], | ||
"license": "MIT", | ||
"homepage": "http://www.benplum.com/formstone/shifter/", | ||
"main": [ | ||
"jquery.fs.shifter.css", | ||
"jquery.fs.shifter.min.js" | ||
], | ||
"ignore": [ | ||
"*.json" | ||
], | ||
"dependencies": { | ||
"jquery": ">= 1.7.0" | ||
}, | ||
"devDependencies": {} | ||
"name": "Shifter", | ||
"version": "1.0.1", | ||
"description": "A jQuery plugin for simple slide-out mobile navigation.", | ||
"author": { | ||
"name": "Ben Plum", | ||
"email": "mr@benplum.com", | ||
"url": "http://www.benplum.com" | ||
}, | ||
"license": "MIT", | ||
"homepage": "http://www.benplum.com/formstone/shifter/" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license - IE8 VERSION! */ | ||
window.matchMedia = window.matchMedia || (function(doc, undefined){ | ||
|
||
var docElem = doc.documentElement, | ||
refNode = docElem.firstElementChild || docElem.firstChild, | ||
// fakeBody required for <FF4 when executed in <head> | ||
fakeBody = doc.createElement('body'), | ||
div = doc.createElement('div'); | ||
|
||
div.id = 'mq-test-1'; | ||
div.style.cssText = "position:absolute;top:-100em"; | ||
fakeBody.style.background = "none"; | ||
fakeBody.appendChild(div); | ||
|
||
var mqRun = function ( mq ) { | ||
div.innerHTML = '­<style media="' + mq + '"> #mq-test-1 { width: 42px; }</style>'; | ||
docElem.insertBefore( fakeBody, refNode ); | ||
bool = div.offsetWidth === 42; | ||
docElem.removeChild( fakeBody ); | ||
|
||
return { matches: bool, media: mq }; | ||
}, | ||
|
||
getEmValue = function () { | ||
var ret, | ||
body = docElem.body, | ||
fakeUsed = false; | ||
|
||
div.style.cssText = "position:absolute;font-size:1em;width:1em"; | ||
|
||
if( !body ) { | ||
body = fakeUsed = doc.createElement( "body" ); | ||
body.style.background = "none"; | ||
} | ||
|
||
body.appendChild( div ); | ||
|
||
docElem.insertBefore( body, docElem.firstChild ); | ||
|
||
if( fakeUsed ) { | ||
docElem.removeChild( body ); | ||
} else { | ||
body.removeChild( div ); | ||
} | ||
|
||
//also update eminpx before returning | ||
ret = eminpx = parseFloat( div.offsetWidth ); | ||
|
||
return ret; | ||
}, | ||
|
||
//cached container for 1em value, populated the first time it's needed | ||
eminpx, | ||
|
||
// verify that we have support for a simple media query | ||
mqSupport = mqRun( '(min-width: 0px)' ).matches; | ||
|
||
return function ( mq ) { | ||
if( mqSupport ) { | ||
return mqRun( mq ); | ||
} else { | ||
if (doc.body) { | ||
var min = mq.match( /\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ), | ||
max = mq.match( /\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ), | ||
minnull = min === null, | ||
maxnull = max === null, | ||
currWidth = doc.body.offsetWidth, | ||
em = 'em'; | ||
|
||
if( !!min ) { min = parseFloat( min ) * ( min.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); } | ||
if( !!max ) { max = parseFloat( max ) * ( max.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); } | ||
|
||
bool = ( !minnull || !maxnull ) && ( minnull || currWidth >= min ) && ( maxnull || currWidth <= max ); | ||
|
||
return { matches: bool, media: mq }; | ||
} else { | ||
return { matches: false, media: {} }; | ||
} | ||
} | ||
}; | ||
|
||
}( document )); | ||
|
||
/*! matchMedia() polyfill addListener/removeListener extension. Author & copyright (c) 2012: Scott Jehl. Dual MIT/BSD license - IE8 VERSION! */ | ||
(function(){ | ||
// monkeypatch unsupported addListener/removeListener with polling | ||
if(typeof window.matchMedia( "" ) !== "undefined"){ | ||
var oldMM = window.matchMedia; | ||
|
||
window.matchMedia = function( q ){ | ||
var ret = oldMM( q ), | ||
listeners = [], | ||
last = false, | ||
timer, | ||
check = function(){ | ||
var list = oldMM( q ), | ||
unmatchToMatch = list.matches && !last, | ||
matchToUnmatch = !list.matches && last; | ||
|
||
//fire callbacks only if transitioning to or from matched state | ||
if( unmatchToMatch || matchToUnmatch ){ | ||
for( var i =0, il = listeners.length; i< il; i++ ){ | ||
listeners[ i ].call( ret, list ); | ||
} | ||
} | ||
last = list.matches; | ||
}; | ||
|
||
ret.addListener = function( cb ){ | ||
listeners.push( cb ); | ||
if( !timer ){ | ||
timer = setInterval( check, 1000 ); | ||
} | ||
}; | ||
|
||
ret.removeListener = function( cb ){ | ||
for( var i =0, il = listeners.length; i< il; i++ ){ | ||
if( listeners[ i ] === cb ){ | ||
listeners.splice( i, 1 ); | ||
} | ||
} | ||
if( !listeners.length && timer ){ | ||
clearInterval( timer ); | ||
} | ||
}; | ||
|
||
return ret; | ||
}; | ||
} | ||
}()); |
Oops, something went wrong.