sassqwatch
Advanced tools
Comparing version 0.1.2 to 0.2.0-0
@@ -170,2 +170,4 @@ /** | ||
sassqwatch.onMediaQueryChange(updateImages); | ||
return sassqwatch; | ||
}; |
@@ -1,2 +0,1 @@ | ||
// Dependencies | ||
@@ -7,5 +6,2 @@ var | ||
// SassQwatch object | ||
var sassqwatch = {}; | ||
// Elements | ||
@@ -36,3 +32,3 @@ var | ||
*/ | ||
var onResize = function () { | ||
var onResize = function() { | ||
var lastMediaQuery = currentMediaQuery; | ||
@@ -53,3 +49,3 @@ | ||
*/ | ||
var setOrder = function () { | ||
var setOrder = function() { | ||
var mediaQueries = $orderElement.css('font-family'); | ||
@@ -63,2 +59,6 @@ mqOrderNumbered = mediaQueries.replace(/['"\s]/g, "").split(','); | ||
/** | ||
* Public: Event fires when the media query changes | ||
* @param callback - The function to call when the event is fired | ||
*/ | ||
var onMediaQueryChange = function(callback) { | ||
@@ -68,7 +68,55 @@ $listenElement.on('mediaQueryChange', function(e, newMediaQuery, oldMediaQuery) { | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Public: Event fires on the specified media query | ||
* @param which - The media query to check against | ||
* @param callback - The function to call when the event is fired | ||
*/ | ||
var onMediaQuery = function(which, callback) { | ||
$listenElement.on('mediaQueryChange', function(e, newMediaQuery, oldMediaQuery) { | ||
if (matches(which)) { | ||
callback(oldMediaQuery); | ||
} | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Public: A convenience method to fire a callback when above or below a specified breakpoint | ||
* @param direction - A string "above" or "below" | ||
* @param which - The media query to check against | ||
* @param callback - The function to call when the event is fired | ||
*/ | ||
var when = function(direction, which, callback) { | ||
var | ||
dir = direction.toLowerCase(), | ||
check; | ||
if (dir === 'above') { | ||
check = function() { | ||
if (isAbove(which)) { | ||
callback(); | ||
} | ||
} | ||
} else if (dir === 'below') { | ||
check = function() { | ||
if (isBelow(which)) { | ||
callback(); | ||
} | ||
} | ||
} | ||
if (typeof check === 'function') { | ||
check(); | ||
$listenElement.on('mediaQueryChange', check); | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Public: Checks if the media query is greater than the specified | ||
* @param which The media query to check against | ||
* @param which - The media query to check against | ||
*/ | ||
@@ -84,3 +132,3 @@ var isAbove = function (which) { | ||
* Public: Checks if the media query is less than the specified | ||
* @param which The media query to check against | ||
* @param which - The media query to check against | ||
*/ | ||
@@ -109,3 +157,3 @@ var isBelow = function (which) { | ||
* Public: Fetch the index of a named breakpoint | ||
* @param mediaQuery A string referencing the desired breakpoint | ||
* @param mediaQuery - A string referencing the desired breakpoint | ||
*/ | ||
@@ -118,3 +166,3 @@ var fetchMqIndex = function(mediaQuery) { | ||
* Public: Fetch the name of a breakpoint by its index | ||
* @param index An integer referencing the desired breakpoint in the order | ||
* @param index - An integer referencing the desired breakpoint in the order | ||
*/ | ||
@@ -127,2 +175,3 @@ var fetchMqName = function(index) { | ||
* Public: Turn throttling ON for more effecient resizing events | ||
* @param duration - An integer specifying the duration of the throttling | ||
*/ | ||
@@ -150,5 +199,6 @@ var throttleOn = function(duration) { | ||
/** | ||
* Set everything up | ||
* Internal: Immediately invoked constructor function | ||
* Sets everything up and then returns all the public methods. | ||
*/ | ||
(function() { | ||
var constructor = function() { | ||
// set the order of the breakpoints | ||
@@ -163,16 +213,18 @@ setOrder(); | ||
// bundle up the public properties & methods | ||
sassqwatch = { | ||
// return the public methods | ||
return { | ||
onMediaQueryChange: onMediaQueryChange, | ||
fetchMediaQuery: fetchMediaQuery, | ||
fetchMqIndex: fetchMqIndex, | ||
fetchMqName: fetchMqName, | ||
isAbove: isAbove, | ||
isBelow: isBelow, | ||
throttleOn: throttleOn, | ||
throttleOff: throttleOff, | ||
responsiveImages: responsiveImages | ||
onMediaQuery: onMediaQuery, | ||
when: when, | ||
fetchMediaQuery: fetchMediaQuery, | ||
fetchMqIndex: fetchMqIndex, | ||
fetchMqName: fetchMqName, | ||
isAbove: isAbove, | ||
isBelow: isBelow, | ||
throttleOn: throttleOn, | ||
throttleOff: throttleOff, | ||
responsiveImages: responsiveImages | ||
}; | ||
}.call(); | ||
module.exports = sassqwatch; | ||
})(); | ||
module.exports = constructor; |
{ | ||
"name": "sassqwatch", | ||
"version": "0.1.2", | ||
"version": "0.2.0-0", | ||
"description": "The Sass Query Watcher.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/40Digits/sassqwatch/", |
@@ -7,3 +7,3 @@ # SassQwatch - The Sass Query Watcher. | ||
## Setup | ||
## Setup With Browserify | ||
@@ -31,9 +31,9 @@ ### 1. Install with NPM. | ||
head { | ||
@media (min-width: $break-small) { | ||
@media (min-width: 480px) { | ||
font-family: 'mq-small'; | ||
} | ||
@media (min-width: $break-medium) { | ||
@media (min-width: 600px) { | ||
font-family: 'mq-small'; | ||
} | ||
@media (min-width: $break-large) { | ||
@media (min-width: 768px) { | ||
font-family: 'mq-large'; | ||
@@ -76,4 +76,4 @@ } | ||
#### onMediaQueryChange( function ) | ||
`function`: the callback function to call when the media changes | ||
#### onMediaQueryChange( callback ) | ||
`callback` (function): the callback function to call when the media query changes | ||
@@ -88,2 +88,27 @@ The callback is provided the name of the new media query and the name of the previous media query. | ||
#### onMediaQuery( breakpoint, callback ) | ||
`breakpoint` (string): the name of the media query to check for | ||
`callback` (function): the callback function to call | ||
Listens for when a specified breakpoint is active. The callback is provided the name of the previous media query. | ||
```javascript | ||
sassqwatch.onMediaQuery('mq-medium', function (oldMediaQuery) { | ||
console.log('Media query switched to mq-medium from ' + oldMediaQuery); | ||
}); | ||
``` | ||
#### when( direction, breakpoint, callback ) | ||
`direction` (string): "above" or "below" | ||
`breakpoint` (string): the name of the media query to check for | ||
`callback` (function): the callback function to call | ||
Listens for when a specified breakpoint is active. The callback is provided the name of the previous media query. | ||
```javascript | ||
sassqwatch.onMediaQuery('mq-medium', function (oldMediaQuery) { | ||
console.log('Media query switched to mq-medium from ' + oldMediaQuery); | ||
}); | ||
``` | ||
## Methods | ||
@@ -99,4 +124,4 @@ | ||
#### fetchMqName( number ) | ||
`number`: the index of the media query to return | ||
#### fetchMqName( index ) | ||
`index` (number): the index of the media query to return | ||
@@ -115,4 +140,4 @@ Returns a string of the name of the requested media query from the ordered array of media queries. | ||
#### fetchMqIndex( string ) | ||
`string`: the name of the media query to return | ||
#### fetchMqIndex( breakpoint ) | ||
`breakpoint` (string): the name of the media query to return | ||
@@ -127,4 +152,4 @@ Returns an integer of the index of the requested media query from the ordered array of media queries. | ||
#### isBelow( string ) | ||
`string`: the media query to check against. | ||
#### isBelow( breakpoint ) | ||
`breakpoint` (string): the media query to check against. | ||
@@ -139,4 +164,4 @@ Returns `true` if the current media query is below a specified media query, and `false` otherwise. | ||
#### isAbove( string ) | ||
`string`: the media query to check against. | ||
#### isAbove( breakpoint ) | ||
`breakpoint` (string): the media query to check against. | ||
@@ -151,4 +176,4 @@ Returns `true` if the current media query is above a specified media query, and `false` otherwise. | ||
#### throttleOn( number ) | ||
`number`: the interval in milliseconds at which to throttle the event (default: `250`) | ||
#### throttleOn( interval ) | ||
`interval` (number): the interval in milliseconds at which to throttle the event (default: `250`) | ||
@@ -155,0 +180,0 @@ Turns throttling on for the resize event on the `$(window)`. This makes the window resizing on your app more effecient, but less precise. |
@@ -208,2 +208,4 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
sassqwatch.onMediaQueryChange(updateImages); | ||
return sassqwatch; | ||
}; | ||
@@ -314,3 +316,2 @@ }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
(function (global){ | ||
// Dependencies | ||
@@ -321,5 +322,2 @@ var | ||
// SassQwatch object | ||
var sassqwatch = {}; | ||
// Elements | ||
@@ -350,3 +348,3 @@ var | ||
*/ | ||
var onResize = function () { | ||
var onResize = function() { | ||
var lastMediaQuery = currentMediaQuery; | ||
@@ -367,3 +365,3 @@ | ||
*/ | ||
var setOrder = function () { | ||
var setOrder = function() { | ||
var mediaQueries = $orderElement.css('font-family'); | ||
@@ -377,2 +375,6 @@ mqOrderNumbered = mediaQueries.replace(/['"\s]/g, "").split(','); | ||
/** | ||
* Public: Event fires when the media query changes | ||
* @param callback - The function to call when the event is fired | ||
*/ | ||
var onMediaQueryChange = function(callback) { | ||
@@ -382,7 +384,55 @@ $listenElement.on('mediaQueryChange', function(e, newMediaQuery, oldMediaQuery) { | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Public: Event fires on the specified media query | ||
* @param which - The media query to check against | ||
* @param callback - The function to call when the event is fired | ||
*/ | ||
var onMediaQuery = function(which, callback) { | ||
$listenElement.on('mediaQueryChange', function(e, newMediaQuery, oldMediaQuery) { | ||
if (matches(which)) { | ||
callback(oldMediaQuery); | ||
} | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Public: A convenience method to fire a callback when above or below a specified breakpoint | ||
* @param direction - A string "above" or "below" | ||
* @param which - The media query to check against | ||
* @param callback - The function to call when the event is fired | ||
*/ | ||
var when = function(direction, which, callback) { | ||
var | ||
dir = direction.toLowerCase(), | ||
check; | ||
if (dir === 'above') { | ||
check = function() { | ||
if (isAbove(which)) { | ||
callback(); | ||
} | ||
} | ||
} else if (dir === 'below') { | ||
check = function() { | ||
if (isBelow(which)) { | ||
callback(); | ||
} | ||
} | ||
} | ||
if (typeof check === 'function') { | ||
check(); | ||
$listenElement.on('mediaQueryChange', check); | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Public: Checks if the media query is greater than the specified | ||
* @param which The media query to check against | ||
* @param which - The media query to check against | ||
*/ | ||
@@ -398,3 +448,3 @@ var isAbove = function (which) { | ||
* Public: Checks if the media query is less than the specified | ||
* @param which The media query to check against | ||
* @param which - The media query to check against | ||
*/ | ||
@@ -423,3 +473,3 @@ var isBelow = function (which) { | ||
* Public: Fetch the index of a named breakpoint | ||
* @param mediaQuery A string referencing the desired breakpoint | ||
* @param mediaQuery - A string referencing the desired breakpoint | ||
*/ | ||
@@ -432,3 +482,3 @@ var fetchMqIndex = function(mediaQuery) { | ||
* Public: Fetch the name of a breakpoint by its index | ||
* @param index An integer referencing the desired breakpoint in the order | ||
* @param index - An integer referencing the desired breakpoint in the order | ||
*/ | ||
@@ -441,2 +491,3 @@ var fetchMqName = function(index) { | ||
* Public: Turn throttling ON for more effecient resizing events | ||
* @param duration - An integer specifying the duration of the throttling | ||
*/ | ||
@@ -464,5 +515,6 @@ var throttleOn = function(duration) { | ||
/** | ||
* Set everything up | ||
* Internal: Immediately invoked constructor function | ||
* Sets everything up and then returns all the public methods. | ||
*/ | ||
(function() { | ||
var constructor = function() { | ||
// set the order of the breakpoints | ||
@@ -477,18 +529,20 @@ setOrder(); | ||
// bundle up the public properties & methods | ||
sassqwatch = { | ||
// return the public methods | ||
return { | ||
onMediaQueryChange: onMediaQueryChange, | ||
fetchMediaQuery: fetchMediaQuery, | ||
fetchMqIndex: fetchMqIndex, | ||
fetchMqName: fetchMqName, | ||
isAbove: isAbove, | ||
isBelow: isBelow, | ||
throttleOn: throttleOn, | ||
throttleOff: throttleOff, | ||
responsiveImages: responsiveImages | ||
onMediaQuery: onMediaQuery, | ||
when: when, | ||
fetchMediaQuery: fetchMediaQuery, | ||
fetchMqIndex: fetchMqIndex, | ||
fetchMqName: fetchMqName, | ||
isAbove: isAbove, | ||
isBelow: isBelow, | ||
throttleOn: throttleOn, | ||
throttleOff: throttleOff, | ||
responsiveImages: responsiveImages | ||
}; | ||
}.call(); | ||
module.exports = sassqwatch; | ||
})(); | ||
module.exports = constructor; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"./responsiveImages":3,"./throttleDebounce":4}]},{},[]); |
@@ -1,1 +0,1 @@ | ||
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){(function(global){var $="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null;module.exports=function(el){return"string"==typeof el?$(el):el}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(require,module,exports){var preloader=function(src,callback){var loaded=!1,img=new Image,loadHandler=function(){loaded||(loaded=!0,callback(src),img=null)};img.addEventListener("load",loadHandler),img.src=src,img.complete&&loadHandler()};module.exports=preloader},{}],3:[function(require,module,exports){(function(global){module.exports=function(options){var $="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null,sassqwatch=require("./sassqwatch"),toDashed=require("./toDashed"),elementify=require("./elementify"),preloader=require("./preloader"),defaultSelector=$(".sassqwatch"),settings=$.extend({selector:defaultSelector},options),knownSizes=[],storeSizes=function($image){var mqName,src=getSource($image),responsiveSrcs=$image.data(),sizes={image:$image,loaded:[],originalSrc:src,activeSrc:src};$.each(responsiveSrcs,function(key,value){mqName=toDashed(key),sizes[mqName]=value}),knownSizes.push(sizes)},getSource=function($image){var imageSrc;return imageSrc=$image.is("img")?$image.attr("src"):$image.css("background-image").replace(/^url\(['"]?/,"").replace(/['"]?\)$/,"")},swapImage=function($target,newImageSrc){$target.is("img")?$target.attr("src",newImageSrc):$target.css("background-image","url("+newImageSrc+")")},updateImages=function(newMediaQuery){var isLoaded=!1;null==newMediaQuery&&(newMediaQuery=sassqwatch.fetchMediaQuery()),$.each(knownSizes,function(i){var thisImage=knownSizes[i],newSource=thisImage[newMediaQuery];if(!newSource){var thisMQ,ii=sassqwatch.fetchMqIndex(newMediaQuery);for(ii;ii>0;ii--)if(thisMQ=sassqwatch.fetchMqName(ii),thisImage[thisMQ]){newSource=thisImage[thisMQ];break}newSource=newSource||thisImage.originalSrc}-1===newSource.indexOf(thisImage.activeSrc)&&($.each(thisImage.loaded,function(i){return thisImage.loaded[i].indexOf(newSource)>0?void(isLoaded=!0):void 0}),isLoaded?swapImage(thisImage.image,newSource):preloader(newSource,function(src){swapImage(thisImage.image,src),thisImage.loaded.push(src)}),thisImage.activeSrc=newSource)})};settings.selector!==defaultSelector&&(settings.selector=elementify(settings.selector)),settings.selector.each(function(){storeSizes($(this))}),updateImages(),sassqwatch.onMediaQueryChange(updateImages)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./elementify":1,"./preloader":2,"./sassqwatch":"sassqwatch","./toDashed":5}],4:[function(require,module,exports){var jq_throttle;exports.throttle=jq_throttle=function(delay,no_trailing,callback,debounce_mode){function wrapper(){function exec(){last_exec=+new Date,callback.apply(that,args)}function clear(){timeout_id=void 0}var that=this,elapsed=+new Date-last_exec,args=arguments;debounce_mode&&!timeout_id&&exec(),timeout_id&&clearTimeout(timeout_id),void 0===debounce_mode&&elapsed>delay?exec():no_trailing!==!0&&(timeout_id=setTimeout(debounce_mode?clear:exec,void 0===debounce_mode?delay-elapsed:delay))}var timeout_id,last_exec=0;return"boolean"!=typeof no_trailing&&(debounce_mode=callback,callback=no_trailing,no_trailing=void 0),wrapper},exports.debounce=function(delay,at_begin,callback){return void 0===callback?jq_throttle(delay,at_begin,!1):jq_throttle(delay,callback,at_begin!==!1)}},{}],5:[function(require,module,exports){module.exports=function(string){var words=[],currentChar="",currentWord="",i=0;for(i;string.length>=i;i++)currentChar=string.charAt(i),currentChar===currentChar.toUpperCase()?(words.push(currentWord),currentWord=currentChar.toLowerCase()):currentWord+=currentChar;return words.join("-")}},{}],sassqwatch:[function(require,module,exports){(function(global){var $="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null,td=require("./throttleDebounce"),sassqwatch={},$window=$(window),$orderElement=($("body"),$("title")),$listenElement=$("head"),currentMediaQuery="",mqOrderNamed={},mqOrderNumbered=[],onResize=function(){var lastMediaQuery=currentMediaQuery;currentMediaQuery=fetchMediaQuery(),currentMediaQuery!=lastMediaQuery&&$listenElement.trigger("mediaQueryChange",[currentMediaQuery,lastMediaQuery])},setOrder=function(){var mediaQueries=$orderElement.css("font-family");mqOrderNumbered=mediaQueries.replace(/['"\s]/g,"").split(","),$.each(mqOrderNumbered,function(index,value){mqOrderNamed[value]=index})},onMediaQueryChange=function(callback){$listenElement.on("mediaQueryChange",function(e,newMediaQuery,oldMediaQuery){callback(newMediaQuery,oldMediaQuery)})},isAbove=function(which){var currentMq=mqOrderNamed[fetchMediaQuery()],whichMq=mqOrderNamed[which];return currentMq>=whichMq},isBelow=function(which){var currentMq=mqOrderNamed[fetchMediaQuery()],whichMq=mqOrderNamed[which];return whichMq>currentMq},fetchMediaQuery=function(){var mq=$listenElement.css("font-family");return mq=mq.replace(/['",]/g,"")},fetchMqIndex=function(mediaQuery){return mqOrderNamed[mediaQuery]},fetchMqName=function(index){return mqOrderNumbered[index]},throttleOn=function(duration){return $window.on("resize.throttle",td.throttle(duration||250,onResize)),$window.off("resize.no-throttle"),this},throttleOff=function(){return $window.on("resize.no-throttle",onResize),$window.off("resize.throttle"),this},responsiveImages=require("./responsiveImages");!function(){setOrder(),currentMediaQuery=fetchMediaQuery(),throttleOff(),sassqwatch={onMediaQueryChange:onMediaQueryChange,fetchMediaQuery:fetchMediaQuery,fetchMqIndex:fetchMqIndex,fetchMqName:fetchMqName,isAbove:isAbove,isBelow:isBelow,throttleOn:throttleOn,throttleOff:throttleOff,responsiveImages:responsiveImages},module.exports=sassqwatch}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./responsiveImages":3,"./throttleDebounce":4}]},{},[]); | ||
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){(function(global){var $="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null;module.exports=function(el){return"string"==typeof el?$(el):el}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(require,module,exports){var preloader=function(src,callback){var loaded=!1,img=new Image,loadHandler=function(){loaded||(loaded=!0,callback(src),img=null)};img.addEventListener("load",loadHandler),img.src=src,img.complete&&loadHandler()};module.exports=preloader},{}],3:[function(require,module,exports){(function(global){module.exports=function(options){var $="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null,sassqwatch=require("./sassqwatch"),toDashed=require("./toDashed"),elementify=require("./elementify"),preloader=require("./preloader"),defaultSelector=$(".sassqwatch"),settings=$.extend({selector:defaultSelector},options),knownSizes=[],storeSizes=function($image){var mqName,src=getSource($image),responsiveSrcs=$image.data(),sizes={image:$image,loaded:[],originalSrc:src,activeSrc:src};$.each(responsiveSrcs,function(key,value){mqName=toDashed(key),sizes[mqName]=value}),knownSizes.push(sizes)},getSource=function($image){var imageSrc;return imageSrc=$image.is("img")?$image.attr("src"):$image.css("background-image").replace(/^url\(['"]?/,"").replace(/['"]?\)$/,"")},swapImage=function($target,newImageSrc){$target.is("img")?$target.attr("src",newImageSrc):$target.css("background-image","url("+newImageSrc+")")},updateImages=function(newMediaQuery){var isLoaded=!1;null==newMediaQuery&&(newMediaQuery=sassqwatch.fetchMediaQuery()),$.each(knownSizes,function(i){var thisImage=knownSizes[i],newSource=thisImage[newMediaQuery];if(!newSource){var thisMQ,ii=sassqwatch.fetchMqIndex(newMediaQuery);for(ii;ii>0;ii--)if(thisMQ=sassqwatch.fetchMqName(ii),thisImage[thisMQ]){newSource=thisImage[thisMQ];break}newSource=newSource||thisImage.originalSrc}-1===newSource.indexOf(thisImage.activeSrc)&&($.each(thisImage.loaded,function(i){return thisImage.loaded[i].indexOf(newSource)>0?void(isLoaded=!0):void 0}),isLoaded?swapImage(thisImage.image,newSource):preloader(newSource,function(src){swapImage(thisImage.image,src),thisImage.loaded.push(src)}),thisImage.activeSrc=newSource)})};return settings.selector!==defaultSelector&&(settings.selector=elementify(settings.selector)),settings.selector.each(function(){storeSizes($(this))}),updateImages(),sassqwatch.onMediaQueryChange(updateImages),sassqwatch}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./elementify":1,"./preloader":2,"./sassqwatch":"sassqwatch","./toDashed":5}],4:[function(require,module,exports){var jq_throttle;exports.throttle=jq_throttle=function(delay,no_trailing,callback,debounce_mode){function wrapper(){function exec(){last_exec=+new Date,callback.apply(that,args)}function clear(){timeout_id=void 0}var that=this,elapsed=+new Date-last_exec,args=arguments;debounce_mode&&!timeout_id&&exec(),timeout_id&&clearTimeout(timeout_id),void 0===debounce_mode&&elapsed>delay?exec():no_trailing!==!0&&(timeout_id=setTimeout(debounce_mode?clear:exec,void 0===debounce_mode?delay-elapsed:delay))}var timeout_id,last_exec=0;return"boolean"!=typeof no_trailing&&(debounce_mode=callback,callback=no_trailing,no_trailing=void 0),wrapper},exports.debounce=function(delay,at_begin,callback){return void 0===callback?jq_throttle(delay,at_begin,!1):jq_throttle(delay,callback,at_begin!==!1)}},{}],5:[function(require,module,exports){module.exports=function(string){var words=[],currentChar="",currentWord="",i=0;for(i;string.length>=i;i++)currentChar=string.charAt(i),currentChar===currentChar.toUpperCase()?(words.push(currentWord),currentWord=currentChar.toLowerCase()):currentWord+=currentChar;return words.join("-")}},{}],sassqwatch:[function(require,module,exports){(function(global){var $="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null,td=require("./throttleDebounce"),$window=$(window),$orderElement=($("body"),$("title")),$listenElement=$("head"),currentMediaQuery="",mqOrderNamed={},mqOrderNumbered=[],matches=function(which){return fetchMediaQuery()==which},onResize=function(){var lastMediaQuery=currentMediaQuery;currentMediaQuery=fetchMediaQuery(),currentMediaQuery!=lastMediaQuery&&$listenElement.trigger("mediaQueryChange",[currentMediaQuery,lastMediaQuery])},setOrder=function(){var mediaQueries=$orderElement.css("font-family");mqOrderNumbered=mediaQueries.replace(/['"\s]/g,"").split(","),$.each(mqOrderNumbered,function(index,value){mqOrderNamed[value]=index})},onMediaQueryChange=function(callback){return $listenElement.on("mediaQueryChange",function(e,newMediaQuery,oldMediaQuery){callback(newMediaQuery,oldMediaQuery)}),this},onMediaQuery=function(which,callback){return $listenElement.on("mediaQueryChange",function(e,newMediaQuery,oldMediaQuery){matches(which)&&callback(oldMediaQuery)}),this},when=function(direction,which,callback){var check,dir=direction.toLowerCase();return"above"===dir?check=function(){isAbove(which)&&callback()}:"below"===dir&&(check=function(){isBelow(which)&&callback()}),"function"==typeof check&&(check(),$listenElement.on("mediaQueryChange",check)),this},isAbove=function(which){var currentMq=mqOrderNamed[fetchMediaQuery()],whichMq=mqOrderNamed[which];return currentMq>=whichMq},isBelow=function(which){var currentMq=mqOrderNamed[fetchMediaQuery()],whichMq=mqOrderNamed[which];return whichMq>currentMq},fetchMediaQuery=function(){var mq=$listenElement.css("font-family");return mq=mq.replace(/['",]/g,"")},fetchMqIndex=function(mediaQuery){return mqOrderNamed[mediaQuery]},fetchMqName=function(index){return mqOrderNumbered[index]},throttleOn=function(duration){return $window.on("resize.throttle",td.throttle(duration||250,onResize)),$window.off("resize.no-throttle"),this},throttleOff=function(){return $window.on("resize.no-throttle",onResize),$window.off("resize.throttle"),this},responsiveImages=require("./responsiveImages"),constructor=function(){return setOrder(),currentMediaQuery=fetchMediaQuery(),throttleOff(),{onMediaQueryChange:onMediaQueryChange,onMediaQuery:onMediaQuery,when:when,fetchMediaQuery:fetchMediaQuery,fetchMqIndex:fetchMqIndex,fetchMqName:fetchMqName,isAbove:isAbove,isBelow:isBelow,throttleOn:throttleOn,throttleOff:throttleOff,responsiveImages:responsiveImages}}.call();module.exports=constructor}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./responsiveImages":3,"./throttleDebounce":4}]},{},[]); |
Sorry, the diff of this file is not supported yet
788423
32
1185
237