This repository has been archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memphis.min.js
1 lines (1 loc) · 1.65 KB
/
memphis.min.js
1
define(["jquery"],function(a){function c(a,b,c){var d;return function e(){function g(){c||a.apply(e,f),d=null}var e=this,f=arguments;d?clearTimeout(d):c&&a.apply(e,f),d=setTimeout(g,b||100)}}"use strict";var b={};return b.mediator=function(){function b(b,c){a[b]||(a[b]=[]),a[b].push({context:this,callback:c})}function c(b,c){var d,e,f;if(!a[b])return;f=a[b];for(d=0,e=f.length;d<e;d++)if(c===f[d].callback){a[b]=f.slice(0,d).concat(f.slice(d+1));return}}function d(b){var c,d,e,f;if(!a[b])return;c=Array.prototype.slice.call(arguments,1);for(d=0,e=a[b].length;d<e;d++)f=a[b][d],f.callback.apply(f.context,c)}function e(b){if(!a[b])return;delete a[b]}var a={};return{channels:a,publish:d,subscribe:b,unsubscribe:c,clear:e,installTo:function(a){a.subscribe=b,a.unsubscribe=c,a.publish=d}}}(),b.mediator.installTo(b),b.window=function(){function g(a){a&&j(a),e.width=d.width(),e.height=d.height(),d.on("resize",c(k,300)),l()}function h(){return e}function i(){return f}function j(a){f=a}function k(){var a=d.width(),c=d.height();if(a===e.width&&c===e.height)return;e.width=a,e.height=c,b.publish("window.resize",e),l()}function l(){var a,c=1;if(!f.length)return;for(var d in f)f[d]<e.width&&(c=f[d]);if(c===e.currBreakpoint)return;e.currBreakpoint&&(e.lastBreakpoint=e.currBreakpoint),e.currBreakpoint=c,b.publish("window.breakpoint",e),e.lastBreakpoint&&b.publish("window.breakpoint.out"+e.lastBreakpoint,e),b.publish("window.breakpoint.in"+e.currBreakpoint,e)}var d=a(window),e={currBreakpoint:null,lastBreakpoint:null,width:0,height:0},f=[];return{init:g,getViewport:h,getBreakpoints:i,setBreakpoints:j}}(),b.getViewport=b.window.getViewport,b.utils={debounce:c},window.memphis=b,b});