Comparing version 2.2.2 to 2.2.3
82
baron.js
@@ -1,7 +0,6 @@ | ||
(function(window, undefined) { | ||
(function(scopedWindow, undefined) { | ||
'use strict'; | ||
if (!window) return; // Server side | ||
var $ = window.$; | ||
var onClient = typeof window != 'undefined'; | ||
var $ = scopedWindow.$; | ||
var _baron = baron; // Stored baron value for noConflict usage | ||
@@ -37,3 +36,3 @@ var pos = ['left', 'top', 'right', 'bottom', 'width', 'height']; | ||
var macosxffRe = /[\s\S]*Macintosh[\s\S]*\) Gecko[\s\S]*/; | ||
var isMacFF = macosxffRe.test(window.navigator.userAgent); | ||
var isMacFF = macosxffRe.test(scopedWindow.navigator && scopedWindow.navigator.userAgent); | ||
@@ -57,3 +56,3 @@ // removeIf(production) | ||
var defaultParams = { | ||
$: window.jQuery, | ||
$: scopedWindow.jQuery, | ||
direction: 'v', | ||
@@ -120,3 +119,3 @@ barOnCls: '_scrollbar', | ||
if (obj.length === undefined || obj === window) obj = [obj]; | ||
if (obj.length === undefined || obj === scopedWindow) obj = [obj]; | ||
@@ -314,3 +313,3 @@ while (obj[i]) { | ||
// onResize: | ||
element: window, | ||
element: scopedWindow, | ||
@@ -847,3 +846,3 @@ handler: function() { | ||
// getComputedStyle is ie9+, but we here only in f ff | ||
var paddingWas = window.getComputedStyle(this.scroller)[[padding]]; | ||
var paddingWas = scopedWindow.getComputedStyle(this.scroller)[[padding]]; | ||
var delta = this.scroller[this.origin.crossOffset] - | ||
@@ -932,3 +931,3 @@ this.scroller[this.origin.crossClient]; | ||
baron.noConflict = function() { | ||
window.baron = _baron; // Restoring original value of "baron" global var | ||
scopedWindow.baron = _baron; // Restoring original value of "baron" global var | ||
@@ -938,18 +937,31 @@ return baron; | ||
baron.version = '2.2.2'; | ||
baron.version = '2.2.3'; | ||
if ($ && $.fn) { // Adding baron to jQuery as plugin | ||
$.fn.baron = baron; | ||
// No AMD support, need it? Notify me. | ||
if (typeof module != 'undefined') { | ||
module.exports = baron; | ||
// @todo webpack | ||
require('./fix'); | ||
require('./pull'); | ||
require('./controls'); | ||
require('./autoUpdate'); | ||
} else { | ||
window.baron = baron; | ||
if ($ && $.fn) { // Adding baron to jQuery as plugin | ||
$.fn.baron = baron; | ||
} | ||
} | ||
})(this); | ||
window.baron = baron; // Use noConflict method if you need window.baron var for another purposes | ||
/* Fixable elements plugin for baron 0.6+ */ | ||
(function(scopedWindow, undefined) { | ||
var scopedBaron; | ||
if (typeof module != 'undefined') { | ||
module.exports = baron.noConflict(); | ||
scopedBaron = require('./core.js'); | ||
} else { | ||
scopedBaron = scopedWindow.baron; | ||
} | ||
})(window); | ||
/* Fixable elements plugin for baron 0.6+ */ | ||
(function(window, undefined) { | ||
// By now window.baron points to real baron | ||
var scopedBaron = window.baron; | ||
// removeIf(production) | ||
@@ -1209,9 +1221,13 @@ var log = function() { | ||
}; | ||
})(window); | ||
})(this); | ||
/* Autoupdate plugin for baron 0.6+ */ | ||
(function(window) { | ||
// By now window.baron points to real baron | ||
var scopedBaron = window.baron; | ||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver || null; | ||
(function(scopedWindow) { | ||
if (typeof module != 'undefined') { | ||
scopedBaron = require('./core'); | ||
} else { | ||
scopedBaron = scopedWindow.baron; | ||
} | ||
var MutationObserver = scopedWindow.MutationObserver || scopedWindow.WebKitMutationObserver || scopedWindow.MozMutationObserver || null; | ||
var autoUpdate = function() { | ||
@@ -1296,9 +1312,14 @@ var self = this; | ||
}; | ||
})(window); | ||
})(this); | ||
/* Controls plugin for baron 0.6+ */ | ||
(function(window, undefined) { | ||
// By now window.baron points to real baron | ||
var scopedBaron = window.baron; | ||
(function(scopedWindow, undefined) { | ||
var scopedBaron; | ||
if (typeof module != 'undefined') { | ||
scopedBaron = require('./core'); | ||
} else { | ||
scopedBaron = scopedWindow.baron; | ||
} | ||
var controls = function(params) { | ||
@@ -1397,3 +1418,4 @@ var forward, backward, track, screen, | ||
}; | ||
})(window); | ||
})(this); | ||
// removeIf(production) | ||
@@ -1400,0 +1422,0 @@ baron.fn.log = function(level, msg, nodes) { |
@@ -1,1 +0,1 @@ | ||
!function(t,i){"use strict";function s(e){var r,o,n=!!e,l={$:t.jQuery,direction:"v",barOnCls:"_scrollbar",resizeDebounce:0,event:function(t,i,s,r){e.$(t)[r||"on"](i,s)},cssGuru:!1,impact:"scroller",position:"static"};e=e||{};for(var c in l)e[c]===i&&(e[c]=l[c]);r=e.$&&this instanceof e.$,e._chain?o=e.root:r?e.root=o=this:o=e.$?e.$(e.root||e.scroller):[];var a=new s.fn.constructor(o,e,n);return a.autoUpdate&&a.autoUpdate(),a}function e(s,e){var r=0;for((s.length===i||s===t)&&(s=[s]);s[r];)e.call(this,s[r],r),r++}function r(){return(new Date).getTime()}function o(i,s,r){i._eventHandlers=i._eventHandlers||[{element:i.scroller,handler:function(t){i.scroll(t)},type:"scroll"},{element:i.root,handler:function(){i.update()},type:"transitionend animationend"},{element:i.scroller,handler:function(){i.update()},type:"keyup"},{element:i.bar,handler:function(t){t.preventDefault(),i.selection(),i.drag.now=1,i.draggingCls&&h(i.root).addClass(i.draggingCls)},type:"touchstart mousedown"},{element:document,handler:function(){i.selection(1),i.drag.now=0,i.draggingCls&&h(i.root).removeClass(i.draggingCls)},type:"mouseup blur touchend"},{element:document,handler:function(t){2!=t.button&&i._pos0(t)},type:"touchstart mousedown"},{element:document,handler:function(t){i.drag.now&&i.drag(t)},type:"mousemove touchmove"},{element:t,handler:function(){i.update()},type:"resize"},{element:i.root,handler:function(){i.update()},type:"sizeChange"},{element:i.clipper,handler:function(){i.clipperOnScroll()},type:"scroll"}],e(i._eventHandlers,function(t){t.element&&s(t.element,t.type,t.handler,r)})}function n(t,i,s,e){var r="data-baron-"+i+"-id";if("on"==s)t.setAttribute(r,e);else{if("off"!=s)return t.getAttribute(r);t.removeAttribute(r)}}function l(t){var i=new C.prototype.constructor(t);return o(i,t.event,"on"),n(i.root,t.direction,"on",p.length),p.push(i),i.update(),i}function c(t){var i={};t=t||{};for(var s in t)t.hasOwnProperty(s)&&(i[s]=t[s]);return i}function a(t){if(this.events&&this.events[t])for(var i=0;i<this.events[t].length;i++){var s=Array.prototype.slice.call(arguments,1);this.events[t][i].apply(this,s)}}if(t){var h=t.$,u=s,f=["left","top","right","bottom","width","height"],p=[],d={v:{x:"Y",pos:f[1],oppos:f[3],crossPos:f[0],crossOpPos:f[2],size:f[5],crossSize:f[4],crossMinSize:"min-"+f[4],crossMaxSize:"max-"+f[4],client:"clientHeight",crossClient:"clientWidth",scrollEdge:"scrollLeft",offset:"offsetHeight",crossOffset:"offsetWidth",offsetPos:"offsetTop",scroll:"scrollTop",scrollSize:"scrollHeight"},h:{x:"X",pos:f[0],oppos:f[2],crossPos:f[1],crossOpPos:f[3],size:f[4],crossSize:f[5],crossMinSize:"min-"+f[5],crossMaxSize:"max-"+f[5],client:"clientWidth",crossClient:"clientHeight",scrollEdge:"scrollTop",offset:"offsetWidth",crossOffset:"offsetHeight",offsetPos:"offsetLeft",scroll:"scrollLeft",scrollSize:"scrollWidth"}},v=17,g=15,m=/[\s\S]*Macintosh[\s\S]*\) Gecko[\s\S]*/,b=m.test(t.navigator.userAgent);s.fn={constructor:function(t,i,s){var r=c(i);r.event=function(t,s,r,o){e(t,function(t){i.event(t,s,r,o)})},this.length=0,e.call(this,t,function(t,i){var s=n(t,r.direction),e=+s;if(e==e&&null!==s&&p[e])this[i]=p[e];else{var o=c(r);if(r.root&&r.scroller){if(o.scroller=r.$(r.scroller,t),!o.scroller.length)return}else o.scroller=t;o.root=t,this[i]=l(o)}this.length=i+1}),this.params=r},dispose:function(){var t=this.params;e(this,function(i,s){i.dispose(t),p[s]=null}),this.params=null},update:function(){var t=arguments;e(this,function(i,s){i.update.apply(i,t)})},baron:function(t){return t.root=[],this.params.root&&(t.scroller=this.params.scroller),e.call(this,this,function(i){t.root.push(i.root)}),t.direction="v"==this.params.direction?"h":"v",t._chain=!0,s(t)}};var C={};C.prototype={_debounce:function(t,s){var e,o,n=this,l=function(){if(n._disposed)return clearTimeout(e),e=n=null,i;var c=r()-o;s>c&&c>=0?e=setTimeout(l,s-c):(e=null,t())};return function(){o=r(),e||(e=setTimeout(l,s))}},constructor:function(s){function e(t,i){return f(t,i)[0]}function o(t){var i=this.barMinSize||20;t>0&&i>t&&(t=i),this.bar&&f(this.bar).css(this.origin.size,parseInt(t,10)+"px")}function n(t){if(this.bar){var i=f(this.bar).css(this.origin.pos),s=+t+"px";s&&s!=i&&f(this.bar).css(this.origin.pos,s)}}function l(){return C[this.origin.client]-this.barTopLimit-this.bar[this.origin.offset]}function c(t){return t*l.call(this)+this.barTopLimit}function h(t){return(t-this.barTopLimit)/l.call(this)}function u(){return!1}var f,p,m,C,y,z,$,w,S;if(w=$=r(),f=this.$=s.$,this.event=s.event,this.events={},this.root=s.root,this.scroller=e(s.scroller),this.bar=e(s.bar,this.root),C=this.track=e(s.track,this.root),!this.track&&this.bar&&(C=this.bar.parentNode),this.clipper=this.scroller.parentNode,this.direction=s.direction,this.rtl=s.rtl,this.origin=d[this.direction],this.barOnCls=s.barOnCls,this.scrollingCls=s.scrollingCls,this.draggingCls=s.draggingCls,this.impact=s.impact,this.position=s.position,this.rtl=s.rtl,this.barTopLimit=0,this.resizeDebounce=s.resizeDebounce,this.cursor=function(t){return t["client"+this.origin.x]||(((t.originalEvent||t).touches||{})[0]||{})["page"+this.origin.x]},this.pos=function(t){var s="page"+this.origin.x+"Offset",e=this.scroller[s]?s:this.origin.scroll;return t!==i&&(this.scroller[e]=t),this.scroller[e]},this.rpos=function(t){var i,s=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];return i=t?this.pos(t*s):this.pos(),i/(s||1)},this.barOn=function(t){this.barOnCls&&(t||this.scroller[this.origin.client]>=this.scroller[this.origin.scrollSize]?f(this.root).hasClass(this.barOnCls)&&f(this.root).removeClass(this.barOnCls):f(this.root).hasClass(this.barOnCls)||f(this.root).addClass(this.barOnCls))},this._pos0=function(t){m=this.cursor(t)-p},this.drag=function(t){var i=h.call(this,this.cursor(t)-m),s=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];this.scroller[this.origin.scroll]=i*s},this.selection=function(t){this.event(document,"selectpos selectstart",u,t?"off":"on")},this.resize=function(){function t(){var t=s.scroller[s.origin.crossOffset],i=s.scroller[s.origin.crossClient],e=0;if(b?e=g:i>0&&0===t&&(t=i+v),t)if(s.barOn(),"scroller"==s.impact){var o=t-i+e;if("static"==s.position){var n=s.$(s.scroller).css(s.origin.crossSize),l=s.clipper[s.origin.crossClient]+o+"px";n!=l&&s._setCrossSizes(s.scroller,l)}else{var c={},h=s.rtl?"Left":"Right";"h"==s.direction&&(h="Bottom"),c["padding"+h]=o+"px",s.$(s.scroller).css(c)}}else{var n=f(s.clipper).css(s.origin.crossSize),l=i+"px";n!=l&&s._setCrossSizes(s.clipper,l)}Array.prototype.unshift.call(arguments,"resize"),a.apply(s,arguments),w=r()}var s=this,e=s.resizeDebounce===i?300:s.resizeDebounce,o=0;r()-w<e&&(clearTimeout(y),o=e),o?y=setTimeout(t,o):t()},this.updatePositions=function(){var t,i=this;i.bar&&(t=(C[i.origin.client]-i.barTopLimit)*i.scroller[i.origin.client]/i.scroller[i.origin.scrollSize],parseInt(S,10)!=parseInt(t,10)&&(o.call(i,t),S=t),p=c.call(i,i.rpos()),n.call(i,p)),Array.prototype.unshift.call(arguments,"scroll"),a.apply(i,arguments),$=r()},this.scroll=function(){var t=this;t.updatePositions(),t.scrollingCls&&(z||t.$(t.root).addClass(t.scrollingCls),clearTimeout(z),z=setTimeout(function(){t.$(t.root).removeClass(t.scrollingCls),z=i},300))},this.clipperOnScroll=function(){this.rtl?this.clipper[this.origin.scrollEdge]=this.clipper[this.origin.scrollSize]:this.clipper[this.origin.scrollEdge]=0},this._setCrossSizes=function(t,i){var s={};s[this.origin.crossSize]=i,s[this.origin.crossMinSize]=i,s[this.origin.crossMaxSize]=i,this.$(t).css(s)},this._dumbCss=function(t){if(!s.cssGuru){var i=t?"hidden":null,e=t?"none":null;this.$(this.clipper).css({overflow:i,msOverflowStyle:e,position:"static"==this.position?"":"relative"});var r=t?"scroll":null,o="v"==this.direction?"y":"x",n={};n["overflow-"+o]=r,n["box-sizing"]="border-box",n.margin="0",n.border="0","absolute"==this.position&&(n.position="absolute",n.top="0","h"==this.direction?n.left=n.right="0":(n.bottom="0",n.right=this.rtl?"0":"",n.left=this.rtl?"":"0")),this.$(this.scroller).css(n)}},this._dumbCss(!0),b){var _="paddingRight",x={},O=t.getComputedStyle(this.scroller)[[_]];this.scroller[this.origin.crossOffset]-this.scroller[this.origin.crossClient];"h"==s.direction?_="paddingBottom":s.rtl&&(_="paddingLeft");var T=parseInt(O,10);T!=T&&(T=0),x[_]=g+T+"px",f(this.scroller).css(x)}return this},update:function(t){return a.call(this,"upd",t),this.resize(1),this.updatePositions(),this},dispose:function(t){o(this,this.event,"off"),n(this.root,t.direction,"off"),"v"==t.direction?this._setCrossSizes(this.scroller,""):this._setCrossSizes(this.clipper,""),this._dumbCss(!1),this.barOn(!0),a.call(this,"dispose"),this._disposed=!0},on:function(t,i,s){for(var e=t.split(" "),r=0;r<e.length;r++)"init"==e[r]?i.call(this,s):(this.events[e[r]]=this.events[e[r]]||[],this.events[e[r]].push(function(t){i.call(this,t||s)}))}},s.fn.constructor.prototype=s.fn,C.prototype.constructor.prototype=C.prototype,s.noConflict=function(){return t.baron=u,s},s.version="2.2.2",h&&h.fn&&(h.fn.baron=s),t.baron=s,"undefined"!=typeof module&&(module.exports=s.noConflict())}}(window),function(t,s){var e=t.baron,r=function(t){function e(t,i,e){var r=1==e?"pos":"oppos";l<(c.minView||0)&&(i=s),this.$(n[t]).css(this.origin.pos,"").css(this.origin.oppos,"").removeClass(c.outside),i!==s&&(i+="px",this.$(n[t]).css(this.origin[r],i).addClass(c.outside))}function r(t){try{i=document.createEvent("WheelEvent"),i.initWebKitWheelEvent(t.originalEvent.wheelDeltaX,t.originalEvent.wheelDeltaY),f.dispatchEvent(i),t.preventDefault()}catch(t){}}function o(t){var i;for(var s in t)c[s]=t[s];if(n=this.$(c.elements,this.scroller)){l=this.scroller[this.origin.client];for(var e=0;e<n.length;e++)i={},i[this.origin.size]=n[e][this.origin.offset],n[e].parentNode!==this.scroller&&this.$(n[e].parentNode).css(i),i={},i[this.origin.crossSize]=n[e].parentNode[this.origin.crossClient],this.$(n[e]).css(i),l-=n[e][this.origin.offset],u[e]=n[e].parentNode[this.origin.offsetPos],a[e]=a[e-1]||0,h[e]=h[e-1]||Math.min(u[e],0),n[e-1]&&(a[e]+=n[e-1][this.origin.offset],h[e]+=n[e-1][this.origin.offset]),(0!=e||0!=u[e])&&(this.event(n[e],"mousewheel",r,"off"),this.event(n[e],"mousewheel",r));c.limiter&&n[0]&&(this.track&&this.track!=this.scroller?(i={},i[this.origin.pos]=n[0].parentNode[this.origin.offset],this.$(this.track).css(i)):this.barTopLimit=n[0].parentNode[this.origin.offset],this.scroll()),c.limiter===!1&&(this.barTopLimit=0)}var o={element:n,handler:function(){for(var t,i=d(this)[0].parentNode,s=i.offsetTop,e=0;e<n.length;e++)n[e]===this&&(t=e);var r=s-a[t];c.scroll?c.scroll({x1:v.scroller.scrollTop,x2:r}):v.scroller.scrollTop=r},type:"click"};c.clickable&&(this._eventHandlers.push(o),p(o.element,o.type,o.handler,"on"))}var n,l,c={outside:"",inside:"",before:"",after:"",past:"",future:"",radius:0,minView:0},a=[],h=[],u=[],f=this.scroller,p=this.event,d=this.$,v=this;this.on("init",o,t);var g=[],m=[];this.on("init scroll",function(){var t,i,r;if(n){for(var o,f=0;f<n.length;f++)t=0,u[f]-this.pos()<h[f]+c.radius?(t=1,i=a[f]):u[f]-this.pos()>h[f]+l-c.radius?(t=2,i=this.scroller[this.origin.client]-n[f][this.origin.offset]-a[f]-l):(t=3,i=s),r=!1,(u[f]-this.pos()<h[f]||u[f]-this.pos()>h[f]+l)&&(r=!0),(t!=g[f]||r!=m[f])&&(e.call(this,f,i,t),g[f]=t,m[f]=r,o=!0);if(o)for(f=0;f<n.length;f++)1==g[f]&&c.past&&this.$(n[f]).addClass(c.past).removeClass(c.future),2==g[f]&&c.future&&this.$(n[f]).addClass(c.future).removeClass(c.past),3==g[f]?((c.future||c.past)&&this.$(n[f]).removeClass(c.past).removeClass(c.future),c.inside&&this.$(n[f]).addClass(c.inside)):c.inside&&this.$(n[f]).removeClass(c.inside),g[f]!=g[f+1]&&1==g[f]&&c.before?this.$(n[f]).addClass(c.before).removeClass(c.after):g[f]!=g[f-1]&&2==g[f]&&c.after?this.$(n[f]).addClass(c.after).removeClass(c.before):this.$(n[f]).removeClass(c.before).removeClass(c.after),c.grad&&(m[f]?this.$(n[f]).addClass(c.grad):this.$(n[f]).removeClass(c.grad))}}),this.on("resize upd",function(t){o.call(this,t&&t.fix)})};e.fn.fix=function(t){for(var i=0;this[i];)r.call(this[i],t),i++;return this}}(window),function(t){var i=t.baron,s=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver||null,e=function(){function t(){o.root[o.origin.offset]?e():i()}function i(){r||(r=setInterval(function(){o.root[o.origin.offset]&&(e(),o.update())},300))}function e(){clearInterval(r),r=null}var r,o=this;if(!this._au){var n=o._debounce(function(){o.update()},300);this._observer=new s(function(){t(),o.update(),n()}),this.on("init",function(){o._observer.observe(o.root,{childList:!0,subtree:!0,characterData:!0}),t()}),this.on("dispose",function(){o._observer.disconnect(),e(),delete o._observer}),this._au=!0}};i.fn.autoUpdate=function(t){if(!s)return this;for(var i=0;this[i];)e.call(this[i],t),i++;return this}}(window),function(t,i){var s=t.baron,e=function(t){var i,s,e,r,o,n=this;r=t.screen||.9,t.forward&&(i=this.$(t.forward,this.clipper),o={element:i,handler:function(){var i=n.pos()+(t.delta||30);n.pos(i)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.backward&&(s=this.$(t.backward,this.clipper),o={element:s,handler:function(){var i=n.pos()-(t.delta||30);n.pos(i)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.track&&(e=t.track===!0?this.track:this.$(t.track,this.clipper)[0],e&&(o={element:e,handler:function(t){if(t.target==e){var i=t["offset"+n.origin.x],s=n.bar[n.origin.offsetPos],o=0;s>i?o=-1:i>s+n.bar[n.origin.offset]&&(o=1);var l=n.pos()+o*r*n.scroller[n.origin.client];n.pos(l)}},type:"mousedown"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")))};s.fn.controls=function(t){for(var i=0;this[i];)e.call(this[i],t),i++;return this}}(window); | ||
!function(t,i){"use strict";function s(e){var r,o,n=!!e,l={$:t.jQuery,direction:"v",barOnCls:"_scrollbar",resizeDebounce:0,event:function(t,i,s,r){e.$(t)[r||"on"](i,s)},cssGuru:!1,impact:"scroller",position:"static"};e=e||{};for(var c in l)e[c]===i&&(e[c]=l[c]);r=e.$&&this instanceof e.$,e._chain?o=e.root:r?e.root=o=this:o=e.$?e.$(e.root||e.scroller):[];var a=new s.fn.constructor(o,e,n);return a.autoUpdate&&a.autoUpdate(),a}function e(s,e){var r=0;for(s.length!==i&&s!==t||(s=[s]);s[r];)e.call(this,s[r],r),r++}function r(){return(new Date).getTime()}function o(i,s,r){i._eventHandlers=i._eventHandlers||[{element:i.scroller,handler:function(t){i.scroll(t)},type:"scroll"},{element:i.root,handler:function(){i.update()},type:"transitionend animationend"},{element:i.scroller,handler:function(){i.update()},type:"keyup"},{element:i.bar,handler:function(t){t.preventDefault(),i.selection(),i.drag.now=1,i.draggingCls&&h(i.root).addClass(i.draggingCls)},type:"touchstart mousedown"},{element:document,handler:function(){i.selection(1),i.drag.now=0,i.draggingCls&&h(i.root).removeClass(i.draggingCls)},type:"mouseup blur touchend"},{element:document,handler:function(t){2!=t.button&&i._pos0(t)},type:"touchstart mousedown"},{element:document,handler:function(t){i.drag.now&&i.drag(t)},type:"mousemove touchmove"},{element:t,handler:function(){i.update()},type:"resize"},{element:i.root,handler:function(){i.update()},type:"sizeChange"},{element:i.clipper,handler:function(){i.clipperOnScroll()},type:"scroll"}],e(i._eventHandlers,function(t){t.element&&s(t.element,t.type,t.handler,r)})}function n(t,i,s,e){var r="data-baron-"+i+"-id";if("on"==s)t.setAttribute(r,e);else{if("off"!=s)return t.getAttribute(r);t.removeAttribute(r)}}function l(t){var i=new C.prototype.constructor(t);return o(i,t.event,"on"),n(i.root,t.direction,"on",p.length),p.push(i),i.update(),i}function c(t){var i={};t=t||{};for(var s in t)t.hasOwnProperty(s)&&(i[s]=t[s]);return i}function a(t){if(this.events&&this.events[t])for(var i=0;i<this.events[t].length;i++){var s=Array.prototype.slice.call(arguments,1);this.events[t][i].apply(this,s)}}var h=("undefined"!=typeof window,t.$),u=s,f=["left","top","right","bottom","width","height"],p=[],d={v:{x:"Y",pos:f[1],oppos:f[3],crossPos:f[0],crossOpPos:f[2],size:f[5],crossSize:f[4],crossMinSize:"min-"+f[4],crossMaxSize:"max-"+f[4],client:"clientHeight",crossClient:"clientWidth",scrollEdge:"scrollLeft",offset:"offsetHeight",crossOffset:"offsetWidth",offsetPos:"offsetTop",scroll:"scrollTop",scrollSize:"scrollHeight"},h:{x:"X",pos:f[0],oppos:f[2],crossPos:f[1],crossOpPos:f[3],size:f[4],crossSize:f[5],crossMinSize:"min-"+f[5],crossMaxSize:"max-"+f[5],client:"clientWidth",crossClient:"clientHeight",scrollEdge:"scrollTop",offset:"offsetWidth",crossOffset:"offsetHeight",offsetPos:"offsetLeft",scroll:"scrollLeft",scrollSize:"scrollWidth"}},v=17,g=15,m=/[\s\S]*Macintosh[\s\S]*\) Gecko[\s\S]*/,b=m.test(t.navigator&&t.navigator.userAgent);s.fn={constructor:function(t,i,s){var r=c(i);r.event=function(t,s,r,o){e(t,function(t){i.event(t,s,r,o)})},this.length=0,e.call(this,t,function(t,i){var s=n(t,r.direction),e=+s;if(e==e&&null!==s&&p[e])this[i]=p[e];else{var o=c(r);if(r.root&&r.scroller){if(o.scroller=r.$(r.scroller,t),!o.scroller.length)return}else o.scroller=t;o.root=t,this[i]=l(o)}this.length=i+1}),this.params=r},dispose:function(){var t=this.params;e(this,function(i,s){i.dispose(t),p[s]=null}),this.params=null},update:function(){var t=arguments;e(this,function(i,s){i.update.apply(i,t)})},baron:function(t){return t.root=[],this.params.root&&(t.scroller=this.params.scroller),e.call(this,this,function(i){t.root.push(i.root)}),t.direction="v"==this.params.direction?"h":"v",t._chain=!0,s(t)}};var C={};C.prototype={_debounce:function(t,s){var e,o,n=this,l=function(){if(n._disposed)return clearTimeout(e),e=n=null,i;var c=r()-o;s>c&&c>=0?e=setTimeout(l,s-c):(e=null,t())};return function(){o=r(),e||(e=setTimeout(l,s))}},constructor:function(s){function e(t,i){return f(t,i)[0]}function o(t){var i=this.barMinSize||20;t>0&&i>t&&(t=i),this.bar&&f(this.bar).css(this.origin.size,parseInt(t,10)+"px")}function n(t){if(this.bar){var i=f(this.bar).css(this.origin.pos),s=+t+"px";s&&s!=i&&f(this.bar).css(this.origin.pos,s)}}function l(){return C[this.origin.client]-this.barTopLimit-this.bar[this.origin.offset]}function c(t){return t*l.call(this)+this.barTopLimit}function h(t){return(t-this.barTopLimit)/l.call(this)}function u(){return!1}var f,p,m,C,y,z,$,S,_;if(S=$=r(),f=this.$=s.$,this.event=s.event,this.events={},this.root=s.root,this.scroller=e(s.scroller),this.bar=e(s.bar,this.root),C=this.track=e(s.track,this.root),!this.track&&this.bar&&(C=this.bar.parentNode),this.clipper=this.scroller.parentNode,this.direction=s.direction,this.rtl=s.rtl,this.origin=d[this.direction],this.barOnCls=s.barOnCls,this.scrollingCls=s.scrollingCls,this.draggingCls=s.draggingCls,this.impact=s.impact,this.position=s.position,this.rtl=s.rtl,this.barTopLimit=0,this.resizeDebounce=s.resizeDebounce,this.cursor=function(t){return t["client"+this.origin.x]||(((t.originalEvent||t).touches||{})[0]||{})["page"+this.origin.x]},this.pos=function(t){var s="page"+this.origin.x+"Offset",e=this.scroller[s]?s:this.origin.scroll;return t!==i&&(this.scroller[e]=t),this.scroller[e]},this.rpos=function(t){var i,s=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];return i=t?this.pos(t*s):this.pos(),i/(s||1)},this.barOn=function(t){this.barOnCls&&(t||this.scroller[this.origin.client]>=this.scroller[this.origin.scrollSize]?f(this.root).hasClass(this.barOnCls)&&f(this.root).removeClass(this.barOnCls):f(this.root).hasClass(this.barOnCls)||f(this.root).addClass(this.barOnCls))},this._pos0=function(t){m=this.cursor(t)-p},this.drag=function(t){var i=h.call(this,this.cursor(t)-m),s=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];this.scroller[this.origin.scroll]=i*s},this.selection=function(t){this.event(document,"selectpos selectstart",u,t?"off":"on")},this.resize=function(){function t(){var t=s.scroller[s.origin.crossOffset],i=s.scroller[s.origin.crossClient],e=0;if(b?e=g:i>0&&0===t&&(t=i+v),t)if(s.barOn(),"scroller"==s.impact){var o=t-i+e;if("static"==s.position){var n=s.$(s.scroller).css(s.origin.crossSize),l=s.clipper[s.origin.crossClient]+o+"px";n!=l&&s._setCrossSizes(s.scroller,l)}else{var c={},h=s.rtl?"Left":"Right";"h"==s.direction&&(h="Bottom"),c["padding"+h]=o+"px",s.$(s.scroller).css(c)}}else{var n=f(s.clipper).css(s.origin.crossSize),l=i+"px";n!=l&&s._setCrossSizes(s.clipper,l)}Array.prototype.unshift.call(arguments,"resize"),a.apply(s,arguments),S=r()}var s=this,e=s.resizeDebounce===i?300:s.resizeDebounce,o=0;r()-S<e&&(clearTimeout(y),o=e),o?y=setTimeout(t,o):t()},this.updatePositions=function(){var t,i=this;i.bar&&(t=(C[i.origin.client]-i.barTopLimit)*i.scroller[i.origin.client]/i.scroller[i.origin.scrollSize],parseInt(_,10)!=parseInt(t,10)&&(o.call(i,t),_=t),p=c.call(i,i.rpos()),n.call(i,p)),Array.prototype.unshift.call(arguments,"scroll"),a.apply(i,arguments),$=r()},this.scroll=function(){var t=this;t.updatePositions(),t.scrollingCls&&(z||t.$(t.root).addClass(t.scrollingCls),clearTimeout(z),z=setTimeout(function(){t.$(t.root).removeClass(t.scrollingCls),z=i},300))},this.clipperOnScroll=function(){this.rtl?this.clipper[this.origin.scrollEdge]=this.clipper[this.origin.scrollSize]:this.clipper[this.origin.scrollEdge]=0},this._setCrossSizes=function(t,i){var s={};s[this.origin.crossSize]=i,s[this.origin.crossMinSize]=i,s[this.origin.crossMaxSize]=i,this.$(t).css(s)},this._dumbCss=function(t){if(!s.cssGuru){var i=t?"hidden":null,e=t?"none":null;this.$(this.clipper).css({overflow:i,msOverflowStyle:e,position:"static"==this.position?"":"relative"});var r=t?"scroll":null,o="v"==this.direction?"y":"x",n={};n["overflow-"+o]=r,n["box-sizing"]="border-box",n.margin="0",n.border="0","absolute"==this.position&&(n.position="absolute",n.top="0","h"==this.direction?n.left=n.right="0":(n.bottom="0",n.right=this.rtl?"0":"",n.left=this.rtl?"":"0")),this.$(this.scroller).css(n)}},this._dumbCss(!0),b){var w="paddingRight",x={},O=t.getComputedStyle(this.scroller)[[w]];this.scroller[this.origin.crossOffset]-this.scroller[this.origin.crossClient];"h"==s.direction?w="paddingBottom":s.rtl&&(w="paddingLeft");var T=parseInt(O,10);T!=T&&(T=0),x[w]=g+T+"px",f(this.scroller).css(x)}return this},update:function(t){return a.call(this,"upd",t),this.resize(1),this.updatePositions(),this},dispose:function(t){o(this,this.event,"off"),n(this.root,t.direction,"off"),"v"==t.direction?this._setCrossSizes(this.scroller,""):this._setCrossSizes(this.clipper,""),this._dumbCss(!1),this.barOn(!0),a.call(this,"dispose"),this._disposed=!0},on:function(t,i,s){for(var e=t.split(" "),r=0;r<e.length;r++)"init"==e[r]?i.call(this,s):(this.events[e[r]]=this.events[e[r]]||[],this.events[e[r]].push(function(t){i.call(this,t||s)}))}},s.fn.constructor.prototype=s.fn,C.prototype.constructor.prototype=C.prototype,s.noConflict=function(){return t.baron=u,s},s.version="2.2.3","undefined"!=typeof module?(module.exports=s,require("./fix"),require("./pull"),require("./controls"),require("./autoUpdate")):(window.baron=s,h&&h.fn&&(h.fn.baron=s))}(this),function(t,s){var e;e="undefined"!=typeof module?require("./core.js"):t.baron;var r=function(t){function e(t,i,e){var r=1==e?"pos":"oppos";l<(c.minView||0)&&(i=s),this.$(n[t]).css(this.origin.pos,"").css(this.origin.oppos,"").removeClass(c.outside),i!==s&&(i+="px",this.$(n[t]).css(this.origin[r],i).addClass(c.outside))}function r(t){try{i=document.createEvent("WheelEvent"),i.initWebKitWheelEvent(t.originalEvent.wheelDeltaX,t.originalEvent.wheelDeltaY),f.dispatchEvent(i),t.preventDefault()}catch(t){}}function o(t){var i;for(var s in t)c[s]=t[s];if(n=this.$(c.elements,this.scroller)){l=this.scroller[this.origin.client];for(var e=0;e<n.length;e++)i={},i[this.origin.size]=n[e][this.origin.offset],n[e].parentNode!==this.scroller&&this.$(n[e].parentNode).css(i),i={},i[this.origin.crossSize]=n[e].parentNode[this.origin.crossClient],this.$(n[e]).css(i),l-=n[e][this.origin.offset],u[e]=n[e].parentNode[this.origin.offsetPos],a[e]=a[e-1]||0,h[e]=h[e-1]||Math.min(u[e],0),n[e-1]&&(a[e]+=n[e-1][this.origin.offset],h[e]+=n[e-1][this.origin.offset]),0==e&&0==u[e]||(this.event(n[e],"mousewheel",r,"off"),this.event(n[e],"mousewheel",r));c.limiter&&n[0]&&(this.track&&this.track!=this.scroller?(i={},i[this.origin.pos]=n[0].parentNode[this.origin.offset],this.$(this.track).css(i)):this.barTopLimit=n[0].parentNode[this.origin.offset],this.scroll()),c.limiter===!1&&(this.barTopLimit=0)}var o={element:n,handler:function(){for(var t,i=d(this)[0].parentNode,s=i.offsetTop,e=0;e<n.length;e++)n[e]===this&&(t=e);var r=s-a[t];c.scroll?c.scroll({x1:v.scroller.scrollTop,x2:r}):v.scroller.scrollTop=r},type:"click"};c.clickable&&(this._eventHandlers.push(o),p(o.element,o.type,o.handler,"on"))}var n,l,c={outside:"",inside:"",before:"",after:"",past:"",future:"",radius:0,minView:0},a=[],h=[],u=[],f=this.scroller,p=this.event,d=this.$,v=this;this.on("init",o,t);var g=[],m=[];this.on("init scroll",function(){var t,i,r;if(n){for(var o,f=0;f<n.length;f++)t=0,u[f]-this.pos()<h[f]+c.radius?(t=1,i=a[f]):u[f]-this.pos()>h[f]+l-c.radius?(t=2,i=this.scroller[this.origin.client]-n[f][this.origin.offset]-a[f]-l):(t=3,i=s),r=!1,(u[f]-this.pos()<h[f]||u[f]-this.pos()>h[f]+l)&&(r=!0),t==g[f]&&r==m[f]||(e.call(this,f,i,t),g[f]=t,m[f]=r,o=!0);if(o)for(f=0;f<n.length;f++)1==g[f]&&c.past&&this.$(n[f]).addClass(c.past).removeClass(c.future),2==g[f]&&c.future&&this.$(n[f]).addClass(c.future).removeClass(c.past),3==g[f]?((c.future||c.past)&&this.$(n[f]).removeClass(c.past).removeClass(c.future),c.inside&&this.$(n[f]).addClass(c.inside)):c.inside&&this.$(n[f]).removeClass(c.inside),g[f]!=g[f+1]&&1==g[f]&&c.before?this.$(n[f]).addClass(c.before).removeClass(c.after):g[f]!=g[f-1]&&2==g[f]&&c.after?this.$(n[f]).addClass(c.after).removeClass(c.before):this.$(n[f]).removeClass(c.before).removeClass(c.after),c.grad&&(m[f]?this.$(n[f]).addClass(c.grad):this.$(n[f]).removeClass(c.grad))}}),this.on("resize upd",function(t){o.call(this,t&&t.fix)})};e.fn.fix=function(t){for(var i=0;this[i];)r.call(this[i],t),i++;return this}}(this),function(t){"undefined"!=typeof module?scopedBaron=require("./core"):scopedBaron=t.baron;var i=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver||null,s=function(){function t(){o.root[o.origin.offset]?e():s()}function s(){r||(r=setInterval(function(){o.root[o.origin.offset]&&(e(),o.update())},300))}function e(){clearInterval(r),r=null}var r,o=this;if(!this._au){var n=o._debounce(function(){o.update()},300);this._observer=new i(function(){t(),o.update(),n()}),this.on("init",function(){o._observer.observe(o.root,{childList:!0,subtree:!0,characterData:!0}),t()}),this.on("dispose",function(){o._observer.disconnect(),e(),delete o._observer}),this._au=!0}};scopedBaron.fn.autoUpdate=function(t){if(!i)return this;for(var e=0;this[e];)s.call(this[e],t),e++;return this}}(this),function(t,i){var s;s="undefined"!=typeof module?require("./core"):t.baron;var e=function(t){var i,s,e,r,o,n=this;r=t.screen||.9,t.forward&&(i=this.$(t.forward,this.clipper),o={element:i,handler:function(){var i=n.pos()+(t.delta||30);n.pos(i)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.backward&&(s=this.$(t.backward,this.clipper),o={element:s,handler:function(){var i=n.pos()-(t.delta||30);n.pos(i)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.track&&(e=t.track===!0?this.track:this.$(t.track,this.clipper)[0],e&&(o={element:e,handler:function(t){if(t.target==e){var i=t["offset"+n.origin.x],s=n.bar[n.origin.offsetPos],o=0;s>i?o=-1:i>s+n.bar[n.origin.offset]&&(o=1);var l=n.pos()+o*r*n.scroller[n.origin.client];n.pos(l)}},type:"mousedown"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")))};s.fn.controls=function(t){for(var i=0;this[i];)e.call(this[i],t),i++;return this}}(this); |
{ | ||
"name": "baron", | ||
"description": "A small, fast and crossbrowser custom scrollbar with native system scroll mechanic.", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"readmeFilename": "README.md", | ||
"homepage": "https://github.com/Diokuz/baron", | ||
"scripts": { | ||
"start": "gulp build", | ||
"test": "gulp t" | ||
"start": "./node_modules/gulp/bin/gulp.js build", | ||
"test": "./node_modules/gulp/bin/gulp.js t", | ||
"build": "./node_modules/gulp/bin/gulp.js build" | ||
}, | ||
@@ -23,3 +24,3 @@ "authors": [ | ||
], | ||
"main": "./baron.min.js", | ||
"main": "./src/core.js", | ||
"devDependencies": { | ||
@@ -31,2 +32,3 @@ "chai": "~3.2.0", | ||
"gulp-jshint": "^1.11.2", | ||
"gulp-mocha": "^2.2.0", | ||
"gulp-mocha-phantomjs": "^0.10.1", | ||
@@ -33,0 +35,0 @@ "gulp-remove-code": "^1.0.2", |
/* Autoupdate plugin for baron 0.6+ */ | ||
(function(window) { | ||
// By now window.baron points to real baron | ||
var scopedBaron = window.baron; | ||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver || null; | ||
(function(scopedWindow) { | ||
if (typeof module != 'undefined') { | ||
scopedBaron = require('./core'); | ||
} else { | ||
scopedBaron = scopedWindow.baron; | ||
} | ||
var MutationObserver = scopedWindow.MutationObserver || scopedWindow.WebKitMutationObserver || scopedWindow.MozMutationObserver || null; | ||
var autoUpdate = function() { | ||
@@ -86,2 +90,2 @@ var self = this; | ||
}; | ||
})(window); | ||
})(this); |
/* Controls plugin for baron 0.6+ */ | ||
(function(window, undefined) { | ||
// By now window.baron points to real baron | ||
var scopedBaron = window.baron; | ||
(function(scopedWindow, undefined) { | ||
var scopedBaron; | ||
if (typeof module != 'undefined') { | ||
scopedBaron = require('./core'); | ||
} else { | ||
scopedBaron = scopedWindow.baron; | ||
} | ||
var controls = function(params) { | ||
@@ -99,2 +104,2 @@ var forward, backward, track, screen, | ||
}; | ||
})(window); | ||
})(this); |
@@ -1,7 +0,6 @@ | ||
(function(window, undefined) { | ||
(function(scopedWindow, undefined) { | ||
'use strict'; | ||
if (!window) return; // Server side | ||
var $ = window.$; | ||
var onClient = typeof window != 'undefined'; | ||
var $ = scopedWindow.$; | ||
var _baron = baron; // Stored baron value for noConflict usage | ||
@@ -37,3 +36,3 @@ var pos = ['left', 'top', 'right', 'bottom', 'width', 'height']; | ||
var macosxffRe = /[\s\S]*Macintosh[\s\S]*\) Gecko[\s\S]*/; | ||
var isMacFF = macosxffRe.test(window.navigator.userAgent); | ||
var isMacFF = macosxffRe.test(scopedWindow.navigator && scopedWindow.navigator.userAgent); | ||
@@ -57,3 +56,3 @@ // removeIf(production) | ||
var defaultParams = { | ||
$: window.jQuery, | ||
$: scopedWindow.jQuery, | ||
direction: 'v', | ||
@@ -120,3 +119,3 @@ barOnCls: '_scrollbar', | ||
if (obj.length === undefined || obj === window) obj = [obj]; | ||
if (obj.length === undefined || obj === scopedWindow) obj = [obj]; | ||
@@ -314,3 +313,3 @@ while (obj[i]) { | ||
// onResize: | ||
element: window, | ||
element: scopedWindow, | ||
@@ -847,3 +846,3 @@ handler: function() { | ||
// getComputedStyle is ie9+, but we here only in f ff | ||
var paddingWas = window.getComputedStyle(this.scroller)[[padding]]; | ||
var paddingWas = scopedWindow.getComputedStyle(this.scroller)[[padding]]; | ||
var delta = this.scroller[this.origin.crossOffset] - | ||
@@ -932,3 +931,3 @@ this.scroller[this.origin.crossClient]; | ||
baron.noConflict = function() { | ||
window.baron = _baron; // Restoring original value of "baron" global var | ||
scopedWindow.baron = _baron; // Restoring original value of "baron" global var | ||
@@ -938,12 +937,19 @@ return baron; | ||
baron.version = '2.2.2'; | ||
baron.version = '2.2.3'; | ||
if ($ && $.fn) { // Adding baron to jQuery as plugin | ||
$.fn.baron = baron; | ||
} | ||
// No AMD support, need it? Notify me. | ||
if (typeof module != 'undefined') { | ||
module.exports = baron; | ||
// @todo webpack | ||
require('./fix'); | ||
require('./pull'); | ||
require('./controls'); | ||
require('./autoUpdate'); | ||
} else { | ||
window.baron = baron; | ||
window.baron = baron; // Use noConflict method if you need window.baron var for another purposes | ||
if (typeof module != 'undefined') { | ||
module.exports = baron.noConflict(); | ||
if ($ && $.fn) { // Adding baron to jQuery as plugin | ||
$.fn.baron = baron; | ||
} | ||
} | ||
})(window); | ||
})(this); |
/* Fixable elements plugin for baron 0.6+ */ | ||
(function(window, undefined) { | ||
// By now window.baron points to real baron | ||
var scopedBaron = window.baron; | ||
(function(scopedWindow, undefined) { | ||
var scopedBaron; | ||
if (typeof module != 'undefined') { | ||
scopedBaron = require('./core.js'); | ||
} else { | ||
scopedBaron = scopedWindow.baron; | ||
} | ||
// removeIf(production) | ||
@@ -259,2 +265,2 @@ var log = function() { | ||
}; | ||
})(window); | ||
})(this); |
/* Pull to load plugin for baron 0.6+ */ | ||
(function(window, undefined) { | ||
// By now window.baron points to real baron | ||
var scopedBaron = window.baron; | ||
(function(scopedWindow, undefined) { | ||
var scopedBaron; | ||
if (typeof module != 'undefined') { | ||
scopedBaron = require('./core'); | ||
} else { | ||
scopedBaron = scopedWindow.baron; | ||
} | ||
var pull = function(params) { | ||
@@ -154,2 +160,2 @@ var block = this.$(params.block), | ||
}; | ||
})(window); | ||
})(this); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135267
17
15
2752
1