5636 lines
278 KiB
JavaScript
5636 lines
278 KiB
JavaScript
|
|
/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
|
||
|
|
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("B
|
||
|
|
if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radi
|
||
|
|
},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);r
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
|
||
|
|
|
||
|
|
Magic Thumb v2.0.47
|
||
|
|
Copyright 2011 Magic Toolbox
|
||
|
|
Buy a license: www.magictoolbox.com/magicthumb/
|
||
|
|
License agreement: http://www.magictoolbox.com/license/
|
||
|
|
|
||
|
|
|
||
|
|
*/
|
||
|
|
eval(function(m,a,g,i,c,k){c=function(e){return(e<a?'':c(parseInt(e/a)))+((e=e%a)>35?String.fromCharCode(e+29):e.toString(36))};if(!''.replace(/^/,String)){while(g--){k[c(g)]=i[g]||c(g)}i=[function(e){return k[e]}];c=function(){return'\\w+'};g=1};while(g--){if(i[g]){m=m.replace(new RegExp('\\b'+c(g)+'\\b','g'),i[g])}}return m}('(w(){C(P.8A){B}E a={2G:"7Z.4.5",9d:0,3I:{},$6S:w(c){B(c.$2C||(c.$2C=++$J.9d))},56:w(c){B($J.3I[c]||($J.3I[c]={}))},$F:w(){},$R:w(){B R},1Q:w(c){B(2t!=c)},9G:w(c){B!!(c)},2I:w(c){C(!$J.1Q(c)){B R}C(c.$2y){B c.$2y}C(!!c.3c){C(1==c.3c){B"63"}C(3==c.3c){B"8c"}}C(c.1n&&c.5b){B"9p"}C(c.1n&&c.5J){B"1v"}C((c 2Y P.9r||c 2Y P.6O)&&c.2K===$J.2P){B"6R"}C(c 2Y P.3M){B"3H"}C(c 2Y P.6O){B"w"}C(c 2Y P.6c){B"5H"}C($J.K.1S){C($J.1Q(c.7j)){B"3q"}}1c{C(c===P.3q||c.2K==P.6P||c.2K==P.9w||c.2K==P.al||c.2K==P.aj||c.2K==P.ax){B"3q"}}C(c 2Y P.8V){B"8S"}C(c 2Y P.4A){B"a0"}C(c===P){B"P"}C(c===12){B"12"}B 55(c)},1x:w(j,g){C(!(j 2Y P.3M)){j=[j]}1j(E f=0,d=j.1n;f<d;f++){C(!$J.1Q(j)){3Y}1j(E e 1r(g||{})){21{j[f][e]=g[e]}2e(c){}}}B j[0]},4Y:w(g,f){C(!(g 2Y P.3M)){g=[g]}1j(E e=0,c=g.1n;e<c;e++){C(!$J.1Q(g[e])){3Y}C(!g[e].1H){3Y}1j(E d 1r(f||{})){C(!g[e].1H[d]){g[e].1H[d]=f[d]}}}B g[0]},8m:w(e,d){C(!$J.1Q(e)){B e}1j(E c 1r(d||{})){C(!e[c]){e[c]=d[c]}}B e},$21:w(){1j(E d=0,c=1v.1n;d<c;d++){21{B 1v[d]()}2e(f){}}B M},$A:w(e){C(!$J.1Q(e)){B $I([])}C(e.8X){B $I(e.8X())}C(e.5b){E d=e.1n||0,c=X 3M(d);3j(d--){c[d]=e[d]}B $I(c)}B $I(3M.1H.a7.2b(e))},4L:w(){B X 8V().a8()},3f:w(g){E e;1K($J.2I(g)){S"7Y":e={};1j(E f 1r g){e[f]=$J.3f(g[f])}V;S"3H":e=[];1j(E d=0,c=g.1n;d<c;d++){e[d]=$J.3f(g[d])}V;25:B g}B $J.$(e)},$:w(d){C(!$J.1Q(d)){B M}C(d.$6U){B d}1K($J.2I(d)){S"3H":d=$J.8m(d,$J.1x($J.3M,{$6U:$J.$F}));d.3z=d.2x;B d;V;S"5H":E c=12.at(d);C($J.1Q(c)){B $J.$(c)}B M;V;S"P":S"12":$J.$6S(d);d=$J.1x(d,$J.4g);V;S"63":$J.$6S(d);d=$J.1x(d,$J.24);V;S"3q":d=$J.1x(d,$J.6P);V;S"8c":B d;V;S"w":S"3H":S"8S":25:V}B $J.1x(d,{$6U:$J.$F})},$X:w(c,e,d){B $I($J.1C.7x(c)).7N(e||{}).Y(d||{})}};P.8A=P.$J=a;P.$I=a.$;$J.3M={$2y:"3H",3C:w(f,g){E c=v.1n;1j(E d=v.1n,e=(g<0)?13.4D(0,d+g):g||0;e<d;e++){C(v[e]===f){B e}}B-1},3D:w(c,d){B v.3C(c,d)!=-1},2x:w(c,f){1j(E e=0,d=v.1n;e<d;e++){C(e 1r v){c.2b(f,v[e],e,v)}}},1Y:w(c,j){E g=[];1j(E f=0,d=v.1n;f<d;f++){C(f 1r v){E e=v[f];C(c.2b(j,v[f],f,v)){g.4v(e)}}}B g},96:w(c,g){E f=[];1j(E e=0,d=v.1n;e<d;e++){C(e 1r v){f[e]=c.2b(g,v[e],e,v)}}B f}};$J.4Y(6c,{$2y:"5H",4h:w(){B v.1y(/^\\s+|\\s+$/g,"")},9R:w(){B v.1y(/^\\s+/g,"")},9y:w(){B v.1y(/\\s+$/g,"")},9F:w(c){B(v.5r()===c.5r())},bJ:w(c){B(v.23().5r()===c.23().5r())},5c:w(){B v.1y(/-\\D/g,w(c){B c.8x(1).bI()})},4U:w(){B v.1y(/[A-Z]/g,w(c){B("-"+c.8x(0).23())})},1g:w(c){B 3V(v,c||10)},8v:w(){B 5Z(v)},8O:w(){B!v.1y(/U/i,"").4h()},4i:w(d,c){c=c||"";B(c+v+c).3C(c+d+c)>-1}});a.4Y(6O,{$2y:"w",1b:w(){E d=$J.$A(1v),c=v,e=d.4s();B w(){B c.3w(e||M,d.8w($J.$A(1v)))}},2z:w(){E d=$J.$A(1v),c=v,e=d.4s();B w(f){B c.3w(e||M,$I([f||P.3q]).8w(d))}},22:w(){E d=$J.$A(1v),c=v,e=d.4s();B P.bz(w(){B c.3w(c,d)},e||0)},7D:w(){E d=$J.$A(1v),c=v;B w(){B c.22.3w(c,d)}},77:w(){E d=$J.$A(1v),c=v,e=d.4s();B P.aD(w(){B c.3w(c,d)},e||0)}});E b=69.bx.23();$J.K={5o:{70:!!(12.bB),cc:!!(P.c9),6x:!!(12.cd)},2N:(P.bT)?"7u":!!(P.aT)?"1S":(!69.aX)?"3v":(2t!=12.aY||M!=P.bo)?"6L":"bp",2G:"",5a:b.3i(/br(?:ad|bw|aG)/)?"7t":(b.3i(/(?:8a|7o)/)||69.5a.3i(/8o|3B|bV/i)||["bW"])[0].23(),3u:12.5g&&"83"==12.5g.23(),2p:w(){B(12.5g&&"83"==12.5g.23())?12.2i:12.60},1B:R,4t:w(){C($J.K.1B){B}$J.K.1B=U;$J.2i=$I(12.2i);$J.3B=$I(P);$I(12).7E("3t")}};$J.K.bD=$J.$A(["7t","8a","7o"]).3D($J.K.5a);(w(){w c(){B!!(1v.5J.6Q)}$J.K.2G=("7u"==$J.K.2N)?!!(12.7T)?9D:!!(P.9C)?9z:!!(P.7S)?5O:($J.K.5o.6x)?9k:((c())?9l:((12.4w)?9u:6t)):("1S"==$J.K.2N)?!!(P.9v||P.9t)?8E:!!(P.7e&&P.9q)?6:((P.7e)?5:4):("3v"==$J.K.2N)?(($J.K.5o.70)?(($J.K.5o.6x)?9M:7w):ao):("6L"==$J.K.2N)?!!(12.7T)?6t:!!12.5f?ai:!!(P.7S)?ar:((12.4w)?aA:ay):"";$J.K[$J.K.2N]=$J.K[$J.K.2N+$J.K.2G]=U;C(P.7Q){$J.K.7Q=U}})();$J.24={6p:w(c){B v.2w.4i(c," ")},2D:w(c){C(c&&!v.6p(c)){v.2w+=(v.2w?" ":"")+c}B v},51:w(c){c=c||".*";v.2w=v.2w.1y(X 4A("(^|\\\\s)"+c+"(?:\\\\s|$)"),"$1").4h();B v},au:w(c){B v.6p(c)
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates a carousel.
|
||
|
|
* @class The Owl Carousel.
|
||
|
|
* @public
|
||
|
|
* @param {HTMLElement|jQuery} element - The element to create the carousel for.
|
||
|
|
* @param {Object} [options] - The options
|
||
|
|
*/
|
||
|
|
function Owl(element, options) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Current settings for the carousel.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
this.settings = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Current options set by the caller including defaults.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
this.options = $.extend({}, Owl.Defaults, options);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Plugin element.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
this.$element = $(element);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Proxied event handlers.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._handlers = {};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* References to the running plugins of this carousel.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._plugins = {};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Currently suppressed events to prevent them from being retriggered.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._supress = {};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Absolute current position.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._current = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Animation speed in milliseconds.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._speed = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Coordinates of all items in pixel.
|
||
|
|
* @todo The name of this member is missleading.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._coordinates = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Current breakpoint.
|
||
|
|
* @todo Real media queries would be nice.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._breakpoint = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Current width of the plugin element.
|
||
|
|
*/
|
||
|
|
this._width = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All real items.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._items = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All cloned items.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._clones = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Merge values of all items.
|
||
|
|
* @todo Maybe this could be part of a plugin.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._mergers = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Widths of all items.
|
||
|
|
*/
|
||
|
|
this._widths = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Invalidated parts within the update process.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._invalidated = {};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Ordered list of workers for the update process.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._pipe = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Current state information for the drag operation.
|
||
|
|
* @todo #261
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._drag = {
|
||
|
|
time: null,
|
||
|
|
target: null,
|
||
|
|
pointer: null,
|
||
|
|
stage: {
|
||
|
|
start: null,
|
||
|
|
current: null
|
||
|
|
},
|
||
|
|
direction: null
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Current state information and their tags.
|
||
|
|
* @type {Object}
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
this._states = {
|
||
|
|
current: {},
|
||
|
|
tags: {
|
||
|
|
'initializing': [ 'busy' ],
|
||
|
|
'animating': [ 'busy' ],
|
||
|
|
'dragging': [ 'interacting' ]
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.each([ 'onResize', 'onThrottledResize' ], $.proxy(function(i, handler) {
|
||
|
|
this._handlers[handler] = $.proxy(this[handler], this);
|
||
|
|
}, this));
|
||
|
|
|
||
|
|
$.each(Owl.Plugins, $.proxy(function(key, plugin) {
|
||
|
|
this._plugins[key.charAt(0).toLowerCase() + key.slice(1)]
|
||
|
|
= new plugin(this);
|
||
|
|
}, this));
|
||
|
|
|
||
|
|
$.each(Owl.Workers, $.proxy(function(priority, worker) {
|
||
|
|
this._pipe.push({
|
||
|
|
'filter': worker.filter,
|
||
|
|
'run': $.proxy(worker.run, this)
|
||
|
|
});
|
||
|
|
}, this));
|
||
|
|
|
||
|
|
this.setup();
|
||
|
|
this.initialize();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options for the carousel.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Owl.Defaults = {
|
||
|
|
items: 1,
|
||
|
|
loop: false,
|
||
|
|
center: false,
|
||
|
|
rewind: false,
|
||
|
|
checkVisibility: true,
|
||
|
|
|
||
|
|
mouseDrag: true,
|
||
|
|
touchDrag: true,
|
||
|
|
pullDrag: true,
|
||
|
|
freeDrag: false,
|
||
|
|
|
||
|
|
margin: 0,
|
||
|
|
stagePadding: 0,
|
||
|
|
|
||
|
|
merge: false,
|
||
|
|
mergeFit: true,
|
||
|
|
autoWidth: false,
|
||
|
|
|
||
|
|
startPosition: 0,
|
||
|
|
rtl: false,
|
||
|
|
|
||
|
|
smartSpeed: 250,
|
||
|
|
fluidSpeed: false,
|
||
|
|
dragEndSpeed: false,
|
||
|
|
|
||
|
|
responsive: {
|
||
|
|
},
|
||
|
|
responsiveRefreshRate: 200,
|
||
|
|
responsiveBaseElement: window,
|
||
|
|
|
||
|
|
fallbackEasing: 'swing',
|
||
|
|
slideTransition: '',
|
||
|
|
|
||
|
|
info: false,
|
||
|
|
|
||
|
|
nestedItemSelector: false,
|
||
|
|
itemElement: 'div',
|
||
|
|
stageElement: 'div',
|
||
|
|
|
||
|
|
refreshClass: 'owl-refresh',
|
||
|
|
loadedClass: 'owl-loaded',
|
||
|
|
loadingClass: 'owl-loading',
|
||
|
|
rtlClass: 'owl-rtl',
|
||
|
|
responsiveClass: 'owl-responsive',
|
||
|
|
dragClass: 'owl-drag',
|
||
|
|
itemClass: 'owl-item',
|
||
|
|
stageClass: 'owl-stage',
|
||
|
|
stageOuterClass: 'owl-stage-outer',
|
||
|
|
grabClass: 'owl-grab'
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Enumeration for width.
|
||
|
|
* @public
|
||
|
|
* @readonly
|
||
|
|
* @enum {String}
|
||
|
|
*/
|
||
|
|
Owl.Width = {
|
||
|
|
Default: 'default',
|
||
|
|
Inner: 'inner',
|
||
|
|
Outer: 'outer'
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Enumeration for types.
|
||
|
|
* @public
|
||
|
|
* @readonly
|
||
|
|
* @enum {String}
|
||
|
|
*/
|
||
|
|
Owl.Type = {
|
||
|
|
Event: 'event',
|
||
|
|
State: 'state'
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Contains all registered plugins.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Owl.Plugins = {};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* List of workers involved in the update process.
|
||
|
|
*/
|
||
|
|
Owl.Workers = [ {
|
||
|
|
filter: [ 'width', 'settings' ],
|
||
|
|
run: function() {
|
||
|
|
this._width = this.$element.width();
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'width', 'items', 'settings' ],
|
||
|
|
run: function(cache) {
|
||
|
|
cache.current = this._items && this._items[this.relative(this._current)];
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'items', 'settings' ],
|
||
|
|
run: function() {
|
||
|
|
this.$stage.children('.cloned').remove();
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'width', 'items', 'settings' ],
|
||
|
|
run: function(cache) {
|
||
|
|
var margin = this.settings.margin || '',
|
||
|
|
grid = !this.settings.autoWidth,
|
||
|
|
rtl = this.settings.rtl,
|
||
|
|
css = {
|
||
|
|
'width': 'auto',
|
||
|
|
'margin-left': rtl ? margin : '',
|
||
|
|
'margin-right': rtl ? '' : margin
|
||
|
|
};
|
||
|
|
|
||
|
|
!grid && this.$stage.children().css(css);
|
||
|
|
|
||
|
|
cache.css = css;
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'width', 'items', 'settings' ],
|
||
|
|
run: function(cache) {
|
||
|
|
var width = (this.width() / this.settings.items).toFixed(3) - this.settings.margin,
|
||
|
|
merge = null,
|
||
|
|
iterator = this._items.length,
|
||
|
|
grid = !this.settings.autoWidth,
|
||
|
|
widths = [];
|
||
|
|
|
||
|
|
cache.items = {
|
||
|
|
merge: false,
|
||
|
|
width: width
|
||
|
|
};
|
||
|
|
|
||
|
|
while (iterator--) {
|
||
|
|
merge = this._mergers[iterator];
|
||
|
|
merge = this.settings.mergeFit && Math.min(merge, this.settings.items) || merge;
|
||
|
|
|
||
|
|
cache.items.merge = merge > 1 || cache.items.merge;
|
||
|
|
|
||
|
|
widths[iterator] = !grid ? this._items[iterator].width() : width * merge;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._widths = widths;
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'items', 'settings' ],
|
||
|
|
run: function() {
|
||
|
|
var clones = [],
|
||
|
|
items = this._items,
|
||
|
|
settings = this.settings,
|
||
|
|
// TODO: Should be computed from number of min width items in stage
|
||
|
|
view = Math.max(settings.items * 2, 4),
|
||
|
|
size = Math.ceil(items.length / 2) * 2,
|
||
|
|
repeat = settings.loop && items.length ? settings.rewind ? view : Math.max(view, size) : 0,
|
||
|
|
append = '',
|
||
|
|
prepend = '';
|
||
|
|
|
||
|
|
repeat /= 2;
|
||
|
|
|
||
|
|
while (repeat > 0) {
|
||
|
|
// Switch to only using appended clones
|
||
|
|
clones.push(this.normalize(clones.length / 2, true));
|
||
|
|
append = append + items[clones[clones.length - 1]][0].outerHTML;
|
||
|
|
clones.push(this.normalize(items.length - 1 - (clones.length - 1) / 2, true));
|
||
|
|
prepend = items[clones[clones.length - 1]][0].outerHTML + prepend;
|
||
|
|
repeat -= 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._clones = clones;
|
||
|
|
|
||
|
|
$(append).addClass('cloned').appendTo(this.$stage);
|
||
|
|
$(prepend).addClass('cloned').prependTo(this.$stage);
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'width', 'items', 'settings' ],
|
||
|
|
run: function() {
|
||
|
|
var rtl = this.settings.rtl ? 1 : -1,
|
||
|
|
size = this._clones.length + this._items.length,
|
||
|
|
iterator = -1,
|
||
|
|
previous = 0,
|
||
|
|
current = 0,
|
||
|
|
coordinates = [];
|
||
|
|
|
||
|
|
while (++iterator < size) {
|
||
|
|
previous = coordinates[iterator - 1] || 0;
|
||
|
|
current = this._widths[this.relative(iterator)] + this.settings.margin;
|
||
|
|
coordinates.push(previous + current * rtl);
|
||
|
|
}
|
||
|
|
|
||
|
|
this._coordinates = coordinates;
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'width', 'items', 'settings' ],
|
||
|
|
run: function() {
|
||
|
|
var padding = this.settings.stagePadding,
|
||
|
|
coordinates = this._coordinates,
|
||
|
|
css = {
|
||
|
|
'width': Math.ceil(Math.abs(coordinates[coordinates.length - 1])) + padding * 2,
|
||
|
|
'padding-left': padding || '',
|
||
|
|
'padding-right': padding || ''
|
||
|
|
};
|
||
|
|
|
||
|
|
this.$stage.css(css);
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'width', 'items', 'settings' ],
|
||
|
|
run: function(cache) {
|
||
|
|
var iterator = this._coordinates.length,
|
||
|
|
grid = !this.settings.autoWidth,
|
||
|
|
items = this.$stage.children();
|
||
|
|
|
||
|
|
if (grid && cache.items.merge) {
|
||
|
|
while (iterator--) {
|
||
|
|
cache.css.width = this._widths[this.relative(iterator)];
|
||
|
|
items.eq(iterator).css(cache.css);
|
||
|
|
}
|
||
|
|
} else if (grid) {
|
||
|
|
cache.css.width = cache.items.width;
|
||
|
|
items.css(cache.css);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'items' ],
|
||
|
|
run: function() {
|
||
|
|
this._coordinates.length < 1 && this.$stage.removeAttr('style');
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'width', 'items', 'settings' ],
|
||
|
|
run: function(cache) {
|
||
|
|
cache.current = cache.current ? this.$stage.children().index(cache.current) : 0;
|
||
|
|
cache.current = Math.max(this.minimum(), Math.min(this.maximum(), cache.current));
|
||
|
|
this.reset(cache.current);
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'position' ],
|
||
|
|
run: function() {
|
||
|
|
this.animate(this.coordinates(this._current));
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
filter: [ 'width', 'position', 'items', 'settings' ],
|
||
|
|
run: function() {
|
||
|
|
var rtl = this.settings.rtl ? 1 : -1,
|
||
|
|
padding = this.settings.stagePadding * 2,
|
||
|
|
begin = this.coordinates(this.current()) + padding,
|
||
|
|
end = begin + this.width() * rtl,
|
||
|
|
inner, outer, matches = [], i, n;
|
||
|
|
|
||
|
|
for (i = 0, n = this._coordinates.length; i < n; i++) {
|
||
|
|
inner = this._coordinates[i - 1] || 0;
|
||
|
|
outer = Math.abs(this._coordinates[i]) + padding * rtl;
|
||
|
|
|
||
|
|
if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end)))
|
||
|
|
|| (this.op(outer, '<', begin) && this.op(outer, '>', end))) {
|
||
|
|
matches.push(i);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.$stage.children('.active').removeClass('active');
|
||
|
|
this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass('active');
|
||
|
|
|
||
|
|
this.$stage.children('.center').removeClass('center');
|
||
|
|
if (this.settings.center) {
|
||
|
|
this.$stage.children().eq(this.current()).addClass('center');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} ];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create the stage DOM element
|
||
|
|
*/
|
||
|
|
Owl.prototype.initializeStage = function() {
|
||
|
|
this.$stage = this.$element.find('.' + this.settings.stageClass);
|
||
|
|
|
||
|
|
// if the stage is already in the DOM, grab it and skip stage initialization
|
||
|
|
if (this.$stage.length) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.$element.addClass(this.options.loadingClass);
|
||
|
|
|
||
|
|
// create stage
|
||
|
|
this.$stage = $('<' + this.settings.stageElement + '>', {
|
||
|
|
"class": this.settings.stageClass
|
||
|
|
}).wrap( $( '<div/>', {
|
||
|
|
"class": this.settings.stageOuterClass
|
||
|
|
}));
|
||
|
|
|
||
|
|
// append stage
|
||
|
|
this.$element.append(this.$stage.parent());
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create item DOM elements
|
||
|
|
*/
|
||
|
|
Owl.prototype.initializeItems = function() {
|
||
|
|
var $items = this.$element.find('.owl-item');
|
||
|
|
|
||
|
|
// if the items are already in the DOM, grab them and skip item initialization
|
||
|
|
if ($items.length) {
|
||
|
|
this._items = $items.get().map(function(item) {
|
||
|
|
return $(item);
|
||
|
|
});
|
||
|
|
|
||
|
|
this._mergers = this._items.map(function() {
|
||
|
|
return 1;
|
||
|
|
});
|
||
|
|
|
||
|
|
this.refresh();
|
||
|
|
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// append content
|
||
|
|
this.replace(this.$element.children().not(this.$stage.parent()));
|
||
|
|
|
||
|
|
// check visibility
|
||
|
|
if (this.isVisible()) {
|
||
|
|
// update view
|
||
|
|
this.refresh();
|
||
|
|
} else {
|
||
|
|
// invalidate width
|
||
|
|
this.invalidate('width');
|
||
|
|
}
|
||
|
|
|
||
|
|
this.$element
|
||
|
|
.removeClass(this.options.loadingClass)
|
||
|
|
.addClass(this.options.loadedClass);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Initializes the carousel.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Owl.prototype.initialize = function() {
|
||
|
|
this.enter('initializing');
|
||
|
|
this.trigger('initialize');
|
||
|
|
|
||
|
|
this.$element.toggleClass(this.settings.rtlClass, this.settings.rtl);
|
||
|
|
|
||
|
|
if (this.settings.autoWidth && !this.is('pre-loading')) {
|
||
|
|
var imgs, nestedSelector, width;
|
||
|
|
imgs = this.$element.find('img');
|
||
|
|
nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined;
|
||
|
|
width = this.$element.children(nestedSelector).width();
|
||
|
|
|
||
|
|
if (imgs.length && width <= 0) {
|
||
|
|
this.preloadAutoWidthImages(imgs);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.initializeStage();
|
||
|
|
this.initializeItems();
|
||
|
|
|
||
|
|
// register event handlers
|
||
|
|
this.registerEventHandlers();
|
||
|
|
|
||
|
|
this.leave('initializing');
|
||
|
|
this.trigger('initialized');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @returns {Boolean} visibility of $element
|
||
|
|
* if you know the carousel will always be visible you can set `checkVisibility` to `false` to
|
||
|
|
* prevent the expensive browser layout forced reflow the $element.is(':visible') does
|
||
|
|
*/
|
||
|
|
Owl.prototype.isVisible = function() {
|
||
|
|
return this.settings.checkVisibility
|
||
|
|
? this.$element.is(':visible')
|
||
|
|
: true;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Setups the current settings.
|
||
|
|
* @todo Remove responsive classes. Why should adaptive designs be brought into IE8?
|
||
|
|
* @todo Support for media queries by using `matchMedia` would be nice.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Owl.prototype.setup = function() {
|
||
|
|
var viewport = this.viewport(),
|
||
|
|
overwrites = this.options.responsive,
|
||
|
|
match = -1,
|
||
|
|
settings = null;
|
||
|
|
|
||
|
|
if (!overwrites) {
|
||
|
|
settings = $.extend({}, this.options);
|
||
|
|
} else {
|
||
|
|
$.each(overwrites, function(breakpoint) {
|
||
|
|
if (breakpoint <= viewport && breakpoint > match) {
|
||
|
|
match = Number(breakpoint);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
settings = $.extend({}, this.options, overwrites[match]);
|
||
|
|
if (typeof settings.stagePadding === 'function') {
|
||
|
|
settings.stagePadding = settings.stagePadding();
|
||
|
|
}
|
||
|
|
delete settings.responsive;
|
||
|
|
|
||
|
|
// responsive class
|
||
|
|
if (settings.responsiveClass) {
|
||
|
|
this.$element.attr('class',
|
||
|
|
this.$element.attr('class').replace(new RegExp('(' + this.options.responsiveClass + '-)\\S+\\s', 'g'), '$1' + match)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.trigger('change', { property: { name: 'settings', value: settings } });
|
||
|
|
this._breakpoint = match;
|
||
|
|
this.settings = settings;
|
||
|
|
this.invalidate('settings');
|
||
|
|
this.trigger('changed', { property: { name: 'settings', value: this.settings } });
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Updates option logic if necessery.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Owl.prototype.optionsLogic = function() {
|
||
|
|
if (this.settings.autoWidth) {
|
||
|
|
this.settings.stagePadding = false;
|
||
|
|
this.settings.merge = false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Prepares an item before add.
|
||
|
|
* @todo Rename event parameter `content` to `item`.
|
||
|
|
* @protected
|
||
|
|
* @returns {jQuery|HTMLElement} - The item container.
|
||
|
|
*/
|
||
|
|
Owl.prototype.prepare = function(item) {
|
||
|
|
var event = this.trigger('prepare', { content: item });
|
||
|
|
|
||
|
|
if (!event.data) {
|
||
|
|
event.data = $('<' + this.settings.itemElement + '/>')
|
||
|
|
.addClass(this.options.itemClass).append(item)
|
||
|
|
}
|
||
|
|
|
||
|
|
this.trigger('prepared', { content: event.data });
|
||
|
|
|
||
|
|
return event.data;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Updates the view.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Owl.prototype.update = function() {
|
||
|
|
var i = 0,
|
||
|
|
n = this._pipe.length,
|
||
|
|
filter = $.proxy(function(p) { return this[p] }, this._invalidated),
|
||
|
|
cache = {};
|
||
|
|
|
||
|
|
while (i < n) {
|
||
|
|
if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) {
|
||
|
|
this._pipe[i].run(cache);
|
||
|
|
}
|
||
|
|
i++;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._invalidated = {};
|
||
|
|
|
||
|
|
!this.is('valid') && this.enter('valid');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the width of the view.
|
||
|
|
* @public
|
||
|
|
* @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return.
|
||
|
|
* @returns {Number} - The width of the view in pixel.
|
||
|
|
*/
|
||
|
|
Owl.prototype.width = function(dimension) {
|
||
|
|
dimension = dimension || Owl.Width.Default;
|
||
|
|
switch (dimension) {
|
||
|
|
case Owl.Width.Inner:
|
||
|
|
case Owl.Width.Outer:
|
||
|
|
return this._width;
|
||
|
|
default:
|
||
|
|
return this._width - this.settings.stagePadding * 2 + this.settings.margin;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Refreshes the carousel primarily for adaptive purposes.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Owl.prototype.refresh = function() {
|
||
|
|
this.enter('refreshing');
|
||
|
|
this.trigger('refresh');
|
||
|
|
|
||
|
|
this.setup();
|
||
|
|
|
||
|
|
this.optionsLogic();
|
||
|
|
|
||
|
|
this.$element.addClass(this.options.refreshClass);
|
||
|
|
|
||
|
|
this.update();
|
||
|
|
|
||
|
|
this.$element.removeClass(this.options.refreshClass);
|
||
|
|
|
||
|
|
this.leave('refreshing');
|
||
|
|
this.trigger('refreshed');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Checks window `resize` event.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Owl.prototype.onThrottledResize = function() {
|
||
|
|
window.clearTimeout(this.resizeTimer);
|
||
|
|
this.resizeTimer = window.setTimeout(this._handlers.onResize, this.settings.responsiveRefreshRate);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Checks window `resize` event.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Owl.prototype.onResize = function() {
|
||
|
|
if (!this._items.length) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this._width === this.$element.width()) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!this.isVisible()) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.enter('resizing');
|
||
|
|
|
||
|
|
if (this.trigger('resize').isDefaultPrevented()) {
|
||
|
|
this.leave('resizing');
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.invalidate('width');
|
||
|
|
|
||
|
|
this.refresh();
|
||
|
|
|
||
|
|
this.leave('resizing');
|
||
|
|
this.trigger('resized');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Registers event handlers.
|
||
|
|
* @todo Check `msPointerEnabled`
|
||
|
|
* @todo #261
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Owl.prototype.registerEventHandlers = function() {
|
||
|
|
if ($.support.transition) {
|
||
|
|
this.$stage.on($.support.transition.end + '.owl.core', $.proxy(this.onTransitionEnd, this));
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.settings.responsive !== false) {
|
||
|
|
this.on(window, 'resize', this._handlers.onThrottledResize);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.settings.mouseDrag) {
|
||
|
|
this.$element.addClass(this.options.dragClass);
|
||
|
|
this.$stage.on('mousedown.owl.core', $.proxy(this.onDragStart, this));
|
||
|
|
this.$stage.on('dragstart.owl.core selectstart.owl.core', function() { return false });
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.settings.touchDrag){
|
||
|
|
this.$stage.on('touchstart.owl.core', $.proxy(this.onDragStart, this));
|
||
|
|
this.$stage.on('touchcancel.owl.core', $.proxy(this.onDragEnd, this));
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Handles `touchstart` and `mousedown` events.
|
||
|
|
* @todo Horizontal swipe threshold as option
|
||
|
|
* @todo #261
|
||
|
|
* @protected
|
||
|
|
* @param {Event} event - The event arguments.
|
||
|
|
*/
|
||
|
|
Owl.prototype.onDragStart = function(event) {
|
||
|
|
var stage = null;
|
||
|
|
|
||
|
|
if (event.which === 3) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($.support.transform) {
|
||
|
|
stage = this.$stage.css('transform').replace(/.*\(|\)| /g, '').split(',');
|
||
|
|
stage = {
|
||
|
|
x: stage[stage.length === 16 ? 12 : 4],
|
||
|
|
y: stage[stage.length === 16 ? 13 : 5]
|
||
|
|
};
|
||
|
|
} else {
|
||
|
|
stage = this.$stage.position();
|
||
|
|
stage = {
|
||
|
|
x: this.settings.rtl ?
|
||
|
|
stage.left + this.$stage.width() - this.width() + this.settings.margin :
|
||
|
|
stage.left,
|
||
|
|
y: stage.top
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.is('animating')) {
|
||
|
|
$.support.transform ? this.animate(stage.x) : this.$stage.stop()
|
||
|
|
this.invalidate('position');
|
||
|
|
}
|
||
|
|
|
||
|
|
this.$element.toggleClass(this.options.grabClass, event.type === 'mousedown');
|
||
|
|
|
||
|
|
this.speed(0);
|
||
|
|
|
||
|
|
this._drag.time = new Date().getTime();
|
||
|
|
this._drag.target = $(event.target);
|
||
|
|
this._drag.stage.start = stage;
|
||
|
|
this._drag.stage.current = stage;
|
||
|
|
this._drag.pointer = this.pointer(event);
|
||
|
|
|
||
|
|
$(document).on('mouseup.owl.core touchend.owl.core', $.proxy(this.onDragEnd, this));
|
||
|
|
|
||
|
|
$(document).one('mousemove.owl.core touchmove.owl.core', $.proxy(function(event) {
|
||
|
|
var delta = this.difference(this._drag.pointer, this.pointer(event));
|
||
|
|
|
||
|
|
$(document).on('mousemove.owl.core touchmove.owl.core', $.proxy(this.onDragMove, this));
|
||
|
|
|
||
|
|
if (Math.abs(delta.x) < Math.abs(delta.y) && this.is('valid')) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
event.preventDefault();
|
||
|
|
|
||
|
|
this.enter('dragging');
|
||
|
|
this.trigger('drag');
|
||
|
|
}, this));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Handles the `touchmove` and `mousemove` events.
|
||
|
|
* @todo #261
|
||
|
|
* @protected
|
||
|
|
* @param {Event} event - The event arguments.
|
||
|
|
*/
|
||
|
|
Owl.prototype.onDragMove = function(event) {
|
||
|
|
var minimum = null,
|
||
|
|
maximum = null,
|
||
|
|
pull = null,
|
||
|
|
delta = this.difference(this._drag.pointer, this.pointer(event)),
|
||
|
|
stage = this.difference(this._drag.stage.start, delta);
|
||
|
|
|
||
|
|
if (!this.is('dragging')) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
event.preventDefault();
|
||
|
|
|
||
|
|
if (this.settings.loop) {
|
||
|
|
minimum = this.coordinates(this.minimum());
|
||
|
|
maximum = this.coordinates(this.maximum() + 1) - minimum;
|
||
|
|
stage.x = (((stage.x - minimum) % maximum + maximum) % maximum) + minimum;
|
||
|
|
} else {
|
||
|
|
minimum = this.settings.rtl ? this.coordinates(this.maximum()) : this.coordinates(this.minimum());
|
||
|
|
maximum = this.settings.rtl ? this.coordinates(this.minimum()) : this.coordinates(this.maximum());
|
||
|
|
pull = this.settings.pullDrag ? -1 * delta.x / 5 : 0;
|
||
|
|
stage.x = Math.max(Math.min(stage.x, minimum + pull), maximum + pull);
|
||
|
|
}
|
||
|
|
|
||
|
|
this._drag.stage.current = stage;
|
||
|
|
|
||
|
|
this.animate(stage.x);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Handles the `touchend` and `mouseup` events.
|
||
|
|
* @todo #261
|
||
|
|
* @todo Threshold for click event
|
||
|
|
* @protected
|
||
|
|
* @param {Event} event - The event arguments.
|
||
|
|
*/
|
||
|
|
Owl.prototype.onDragEnd = function(event) {
|
||
|
|
var delta = this.difference(this._drag.pointer, this.pointer(event)),
|
||
|
|
stage = this._drag.stage.current,
|
||
|
|
direction = delta.x > 0 ^ this.settings.rtl ? 'left' : 'right';
|
||
|
|
|
||
|
|
$(document).off('.owl.core');
|
||
|
|
|
||
|
|
this.$element.removeClass(this.options.grabClass);
|
||
|
|
|
||
|
|
if (delta.x !== 0 && this.is('dragging') || !this.is('valid')) {
|
||
|
|
this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed);
|
||
|
|
this.current(this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction));
|
||
|
|
this.invalidate('position');
|
||
|
|
this.update();
|
||
|
|
|
||
|
|
this._drag.direction = direction;
|
||
|
|
|
||
|
|
if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) {
|
||
|
|
this._drag.target.one('click.owl.core', function() { return false; });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!this.is('dragging')) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.leave('dragging');
|
||
|
|
this.trigger('dragged');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets absolute position of the closest item for a coordinate.
|
||
|
|
* @todo Setting `freeDrag` makes `closest` not reusable. See #165.
|
||
|
|
* @protected
|
||
|
|
* @param {Number} coordinate - The coordinate in pixel.
|
||
|
|
* @param {String} direction - The direction to check for the closest item. Ether `left` or `right`.
|
||
|
|
* @return {Number} - The absolute position of the closest item.
|
||
|
|
*/
|
||
|
|
Owl.prototype.closest = function(coordinate, direction) {
|
||
|
|
var position = -1,
|
||
|
|
pull = 30,
|
||
|
|
width = this.width(),
|
||
|
|
coordinates = this.coordinates();
|
||
|
|
|
||
|
|
if (!this.settings.freeDrag) {
|
||
|
|
// check closest item
|
||
|
|
$.each(coordinates, $.proxy(function(index, value) {
|
||
|
|
// on a left pull, check on current index
|
||
|
|
if (direction === 'left' && coordinate > value - pull && coordinate < value + pull) {
|
||
|
|
position = index;
|
||
|
|
// on a right pull, check on previous index
|
||
|
|
// to do so, subtract width from value and set position = index + 1
|
||
|
|
} else if (direction === 'right' && coordinate > value - width - pull && coordinate < value - width + pull) {
|
||
|
|
position = index + 1;
|
||
|
|
} else if (this.op(coordinate, '<', value)
|
||
|
|
&& this.op(coordinate, '>', coordinates[index + 1] !== undefined ? coordinates[index + 1] : value - width)) {
|
||
|
|
position = direction === 'left' ? index + 1 : index;
|
||
|
|
}
|
||
|
|
return position === -1;
|
||
|
|
}, this));
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!this.settings.loop) {
|
||
|
|
// non loop boundries
|
||
|
|
if (this.op(coordinate, '>', coordinates[this.minimum()])) {
|
||
|
|
position = coordinate = this.minimum();
|
||
|
|
} else if (this.op(coordinate, '<', coordinates[this.maximum()])) {
|
||
|
|
position = coordinate = this.maximum();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return position;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Animates the stage.
|
||
|
|
* @todo #270
|
||
|
|
* @public
|
||
|
|
* @param {Number} coordinate - The coordinate in pixels.
|
||
|
|
*/
|
||
|
|
Owl.prototype.animate = function(coordinate) {
|
||
|
|
var animate = this.speed() > 0;
|
||
|
|
|
||
|
|
this.is('animating') && this.onTransitionEnd();
|
||
|
|
|
||
|
|
if (animate) {
|
||
|
|
this.enter('animating');
|
||
|
|
this.trigger('translate');
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($.support.transform3d && $.support.transition) {
|
||
|
|
this.$stage.css({
|
||
|
|
transform: 'translate3d(' + coordinate + 'px,0px,0px)',
|
||
|
|
transition: (this.speed() / 1000) + 's' + (
|
||
|
|
this.settings.slideTransition ? ' ' + this.settings.slideTransition : ''
|
||
|
|
)
|
||
|
|
});
|
||
|
|
} else if (animate) {
|
||
|
|
this.$stage.animate({
|
||
|
|
left: coordinate + 'px'
|
||
|
|
}, this.speed(), this.settings.fallbackEasing, $.proxy(this.onTransitionEnd, this));
|
||
|
|
} else {
|
||
|
|
this.$stage.css({
|
||
|
|
left: coordinate + 'px'
|
||
|
|
});
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Checks whether the carousel is in a specific state or not.
|
||
|
|
* @param {String} state - The state to check.
|
||
|
|
* @returns {Boolean} - The flag which indicates if the carousel is busy.
|
||
|
|
*/
|
||
|
|
Owl.prototype.is = function(state) {
|
||
|
|
return this._states.current[state] && this._states.current[state] > 0;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Sets the absolute position of the current item.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [position] - The new absolute position or nothing to leave it unchanged.
|
||
|
|
* @returns {Number} - The absolute position of the current item.
|
||
|
|
*/
|
||
|
|
Owl.prototype.current = function(position) {
|
||
|
|
if (position === undefined) {
|
||
|
|
return this._current;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this._items.length === 0) {
|
||
|
|
return undefined;
|
||
|
|
}
|
||
|
|
|
||
|
|
position = this.normalize(position);
|
||
|
|
|
||
|
|
if (this._current !== position) {
|
||
|
|
var event = this.trigger('change', { property: { name: 'position', value: position } });
|
||
|
|
|
||
|
|
if (event.data !== undefined) {
|
||
|
|
position = this.normalize(event.data);
|
||
|
|
}
|
||
|
|
|
||
|
|
this._current = position;
|
||
|
|
|
||
|
|
this.invalidate('position');
|
||
|
|
|
||
|
|
this.trigger('changed', { property: { name: 'position', value: this._current } });
|
||
|
|
}
|
||
|
|
|
||
|
|
return this._current;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Invalidates the given part of the update routine.
|
||
|
|
* @param {String} [part] - The part to invalidate.
|
||
|
|
* @returns {Array.<String>} - The invalidated parts.
|
||
|
|
*/
|
||
|
|
Owl.prototype.invalidate = function(part) {
|
||
|
|
if ($.type(part) === 'string') {
|
||
|
|
this._invalidated[part] = true;
|
||
|
|
this.is('valid') && this.leave('valid');
|
||
|
|
}
|
||
|
|
return $.map(this._invalidated, function(v, i) { return i });
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Resets the absolute position of the current item.
|
||
|
|
* @public
|
||
|
|
* @param {Number} position - The absolute position of the new item.
|
||
|
|
*/
|
||
|
|
Owl.prototype.reset = function(position) {
|
||
|
|
position = this.normalize(position);
|
||
|
|
|
||
|
|
if (position === undefined) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._speed = 0;
|
||
|
|
this._current = position;
|
||
|
|
|
||
|
|
this.suppress([ 'translate', 'translated' ]);
|
||
|
|
|
||
|
|
this.animate(this.coordinates(position));
|
||
|
|
|
||
|
|
this.release([ 'translate', 'translated' ]);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Normalizes an absolute or a relative position of an item.
|
||
|
|
* @public
|
||
|
|
* @param {Number} position - The absolute or relative position to normalize.
|
||
|
|
* @param {Boolean} [relative=false] - Whether the given position is relative or not.
|
||
|
|
* @returns {Number} - The normalized position.
|
||
|
|
*/
|
||
|
|
Owl.prototype.normalize = function(position, relative) {
|
||
|
|
var n = this._items.length,
|
||
|
|
m = relative ? 0 : this._clones.length;
|
||
|
|
|
||
|
|
if (!this.isNumeric(position) || n < 1) {
|
||
|
|
position = undefined;
|
||
|
|
} else if (position < 0 || position >= n + m) {
|
||
|
|
position = ((position - m / 2) % n + n) % n + m / 2;
|
||
|
|
}
|
||
|
|
|
||
|
|
return position;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Converts an absolute position of an item into a relative one.
|
||
|
|
* @public
|
||
|
|
* @param {Number} position - The absolute position to convert.
|
||
|
|
* @returns {Number} - The converted position.
|
||
|
|
*/
|
||
|
|
Owl.prototype.relative = function(position) {
|
||
|
|
position -= this._clones.length / 2;
|
||
|
|
return this.normalize(position, true);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the maximum position for the current item.
|
||
|
|
* @public
|
||
|
|
* @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
|
||
|
|
* @returns {Number}
|
||
|
|
*/
|
||
|
|
Owl.prototype.maximum = function(relative) {
|
||
|
|
var settings = this.settings,
|
||
|
|
maximum = this._coordinates.length,
|
||
|
|
iterator,
|
||
|
|
reciprocalItemsWidth,
|
||
|
|
elementWidth;
|
||
|
|
|
||
|
|
if (settings.loop) {
|
||
|
|
maximum = this._clones.length / 2 + this._items.length - 1;
|
||
|
|
} else if (settings.autoWidth || settings.merge) {
|
||
|
|
iterator = this._items.length;
|
||
|
|
if (iterator) {
|
||
|
|
reciprocalItemsWidth = this._items[--iterator].width();
|
||
|
|
elementWidth = this.$element.width();
|
||
|
|
while (iterator--) {
|
||
|
|
reciprocalItemsWidth += this._items[iterator].width() + this.settings.margin;
|
||
|
|
if (reciprocalItemsWidth > elementWidth) {
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
maximum = iterator + 1;
|
||
|
|
} else if (settings.center) {
|
||
|
|
maximum = this._items.length - 1;
|
||
|
|
} else {
|
||
|
|
maximum = this._items.length - settings.items;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (relative) {
|
||
|
|
maximum -= this._clones.length / 2;
|
||
|
|
}
|
||
|
|
|
||
|
|
return Math.max(maximum, 0);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the minimum position for the current item.
|
||
|
|
* @public
|
||
|
|
* @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
|
||
|
|
* @returns {Number}
|
||
|
|
*/
|
||
|
|
Owl.prototype.minimum = function(relative) {
|
||
|
|
return relative ? 0 : this._clones.length / 2;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets an item at the specified relative position.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [position] - The relative position of the item.
|
||
|
|
* @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
|
||
|
|
*/
|
||
|
|
Owl.prototype.items = function(position) {
|
||
|
|
if (position === undefined) {
|
||
|
|
return this._items.slice();
|
||
|
|
}
|
||
|
|
|
||
|
|
position = this.normalize(position, true);
|
||
|
|
return this._items[position];
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets an item at the specified relative position.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [position] - The relative position of the item.
|
||
|
|
* @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
|
||
|
|
*/
|
||
|
|
Owl.prototype.mergers = function(position) {
|
||
|
|
if (position === undefined) {
|
||
|
|
return this._mergers.slice();
|
||
|
|
}
|
||
|
|
|
||
|
|
position = this.normalize(position, true);
|
||
|
|
return this._mergers[position];
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the absolute positions of clones for an item.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [position] - The relative position of the item.
|
||
|
|
* @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given.
|
||
|
|
*/
|
||
|
|
Owl.prototype.clones = function(position) {
|
||
|
|
var odd = this._clones.length / 2,
|
||
|
|
even = odd + this._items.length,
|
||
|
|
map = function(index) { return index % 2 === 0 ? even + index / 2 : odd - (index + 1) / 2 };
|
||
|
|
|
||
|
|
if (position === undefined) {
|
||
|
|
return $.map(this._clones, function(v, i) { return map(i) });
|
||
|
|
}
|
||
|
|
|
||
|
|
return $.map(this._clones, function(v, i) { return v === position ? map(i) : null });
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Sets the current animation speed.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged.
|
||
|
|
* @returns {Number} - The current animation speed in milliseconds.
|
||
|
|
*/
|
||
|
|
Owl.prototype.speed = function(speed) {
|
||
|
|
if (speed !== undefined) {
|
||
|
|
this._speed = speed;
|
||
|
|
}
|
||
|
|
|
||
|
|
return this._speed;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the coordinate of an item.
|
||
|
|
* @todo The name of this method is missleanding.
|
||
|
|
* @public
|
||
|
|
* @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`.
|
||
|
|
* @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates.
|
||
|
|
*/
|
||
|
|
Owl.prototype.coordinates = function(position) {
|
||
|
|
var multiplier = 1,
|
||
|
|
newPosition = position - 1,
|
||
|
|
coordinate;
|
||
|
|
|
||
|
|
if (position === undefined) {
|
||
|
|
return $.map(this._coordinates, $.proxy(function(coordinate, index) {
|
||
|
|
return this.coordinates(index);
|
||
|
|
}, this));
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.settings.center) {
|
||
|
|
if (this.settings.rtl) {
|
||
|
|
multiplier = -1;
|
||
|
|
newPosition = position + 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
coordinate = this._coordinates[position];
|
||
|
|
coordinate += (this.width() - coordinate + (this._coordinates[newPosition] || 0)) / 2 * multiplier;
|
||
|
|
} else {
|
||
|
|
coordinate = this._coordinates[newPosition] || 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
coordinate = Math.ceil(coordinate);
|
||
|
|
|
||
|
|
return coordinate;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Calculates the speed for a translation.
|
||
|
|
* @protected
|
||
|
|
* @param {Number} from - The absolute position of the start item.
|
||
|
|
* @param {Number} to - The absolute position of the target item.
|
||
|
|
* @param {Number} [factor=undefined] - The time factor in milliseconds.
|
||
|
|
* @returns {Number} - The time in milliseconds for the translation.
|
||
|
|
*/
|
||
|
|
Owl.prototype.duration = function(from, to, factor) {
|
||
|
|
if (factor === 0) {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Slides to the specified item.
|
||
|
|
* @public
|
||
|
|
* @param {Number} position - The position of the item.
|
||
|
|
* @param {Number} [speed] - The time in milliseconds for the transition.
|
||
|
|
*/
|
||
|
|
Owl.prototype.to = function(position, speed) {
|
||
|
|
var current = this.current(),
|
||
|
|
revert = null,
|
||
|
|
distance = position - this.relative(current),
|
||
|
|
direction = (distance > 0) - (distance < 0),
|
||
|
|
items = this._items.length,
|
||
|
|
minimum = this.minimum(),
|
||
|
|
maximum = this.maximum();
|
||
|
|
|
||
|
|
if (this.settings.loop) {
|
||
|
|
if (!this.settings.rewind && Math.abs(distance) > items / 2) {
|
||
|
|
distance += direction * -1 * items;
|
||
|
|
}
|
||
|
|
|
||
|
|
position = current + distance;
|
||
|
|
revert = ((position - minimum) % items + items) % items + minimum;
|
||
|
|
|
||
|
|
if (revert !== position && revert - distance <= maximum && revert - distance > 0) {
|
||
|
|
current = revert - distance;
|
||
|
|
position = revert;
|
||
|
|
this.reset(current);
|
||
|
|
}
|
||
|
|
} else if (this.settings.rewind) {
|
||
|
|
maximum += 1;
|
||
|
|
position = (position % maximum + maximum) % maximum;
|
||
|
|
} else {
|
||
|
|
position = Math.max(minimum, Math.min(maximum, position));
|
||
|
|
}
|
||
|
|
|
||
|
|
this.speed(this.duration(current, position, speed));
|
||
|
|
this.current(position);
|
||
|
|
|
||
|
|
if (this.isVisible()) {
|
||
|
|
this.update();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Slides to the next item.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [speed] - The time in milliseconds for the transition.
|
||
|
|
*/
|
||
|
|
Owl.prototype.next = function(speed) {
|
||
|
|
speed = speed || false;
|
||
|
|
this.to(this.relative(this.current()) + 1, speed);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Slides to the previous item.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [speed] - The time in milliseconds for the transition.
|
||
|
|
*/
|
||
|
|
Owl.prototype.prev = function(speed) {
|
||
|
|
speed = speed || false;
|
||
|
|
this.to(this.relative(this.current()) - 1, speed);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Handles the end of an animation.
|
||
|
|
* @protected
|
||
|
|
* @param {Event} event - The event arguments.
|
||
|
|
*/
|
||
|
|
Owl.prototype.onTransitionEnd = function(event) {
|
||
|
|
|
||
|
|
// if css2 animation then event object is undefined
|
||
|
|
if (event !== undefined) {
|
||
|
|
event.stopPropagation();
|
||
|
|
|
||
|
|
// Catch only owl-stage transitionEnd event
|
||
|
|
if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.leave('animating');
|
||
|
|
this.trigger('translated');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets viewport width.
|
||
|
|
* @protected
|
||
|
|
* @return {Number} - The width in pixel.
|
||
|
|
*/
|
||
|
|
Owl.prototype.viewport = function() {
|
||
|
|
var width;
|
||
|
|
if (this.options.responsiveBaseElement !== window) {
|
||
|
|
width = $(this.options.responsiveBaseElement).width();
|
||
|
|
} else if (window.innerWidth) {
|
||
|
|
width = window.innerWidth;
|
||
|
|
} else if (document.documentElement && document.documentElement.clientWidth) {
|
||
|
|
width = document.documentElement.clientWidth;
|
||
|
|
} else {
|
||
|
|
console.warn('Can not detect viewport width.');
|
||
|
|
}
|
||
|
|
return width;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Replaces the current content.
|
||
|
|
* @public
|
||
|
|
* @param {HTMLElement|jQuery|String} content - The new content.
|
||
|
|
*/
|
||
|
|
Owl.prototype.replace = function(content) {
|
||
|
|
this.$stage.empty();
|
||
|
|
this._items = [];
|
||
|
|
|
||
|
|
if (content) {
|
||
|
|
content = (content instanceof jQuery) ? content : $(content);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.settings.nestedItemSelector) {
|
||
|
|
content = content.find('.' + this.settings.nestedItemSelector);
|
||
|
|
}
|
||
|
|
|
||
|
|
content.filter(function() {
|
||
|
|
return this.nodeType === 1;
|
||
|
|
}).each($.proxy(function(index, item) {
|
||
|
|
item = this.prepare(item);
|
||
|
|
this.$stage.append(item);
|
||
|
|
this._items.push(item);
|
||
|
|
this._mergers.push(item.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
|
||
|
|
}, this));
|
||
|
|
|
||
|
|
this.reset(this.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0);
|
||
|
|
|
||
|
|
this.invalidate('items');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Adds an item.
|
||
|
|
* @todo Use `item` instead of `content` for the event arguments.
|
||
|
|
* @public
|
||
|
|
* @param {HTMLElement|jQuery|String} content - The item content to add.
|
||
|
|
* @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end.
|
||
|
|
*/
|
||
|
|
Owl.prototype.add = function(content, position) {
|
||
|
|
var current = this.relative(this._current);
|
||
|
|
|
||
|
|
position = position === undefined ? this._items.length : this.normalize(position, true);
|
||
|
|
content = content instanceof jQuery ? content : $(content);
|
||
|
|
|
||
|
|
this.trigger('add', { content: content, position: position });
|
||
|
|
|
||
|
|
content = this.prepare(content);
|
||
|
|
|
||
|
|
if (this._items.length === 0 || position === this._items.length) {
|
||
|
|
this._items.length === 0 && this.$stage.append(content);
|
||
|
|
this._items.length !== 0 && this._items[position - 1].after(content);
|
||
|
|
this._items.push(content);
|
||
|
|
this._mergers.push(content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
|
||
|
|
} else {
|
||
|
|
this._items[position].before(content);
|
||
|
|
this._items.splice(position, 0, content);
|
||
|
|
this._mergers.splice(position, 0, content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
this._items[current] && this.reset(this._items[current].index());
|
||
|
|
|
||
|
|
this.invalidate('items');
|
||
|
|
|
||
|
|
this.trigger('added', { content: content, position: position });
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Removes an item by its position.
|
||
|
|
* @todo Use `item` instead of `content` for the event arguments.
|
||
|
|
* @public
|
||
|
|
* @param {Number} position - The relative position of the item to remove.
|
||
|
|
*/
|
||
|
|
Owl.prototype.remove = function(position) {
|
||
|
|
position = this.normalize(position, true);
|
||
|
|
|
||
|
|
if (position === undefined) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.trigger('remove', { content: this._items[position], position: position });
|
||
|
|
|
||
|
|
this._items[position].remove();
|
||
|
|
this._items.splice(position, 1);
|
||
|
|
this._mergers.splice(position, 1);
|
||
|
|
|
||
|
|
this.invalidate('items');
|
||
|
|
|
||
|
|
this.trigger('removed', { content: null, position: position });
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Preloads images with auto width.
|
||
|
|
* @todo Replace by a more generic approach
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Owl.prototype.preloadAutoWidthImages = function(images) {
|
||
|
|
images.each($.proxy(function(i, element) {
|
||
|
|
this.enter('pre-loading');
|
||
|
|
element = $(element);
|
||
|
|
$(new Image()).one('load', $.proxy(function(e) {
|
||
|
|
element.attr('src', e.target.src);
|
||
|
|
element.css('opacity', 1);
|
||
|
|
this.leave('pre-loading');
|
||
|
|
!this.is('pre-loading') && !this.is('initializing') && this.refresh();
|
||
|
|
}, this)).attr('src', element.attr('src') || element.attr('data-src') || element.attr('data-src-retina'));
|
||
|
|
}, this));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys the carousel.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Owl.prototype.destroy = function() {
|
||
|
|
|
||
|
|
this.$element.off('.owl.core');
|
||
|
|
this.$stage.off('.owl.core');
|
||
|
|
$(document).off('.owl.core');
|
||
|
|
|
||
|
|
if (this.settings.responsive !== false) {
|
||
|
|
window.clearTimeout(this.resizeTimer);
|
||
|
|
this.off(window, 'resize', this._handlers.onThrottledResize);
|
||
|
|
}
|
||
|
|
|
||
|
|
for (var i in this._plugins) {
|
||
|
|
this._plugins[i].destroy();
|
||
|
|
}
|
||
|
|
|
||
|
|
this.$stage.children('.cloned').remove();
|
||
|
|
|
||
|
|
this.$stage.unwrap();
|
||
|
|
this.$stage.children().contents().unwrap();
|
||
|
|
this.$stage.children().unwrap();
|
||
|
|
this.$stage.remove();
|
||
|
|
this.$element
|
||
|
|
.removeClass(this.options.refreshClass)
|
||
|
|
.removeClass(this.options.loadingClass)
|
||
|
|
.removeClass(this.options.loadedClass)
|
||
|
|
.removeClass(this.options.rtlClass)
|
||
|
|
.removeClass(this.options.dragClass)
|
||
|
|
.removeClass(this.options.grabClass)
|
||
|
|
.attr('class', this.$element.attr('class').replace(new RegExp(this.options.responsiveClass + '-\\S+\\s', 'g'), ''))
|
||
|
|
.removeData('owl.carousel');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Operators to calculate right-to-left and left-to-right.
|
||
|
|
* @protected
|
||
|
|
* @param {Number} [a] - The left side operand.
|
||
|
|
* @param {String} [o] - The operator.
|
||
|
|
* @param {Number} [b] - The right side operand.
|
||
|
|
*/
|
||
|
|
Owl.prototype.op = function(a, o, b) {
|
||
|
|
var rtl = this.settings.rtl;
|
||
|
|
switch (o) {
|
||
|
|
case '<':
|
||
|
|
return rtl ? a > b : a < b;
|
||
|
|
case '>':
|
||
|
|
return rtl ? a < b : a > b;
|
||
|
|
case '>=':
|
||
|
|
return rtl ? a <= b : a >= b;
|
||
|
|
case '<=':
|
||
|
|
return rtl ? a >= b : a <= b;
|
||
|
|
default:
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Attaches to an internal event.
|
||
|
|
* @protected
|
||
|
|
* @param {HTMLElement} element - The event source.
|
||
|
|
* @param {String} event - The event name.
|
||
|
|
* @param {Function} listener - The event handler to attach.
|
||
|
|
* @param {Boolean} capture - Wether the event should be handled at the capturing phase or not.
|
||
|
|
*/
|
||
|
|
Owl.prototype.on = function(element, event, listener, capture) {
|
||
|
|
if (element.addEventListener) {
|
||
|
|
element.addEventListener(event, listener, capture);
|
||
|
|
} else if (element.attachEvent) {
|
||
|
|
element.attachEvent('on' + event, listener);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Detaches from an internal event.
|
||
|
|
* @protected
|
||
|
|
* @param {HTMLElement} element - The event source.
|
||
|
|
* @param {String} event - The event name.
|
||
|
|
* @param {Function} listener - The attached event handler to detach.
|
||
|
|
* @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not.
|
||
|
|
*/
|
||
|
|
Owl.prototype.off = function(element, event, listener, capture) {
|
||
|
|
if (element.removeEventListener) {
|
||
|
|
element.removeEventListener(event, listener, capture);
|
||
|
|
} else if (element.detachEvent) {
|
||
|
|
element.detachEvent('on' + event, listener);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Triggers a public event.
|
||
|
|
* @todo Remove `status`, `relatedTarget` should be used instead.
|
||
|
|
* @protected
|
||
|
|
* @param {String} name - The event name.
|
||
|
|
* @param {*} [data=null] - The event data.
|
||
|
|
* @param {String} [namespace=carousel] - The event namespace.
|
||
|
|
* @param {String} [state] - The state which is associated with the event.
|
||
|
|
* @param {Boolean} [enter=false] - Indicates if the call enters the specified state or not.
|
||
|
|
* @returns {Event} - The event arguments.
|
||
|
|
*/
|
||
|
|
Owl.prototype.trigger = function(name, data, namespace, state, enter) {
|
||
|
|
var status = {
|
||
|
|
item: { count: this._items.length, index: this.current() }
|
||
|
|
}, handler = $.camelCase(
|
||
|
|
$.grep([ 'on', name, namespace ], function(v) { return v })
|
||
|
|
.join('-').toLowerCase()
|
||
|
|
), event = $.Event(
|
||
|
|
[ name, 'owl', namespace || 'carousel' ].join('.').toLowerCase(),
|
||
|
|
$.extend({ relatedTarget: this }, status, data)
|
||
|
|
);
|
||
|
|
|
||
|
|
if (!this._supress[name]) {
|
||
|
|
$.each(this._plugins, function(name, plugin) {
|
||
|
|
if (plugin.onTrigger) {
|
||
|
|
plugin.onTrigger(event);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
this.register({ type: Owl.Type.Event, name: name });
|
||
|
|
this.$element.trigger(event);
|
||
|
|
|
||
|
|
if (this.settings && typeof this.settings[handler] === 'function') {
|
||
|
|
this.settings[handler].call(this, event);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return event;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Enters a state.
|
||
|
|
* @param name - The state name.
|
||
|
|
*/
|
||
|
|
Owl.prototype.enter = function(name) {
|
||
|
|
$.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) {
|
||
|
|
if (this._states.current[name] === undefined) {
|
||
|
|
this._states.current[name] = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._states.current[name]++;
|
||
|
|
}, this));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Leaves a state.
|
||
|
|
* @param name - The state name.
|
||
|
|
*/
|
||
|
|
Owl.prototype.leave = function(name) {
|
||
|
|
$.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) {
|
||
|
|
this._states.current[name]--;
|
||
|
|
}, this));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Registers an event or state.
|
||
|
|
* @public
|
||
|
|
* @param {Object} object - The event or state to register.
|
||
|
|
*/
|
||
|
|
Owl.prototype.register = function(object) {
|
||
|
|
if (object.type === Owl.Type.Event) {
|
||
|
|
if (!$.event.special[object.name]) {
|
||
|
|
$.event.special[object.name] = {};
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!$.event.special[object.name].owl) {
|
||
|
|
var _default = $.event.special[object.name]._default;
|
||
|
|
$.event.special[object.name]._default = function(e) {
|
||
|
|
if (_default && _default.apply && (!e.namespace || e.namespace.indexOf('owl') === -1)) {
|
||
|
|
return _default.apply(this, arguments);
|
||
|
|
}
|
||
|
|
return e.namespace && e.namespace.indexOf('owl') > -1;
|
||
|
|
};
|
||
|
|
$.event.special[object.name].owl = true;
|
||
|
|
}
|
||
|
|
} else if (object.type === Owl.Type.State) {
|
||
|
|
if (!this._states.tags[object.name]) {
|
||
|
|
this._states.tags[object.name] = object.tags;
|
||
|
|
} else {
|
||
|
|
this._states.tags[object.name] = this._states.tags[object.name].concat(object.tags);
|
||
|
|
}
|
||
|
|
|
||
|
|
this._states.tags[object.name] = $.grep(this._states.tags[object.name], $.proxy(function(tag, i) {
|
||
|
|
return $.inArray(tag, this._states.tags[object.name]) === i;
|
||
|
|
}, this));
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Suppresses events.
|
||
|
|
* @protected
|
||
|
|
* @param {Array.<String>} events - The events to suppress.
|
||
|
|
*/
|
||
|
|
Owl.prototype.suppress = function(events) {
|
||
|
|
$.each(events, $.proxy(function(index, event) {
|
||
|
|
this._supress[event] = true;
|
||
|
|
}, this));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Releases suppressed events.
|
||
|
|
* @protected
|
||
|
|
* @param {Array.<String>} events - The events to release.
|
||
|
|
*/
|
||
|
|
Owl.prototype.release = function(events) {
|
||
|
|
$.each(events, $.proxy(function(index, event) {
|
||
|
|
delete this._supress[event];
|
||
|
|
}, this));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets unified pointer coordinates from event.
|
||
|
|
* @todo #261
|
||
|
|
* @protected
|
||
|
|
* @param {Event} - The `mousedown` or `touchstart` event.
|
||
|
|
* @returns {Object} - Contains `x` and `y` coordinates of current pointer position.
|
||
|
|
*/
|
||
|
|
Owl.prototype.pointer = function(event) {
|
||
|
|
var result = { x: null, y: null };
|
||
|
|
|
||
|
|
event = event.originalEvent || event || window.event;
|
||
|
|
|
||
|
|
event = event.touches && event.touches.length ?
|
||
|
|
event.touches[0] : event.changedTouches && event.changedTouches.length ?
|
||
|
|
event.changedTouches[0] : event;
|
||
|
|
|
||
|
|
if (event.pageX) {
|
||
|
|
result.x = event.pageX;
|
||
|
|
result.y = event.pageY;
|
||
|
|
} else {
|
||
|
|
result.x = event.clientX;
|
||
|
|
result.y = event.clientY;
|
||
|
|
}
|
||
|
|
|
||
|
|
return result;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Determines if the input is a Number or something that can be coerced to a Number
|
||
|
|
* @protected
|
||
|
|
* @param {Number|String|Object|Array|Boolean|RegExp|Function|Symbol} - The input to be tested
|
||
|
|
* @returns {Boolean} - An indication if the input is a Number or can be coerced to a Number
|
||
|
|
*/
|
||
|
|
Owl.prototype.isNumeric = function(number) {
|
||
|
|
return !isNaN(parseFloat(number));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the difference of two vectors.
|
||
|
|
* @todo #261
|
||
|
|
* @protected
|
||
|
|
* @param {Object} - The first vector.
|
||
|
|
* @param {Object} - The second vector.
|
||
|
|
* @returns {Object} - The difference.
|
||
|
|
*/
|
||
|
|
Owl.prototype.difference = function(first, second) {
|
||
|
|
return {
|
||
|
|
x: first.x - second.x,
|
||
|
|
y: first.y - second.y
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The jQuery Plugin for the Owl Carousel
|
||
|
|
* @todo Navigation plugin `next` and `prev`
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
$.fn.owlCarousel = function(option) {
|
||
|
|
var args = Array.prototype.slice.call(arguments, 1);
|
||
|
|
|
||
|
|
return this.each(function() {
|
||
|
|
var $this = $(this),
|
||
|
|
data = $this.data('owl.carousel');
|
||
|
|
|
||
|
|
if (!data) {
|
||
|
|
data = new Owl(this, typeof option == 'object' && option);
|
||
|
|
$this.data('owl.carousel', data);
|
||
|
|
|
||
|
|
$.each([
|
||
|
|
'next', 'prev', 'to', 'destroy', 'refresh', 'replace', 'add', 'remove'
|
||
|
|
], function(i, event) {
|
||
|
|
data.register({ type: Owl.Type.Event, name: event });
|
||
|
|
data.$element.on(event + '.owl.carousel.core', $.proxy(function(e) {
|
||
|
|
if (e.namespace && e.relatedTarget !== this) {
|
||
|
|
this.suppress([ event ]);
|
||
|
|
data[event].apply(this, [].slice.call(arguments, 1));
|
||
|
|
this.release([ event ]);
|
||
|
|
}
|
||
|
|
}, data));
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
if (typeof option == 'string' && option.charAt(0) !== '_') {
|
||
|
|
data[option].apply(data, args);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The constructor for the jQuery Plugin
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
$.fn.owlCarousel.Constructor = Owl;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* AutoRefresh Plugin
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Artus Kolanowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the auto refresh plugin.
|
||
|
|
* @class The Auto Refresh Plugin
|
||
|
|
* @param {Owl} carousel - The Owl Carousel
|
||
|
|
*/
|
||
|
|
var AutoRefresh = function(carousel) {
|
||
|
|
/**
|
||
|
|
* Reference to the core.
|
||
|
|
* @protected
|
||
|
|
* @type {Owl}
|
||
|
|
*/
|
||
|
|
this._core = carousel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Refresh interval.
|
||
|
|
* @protected
|
||
|
|
* @type {number}
|
||
|
|
*/
|
||
|
|
this._interval = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Whether the element is currently visible or not.
|
||
|
|
* @protected
|
||
|
|
* @type {Boolean}
|
||
|
|
*/
|
||
|
|
this._visible = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All event handlers.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._handlers = {
|
||
|
|
'initialized.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.autoRefresh) {
|
||
|
|
this.watch();
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
// set default options
|
||
|
|
this._core.options = $.extend({}, AutoRefresh.Defaults, this._core.options);
|
||
|
|
|
||
|
|
// register event handlers
|
||
|
|
this._core.$element.on(this._handlers);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
AutoRefresh.Defaults = {
|
||
|
|
autoRefresh: true,
|
||
|
|
autoRefreshInterval: 500
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Watches the element.
|
||
|
|
*/
|
||
|
|
AutoRefresh.prototype.watch = function() {
|
||
|
|
if (this._interval) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._visible = this._core.isVisible();
|
||
|
|
this._interval = window.setInterval($.proxy(this.refresh, this), this._core.settings.autoRefreshInterval);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Refreshes the element.
|
||
|
|
*/
|
||
|
|
AutoRefresh.prototype.refresh = function() {
|
||
|
|
if (this._core.isVisible() === this._visible) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._visible = !this._visible;
|
||
|
|
|
||
|
|
this._core.$element.toggleClass('owl-hidden', !this._visible);
|
||
|
|
|
||
|
|
this._visible && (this._core.invalidate('width') && this._core.refresh());
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys the plugin.
|
||
|
|
*/
|
||
|
|
AutoRefresh.prototype.destroy = function() {
|
||
|
|
var handler, property;
|
||
|
|
|
||
|
|
window.clearInterval(this._interval);
|
||
|
|
|
||
|
|
for (handler in this._handlers) {
|
||
|
|
this._core.$element.off(handler, this._handlers[handler]);
|
||
|
|
}
|
||
|
|
for (property in Object.getOwnPropertyNames(this)) {
|
||
|
|
typeof this[property] != 'function' && (this[property] = null);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.fn.owlCarousel.Constructor.Plugins.AutoRefresh = AutoRefresh;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Lazy Plugin
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Bartosz Wojciechowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the lazy plugin.
|
||
|
|
* @class The Lazy Plugin
|
||
|
|
* @param {Owl} carousel - The Owl Carousel
|
||
|
|
*/
|
||
|
|
var Lazy = function(carousel) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Reference to the core.
|
||
|
|
* @protected
|
||
|
|
* @type {Owl}
|
||
|
|
*/
|
||
|
|
this._core = carousel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Already loaded items.
|
||
|
|
* @protected
|
||
|
|
* @type {Array.<jQuery>}
|
||
|
|
*/
|
||
|
|
this._loaded = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Event handlers.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._handlers = {
|
||
|
|
'initialized.owl.carousel change.owl.carousel resized.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (!e.namespace) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!this._core.settings || !this._core.settings.lazyLoad) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ((e.property && e.property.name == 'position') || e.type == 'initialized') {
|
||
|
|
var settings = this._core.settings,
|
||
|
|
n = (settings.center && Math.ceil(settings.items / 2) || settings.items),
|
||
|
|
i = ((settings.center && n * -1) || 0),
|
||
|
|
position = (e.property && e.property.value !== undefined ? e.property.value : this._core.current()) + i,
|
||
|
|
clones = this._core.clones().length,
|
||
|
|
load = $.proxy(function(i, v) { this.load(v) }, this);
|
||
|
|
//TODO: Need documentation for this new option
|
||
|
|
if (settings.lazyLoadEager > 0) {
|
||
|
|
n += settings.lazyLoadEager;
|
||
|
|
// If the carousel is looping also preload images that are to the "left"
|
||
|
|
if (settings.loop) {
|
||
|
|
position -= settings.lazyLoadEager;
|
||
|
|
n++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
while (i++ < n) {
|
||
|
|
this.load(clones / 2 + this._core.relative(position));
|
||
|
|
clones && $.each(this._core.clones(this._core.relative(position)), load);
|
||
|
|
position++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
// set the default options
|
||
|
|
this._core.options = $.extend({}, Lazy.Defaults, this._core.options);
|
||
|
|
|
||
|
|
// register event handler
|
||
|
|
this._core.$element.on(this._handlers);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Lazy.Defaults = {
|
||
|
|
lazyLoad: false,
|
||
|
|
lazyLoadEager: 0
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Loads all resources of an item at the specified position.
|
||
|
|
* @param {Number} position - The absolute position of the item.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Lazy.prototype.load = function(position) {
|
||
|
|
var $item = this._core.$stage.children().eq(position),
|
||
|
|
$elements = $item && $item.find('.owl-lazy');
|
||
|
|
|
||
|
|
if (!$elements || $.inArray($item.get(0), this._loaded) > -1) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
$elements.each($.proxy(function(index, element) {
|
||
|
|
var $element = $(element), image,
|
||
|
|
url = (window.devicePixelRatio > 1 && $element.attr('data-src-retina')) || $element.attr('data-src') || $element.attr('data-srcset');
|
||
|
|
|
||
|
|
this._core.trigger('load', { element: $element, url: url }, 'lazy');
|
||
|
|
|
||
|
|
if ($element.is('img')) {
|
||
|
|
$element.one('load.owl.lazy', $.proxy(function() {
|
||
|
|
$element.css('opacity', 1);
|
||
|
|
this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
|
||
|
|
}, this)).attr('src', url);
|
||
|
|
} else if ($element.is('source')) {
|
||
|
|
$element.one('load.owl.lazy', $.proxy(function() {
|
||
|
|
this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
|
||
|
|
}, this)).attr('srcset', url);
|
||
|
|
} else {
|
||
|
|
image = new Image();
|
||
|
|
image.onload = $.proxy(function() {
|
||
|
|
$element.css({
|
||
|
|
'background-image': 'url("' + url + '")',
|
||
|
|
'opacity': '1'
|
||
|
|
});
|
||
|
|
this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
|
||
|
|
}, this);
|
||
|
|
image.src = url;
|
||
|
|
}
|
||
|
|
}, this));
|
||
|
|
|
||
|
|
this._loaded.push($item.get(0));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys the plugin.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Lazy.prototype.destroy = function() {
|
||
|
|
var handler, property;
|
||
|
|
|
||
|
|
for (handler in this.handlers) {
|
||
|
|
this._core.$element.off(handler, this.handlers[handler]);
|
||
|
|
}
|
||
|
|
for (property in Object.getOwnPropertyNames(this)) {
|
||
|
|
typeof this[property] != 'function' && (this[property] = null);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.fn.owlCarousel.Constructor.Plugins.Lazy = Lazy;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* AutoHeight Plugin
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Bartosz Wojciechowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the auto height plugin.
|
||
|
|
* @class The Auto Height Plugin
|
||
|
|
* @param {Owl} carousel - The Owl Carousel
|
||
|
|
*/
|
||
|
|
var AutoHeight = function(carousel) {
|
||
|
|
/**
|
||
|
|
* Reference to the core.
|
||
|
|
* @protected
|
||
|
|
* @type {Owl}
|
||
|
|
*/
|
||
|
|
this._core = carousel;
|
||
|
|
|
||
|
|
this._previousHeight = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All event handlers.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._handlers = {
|
||
|
|
'initialized.owl.carousel refreshed.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.autoHeight) {
|
||
|
|
this.update();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'changed.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.autoHeight && e.property.name === 'position'){
|
||
|
|
this.update();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'loaded.owl.lazy': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.autoHeight
|
||
|
|
&& e.element.closest('.' + this._core.settings.itemClass).index() === this._core.current()) {
|
||
|
|
this.update();
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
// set default options
|
||
|
|
this._core.options = $.extend({}, AutoHeight.Defaults, this._core.options);
|
||
|
|
|
||
|
|
// register event handlers
|
||
|
|
this._core.$element.on(this._handlers);
|
||
|
|
this._intervalId = null;
|
||
|
|
var refThis = this;
|
||
|
|
|
||
|
|
// These changes have been taken from a PR by gavrochelegnou proposed in #1575
|
||
|
|
// and have been made compatible with the latest jQuery version
|
||
|
|
$(window).on('load', function() {
|
||
|
|
if (refThis._core.settings.autoHeight) {
|
||
|
|
refThis.update();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// Autoresize the height of the carousel when window is resized
|
||
|
|
// When carousel has images, the height is dependent on the width
|
||
|
|
// and should also change on resize
|
||
|
|
$(window).resize(function() {
|
||
|
|
if (refThis._core.settings.autoHeight) {
|
||
|
|
if (refThis._intervalId != null) {
|
||
|
|
clearTimeout(refThis._intervalId);
|
||
|
|
}
|
||
|
|
|
||
|
|
refThis._intervalId = setTimeout(function() {
|
||
|
|
refThis.update();
|
||
|
|
}, 250);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
AutoHeight.Defaults = {
|
||
|
|
autoHeight: false,
|
||
|
|
autoHeightClass: 'owl-height'
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Updates the view.
|
||
|
|
*/
|
||
|
|
AutoHeight.prototype.update = function() {
|
||
|
|
var start = this._core._current,
|
||
|
|
end = start + this._core.settings.items,
|
||
|
|
lazyLoadEnabled = this._core.settings.lazyLoad,
|
||
|
|
visible = this._core.$stage.children().toArray().slice(start, end),
|
||
|
|
heights = [],
|
||
|
|
maxheight = 0;
|
||
|
|
|
||
|
|
$.each(visible, function(index, item) {
|
||
|
|
heights.push($(item).height());
|
||
|
|
});
|
||
|
|
|
||
|
|
maxheight = Math.max.apply(null, heights);
|
||
|
|
|
||
|
|
if (maxheight <= 1 && lazyLoadEnabled && this._previousHeight) {
|
||
|
|
maxheight = this._previousHeight;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._previousHeight = maxheight;
|
||
|
|
|
||
|
|
this._core.$stage.parent()
|
||
|
|
.height(maxheight)
|
||
|
|
.addClass(this._core.settings.autoHeightClass);
|
||
|
|
};
|
||
|
|
|
||
|
|
AutoHeight.prototype.destroy = function() {
|
||
|
|
var handler, property;
|
||
|
|
|
||
|
|
for (handler in this._handlers) {
|
||
|
|
this._core.$element.off(handler, this._handlers[handler]);
|
||
|
|
}
|
||
|
|
for (property in Object.getOwnPropertyNames(this)) {
|
||
|
|
typeof this[property] !== 'function' && (this[property] = null);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.fn.owlCarousel.Constructor.Plugins.AutoHeight = AutoHeight;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Video Plugin
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Bartosz Wojciechowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the video plugin.
|
||
|
|
* @class The Video Plugin
|
||
|
|
* @param {Owl} carousel - The Owl Carousel
|
||
|
|
*/
|
||
|
|
var Video = function(carousel) {
|
||
|
|
/**
|
||
|
|
* Reference to the core.
|
||
|
|
* @protected
|
||
|
|
* @type {Owl}
|
||
|
|
*/
|
||
|
|
this._core = carousel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Cache all video URLs.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._videos = {};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Current playing item.
|
||
|
|
* @protected
|
||
|
|
* @type {jQuery}
|
||
|
|
*/
|
||
|
|
this._playing = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All event handlers.
|
||
|
|
* @todo The cloned content removale is too late
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._handlers = {
|
||
|
|
'initialized.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace) {
|
||
|
|
this._core.register({ type: 'state', name: 'playing', tags: [ 'interacting' ] });
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'resize.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.video && this.isInFullScreen()) {
|
||
|
|
e.preventDefault();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'refreshed.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.is('resizing')) {
|
||
|
|
this._core.$stage.find('.cloned .owl-video-frame').remove();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'changed.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && e.property.name === 'position' && this._playing) {
|
||
|
|
this.stop();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'prepared.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (!e.namespace) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
var $element = $(e.content).find('.owl-video');
|
||
|
|
|
||
|
|
if ($element.length) {
|
||
|
|
$element.css('display', 'none');
|
||
|
|
this.fetch($element, $(e.content));
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
// set default options
|
||
|
|
this._core.options = $.extend({}, Video.Defaults, this._core.options);
|
||
|
|
|
||
|
|
// register event handlers
|
||
|
|
this._core.$element.on(this._handlers);
|
||
|
|
|
||
|
|
this._core.$element.on('click.owl.video', '.owl-video-play-icon', $.proxy(function(e) {
|
||
|
|
this.play(e);
|
||
|
|
}, this));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Video.Defaults = {
|
||
|
|
video: false,
|
||
|
|
videoHeight: false,
|
||
|
|
videoWidth: false
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the video ID and the type (YouTube/Vimeo/vzaar only).
|
||
|
|
* @protected
|
||
|
|
* @param {jQuery} target - The target containing the video data.
|
||
|
|
* @param {jQuery} item - The item containing the video.
|
||
|
|
*/
|
||
|
|
Video.prototype.fetch = function(target, item) {
|
||
|
|
var type = (function() {
|
||
|
|
if (target.attr('data-vimeo-id')) {
|
||
|
|
return 'vimeo';
|
||
|
|
} else if (target.attr('data-vzaar-id')) {
|
||
|
|
return 'vzaar'
|
||
|
|
} else {
|
||
|
|
return 'youtube';
|
||
|
|
}
|
||
|
|
})(),
|
||
|
|
id = target.attr('data-vimeo-id') || target.attr('data-youtube-id') || target.attr('data-vzaar-id'),
|
||
|
|
width = target.attr('data-width') || this._core.settings.videoWidth,
|
||
|
|
height = target.attr('data-height') || this._core.settings.videoHeight,
|
||
|
|
url = target.attr('href');
|
||
|
|
|
||
|
|
if (url) {
|
||
|
|
|
||
|
|
/*
|
||
|
|
Parses the id's out of the following urls (and probably more):
|
||
|
|
https://www.youtube.com/watch?v=:id
|
||
|
|
https://youtu.be/:id
|
||
|
|
https://vimeo.com/:id
|
||
|
|
https://vimeo.com/channels/:channel/:id
|
||
|
|
https://vimeo.com/groups/:group/videos/:id
|
||
|
|
https://app.vzaar.com/videos/:id
|
||
|
|
|
||
|
|
Visual example: https://regexper.com/#(http%3A%7Chttps%3A%7C)%5C%2F%5C%2F(player.%7Cwww.%7Capp.)%3F(vimeo%5C.com%7Cyoutu(be%5C.com%7C%5C.be%7Cbe%5C.googleapis%5C.com)%7Cvzaar%5C.com)%5C%2F(video%5C%2F%7Cvideos%5C%2F%7Cembed%5C%2F%7Cchannels%5C%2F.%2B%5C%2F%7Cgroups%5C%2F.%2B%5C%2F%7Cwatch%5C%3Fv%3D%7Cv%5C%2F)%3F(%5BA-Za-z0-9._%25-%5D*)(%5C%26%5CS%2B)%3F
|
||
|
|
*/
|
||
|
|
|
||
|
|
id = url.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/);
|
||
|
|
|
||
|
|
if (id[3].indexOf('youtu') > -1) {
|
||
|
|
type = 'youtube';
|
||
|
|
} else if (id[3].indexOf('vimeo') > -1) {
|
||
|
|
type = 'vimeo';
|
||
|
|
} else if (id[3].indexOf('vzaar') > -1) {
|
||
|
|
type = 'vzaar';
|
||
|
|
} else {
|
||
|
|
throw new Error('Video URL not supported.');
|
||
|
|
}
|
||
|
|
id = id[6];
|
||
|
|
} else {
|
||
|
|
throw new Error('Missing video URL.');
|
||
|
|
}
|
||
|
|
|
||
|
|
this._videos[url] = {
|
||
|
|
type: type,
|
||
|
|
id: id,
|
||
|
|
width: width,
|
||
|
|
height: height
|
||
|
|
};
|
||
|
|
|
||
|
|
item.attr('data-video', url);
|
||
|
|
|
||
|
|
this.thumbnail(target, this._videos[url]);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates video thumbnail.
|
||
|
|
* @protected
|
||
|
|
* @param {jQuery} target - The target containing the video data.
|
||
|
|
* @param {Object} info - The video info object.
|
||
|
|
* @see `fetch`
|
||
|
|
*/
|
||
|
|
Video.prototype.thumbnail = function(target, video) {
|
||
|
|
var tnLink,
|
||
|
|
icon,
|
||
|
|
path,
|
||
|
|
dimensions = video.width && video.height ? 'width:' + video.width + 'px;height:' + video.height + 'px;' : '',
|
||
|
|
customTn = target.find('img'),
|
||
|
|
srcType = 'src',
|
||
|
|
lazyClass = '',
|
||
|
|
settings = this._core.settings,
|
||
|
|
create = function(path) {
|
||
|
|
icon = '<div class="owl-video-play-icon"></div>';
|
||
|
|
|
||
|
|
if (settings.lazyLoad) {
|
||
|
|
tnLink = $('<div/>',{
|
||
|
|
"class": 'owl-video-tn ' + lazyClass,
|
||
|
|
"srcType": path
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
tnLink = $( '<div/>', {
|
||
|
|
"class": "owl-video-tn",
|
||
|
|
"style": 'opacity:1;background-image:url(' + path + ')'
|
||
|
|
});
|
||
|
|
}
|
||
|
|
target.after(tnLink);
|
||
|
|
target.after(icon);
|
||
|
|
};
|
||
|
|
|
||
|
|
// wrap video content into owl-video-wrapper div
|
||
|
|
target.wrap( $( '<div/>', {
|
||
|
|
"class": "owl-video-wrapper",
|
||
|
|
"style": dimensions
|
||
|
|
}));
|
||
|
|
|
||
|
|
if (this._core.settings.lazyLoad) {
|
||
|
|
srcType = 'data-src';
|
||
|
|
lazyClass = 'owl-lazy';
|
||
|
|
}
|
||
|
|
|
||
|
|
// custom thumbnail
|
||
|
|
if (customTn.length) {
|
||
|
|
create(customTn.attr(srcType));
|
||
|
|
customTn.remove();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (video.type === 'youtube') {
|
||
|
|
path = "//img.youtube.com/vi/" + video.id + "/hqdefault.jpg";
|
||
|
|
create(path);
|
||
|
|
} else if (video.type === 'vimeo') {
|
||
|
|
$.ajax({
|
||
|
|
type: 'GET',
|
||
|
|
url: '//vimeo.com/api/v2/video/' + video.id + '.json',
|
||
|
|
jsonp: 'callback',
|
||
|
|
dataType: 'jsonp',
|
||
|
|
success: function(data) {
|
||
|
|
path = data[0].thumbnail_large;
|
||
|
|
create(path);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
} else if (video.type === 'vzaar') {
|
||
|
|
$.ajax({
|
||
|
|
type: 'GET',
|
||
|
|
url: '//vzaar.com/api/videos/' + video.id + '.json',
|
||
|
|
jsonp: 'callback',
|
||
|
|
dataType: 'jsonp',
|
||
|
|
success: function(data) {
|
||
|
|
path = data.framegrab_url;
|
||
|
|
create(path);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Stops the current video.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Video.prototype.stop = function() {
|
||
|
|
this._core.trigger('stop', null, 'video');
|
||
|
|
this._playing.find('.owl-video-frame').remove();
|
||
|
|
this._playing.removeClass('owl-video-playing');
|
||
|
|
this._playing = null;
|
||
|
|
this._core.leave('playing');
|
||
|
|
this._core.trigger('stopped', null, 'video');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Starts the current video.
|
||
|
|
* @public
|
||
|
|
* @param {Event} event - The event arguments.
|
||
|
|
*/
|
||
|
|
Video.prototype.play = function(event) {
|
||
|
|
var target = $(event.target),
|
||
|
|
item = target.closest('.' + this._core.settings.itemClass),
|
||
|
|
video = this._videos[item.attr('data-video')],
|
||
|
|
width = video.width || '100%',
|
||
|
|
height = video.height || this._core.$stage.height(),
|
||
|
|
html,
|
||
|
|
iframe;
|
||
|
|
|
||
|
|
if (this._playing) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._core.enter('playing');
|
||
|
|
this._core.trigger('play', null, 'video');
|
||
|
|
|
||
|
|
item = this._core.items(this._core.relative(item.index()));
|
||
|
|
|
||
|
|
this._core.reset(item.index());
|
||
|
|
|
||
|
|
html = $( '<iframe frameborder="0" allowfullscreen mozallowfullscreen webkitAllowFullScreen ></iframe>' );
|
||
|
|
html.attr( 'height', height );
|
||
|
|
html.attr( 'width', width );
|
||
|
|
if (video.type === 'youtube') {
|
||
|
|
html.attr( 'src', '//www.youtube.com/embed/' + video.id + '?autoplay=1&rel=0&v=' + video.id );
|
||
|
|
} else if (video.type === 'vimeo') {
|
||
|
|
html.attr( 'src', '//player.vimeo.com/video/' + video.id + '?autoplay=1' );
|
||
|
|
} else if (video.type === 'vzaar') {
|
||
|
|
html.attr( 'src', '//view.vzaar.com/' + video.id + '/player?autoplay=true' );
|
||
|
|
}
|
||
|
|
|
||
|
|
iframe = $(html).wrap( '<div class="owl-video-frame" />' ).insertAfter(item.find('.owl-video'));
|
||
|
|
|
||
|
|
this._playing = item.addClass('owl-video-playing');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Checks whether an video is currently in full screen mode or not.
|
||
|
|
* @todo Bad style because looks like a readonly method but changes members.
|
||
|
|
* @protected
|
||
|
|
* @returns {Boolean}
|
||
|
|
*/
|
||
|
|
Video.prototype.isInFullScreen = function() {
|
||
|
|
var element = document.fullscreenElement || document.mozFullScreenElement ||
|
||
|
|
document.webkitFullscreenElement;
|
||
|
|
|
||
|
|
return element && $(element).parent().hasClass('owl-video-frame');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys the plugin.
|
||
|
|
*/
|
||
|
|
Video.prototype.destroy = function() {
|
||
|
|
var handler, property;
|
||
|
|
|
||
|
|
this._core.$element.off('click.owl.video');
|
||
|
|
|
||
|
|
for (handler in this._handlers) {
|
||
|
|
this._core.$element.off(handler, this._handlers[handler]);
|
||
|
|
}
|
||
|
|
for (property in Object.getOwnPropertyNames(this)) {
|
||
|
|
typeof this[property] != 'function' && (this[property] = null);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.fn.owlCarousel.Constructor.Plugins.Video = Video;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Animate Plugin
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Bartosz Wojciechowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the animate plugin.
|
||
|
|
* @class The Navigation Plugin
|
||
|
|
* @param {Owl} scope - The Owl Carousel
|
||
|
|
*/
|
||
|
|
var Animate = function(scope) {
|
||
|
|
this.core = scope;
|
||
|
|
this.core.options = $.extend({}, Animate.Defaults, this.core.options);
|
||
|
|
this.swapping = true;
|
||
|
|
this.previous = undefined;
|
||
|
|
this.next = undefined;
|
||
|
|
|
||
|
|
this.handlers = {
|
||
|
|
'change.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && e.property.name == 'position') {
|
||
|
|
this.previous = this.core.current();
|
||
|
|
this.next = e.property.value;
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace) {
|
||
|
|
this.swapping = e.type == 'translated';
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'translate.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) {
|
||
|
|
this.swap();
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
this.core.$element.on(this.handlers);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Animate.Defaults = {
|
||
|
|
animateOut: false,
|
||
|
|
animateIn: false
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Toggles the animation classes whenever an translations starts.
|
||
|
|
* @protected
|
||
|
|
* @returns {Boolean|undefined}
|
||
|
|
*/
|
||
|
|
Animate.prototype.swap = function() {
|
||
|
|
|
||
|
|
if (this.core.settings.items !== 1) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!$.support.animation || !$.support.transition) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.core.speed(0);
|
||
|
|
|
||
|
|
var left,
|
||
|
|
clear = $.proxy(this.clear, this),
|
||
|
|
previous = this.core.$stage.children().eq(this.previous),
|
||
|
|
next = this.core.$stage.children().eq(this.next),
|
||
|
|
incoming = this.core.settings.animateIn,
|
||
|
|
outgoing = this.core.settings.animateOut;
|
||
|
|
|
||
|
|
if (this.core.current() === this.previous) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (outgoing) {
|
||
|
|
left = this.core.coordinates(this.previous) - this.core.coordinates(this.next);
|
||
|
|
previous.one($.support.animation.end, clear)
|
||
|
|
.css( { 'left': left + 'px' } )
|
||
|
|
.addClass('animated owl-animated-out')
|
||
|
|
.addClass(outgoing);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (incoming) {
|
||
|
|
next.one($.support.animation.end, clear)
|
||
|
|
.addClass('animated owl-animated-in')
|
||
|
|
.addClass(incoming);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
Animate.prototype.clear = function(e) {
|
||
|
|
$(e.target).css( { 'left': '' } )
|
||
|
|
.removeClass('animated owl-animated-out owl-animated-in')
|
||
|
|
.removeClass(this.core.settings.animateIn)
|
||
|
|
.removeClass(this.core.settings.animateOut);
|
||
|
|
this.core.onTransitionEnd();
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys the plugin.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Animate.prototype.destroy = function() {
|
||
|
|
var handler, property;
|
||
|
|
|
||
|
|
for (handler in this.handlers) {
|
||
|
|
this.core.$element.off(handler, this.handlers[handler]);
|
||
|
|
}
|
||
|
|
for (property in Object.getOwnPropertyNames(this)) {
|
||
|
|
typeof this[property] != 'function' && (this[property] = null);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.fn.owlCarousel.Constructor.Plugins.Animate = Animate;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Autoplay Plugin
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Bartosz Wojciechowski
|
||
|
|
* @author Artus Kolanowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @author Tom De Caluwé
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the autoplay plugin.
|
||
|
|
* @class The Autoplay Plugin
|
||
|
|
* @param {Owl} scope - The Owl Carousel
|
||
|
|
*/
|
||
|
|
var Autoplay = function(carousel) {
|
||
|
|
/**
|
||
|
|
* Reference to the core.
|
||
|
|
* @protected
|
||
|
|
* @type {Owl}
|
||
|
|
*/
|
||
|
|
this._core = carousel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The autoplay timeout id.
|
||
|
|
* @type {Number}
|
||
|
|
*/
|
||
|
|
this._call = null;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Depending on the state of the plugin, this variable contains either
|
||
|
|
* the start time of the timer or the current timer value if it's
|
||
|
|
* paused. Since we start in a paused state we initialize the timer
|
||
|
|
* value.
|
||
|
|
* @type {Number}
|
||
|
|
*/
|
||
|
|
this._time = 0;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Stores the timeout currently used.
|
||
|
|
* @type {Number}
|
||
|
|
*/
|
||
|
|
this._timeout = 0;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Indicates whenever the autoplay is paused.
|
||
|
|
* @type {Boolean}
|
||
|
|
*/
|
||
|
|
this._paused = true;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All event handlers.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._handlers = {
|
||
|
|
'changed.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && e.property.name === 'settings') {
|
||
|
|
if (this._core.settings.autoplay) {
|
||
|
|
this.play();
|
||
|
|
} else {
|
||
|
|
this.stop();
|
||
|
|
}
|
||
|
|
} else if (e.namespace && e.property.name === 'position' && this._paused) {
|
||
|
|
// Reset the timer. This code is triggered when the position
|
||
|
|
// of the carousel was changed through user interaction.
|
||
|
|
this._time = 0;
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'initialized.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.autoplay) {
|
||
|
|
this.play();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'play.owl.autoplay': $.proxy(function(e, t, s) {
|
||
|
|
if (e.namespace) {
|
||
|
|
this.play(t, s);
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'stop.owl.autoplay': $.proxy(function(e) {
|
||
|
|
if (e.namespace) {
|
||
|
|
this.stop();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'mouseover.owl.autoplay': $.proxy(function() {
|
||
|
|
if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
|
||
|
|
this.pause();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'mouseleave.owl.autoplay': $.proxy(function() {
|
||
|
|
if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
|
||
|
|
this.play();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'touchstart.owl.core': $.proxy(function() {
|
||
|
|
if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
|
||
|
|
this.pause();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'touchend.owl.core': $.proxy(function() {
|
||
|
|
if (this._core.settings.autoplayHoverPause) {
|
||
|
|
this.play();
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
// register event handlers
|
||
|
|
this._core.$element.on(this._handlers);
|
||
|
|
|
||
|
|
// set default options
|
||
|
|
this._core.options = $.extend({}, Autoplay.Defaults, this._core.options);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Autoplay.Defaults = {
|
||
|
|
autoplay: false,
|
||
|
|
autoplayTimeout: 5000,
|
||
|
|
autoplayHoverPause: false,
|
||
|
|
autoplaySpeed: false
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Transition to the next slide and set a timeout for the next transition.
|
||
|
|
* @private
|
||
|
|
* @param {Number} [speed] - The animation speed for the animations.
|
||
|
|
*/
|
||
|
|
Autoplay.prototype._next = function(speed) {
|
||
|
|
this._call = window.setTimeout(
|
||
|
|
$.proxy(this._next, this, speed),
|
||
|
|
this._timeout * (Math.round(this.read() / this._timeout) + 1) - this.read()
|
||
|
|
);
|
||
|
|
|
||
|
|
if (this._core.is('interacting') || document.hidden) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this._core.next(speed || this._core.settings.autoplaySpeed);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Reads the current timer value when the timer is playing.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Autoplay.prototype.read = function() {
|
||
|
|
return new Date().getTime() - this._time;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Starts the autoplay.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [timeout] - The interval before the next animation starts.
|
||
|
|
* @param {Number} [speed] - The animation speed for the animations.
|
||
|
|
*/
|
||
|
|
Autoplay.prototype.play = function(timeout, speed) {
|
||
|
|
var elapsed;
|
||
|
|
|
||
|
|
if (!this._core.is('rotating')) {
|
||
|
|
this._core.enter('rotating');
|
||
|
|
}
|
||
|
|
|
||
|
|
timeout = timeout || this._core.settings.autoplayTimeout;
|
||
|
|
|
||
|
|
// Calculate the elapsed time since the last transition. If the carousel
|
||
|
|
// wasn't playing this calculation will yield zero.
|
||
|
|
elapsed = Math.min(this._time % (this._timeout || timeout), timeout);
|
||
|
|
|
||
|
|
if (this._paused) {
|
||
|
|
// Start the clock.
|
||
|
|
this._time = this.read();
|
||
|
|
this._paused = false;
|
||
|
|
} else {
|
||
|
|
// Clear the active timeout to allow replacement.
|
||
|
|
window.clearTimeout(this._call);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Adjust the origin of the timer to match the new timeout value.
|
||
|
|
this._time += this.read() % timeout - elapsed;
|
||
|
|
|
||
|
|
this._timeout = timeout;
|
||
|
|
this._call = window.setTimeout($.proxy(this._next, this, speed), timeout - elapsed);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Stops the autoplay.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Autoplay.prototype.stop = function() {
|
||
|
|
if (this._core.is('rotating')) {
|
||
|
|
// Reset the clock.
|
||
|
|
this._time = 0;
|
||
|
|
this._paused = true;
|
||
|
|
|
||
|
|
window.clearTimeout(this._call);
|
||
|
|
this._core.leave('rotating');
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Pauses the autoplay.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Autoplay.prototype.pause = function() {
|
||
|
|
if (this._core.is('rotating') && !this._paused) {
|
||
|
|
// Pause the clock.
|
||
|
|
this._time = this.read();
|
||
|
|
this._paused = true;
|
||
|
|
|
||
|
|
window.clearTimeout(this._call);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys the plugin.
|
||
|
|
*/
|
||
|
|
Autoplay.prototype.destroy = function() {
|
||
|
|
var handler, property;
|
||
|
|
|
||
|
|
this.stop();
|
||
|
|
|
||
|
|
for (handler in this._handlers) {
|
||
|
|
this._core.$element.off(handler, this._handlers[handler]);
|
||
|
|
}
|
||
|
|
for (property in Object.getOwnPropertyNames(this)) {
|
||
|
|
typeof this[property] != 'function' && (this[property] = null);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Navigation Plugin
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Artus Kolanowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the navigation plugin.
|
||
|
|
* @class The Navigation Plugin
|
||
|
|
* @param {Owl} carousel - The Owl Carousel.
|
||
|
|
*/
|
||
|
|
var Navigation = function(carousel) {
|
||
|
|
/**
|
||
|
|
* Reference to the core.
|
||
|
|
* @protected
|
||
|
|
* @type {Owl}
|
||
|
|
*/
|
||
|
|
this._core = carousel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Indicates whether the plugin is initialized or not.
|
||
|
|
* @protected
|
||
|
|
* @type {Boolean}
|
||
|
|
*/
|
||
|
|
this._initialized = false;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The current paging indexes.
|
||
|
|
* @protected
|
||
|
|
* @type {Array}
|
||
|
|
*/
|
||
|
|
this._pages = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All DOM elements of the user interface.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._controls = {};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Markup for an indicator.
|
||
|
|
* @protected
|
||
|
|
* @type {Array.<String>}
|
||
|
|
*/
|
||
|
|
this._templates = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The carousel element.
|
||
|
|
* @type {jQuery}
|
||
|
|
*/
|
||
|
|
this.$element = this._core.$element;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Overridden methods of the carousel.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._overrides = {
|
||
|
|
next: this._core.next,
|
||
|
|
prev: this._core.prev,
|
||
|
|
to: this._core.to
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All event handlers.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._handlers = {
|
||
|
|
'prepared.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.dotsData) {
|
||
|
|
this._templates.push('<div class="' + this._core.settings.dotClass + '">' +
|
||
|
|
$(e.content).find('[data-dot]').addBack('[data-dot]').attr('data-dot') + '</div>');
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'added.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.dotsData) {
|
||
|
|
this._templates.splice(e.position, 0, this._templates.pop());
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'remove.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.dotsData) {
|
||
|
|
this._templates.splice(e.position, 1);
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'changed.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && e.property.name == 'position') {
|
||
|
|
this.draw();
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'initialized.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && !this._initialized) {
|
||
|
|
this._core.trigger('initialize', null, 'navigation');
|
||
|
|
this.initialize();
|
||
|
|
this.update();
|
||
|
|
this.draw();
|
||
|
|
this._initialized = true;
|
||
|
|
this._core.trigger('initialized', null, 'navigation');
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'refreshed.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._initialized) {
|
||
|
|
this._core.trigger('refresh', null, 'navigation');
|
||
|
|
this.update();
|
||
|
|
this.draw();
|
||
|
|
this._core.trigger('refreshed', null, 'navigation');
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
// set default options
|
||
|
|
this._core.options = $.extend({}, Navigation.Defaults, this._core.options);
|
||
|
|
|
||
|
|
// register event handlers
|
||
|
|
this.$element.on(this._handlers);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options.
|
||
|
|
* @public
|
||
|
|
* @todo Rename `slideBy` to `navBy`
|
||
|
|
*/
|
||
|
|
Navigation.Defaults = {
|
||
|
|
nav: false,
|
||
|
|
navText: [
|
||
|
|
'<span aria-label="' + 'Previous' + '">‹</span>',
|
||
|
|
'<span aria-label="' + 'Next' + '">›</span>'
|
||
|
|
],
|
||
|
|
navSpeed: false,
|
||
|
|
navElement: 'button type="button" role="presentation"',
|
||
|
|
navContainer: false,
|
||
|
|
navContainerClass: 'owl-nav',
|
||
|
|
navClass: [
|
||
|
|
'owl-prev',
|
||
|
|
'owl-next'
|
||
|
|
],
|
||
|
|
slideBy: 1,
|
||
|
|
dotClass: 'owl-dot',
|
||
|
|
dotsClass: 'owl-dots',
|
||
|
|
dots: true,
|
||
|
|
dotsEach: false,
|
||
|
|
dotsData: false,
|
||
|
|
dotsSpeed: false,
|
||
|
|
dotsContainer: false
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Initializes the layout of the plugin and extends the carousel.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Navigation.prototype.initialize = function() {
|
||
|
|
var override,
|
||
|
|
settings = this._core.settings;
|
||
|
|
|
||
|
|
// create DOM structure for relative navigation
|
||
|
|
this._controls.$relative = (settings.navContainer ? $(settings.navContainer)
|
||
|
|
: $('<div>').addClass(settings.navContainerClass).appendTo(this.$element)).addClass('disabled');
|
||
|
|
|
||
|
|
this._controls.$previous = $('<' + settings.navElement + '>')
|
||
|
|
.addClass(settings.navClass[0])
|
||
|
|
.html(settings.navText[0])
|
||
|
|
.prependTo(this._controls.$relative)
|
||
|
|
.on('click', $.proxy(function(e) {
|
||
|
|
this.prev(settings.navSpeed);
|
||
|
|
}, this));
|
||
|
|
this._controls.$next = $('<' + settings.navElement + '>')
|
||
|
|
.addClass(settings.navClass[1])
|
||
|
|
.html(settings.navText[1])
|
||
|
|
.appendTo(this._controls.$relative)
|
||
|
|
.on('click', $.proxy(function(e) {
|
||
|
|
this.next(settings.navSpeed);
|
||
|
|
}, this));
|
||
|
|
|
||
|
|
// create DOM structure for absolute navigation
|
||
|
|
if (!settings.dotsData) {
|
||
|
|
this._templates = [ $('<button role="button">')
|
||
|
|
.addClass(settings.dotClass)
|
||
|
|
.append($('<span>'))
|
||
|
|
.prop('outerHTML') ];
|
||
|
|
}
|
||
|
|
|
||
|
|
this._controls.$absolute = (settings.dotsContainer ? $(settings.dotsContainer)
|
||
|
|
: $('<div>').addClass(settings.dotsClass).appendTo(this.$element)).addClass('disabled');
|
||
|
|
|
||
|
|
this._controls.$absolute.on('click', 'button', $.proxy(function(e) {
|
||
|
|
var index = $(e.target).parent().is(this._controls.$absolute)
|
||
|
|
? $(e.target).index() : $(e.target).parent().index();
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
this.to(index, settings.dotsSpeed);
|
||
|
|
}, this));
|
||
|
|
|
||
|
|
/*$el.on('focusin', function() {
|
||
|
|
$(document).off(".carousel");
|
||
|
|
|
||
|
|
$(document).on('keydown.carousel', function(e) {
|
||
|
|
if(e.keyCode == 37) {
|
||
|
|
$el.trigger('prev.owl')
|
||
|
|
}
|
||
|
|
if(e.keyCode == 39) {
|
||
|
|
$el.trigger('next.owl')
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});*/
|
||
|
|
|
||
|
|
// override public methods of the carousel
|
||
|
|
for (override in this._overrides) {
|
||
|
|
this._core[override] = $.proxy(this[override], this);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys the plugin.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Navigation.prototype.destroy = function() {
|
||
|
|
var handler, control, property, override, settings;
|
||
|
|
settings = this._core.settings;
|
||
|
|
|
||
|
|
for (handler in this._handlers) {
|
||
|
|
this.$element.off(handler, this._handlers[handler]);
|
||
|
|
}
|
||
|
|
for (control in this._controls) {
|
||
|
|
if (control === '$relative' && settings.navContainer) {
|
||
|
|
this._controls[control].html('');
|
||
|
|
} else {
|
||
|
|
this._controls[control].remove();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for (override in this.overides) {
|
||
|
|
this._core[override] = this._overrides[override];
|
||
|
|
}
|
||
|
|
for (property in Object.getOwnPropertyNames(this)) {
|
||
|
|
typeof this[property] != 'function' && (this[property] = null);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Updates the internal state.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Navigation.prototype.update = function() {
|
||
|
|
var i, j, k,
|
||
|
|
lower = this._core.clones().length / 2,
|
||
|
|
upper = lower + this._core.items().length,
|
||
|
|
maximum = this._core.maximum(true),
|
||
|
|
settings = this._core.settings,
|
||
|
|
size = settings.center || settings.autoWidth || settings.dotsData
|
||
|
|
? 1 : settings.dotsEach || settings.items;
|
||
|
|
|
||
|
|
if (settings.slideBy !== 'page') {
|
||
|
|
settings.slideBy = Math.min(settings.slideBy, settings.items);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (settings.dots || settings.slideBy == 'page') {
|
||
|
|
this._pages = [];
|
||
|
|
|
||
|
|
for (i = lower, j = 0, k = 0; i < upper; i++) {
|
||
|
|
if (j >= size || j === 0) {
|
||
|
|
this._pages.push({
|
||
|
|
start: Math.min(maximum, i - lower),
|
||
|
|
end: i - lower + size - 1
|
||
|
|
});
|
||
|
|
if (Math.min(maximum, i - lower) === maximum) {
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
j = 0, ++k;
|
||
|
|
}
|
||
|
|
j += this._core.mergers(this._core.relative(i));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Draws the user interface.
|
||
|
|
* @todo The option `dotsData` wont work.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
Navigation.prototype.draw = function() {
|
||
|
|
var difference,
|
||
|
|
settings = this._core.settings,
|
||
|
|
disabled = this._core.items().length <= settings.items,
|
||
|
|
index = this._core.relative(this._core.current()),
|
||
|
|
loop = settings.loop || settings.rewind;
|
||
|
|
|
||
|
|
this._controls.$relative.toggleClass('disabled', !settings.nav || disabled);
|
||
|
|
|
||
|
|
if (settings.nav) {
|
||
|
|
this._controls.$previous.toggleClass('disabled', !loop && index <= this._core.minimum(true));
|
||
|
|
this._controls.$next.toggleClass('disabled', !loop && index >= this._core.maximum(true));
|
||
|
|
}
|
||
|
|
|
||
|
|
this._controls.$absolute.toggleClass('disabled', !settings.dots || disabled);
|
||
|
|
|
||
|
|
if (settings.dots) {
|
||
|
|
difference = this._pages.length - this._controls.$absolute.children().length;
|
||
|
|
|
||
|
|
if (settings.dotsData && difference !== 0) {
|
||
|
|
this._controls.$absolute.html(this._templates.join(''));
|
||
|
|
} else if (difference > 0) {
|
||
|
|
this._controls.$absolute.append(new Array(difference + 1).join(this._templates[0]));
|
||
|
|
} else if (difference < 0) {
|
||
|
|
this._controls.$absolute.children().slice(difference).remove();
|
||
|
|
}
|
||
|
|
|
||
|
|
this._controls.$absolute.find('.active').removeClass('active');
|
||
|
|
this._controls.$absolute.children().eq($.inArray(this.current(), this._pages)).addClass('active');
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Extends event data.
|
||
|
|
* @protected
|
||
|
|
* @param {Event} event - The event object which gets thrown.
|
||
|
|
*/
|
||
|
|
Navigation.prototype.onTrigger = function(event) {
|
||
|
|
var settings = this._core.settings;
|
||
|
|
|
||
|
|
event.page = {
|
||
|
|
index: $.inArray(this.current(), this._pages),
|
||
|
|
count: this._pages.length,
|
||
|
|
size: settings && (settings.center || settings.autoWidth || settings.dotsData
|
||
|
|
? 1 : settings.dotsEach || settings.items)
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the current page position of the carousel.
|
||
|
|
* @protected
|
||
|
|
* @returns {Number}
|
||
|
|
*/
|
||
|
|
Navigation.prototype.current = function() {
|
||
|
|
var current = this._core.relative(this._core.current());
|
||
|
|
return $.grep(this._pages, $.proxy(function(page, index) {
|
||
|
|
return page.start <= current && page.end >= current;
|
||
|
|
}, this)).pop();
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the current succesor/predecessor position.
|
||
|
|
* @protected
|
||
|
|
* @returns {Number}
|
||
|
|
*/
|
||
|
|
Navigation.prototype.getPosition = function(successor) {
|
||
|
|
var position, length,
|
||
|
|
settings = this._core.settings;
|
||
|
|
|
||
|
|
if (settings.slideBy == 'page') {
|
||
|
|
position = $.inArray(this.current(), this._pages);
|
||
|
|
length = this._pages.length;
|
||
|
|
successor ? ++position : --position;
|
||
|
|
position = this._pages[((position % length) + length) % length].start;
|
||
|
|
} else {
|
||
|
|
position = this._core.relative(this._core.current());
|
||
|
|
length = this._core.items().length;
|
||
|
|
successor ? position += settings.slideBy : position -= settings.slideBy;
|
||
|
|
}
|
||
|
|
|
||
|
|
return position;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Slides to the next item or page.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [speed=false] - The time in milliseconds for the transition.
|
||
|
|
*/
|
||
|
|
Navigation.prototype.next = function(speed) {
|
||
|
|
$.proxy(this._overrides.to, this._core)(this.getPosition(true), speed);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Slides to the previous item or page.
|
||
|
|
* @public
|
||
|
|
* @param {Number} [speed=false] - The time in milliseconds for the transition.
|
||
|
|
*/
|
||
|
|
Navigation.prototype.prev = function(speed) {
|
||
|
|
$.proxy(this._overrides.to, this._core)(this.getPosition(false), speed);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Slides to the specified item or page.
|
||
|
|
* @public
|
||
|
|
* @param {Number} position - The position of the item or page.
|
||
|
|
* @param {Number} [speed] - The time in milliseconds for the transition.
|
||
|
|
* @param {Boolean} [standard=false] - Whether to use the standard behaviour or not.
|
||
|
|
*/
|
||
|
|
Navigation.prototype.to = function(position, speed, standard) {
|
||
|
|
var length;
|
||
|
|
|
||
|
|
if (!standard && this._pages.length) {
|
||
|
|
length = this._pages.length;
|
||
|
|
$.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed);
|
||
|
|
} else {
|
||
|
|
$.proxy(this._overrides.to, this._core)(position, speed);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Hash Plugin
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Artus Kolanowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the hash plugin.
|
||
|
|
* @class The Hash Plugin
|
||
|
|
* @param {Owl} carousel - The Owl Carousel
|
||
|
|
*/
|
||
|
|
var Hash = function(carousel) {
|
||
|
|
/**
|
||
|
|
* Reference to the core.
|
||
|
|
* @protected
|
||
|
|
* @type {Owl}
|
||
|
|
*/
|
||
|
|
this._core = carousel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Hash index for the items.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._hashes = {};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The carousel element.
|
||
|
|
* @type {jQuery}
|
||
|
|
*/
|
||
|
|
this.$element = this._core.$element;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* All event handlers.
|
||
|
|
* @protected
|
||
|
|
* @type {Object}
|
||
|
|
*/
|
||
|
|
this._handlers = {
|
||
|
|
'initialized.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && this._core.settings.startPosition === 'URLHash') {
|
||
|
|
$(window).trigger('hashchange.owl.navigation');
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'prepared.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace) {
|
||
|
|
var hash = $(e.content).find('[data-hash]').addBack('[data-hash]').attr('data-hash');
|
||
|
|
|
||
|
|
if (!hash) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._hashes[hash] = e.content;
|
||
|
|
}
|
||
|
|
}, this),
|
||
|
|
'changed.owl.carousel': $.proxy(function(e) {
|
||
|
|
if (e.namespace && e.property.name === 'position') {
|
||
|
|
var current = this._core.items(this._core.relative(this._core.current())),
|
||
|
|
hash = $.map(this._hashes, function(item, hash) {
|
||
|
|
return item === current ? hash : null;
|
||
|
|
}).join();
|
||
|
|
|
||
|
|
if (!hash || window.location.hash.slice(1) === hash) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
window.location.hash = hash;
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
// set default options
|
||
|
|
this._core.options = $.extend({}, Hash.Defaults, this._core.options);
|
||
|
|
|
||
|
|
// register the event handlers
|
||
|
|
this.$element.on(this._handlers);
|
||
|
|
|
||
|
|
// register event listener for hash navigation
|
||
|
|
$(window).on('hashchange.owl.navigation', $.proxy(function(e) {
|
||
|
|
var hash = window.location.hash.substring(1),
|
||
|
|
items = this._core.$stage.children(),
|
||
|
|
position = this._hashes[hash] && items.index(this._hashes[hash]);
|
||
|
|
|
||
|
|
if (position === undefined || position === this._core.current()) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._core.to(this._core.relative(position), false, true);
|
||
|
|
}, this));
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default options.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Hash.Defaults = {
|
||
|
|
URLhashListener: false
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys the plugin.
|
||
|
|
* @public
|
||
|
|
*/
|
||
|
|
Hash.prototype.destroy = function() {
|
||
|
|
var handler, property;
|
||
|
|
|
||
|
|
$(window).off('hashchange.owl.navigation');
|
||
|
|
|
||
|
|
for (handler in this._handlers) {
|
||
|
|
this._core.$element.off(handler, this._handlers[handler]);
|
||
|
|
}
|
||
|
|
for (property in Object.getOwnPropertyNames(this)) {
|
||
|
|
typeof this[property] != 'function' && (this[property] = null);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$.fn.owlCarousel.Constructor.Plugins.Hash = Hash;
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Support Plugin
|
||
|
|
*
|
||
|
|
* @version 2.3.4
|
||
|
|
* @author Vivid Planet Software GmbH
|
||
|
|
* @author Artus Kolanowski
|
||
|
|
* @author David Deutsch
|
||
|
|
* @license The MIT License (MIT)
|
||
|
|
*/
|
||
|
|
;(function($, window, document, undefined) {
|
||
|
|
|
||
|
|
var style = $('<support>').get(0).style,
|
||
|
|
prefixes = 'Webkit Moz O ms'.split(' '),
|
||
|
|
events = {
|
||
|
|
transition: {
|
||
|
|
end: {
|
||
|
|
WebkitTransition: 'webkitTransitionEnd',
|
||
|
|
MozTransition: 'transitionend',
|
||
|
|
OTransition: 'oTransitionEnd',
|
||
|
|
transition: 'transitionend'
|
||
|
|
}
|
||
|
|
},
|
||
|
|
animation: {
|
||
|
|
end: {
|
||
|
|
WebkitAnimation: 'webkitAnimationEnd',
|
||
|
|
MozAnimation: 'animationend',
|
||
|
|
OAnimation: 'oAnimationEnd',
|
||
|
|
animation: 'animationend'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
tests = {
|
||
|
|
csstransforms: function() {
|
||
|
|
return !!test('transform');
|
||
|
|
},
|
||
|
|
csstransforms3d: function() {
|
||
|
|
return !!test('perspective');
|
||
|
|
},
|
||
|
|
csstransitions: function() {
|
||
|
|
return !!test('transition');
|
||
|
|
},
|
||
|
|
cssanimations: function() {
|
||
|
|
return !!test('animation');
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
function test(property, prefixed) {
|
||
|
|
var result = false,
|
||
|
|
upper = property.charAt(0).toUpperCase() + property.slice(1);
|
||
|
|
|
||
|
|
$.each((property + ' ' + prefixes.join(upper + ' ') + upper).split(' '), function(i, property) {
|
||
|
|
if (style[property] !== undefined) {
|
||
|
|
result = prefixed ? property : true;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
function prefixed(property) {
|
||
|
|
return test(property, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (tests.csstransitions()) {
|
||
|
|
/* jshint -W053 */
|
||
|
|
$.support.transition = new String(prefixed('transition'))
|
||
|
|
$.support.transition.end = events.transition.end[ $.support.transition ];
|
||
|
|
}
|
||
|
|
|
||
|
|
if (tests.cssanimations()) {
|
||
|
|
/* jshint -W053 */
|
||
|
|
$.support.animation = new String(prefixed('animation'))
|
||
|
|
$.support.animation.end = events.animation.end[ $.support.animation ];
|
||
|
|
}
|
||
|
|
|
||
|
|
if (tests.csstransforms()) {
|
||
|
|
/* jshint -W053 */
|
||
|
|
$.support.transform = new String(prefixed('transform'));
|
||
|
|
$.support.transform3d = tests.csstransforms3d();
|
||
|
|
}
|
||
|
|
|
||
|
|
})(window.Zepto || window.jQuery, window, document);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$(document).ready(function() {
|
||
|
|
$('.slidecontent').find('.slidecontent_content_container').hide().end().find('.slidecontent_headline').click(function() {
|
||
|
|
var currClass = $(this).attr('class').split(' ')[0];
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
// JavaScript Document
|
||
|
|
|
||
|
|
$(document).ready(function(){
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$('#a80').owlCarousel({
|
||
|
|
loop: false,
|
||
|
|
margin: 0,
|
||
|
|
nav: false,
|
||
|
|
items: 1,
|
||
|
|
dots: true,
|
||
|
|
dotsSpeed: 1000,
|
||
|
|
responsiveClass: true,
|
||
|
|
center: false,
|
||
|
|
responsiveRefreshRate: true
|
||
|
|
});
|
||
|
|
|
||
|
|
$('.owl-three').owlCarousel({
|
||
|
|
items: 4,
|
||
|
|
margin: 0,
|
||
|
|
nav: true,
|
||
|
|
responsive : {
|
||
|
|
0 : {
|
||
|
|
items: 1
|
||
|
|
},
|
||
|
|
768 : {
|
||
|
|
items: 2
|
||
|
|
},
|
||
|
|
960 : {
|
||
|
|
items: 3
|
||
|
|
},
|
||
|
|
1400 : {
|
||
|
|
items: 4
|
||
|
|
},
|
||
|
|
1600 : {
|
||
|
|
items: 4
|
||
|
|
},
|
||
|
|
1920 : {
|
||
|
|
items: 4
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
$('.owl-two').owlCarousel({
|
||
|
|
items: 3,
|
||
|
|
margin: 0,
|
||
|
|
nav: true,
|
||
|
|
responsive : {
|
||
|
|
0 : {
|
||
|
|
items: 1
|
||
|
|
},
|
||
|
|
768 : {
|
||
|
|
items: 2
|
||
|
|
},
|
||
|
|
960 : {
|
||
|
|
items: 2
|
||
|
|
},
|
||
|
|
1400 : {
|
||
|
|
items: 3
|
||
|
|
},
|
||
|
|
1600 : {
|
||
|
|
items: 3
|
||
|
|
},
|
||
|
|
1920 : {
|
||
|
|
items: 3
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/*!
|
||
|
|
* Datepicker for Bootstrap v1.6.4 (https://github.com/eternicode/bootstrap-datepicker)
|
||
|
|
*
|
||
|
|
* Copyright 2012 Stefan Petre
|
||
|
|
* Improvements by Andrew Rowls
|
||
|
|
* Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||
|
|
*/(function(factory){
|
||
|
|
if (typeof define === "function" && define.amd) {
|
||
|
|
define(["jquery"], factory);
|
||
|
|
} else if (typeof exports === 'object') {
|
||
|
|
factory(require('jquery'));
|
||
|
|
} else {
|
||
|
|
factory(jQuery);
|
||
|
|
}
|
||
|
|
}(function($, undefined){
|
||
|
|
|
||
|
|
function UTCDate(){
|
||
|
|
return new Date(Date.UTC.apply(Date, arguments));
|
||
|
|
}
|
||
|
|
function UTCToday(){
|
||
|
|
var today = new Date();
|
||
|
|
return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
|
||
|
|
}
|
||
|
|
function isUTCEquals(date1, date2) {
|
||
|
|
return (
|
||
|
|
date1.getUTCFullYear() === date2.getUTCFullYear() &&
|
||
|
|
date1.getUTCMonth() === date2.getUTCMonth() &&
|
||
|
|
date1.getUTCDate() === date2.getUTCDate()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
function alias(method){
|
||
|
|
return function(){
|
||
|
|
return this[method].apply(this, arguments);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function isValidDate(d) {
|
||
|
|
return d && !isNaN(d.getTime());
|
||
|
|
}
|
||
|
|
|
||
|
|
var DateArray = (function(){
|
||
|
|
var extras = {
|
||
|
|
get: function(i){
|
||
|
|
return this.slice(i)[0];
|
||
|
|
},
|
||
|
|
contains: function(d){
|
||
|
|
// Array.indexOf is not cross-browser;
|
||
|
|
// $.inArray doesn't work with Dates
|
||
|
|
var val = d && d.valueOf();
|
||
|
|
for (var i=0, l=this.length; i < l; i++)
|
||
|
|
if (this[i].valueOf() === val)
|
||
|
|
return i;
|
||
|
|
return -1;
|
||
|
|
},
|
||
|
|
remove: function(i){
|
||
|
|
this.splice(i,1);
|
||
|
|
},
|
||
|
|
replace: function(new_array){
|
||
|
|
if (!new_array)
|
||
|
|
return;
|
||
|
|
if (!$.isArray(new_array))
|
||
|
|
new_array = [new_array];
|
||
|
|
this.clear();
|
||
|
|
this.push.apply(this, new_array);
|
||
|
|
},
|
||
|
|
clear: function(){
|
||
|
|
this.length = 0;
|
||
|
|
},
|
||
|
|
copy: function(){
|
||
|
|
var a = new DateArray();
|
||
|
|
a.replace(this);
|
||
|
|
return a;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
return function(){
|
||
|
|
var a = [];
|
||
|
|
a.push.apply(a, arguments);
|
||
|
|
$.extend(a, extras);
|
||
|
|
return a;
|
||
|
|
};
|
||
|
|
})();
|
||
|
|
|
||
|
|
|
||
|
|
// Picker object
|
||
|
|
|
||
|
|
var Datepicker = function(element, options){
|
||
|
|
$(element).data('datepicker', this);
|
||
|
|
this._process_options(options);
|
||
|
|
|
||
|
|
this.dates = new DateArray();
|
||
|
|
this.viewDate = this.o.defaultViewDate;
|
||
|
|
this.focusDate = null;
|
||
|
|
|
||
|
|
this.element = $(element);
|
||
|
|
this.isInput = this.element.is('input');
|
||
|
|
this.inputField = this.isInput ? this.element : this.element.find('input');
|
||
|
|
this.component = this.element.hasClass('date') ? this.element.find('.add-on, .input-group-addon, .btn') : false;
|
||
|
|
this.hasInput = this.component && this.inputField.length;
|
||
|
|
if (this.component && this.component.length === 0)
|
||
|
|
this.component = false;
|
||
|
|
this.isInline = !this.component && this.element.is('div');
|
||
|
|
|
||
|
|
this.picker = $(DPGlobal.template);
|
||
|
|
|
||
|
|
// Checking templates and inserting
|
||
|
|
if (this._check_template(this.o.templates.leftArrow)) {
|
||
|
|
this.picker.find('.prev').html(this.o.templates.leftArrow);
|
||
|
|
}
|
||
|
|
if (this._check_template(this.o.templates.rightArrow)) {
|
||
|
|
this.picker.find('.next').html(this.o.templates.rightArrow);
|
||
|
|
}
|
||
|
|
|
||
|
|
this._buildEvents();
|
||
|
|
this._attachEvents();
|
||
|
|
|
||
|
|
if (this.isInline){
|
||
|
|
this.picker.addClass('datepicker-inline').appendTo(this.element);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.picker.addClass('datepicker-dropdown dropdown-menu');
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.o.rtl){
|
||
|
|
this.picker.addClass('datepicker-rtl');
|
||
|
|
}
|
||
|
|
|
||
|
|
this.viewMode = this.o.startView;
|
||
|
|
|
||
|
|
if (this.o.calendarWeeks)
|
||
|
|
this.picker.find('thead .datepicker-title, tfoot .today, tfoot .clear')
|
||
|
|
.attr('colspan', function(i, val){
|
||
|
|
return parseInt(val) + 1;
|
||
|
|
});
|
||
|
|
|
||
|
|
this._allow_update = false;
|
||
|
|
|
||
|
|
this.setStartDate(this._o.startDate);
|
||
|
|
this.setEndDate(this._o.endDate);
|
||
|
|
this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
|
||
|
|
this.setDaysOfWeekHighlighted(this.o.daysOfWeekHighlighted);
|
||
|
|
this.setDatesDisabled(this.o.datesDisabled);
|
||
|
|
|
||
|
|
this.fillDow();
|
||
|
|
this.fillMonths();
|
||
|
|
|
||
|
|
this._allow_update = true;
|
||
|
|
|
||
|
|
this.update();
|
||
|
|
this.showMode();
|
||
|
|
|
||
|
|
if (this.isInline){
|
||
|
|
this.show();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
Datepicker.prototype = {
|
||
|
|
constructor: Datepicker,
|
||
|
|
|
||
|
|
_resolveViewName: function(view, default_value){
|
||
|
|
if (view === 0 || view === 'days' || view === 'month') {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
if (view === 1 || view === 'months' || view === 'year') {
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
if (view === 2 || view === 'years' || view === 'decade') {
|
||
|
|
return 2;
|
||
|
|
}
|
||
|
|
if (view === 3 || view === 'decades' || view === 'century') {
|
||
|
|
return 3;
|
||
|
|
}
|
||
|
|
if (view === 4 || view === 'centuries' || view === 'millennium') {
|
||
|
|
return 4;
|
||
|
|
}
|
||
|
|
return default_value === undefined ? false : default_value;
|
||
|
|
},
|
||
|
|
|
||
|
|
_check_template: function(tmp){
|
||
|
|
try {
|
||
|
|
// If empty
|
||
|
|
if (tmp === undefined || tmp === "") {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
// If no html, everything ok
|
||
|
|
if ((tmp.match(/[<>]/g) || []).length <= 0) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
// Checking if html is fine
|
||
|
|
var jDom = $(tmp);
|
||
|
|
return jDom.length > 0;
|
||
|
|
}
|
||
|
|
catch (ex) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
_process_options: function(opts){
|
||
|
|
// Store raw options for reference
|
||
|
|
this._o = $.extend({}, this._o, opts);
|
||
|
|
// Processed options
|
||
|
|
var o = this.o = $.extend({}, this._o);
|
||
|
|
|
||
|
|
// Check if "de-DE" style date is available, if not language should
|
||
|
|
// fallback to 2 letter code eg "de"
|
||
|
|
var lang = o.language;
|
||
|
|
if (!dates[lang]){
|
||
|
|
lang = lang.split('-')[0];
|
||
|
|
if (!dates[lang])
|
||
|
|
lang = defaults.language;
|
||
|
|
}
|
||
|
|
o.language = lang;
|
||
|
|
|
||
|
|
// Retrieve view index from any aliases
|
||
|
|
o.startView = this._resolveViewName(o.startView, 0);
|
||
|
|
o.minViewMode = this._resolveViewName(o.minViewMode, 0);
|
||
|
|
o.maxViewMode = this._resolveViewName(o.maxViewMode, 4);
|
||
|
|
|
||
|
|
// Check that the start view is between min and max
|
||
|
|
o.startView = Math.min(o.startView, o.maxViewMode);
|
||
|
|
o.startView = Math.max(o.startView, o.minViewMode);
|
||
|
|
|
||
|
|
// true, false, or Number > 0
|
||
|
|
if (o.multidate !== true){
|
||
|
|
o.multidate = Number(o.multidate) || false;
|
||
|
|
if (o.multidate !== false)
|
||
|
|
o.multidate = Math.max(0, o.multidate);
|
||
|
|
}
|
||
|
|
o.multidateSeparator = String(o.multidateSeparator);
|
||
|
|
|
||
|
|
o.weekStart %= 7;
|
||
|
|
o.weekEnd = (o.weekStart + 6) % 7;
|
||
|
|
|
||
|
|
var format = DPGlobal.parseFormat(o.format);
|
||
|
|
if (o.startDate !== -Infinity){
|
||
|
|
if (!!o.startDate){
|
||
|
|
if (o.startDate instanceof Date)
|
||
|
|
o.startDate = this._local_to_utc(this._zero_time(o.startDate));
|
||
|
|
else
|
||
|
|
o.startDate = DPGlobal.parseDate(o.startDate, format, o.language, o.assumeNearbyYear);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
o.startDate = -Infinity;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (o.endDate !== Infinity){
|
||
|
|
if (!!o.endDate){
|
||
|
|
if (o.endDate instanceof Date)
|
||
|
|
o.endDate = this._local_to_utc(this._zero_time(o.endDate));
|
||
|
|
else
|
||
|
|
o.endDate = DPGlobal.parseDate(o.endDate, format, o.language, o.assumeNearbyYear);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
o.endDate = Infinity;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
o.daysOfWeekDisabled = o.daysOfWeekDisabled||[];
|
||
|
|
if (!$.isArray(o.daysOfWeekDisabled))
|
||
|
|
o.daysOfWeekDisabled = o.daysOfWeekDisabled.split(/[,\s]*/);
|
||
|
|
o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function(d){
|
||
|
|
return parseInt(d, 10);
|
||
|
|
});
|
||
|
|
|
||
|
|
o.daysOfWeekHighlighted = o.daysOfWeekHighlighted||[];
|
||
|
|
if (!$.isArray(o.daysOfWeekHighlighted))
|
||
|
|
o.daysOfWeekHighlighted = o.daysOfWeekHighlighted.split(/[,\s]*/);
|
||
|
|
o.daysOfWeekHighlighted = $.map(o.daysOfWeekHighlighted, function(d){
|
||
|
|
return parseInt(d, 10);
|
||
|
|
});
|
||
|
|
|
||
|
|
o.datesDisabled = o.datesDisabled||[];
|
||
|
|
if (!$.isArray(o.datesDisabled)) {
|
||
|
|
o.datesDisabled = [
|
||
|
|
o.datesDisabled
|
||
|
|
];
|
||
|
|
}
|
||
|
|
o.datesDisabled = $.map(o.datesDisabled,function(d){
|
||
|
|
return DPGlobal.parseDate(d, format, o.language, o.assumeNearbyYear);
|
||
|
|
});
|
||
|
|
|
||
|
|
var plc = String(o.orientation).toLowerCase().split(/\s+/g),
|
||
|
|
_plc = o.orientation.toLowerCase();
|
||
|
|
plc = $.grep(plc, function(word){
|
||
|
|
return /^auto|left|right|top|bottom$/.test(word);
|
||
|
|
});
|
||
|
|
o.orientation = {x: 'auto', y: 'auto'};
|
||
|
|
if (!_plc || _plc === 'auto')
|
||
|
|
; // no action
|
||
|
|
else if (plc.length === 1){
|
||
|
|
switch (plc[0]){
|
||
|
|
case 'top':
|
||
|
|
case 'bottom':
|
||
|
|
o.orientation.y = plc[0];
|
||
|
|
break;
|
||
|
|
case 'left':
|
||
|
|
case 'right':
|
||
|
|
o.orientation.x = plc[0];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
_plc = $.grep(plc, function(word){
|
||
|
|
return /^left|right$/.test(word);
|
||
|
|
});
|
||
|
|
o.orientation.x = _plc[0] || 'auto';
|
||
|
|
|
||
|
|
_plc = $.grep(plc, function(word){
|
||
|
|
return /^top|bottom$/.test(word);
|
||
|
|
});
|
||
|
|
o.orientation.y = _plc[0] || 'auto';
|
||
|
|
}
|
||
|
|
if (o.defaultViewDate) {
|
||
|
|
var year = o.defaultViewDate.year || new Date().getFullYear();
|
||
|
|
var month = o.defaultViewDate.month || 0;
|
||
|
|
var day = o.defaultViewDate.day || 1;
|
||
|
|
o.defaultViewDate = UTCDate(year, month, day);
|
||
|
|
} else {
|
||
|
|
o.defaultViewDate = UTCToday();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
_events: [],
|
||
|
|
_secondaryEvents: [],
|
||
|
|
_applyEvents: function(evs){
|
||
|
|
for (var i=0, el, ch, ev; i < evs.length; i++){
|
||
|
|
el = evs[i][0];
|
||
|
|
if (evs[i].length === 2){
|
||
|
|
ch = undefined;
|
||
|
|
ev = evs[i][1];
|
||
|
|
}
|
||
|
|
else if (evs[i].length === 3){
|
||
|
|
ch = evs[i][1];
|
||
|
|
ev = evs[i][2];
|
||
|
|
}
|
||
|
|
el.on(ev, ch);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
_unapplyEvents: function(evs){
|
||
|
|
for (var i=0, el, ev, ch; i < evs.length; i++){
|
||
|
|
el = evs[i][0];
|
||
|
|
if (evs[i].length === 2){
|
||
|
|
ch = undefined;
|
||
|
|
ev = evs[i][1];
|
||
|
|
}
|
||
|
|
else if (evs[i].length === 3){
|
||
|
|
ch = evs[i][1];
|
||
|
|
ev = evs[i][2];
|
||
|
|
}
|
||
|
|
el.off(ev, ch);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
_buildEvents: function(){
|
||
|
|
var events = {
|
||
|
|
keyup: $.proxy(function(e){
|
||
|
|
if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
|
||
|
|
this.update();
|
||
|
|
}, this),
|
||
|
|
keydown: $.proxy(this.keydown, this),
|
||
|
|
paste: $.proxy(this.paste, this)
|
||
|
|
};
|
||
|
|
|
||
|
|
if (this.o.showOnFocus === true) {
|
||
|
|
events.focus = $.proxy(this.show, this);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.isInput) { // single input
|
||
|
|
this._events = [
|
||
|
|
[this.element, events]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
else if (this.component && this.hasInput) { // component: input + button
|
||
|
|
this._events = [
|
||
|
|
// For components that are not readonly, allow keyboard nav
|
||
|
|
[this.inputField, events],
|
||
|
|
[this.component, {
|
||
|
|
click: $.proxy(this.show, this)
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this._events = [
|
||
|
|
[this.element, {
|
||
|
|
click: $.proxy(this.show, this),
|
||
|
|
keydown: $.proxy(this.keydown, this)
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
this._events.push(
|
||
|
|
// Component: listen for blur on element descendants
|
||
|
|
[this.element, '*', {
|
||
|
|
blur: $.proxy(function(e){
|
||
|
|
this._focused_from = e.target;
|
||
|
|
}, this)
|
||
|
|
}],
|
||
|
|
// Input: listen for blur on element
|
||
|
|
[this.element, {
|
||
|
|
blur: $.proxy(function(e){
|
||
|
|
this._focused_from = e.target;
|
||
|
|
}, this)
|
||
|
|
}]
|
||
|
|
);
|
||
|
|
|
||
|
|
if (this.o.immediateUpdates) {
|
||
|
|
// Trigger input updates immediately on changed year/month
|
||
|
|
this._events.push([this.element, {
|
||
|
|
'changeYear changeMonth': $.proxy(function(e){
|
||
|
|
this.update(e.date);
|
||
|
|
}, this)
|
||
|
|
}]);
|
||
|
|
}
|
||
|
|
|
||
|
|
this._secondaryEvents = [
|
||
|
|
[this.picker, {
|
||
|
|
click: $.proxy(this.click, this)
|
||
|
|
}],
|
||
|
|
[$(window), {
|
||
|
|
resize: $.proxy(this.place, this)
|
||
|
|
}],
|
||
|
|
[$(document), {
|
||
|
|
mousedown: $.proxy(function(e){
|
||
|
|
// Clicked outside the datepicker, hide it
|
||
|
|
if (!(
|
||
|
|
this.element.is(e.target) ||
|
||
|
|
this.element.find(e.target).length ||
|
||
|
|
this.picker.is(e.target) ||
|
||
|
|
this.picker.find(e.target).length ||
|
||
|
|
this.isInline
|
||
|
|
)){
|
||
|
|
this.hide();
|
||
|
|
}
|
||
|
|
}, this)
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
},
|
||
|
|
_attachEvents: function(){
|
||
|
|
this._detachEvents();
|
||
|
|
this._applyEvents(this._events);
|
||
|
|
},
|
||
|
|
_detachEvents: function(){
|
||
|
|
this._unapplyEvents(this._events);
|
||
|
|
},
|
||
|
|
_attachSecondaryEvents: function(){
|
||
|
|
this._detachSecondaryEvents();
|
||
|
|
this._applyEvents(this._secondaryEvents);
|
||
|
|
},
|
||
|
|
_detachSecondaryEvents: function(){
|
||
|
|
this._unapplyEvents(this._secondaryEvents);
|
||
|
|
},
|
||
|
|
_trigger: function(event, altdate){
|
||
|
|
var date = altdate || this.dates.get(-1),
|
||
|
|
local_date = this._utc_to_local(date);
|
||
|
|
|
||
|
|
this.element.trigger({
|
||
|
|
type: event,
|
||
|
|
date: local_date,
|
||
|
|
dates: $.map(this.dates, this._utc_to_local),
|
||
|
|
format: $.proxy(function(ix, format){
|
||
|
|
if (arguments.length === 0){
|
||
|
|
ix = this.dates.length - 1;
|
||
|
|
format = this.o.format;
|
||
|
|
}
|
||
|
|
else if (typeof ix === 'string'){
|
||
|
|
format = ix;
|
||
|
|
ix = this.dates.length - 1;
|
||
|
|
}
|
||
|
|
format = format || this.o.format;
|
||
|
|
var date = this.dates.get(ix);
|
||
|
|
return DPGlobal.formatDate(date, format, this.o.language);
|
||
|
|
}, this)
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
show: function(){
|
||
|
|
if (this.inputField.prop('disabled') || (this.inputField.prop('readonly') && this.o.enableOnReadonly === false))
|
||
|
|
return;
|
||
|
|
if (!this.isInline)
|
||
|
|
this.picker.appendTo(this.o.container);
|
||
|
|
this.place();
|
||
|
|
this.picker.show();
|
||
|
|
this._attachSecondaryEvents();
|
||
|
|
this._trigger('show');
|
||
|
|
if ((window.navigator.msMaxTouchPoints || 'ontouchstart' in document) && this.o.disableTouchKeyboard) {
|
||
|
|
$(this.element).blur();
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
hide: function(){
|
||
|
|
if (this.isInline || !this.picker.is(':visible'))
|
||
|
|
return this;
|
||
|
|
this.focusDate = null;
|
||
|
|
this.picker.hide().detach();
|
||
|
|
this._detachSecondaryEvents();
|
||
|
|
this.viewMode = this.o.startView;
|
||
|
|
this.showMode();
|
||
|
|
|
||
|
|
if (this.o.forceParse && this.inputField.val())
|
||
|
|
this.setValue();
|
||
|
|
this._trigger('hide');
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
destroy: function(){
|
||
|
|
this.hide();
|
||
|
|
this._detachEvents();
|
||
|
|
this._detachSecondaryEvents();
|
||
|
|
this.picker.remove();
|
||
|
|
delete this.element.data().datepicker;
|
||
|
|
if (!this.isInput){
|
||
|
|
delete this.element.data().date;
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
paste: function(evt){
|
||
|
|
var dateString;
|
||
|
|
if (evt.originalEvent.clipboardData && evt.originalEvent.clipboardData.types
|
||
|
|
&& $.inArray('text/plain', evt.originalEvent.clipboardData.types) !== -1) {
|
||
|
|
dateString = evt.originalEvent.clipboardData.getData('text/plain');
|
||
|
|
}
|
||
|
|
else if (window.clipboardData) {
|
||
|
|
dateString = window.clipboardData.getData('Text');
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.setDate(dateString);
|
||
|
|
this.update();
|
||
|
|
evt.preventDefault();
|
||
|
|
},
|
||
|
|
|
||
|
|
_utc_to_local: function(utc){
|
||
|
|
return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
|
||
|
|
},
|
||
|
|
_local_to_utc: function(local){
|
||
|
|
return local && new Date(local.getTime() - (local.getTimezoneOffset()*60000));
|
||
|
|
},
|
||
|
|
_zero_time: function(local){
|
||
|
|
return local && new Date(local.getFullYear(), local.getMonth(), local.getDate());
|
||
|
|
},
|
||
|
|
_zero_utc_time: function(utc){
|
||
|
|
return utc && new Date(Date.UTC(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate()));
|
||
|
|
},
|
||
|
|
|
||
|
|
getDates: function(){
|
||
|
|
return $.map(this.dates, this._utc_to_local);
|
||
|
|
},
|
||
|
|
|
||
|
|
getUTCDates: function(){
|
||
|
|
return $.map(this.dates, function(d){
|
||
|
|
return new Date(d);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
getDate: function(){
|
||
|
|
return this._utc_to_local(this.getUTCDate());
|
||
|
|
},
|
||
|
|
|
||
|
|
getUTCDate: function(){
|
||
|
|
var selected_date = this.dates.get(-1);
|
||
|
|
if (typeof selected_date !== 'undefined') {
|
||
|
|
return new Date(selected_date);
|
||
|
|
} else {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
clearDates: function(){
|
||
|
|
if (this.inputField) {
|
||
|
|
this.inputField.val('');
|
||
|
|
}
|
||
|
|
|
||
|
|
this.update();
|
||
|
|
this._trigger('changeDate');
|
||
|
|
|
||
|
|
if (this.o.autoclose) {
|
||
|
|
this.hide();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
setDates: function(){
|
||
|
|
var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
|
||
|
|
this.update.apply(this, args);
|
||
|
|
this._trigger('changeDate');
|
||
|
|
this.setValue();
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
setUTCDates: function(){
|
||
|
|
var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
|
||
|
|
this.update.apply(this, $.map(args, this._utc_to_local));
|
||
|
|
this._trigger('changeDate');
|
||
|
|
this.setValue();
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
setDate: alias('setDates'),
|
||
|
|
setUTCDate: alias('setUTCDates'),
|
||
|
|
remove: alias('destroy'),
|
||
|
|
|
||
|
|
setValue: function(){
|
||
|
|
var formatted = this.getFormattedDate();
|
||
|
|
this.inputField.val(formatted);
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
getFormattedDate: function(format){
|
||
|
|
if (format === undefined)
|
||
|
|
format = this.o.format;
|
||
|
|
|
||
|
|
var lang = this.o.language;
|
||
|
|
return $.map(this.dates, function(d){
|
||
|
|
return DPGlobal.formatDate(d, format, lang);
|
||
|
|
}).join(this.o.multidateSeparator);
|
||
|
|
},
|
||
|
|
|
||
|
|
getStartDate: function(){
|
||
|
|
return this.o.startDate;
|
||
|
|
},
|
||
|
|
|
||
|
|
setStartDate: function(startDate){
|
||
|
|
this._process_options({startDate: startDate});
|
||
|
|
this.update();
|
||
|
|
this.updateNavArrows();
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
getEndDate: function(){
|
||
|
|
return this.o.endDate;
|
||
|
|
},
|
||
|
|
|
||
|
|
setEndDate: function(endDate){
|
||
|
|
this._process_options({endDate: endDate});
|
||
|
|
this.update();
|
||
|
|
this.updateNavArrows();
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
setDaysOfWeekDisabled: function(daysOfWeekDisabled){
|
||
|
|
this._process_options({daysOfWeekDisabled: daysOfWeekDisabled});
|
||
|
|
this.update();
|
||
|
|
this.updateNavArrows();
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
setDaysOfWeekHighlighted: function(daysOfWeekHighlighted){
|
||
|
|
this._process_options({daysOfWeekHighlighted: daysOfWeekHighlighted});
|
||
|
|
this.update();
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
setDatesDisabled: function(datesDisabled){
|
||
|
|
this._process_options({datesDisabled: datesDisabled});
|
||
|
|
this.update();
|
||
|
|
this.updateNavArrows();
|
||
|
|
},
|
||
|
|
|
||
|
|
place: function(){
|
||
|
|
if (this.isInline)
|
||
|
|
return this;
|
||
|
|
var calendarWidth = this.picker.outerWidth(),
|
||
|
|
calendarHeight = this.picker.outerHeight(),
|
||
|
|
visualPadding = 10,
|
||
|
|
container = $(this.o.container),
|
||
|
|
windowWidth = container.width(),
|
||
|
|
scrollTop = this.o.container === 'body' ? $(document).scrollTop() : container.scrollTop(),
|
||
|
|
appendOffset = container.offset();
|
||
|
|
|
||
|
|
var parentsZindex = [];
|
||
|
|
this.element.parents().each(function(){
|
||
|
|
var itemZIndex = $(this).css('z-index');
|
||
|
|
if (itemZIndex !== 'auto' && itemZIndex !== 0) parentsZindex.push(parseInt(itemZIndex));
|
||
|
|
});
|
||
|
|
var zIndex = Math.max.apply(Math, parentsZindex) + this.o.zIndexOffset;
|
||
|
|
var offset = this.component ? this.component.parent().offset() : this.element.offset();
|
||
|
|
var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
|
||
|
|
var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
|
||
|
|
var left = offset.left - appendOffset.left,
|
||
|
|
top = offset.top - appendOffset.top;
|
||
|
|
|
||
|
|
if (this.o.container !== 'body') {
|
||
|
|
top += scrollTop;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.picker.removeClass(
|
||
|
|
'datepicker-orient-top datepicker-orient-bottom '+
|
||
|
|
'datepicker-orient-right datepicker-orient-left'
|
||
|
|
);
|
||
|
|
|
||
|
|
if (this.o.orientation.x !== 'auto'){
|
||
|
|
this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
|
||
|
|
if (this.o.orientation.x === 'right')
|
||
|
|
left -= calendarWidth - width;
|
||
|
|
}
|
||
|
|
// auto x orientation is best-placement: if it crosses a window
|
||
|
|
// edge, fudge it sideways
|
||
|
|
else {
|
||
|
|
if (offset.left < 0) {
|
||
|
|
// component is outside the window on the left side. Move it into visible range
|
||
|
|
this.picker.addClass('datepicker-orient-left');
|
||
|
|
left -= offset.left - visualPadding;
|
||
|
|
} else if (left + calendarWidth > windowWidth) {
|
||
|
|
// the calendar passes the widow right edge. Align it to component right side
|
||
|
|
this.picker.addClass('datepicker-orient-right');
|
||
|
|
left += width - calendarWidth;
|
||
|
|
} else {
|
||
|
|
// Default to left
|
||
|
|
this.picker.addClass('datepicker-orient-left');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// auto y orientation is best-situation: top or bottom, no fudging,
|
||
|
|
// decision based on which shows more of the calendar
|
||
|
|
var yorient = this.o.orientation.y,
|
||
|
|
top_overflow;
|
||
|
|
if (yorient === 'auto'){
|
||
|
|
top_overflow = -scrollTop + top - calendarHeight;
|
||
|
|
yorient = top_overflow < 0 ? 'bottom' : 'top';
|
||
|
|
}
|
||
|
|
|
||
|
|
this.picker.addClass('datepicker-orient-' + yorient);
|
||
|
|
if (yorient === 'top')
|
||
|
|
top -= calendarHeight + parseInt(this.picker.css('padding-top'));
|
||
|
|
else
|
||
|
|
top += height;
|
||
|
|
|
||
|
|
if (this.o.rtl) {
|
||
|
|
var right = windowWidth - (left + width);
|
||
|
|
this.picker.css({
|
||
|
|
top: top,
|
||
|
|
right: right,
|
||
|
|
zIndex: zIndex
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
this.picker.css({
|
||
|
|
top: top,
|
||
|
|
left: left,
|
||
|
|
zIndex: zIndex
|
||
|
|
});
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
_allow_update: true,
|
||
|
|
update: function(){
|
||
|
|
if (!this._allow_update)
|
||
|
|
return this;
|
||
|
|
|
||
|
|
var oldDates = this.dates.copy(),
|
||
|
|
dates = [],
|
||
|
|
fromArgs = false;
|
||
|
|
if (arguments.length){
|
||
|
|
$.each(arguments, $.proxy(function(i, date){
|
||
|
|
if (date instanceof Date)
|
||
|
|
date = this._local_to_utc(date);
|
||
|
|
dates.push(date);
|
||
|
|
}, this));
|
||
|
|
fromArgs = true;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
dates = this.isInput
|
||
|
|
? this.element.val()
|
||
|
|
: this.element.data('date') || this.inputField.val();
|
||
|
|
if (dates && this.o.multidate)
|
||
|
|
dates = dates.split(this.o.multidateSeparator);
|
||
|
|
else
|
||
|
|
dates = [dates];
|
||
|
|
delete this.element.data().date;
|
||
|
|
}
|
||
|
|
|
||
|
|
dates = $.map(dates, $.proxy(function(date){
|
||
|
|
return DPGlobal.parseDate(date, this.o.format, this.o.language, this.o.assumeNearbyYear);
|
||
|
|
}, this));
|
||
|
|
dates = $.grep(dates, $.proxy(function(date){
|
||
|
|
return (
|
||
|
|
!this.dateWithinRange(date) ||
|
||
|
|
!date
|
||
|
|
);
|
||
|
|
}, this), true);
|
||
|
|
this.dates.replace(dates);
|
||
|
|
|
||
|
|
if (this.dates.length)
|
||
|
|
this.viewDate = new Date(this.dates.get(-1));
|
||
|
|
else if (this.viewDate < this.o.startDate)
|
||
|
|
this.viewDate = new Date(this.o.startDate);
|
||
|
|
else if (this.viewDate > this.o.endDate)
|
||
|
|
this.viewDate = new Date(this.o.endDate);
|
||
|
|
else
|
||
|
|
this.viewDate = this.o.defaultViewDate;
|
||
|
|
|
||
|
|
if (fromArgs){
|
||
|
|
// setting date by clicking
|
||
|
|
this.setValue();
|
||
|
|
}
|
||
|
|
else if (dates.length){
|
||
|
|
// setting date by typing
|
||
|
|
if (String(oldDates) !== String(this.dates))
|
||
|
|
this._trigger('changeDate');
|
||
|
|
}
|
||
|
|
if (!this.dates.length && oldDates.length)
|
||
|
|
this._trigger('clearDate');
|
||
|
|
|
||
|
|
this.fill();
|
||
|
|
this.element.change();
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
fillDow: function(){
|
||
|
|
var dowCnt = this.o.weekStart,
|
||
|
|
html = '<tr>';
|
||
|
|
if (this.o.calendarWeeks){
|
||
|
|
this.picker.find('.datepicker-days .datepicker-switch')
|
||
|
|
.attr('colspan', function(i, val){
|
||
|
|
return parseInt(val) + 1;
|
||
|
|
});
|
||
|
|
html += '<th class="cw"> </th>';
|
||
|
|
}
|
||
|
|
while (dowCnt < this.o.weekStart + 7){
|
||
|
|
html += '<th class="dow';
|
||
|
|
if ($.inArray(dowCnt, this.o.daysOfWeekDisabled) > -1)
|
||
|
|
html += ' disabled';
|
||
|
|
html += '">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
|
||
|
|
}
|
||
|
|
html += '</tr>';
|
||
|
|
this.picker.find('.datepicker-days thead').append(html);
|
||
|
|
},
|
||
|
|
|
||
|
|
fillMonths: function(){
|
||
|
|
var localDate = this._utc_to_local(this.viewDate);
|
||
|
|
var html = '',
|
||
|
|
i = 0;
|
||
|
|
while (i < 12){
|
||
|
|
var focused = localDate && localDate.getMonth() === i ? ' focused' : '';
|
||
|
|
html += '<span class="month' + focused + '">' + dates[this.o.language].monthsShort[i++]+'</span>';
|
||
|
|
}
|
||
|
|
this.picker.find('.datepicker-months td').html(html);
|
||
|
|
},
|
||
|
|
|
||
|
|
setRange: function(range){
|
||
|
|
if (!range || !range.length)
|
||
|
|
delete this.range;
|
||
|
|
else
|
||
|
|
this.range = $.map(range, function(d){
|
||
|
|
return d.valueOf();
|
||
|
|
});
|
||
|
|
this.fill();
|
||
|
|
},
|
||
|
|
|
||
|
|
getClassNames: function(date){
|
||
|
|
var cls = [],
|
||
|
|
year = this.viewDate.getUTCFullYear(),
|
||
|
|
month = this.viewDate.getUTCMonth(),
|
||
|
|
today = new Date();
|
||
|
|
if (date.getUTCFullYear() < year || (date.getUTCFullYear() === year && date.getUTCMonth() < month)){
|
||
|
|
cls.push('old');
|
||
|
|
}
|
||
|
|
else if (date.getUTCFullYear() > year || (date.getUTCFullYear() === year && date.getUTCMonth() > month)){
|
||
|
|
cls.push('new');
|
||
|
|
}
|
||
|
|
if (this.focusDate && date.valueOf() === this.focusDate.valueOf())
|
||
|
|
cls.push('focused');
|
||
|
|
// Compare internal UTC date with local today, not UTC today
|
||
|
|
if (this.o.todayHighlight &&
|
||
|
|
date.getUTCFullYear() === today.getFullYear() &&
|
||
|
|
date.getUTCMonth() === today.getMonth() &&
|
||
|
|
date.getUTCDate() === today.getDate()){
|
||
|
|
cls.push('today');
|
||
|
|
}
|
||
|
|
if (this.dates.contains(date) !== -1)
|
||
|
|
cls.push('active');
|
||
|
|
if (!this.dateWithinRange(date)){
|
||
|
|
cls.push('disabled');
|
||
|
|
}
|
||
|
|
if (this.dateIsDisabled(date)){
|
||
|
|
cls.push('disabled', 'disabled-date');
|
||
|
|
}
|
||
|
|
if ($.inArray(date.getUTCDay(), this.o.daysOfWeekHighlighted) !== -1){
|
||
|
|
cls.push('highlighted');
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.range){
|
||
|
|
if (date > this.range[0] && date < this.range[this.range.length-1]){
|
||
|
|
cls.push('range');
|
||
|
|
}
|
||
|
|
if ($.inArray(date.valueOf(), this.range) !== -1){
|
||
|
|
cls.push('selected');
|
||
|
|
}
|
||
|
|
if (date.valueOf() === this.range[0]){
|
||
|
|
cls.push('range-start');
|
||
|
|
}
|
||
|
|
if (date.valueOf() === this.range[this.range.length-1]){
|
||
|
|
cls.push('range-end');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return cls;
|
||
|
|
},
|
||
|
|
|
||
|
|
_fill_yearsView: function(selector, cssClass, factor, step, currentYear, startYear, endYear, callback){
|
||
|
|
var html, view, year, steps, startStep, endStep, thisYear, i, classes, tooltip, before;
|
||
|
|
|
||
|
|
html = '';
|
||
|
|
view = this.picker.find(selector);
|
||
|
|
year = parseInt(currentYear / factor, 10) * factor;
|
||
|
|
startStep = parseInt(startYear / step, 10) * step;
|
||
|
|
endStep = parseInt(endYear / step, 10) * step;
|
||
|
|
steps = $.map(this.dates, function(d){
|
||
|
|
return parseInt(d.getUTCFullYear() / step, 10) * step;
|
||
|
|
});
|
||
|
|
|
||
|
|
view.find('.datepicker-switch').text(year + '-' + (year + step * 9));
|
||
|
|
|
||
|
|
thisYear = year - step;
|
||
|
|
for (i = -1; i < 11; i += 1) {
|
||
|
|
classes = [cssClass];
|
||
|
|
tooltip = null;
|
||
|
|
|
||
|
|
if (i === -1) {
|
||
|
|
classes.push('old');
|
||
|
|
} else if (i === 10) {
|
||
|
|
classes.push('new');
|
||
|
|
}
|
||
|
|
if ($.inArray(thisYear, steps) !== -1) {
|
||
|
|
classes.push('active');
|
||
|
|
}
|
||
|
|
if (thisYear < startStep || thisYear > endStep) {
|
||
|
|
classes.push('disabled');
|
||
|
|
}
|
||
|
|
if (thisYear === this.viewDate.getFullYear()) {
|
||
|
|
classes.push('focused');
|
||
|
|
}
|
||
|
|
|
||
|
|
if (callback !== $.noop) {
|
||
|
|
before = callback(new Date(thisYear, 0, 1));
|
||
|
|
if (before === undefined) {
|
||
|
|
before = {};
|
||
|
|
} else if (typeof(before) === 'boolean') {
|
||
|
|
before = {enabled: before};
|
||
|
|
} else if (typeof(before) === 'string') {
|
||
|
|
before = {classes: before};
|
||
|
|
}
|
||
|
|
if (before.enabled === false) {
|
||
|
|
classes.push('disabled');
|
||
|
|
}
|
||
|
|
if (before.classes) {
|
||
|
|
classes = classes.concat(before.classes.split(/\s+/));
|
||
|
|
}
|
||
|
|
if (before.tooltip) {
|
||
|
|
tooltip = before.tooltip;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
html += '<span class="' + classes.join(' ') + '"' + (tooltip ? ' title="' + tooltip + '"' : '') + '>' + thisYear + '</span>';
|
||
|
|
thisYear += step;
|
||
|
|
}
|
||
|
|
view.find('td').html(html);
|
||
|
|
},
|
||
|
|
|
||
|
|
fill: function(){
|
||
|
|
var d = new Date(this.viewDate),
|
||
|
|
year = d.getUTCFullYear(),
|
||
|
|
month = d.getUTCMonth(),
|
||
|
|
startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
|
||
|
|
startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
|
||
|
|
endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
|
||
|
|
endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
|
||
|
|
todaytxt = dates[this.o.language].today || dates['en'].today || '',
|
||
|
|
cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
|
||
|
|
titleFormat = dates[this.o.language].titleFormat || dates['en'].titleFormat,
|
||
|
|
tooltip,
|
||
|
|
before;
|
||
|
|
if (isNaN(year) || isNaN(month))
|
||
|
|
return;
|
||
|
|
this.picker.find('.datepicker-days .datepicker-switch')
|
||
|
|
.text(DPGlobal.formatDate(d, titleFormat, this.o.language));
|
||
|
|
this.picker.find('tfoot .today')
|
||
|
|
.text(todaytxt)
|
||
|
|
.toggle(this.o.todayBtn !== false);
|
||
|
|
this.picker.find('tfoot .clear')
|
||
|
|
.text(cleartxt)
|
||
|
|
.toggle(this.o.clearBtn !== false);
|
||
|
|
this.picker.find('thead .datepicker-title')
|
||
|
|
.text(this.o.title)
|
||
|
|
.toggle(this.o.title !== '');
|
||
|
|
this.updateNavArrows();
|
||
|
|
this.fillMonths();
|
||
|
|
var prevMonth = UTCDate(year, month-1, 28),
|
||
|
|
day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
|
||
|
|
prevMonth.setUTCDate(day);
|
||
|
|
prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
|
||
|
|
var nextMonth = new Date(prevMonth);
|
||
|
|
if (prevMonth.getUTCFullYear() < 100){
|
||
|
|
nextMonth.setUTCFullYear(prevMonth.getUTCFullYear());
|
||
|
|
}
|
||
|
|
nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
|
||
|
|
nextMonth = nextMonth.valueOf();
|
||
|
|
var html = [];
|
||
|
|
var clsName;
|
||
|
|
while (prevMonth.valueOf() < nextMonth){
|
||
|
|
if (prevMonth.getUTCDay() === this.o.weekStart){
|
||
|
|
html.push('<tr>');
|
||
|
|
if (this.o.calendarWeeks){
|
||
|
|
// ISO 8601: First week contains first thursday.
|
||
|
|
// ISO also states week starts on Monday, but we can be more abstract here.
|
||
|
|
var
|
||
|
|
// Start of current week: based on weekstart/current date
|
||
|
|
ws = new Date(+prevMonth + (this.o.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
|
||
|
|
// Thursday of this week
|
||
|
|
th = new Date(Number(ws) + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
|
||
|
|
// First Thursday of year, year from thursday
|
||
|
|
yth = new Date(Number(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
|
||
|
|
// Calendar week: ms between thursdays, div ms per day, div 7 days
|
||
|
|
calWeek = (th - yth) / 864e5 / 7 + 1;
|
||
|
|
html.push('<td class="cw">'+ calWeek +'</td>');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
clsName = this.getClassNames(prevMonth);
|
||
|
|
clsName.push('day');
|
||
|
|
|
||
|
|
if (this.o.beforeShowDay !== $.noop){
|
||
|
|
before = this.o.beforeShowDay(this._utc_to_local(prevMonth));
|
||
|
|
if (before === undefined)
|
||
|
|
before = {};
|
||
|
|
else if (typeof(before) === 'boolean')
|
||
|
|
before = {enabled: before};
|
||
|
|
else if (typeof(before) === 'string')
|
||
|
|
before = {classes: before};
|
||
|
|
if (before.enabled === false)
|
||
|
|
clsName.push('disabled');
|
||
|
|
if (before.classes)
|
||
|
|
clsName = clsName.concat(before.classes.split(/\s+/));
|
||
|
|
if (before.tooltip)
|
||
|
|
tooltip = before.tooltip;
|
||
|
|
}
|
||
|
|
|
||
|
|
//Check if uniqueSort exists (supported by jquery >=1.12 and >=2.2)
|
||
|
|
//Fallback to unique function for older jquery versions
|
||
|
|
if ($.isFunction($.uniqueSort)) {
|
||
|
|
clsName = $.uniqueSort(clsName);
|
||
|
|
} else {
|
||
|
|
clsName = $.unique(clsName);
|
||
|
|
}
|
||
|
|
|
||
|
|
html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>'+prevMonth.getUTCDate() + '</td>');
|
||
|
|
tooltip = null;
|
||
|
|
if (prevMonth.getUTCDay() === this.o.weekEnd){
|
||
|
|
html.push('</tr>');
|
||
|
|
}
|
||
|
|
prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
|
||
|
|
}
|
||
|
|
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
||
|
|
|
||
|
|
var monthsTitle = dates[this.o.language].monthsTitle || dates['en'].monthsTitle || 'Months';
|
||
|
|
var months = this.picker.find('.datepicker-months')
|
||
|
|
.find('.datepicker-switch')
|
||
|
|
.text(this.o.maxViewMode < 2 ? monthsTitle : year)
|
||
|
|
.end()
|
||
|
|
.find('span').removeClass('active');
|
||
|
|
|
||
|
|
$.each(this.dates, function(i, d){
|
||
|
|
if (d.getUTCFullYear() === year)
|
||
|
|
months.eq(d.getUTCMonth()).addClass('active');
|
||
|
|
});
|
||
|
|
|
||
|
|
if (year < startYear || year > endYear){
|
||
|
|
months.addClass('disabled');
|
||
|
|
}
|
||
|
|
if (year === startYear){
|
||
|
|
months.slice(0, startMonth).addClass('disabled');
|
||
|
|
}
|
||
|
|
if (year === endYear){
|
||
|
|
months.slice(endMonth+1).addClass('disabled');
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.o.beforeShowMonth !== $.noop){
|
||
|
|
var that = this;
|
||
|
|
$.each(months, function(i, month){
|
||
|
|
var moDate = new Date(year, i, 1);
|
||
|
|
var before = that.o.beforeShowMonth(moDate);
|
||
|
|
if (before === undefined)
|
||
|
|
before = {};
|
||
|
|
else if (typeof(before) === 'boolean')
|
||
|
|
before = {enabled: before};
|
||
|
|
else if (typeof(before) === 'string')
|
||
|
|
before = {classes: before};
|
||
|
|
if (before.enabled === false && !$(month).hasClass('disabled'))
|
||
|
|
$(month).addClass('disabled');
|
||
|
|
if (before.classes)
|
||
|
|
$(month).addClass(before.classes);
|
||
|
|
if (before.tooltip)
|
||
|
|
$(month).prop('title', before.tooltip);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// Generating decade/years picker
|
||
|
|
this._fill_yearsView(
|
||
|
|
'.datepicker-years',
|
||
|
|
'year',
|
||
|
|
10,
|
||
|
|
1,
|
||
|
|
year,
|
||
|
|
startYear,
|
||
|
|
endYear,
|
||
|
|
this.o.beforeShowYear
|
||
|
|
);
|
||
|
|
|
||
|
|
// Generating century/decades picker
|
||
|
|
this._fill_yearsView(
|
||
|
|
'.datepicker-decades',
|
||
|
|
'decade',
|
||
|
|
100,
|
||
|
|
10,
|
||
|
|
year,
|
||
|
|
startYear,
|
||
|
|
endYear,
|
||
|
|
this.o.beforeShowDecade
|
||
|
|
);
|
||
|
|
|
||
|
|
// Generating millennium/centuries picker
|
||
|
|
this._fill_yearsView(
|
||
|
|
'.datepicker-centuries',
|
||
|
|
'century',
|
||
|
|
1000,
|
||
|
|
100,
|
||
|
|
year,
|
||
|
|
startYear,
|
||
|
|
endYear,
|
||
|
|
this.o.beforeShowCentury
|
||
|
|
);
|
||
|
|
},
|
||
|
|
|
||
|
|
updateNavArrows: function(){
|
||
|
|
if (!this._allow_update)
|
||
|
|
return;
|
||
|
|
|
||
|
|
var d = new Date(this.viewDate),
|
||
|
|
year = d.getUTCFullYear(),
|
||
|
|
month = d.getUTCMonth();
|
||
|
|
switch (this.viewMode){
|
||
|
|
case 0:
|
||
|
|
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() && month <= this.o.startDate.getUTCMonth()){
|
||
|
|
this.picker.find('.prev').css({visibility: 'hidden'});
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.picker.find('.prev').css({visibility: 'visible'});
|
||
|
|
}
|
||
|
|
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() && month >= this.o.endDate.getUTCMonth()){
|
||
|
|
this.picker.find('.next').css({visibility: 'hidden'});
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.picker.find('.next').css({visibility: 'visible'});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case 1:
|
||
|
|
case 2:
|
||
|
|
case 3:
|
||
|
|
case 4:
|
||
|
|
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() || this.o.maxViewMode < 2){
|
||
|
|
this.picker.find('.prev').css({visibility: 'hidden'});
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.picker.find('.prev').css({visibility: 'visible'});
|
||
|
|
}
|
||
|
|
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() || this.o.maxViewMode < 2){
|
||
|
|
this.picker.find('.next').css({visibility: 'hidden'});
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.picker.find('.next').css({visibility: 'visible'});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
click: function(e){
|
||
|
|
e.preventDefault();
|
||
|
|
e.stopPropagation();
|
||
|
|
|
||
|
|
var target, dir, day, year, month, monthChanged, yearChanged;
|
||
|
|
target = $(e.target);
|
||
|
|
|
||
|
|
// Clicked on the switch
|
||
|
|
if (target.hasClass('datepicker-switch')){
|
||
|
|
this.showMode(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Clicked on prev or next
|
||
|
|
var navArrow = target.closest('.prev, .next');
|
||
|
|
if (navArrow.length > 0) {
|
||
|
|
dir = DPGlobal.modes[this.viewMode].navStep * (navArrow.hasClass('prev') ? -1 : 1);
|
||
|
|
if (this.viewMode === 0){
|
||
|
|
this.viewDate = this.moveMonth(this.viewDate, dir);
|
||
|
|
this._trigger('changeMonth', this.viewDate);
|
||
|
|
} else {
|
||
|
|
this.viewDate = this.moveYear(this.viewDate, dir);
|
||
|
|
if (this.viewMode === 1){
|
||
|
|
this._trigger('changeYear', this.viewDate);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.fill();
|
||
|
|
}
|
||
|
|
|
||
|
|
// Clicked on today button
|
||
|
|
if (target.hasClass('today') && !target.hasClass('day')){
|
||
|
|
this.showMode(-2);
|
||
|
|
this._setDate(UTCToday(), this.o.todayBtn === 'linked' ? null : 'view');
|
||
|
|
}
|
||
|
|
|
||
|
|
// Clicked on clear button
|
||
|
|
if (target.hasClass('clear')){
|
||
|
|
this.clearDates();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!target.hasClass('disabled')){
|
||
|
|
// Clicked on a day
|
||
|
|
if (target.hasClass('day')){
|
||
|
|
day = parseInt(target.text(), 10) || 1;
|
||
|
|
year = this.viewDate.getUTCFullYear();
|
||
|
|
month = this.viewDate.getUTCMonth();
|
||
|
|
|
||
|
|
// From last month
|
||
|
|
if (target.hasClass('old')){
|
||
|
|
if (month === 0) {
|
||
|
|
month = 11;
|
||
|
|
year = year - 1;
|
||
|
|
monthChanged = true;
|
||
|
|
yearChanged = true;
|
||
|
|
} else {
|
||
|
|
month = month - 1;
|
||
|
|
monthChanged = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// From next month
|
||
|
|
if (target.hasClass('new')) {
|
||
|
|
if (month === 11){
|
||
|
|
month = 0;
|
||
|
|
year = year + 1;
|
||
|
|
monthChanged = true;
|
||
|
|
yearChanged = true;
|
||
|
|
} else {
|
||
|
|
month = month + 1;
|
||
|
|
monthChanged = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this._setDate(UTCDate(year, month, day));
|
||
|
|
if (yearChanged) {
|
||
|
|
this._trigger('changeYear', this.viewDate);
|
||
|
|
}
|
||
|
|
if (monthChanged) {
|
||
|
|
this._trigger('changeMonth', this.viewDate);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Clicked on a month
|
||
|
|
if (target.hasClass('month')) {
|
||
|
|
this.viewDate.setUTCDate(1);
|
||
|
|
day = 1;
|
||
|
|
month = target.parent().find('span').index(target);
|
||
|
|
year = this.viewDate.getUTCFullYear();
|
||
|
|
this.viewDate.setUTCMonth(month);
|
||
|
|
this._trigger('changeMonth', this.viewDate);
|
||
|
|
if (this.o.minViewMode === 1){
|
||
|
|
this._setDate(UTCDate(year, month, day));
|
||
|
|
this.showMode();
|
||
|
|
} else {
|
||
|
|
this.showMode(-1);
|
||
|
|
}
|
||
|
|
this.fill();
|
||
|
|
}
|
||
|
|
|
||
|
|
// Clicked on a year
|
||
|
|
if (target.hasClass('year')
|
||
|
|
|| target.hasClass('decade')
|
||
|
|
|| target.hasClass('century')) {
|
||
|
|
this.viewDate.setUTCDate(1);
|
||
|
|
|
||
|
|
day = 1;
|
||
|
|
month = 0;
|
||
|
|
year = parseInt(target.text(), 10)||0;
|
||
|
|
this.viewDate.setUTCFullYear(year);
|
||
|
|
|
||
|
|
if (target.hasClass('year')){
|
||
|
|
this._trigger('changeYear', this.viewDate);
|
||
|
|
if (this.o.minViewMode === 2){
|
||
|
|
this._setDate(UTCDate(year, month, day));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (target.hasClass('decade')){
|
||
|
|
this._trigger('changeDecade', this.viewDate);
|
||
|
|
if (this.o.minViewMode === 3){
|
||
|
|
this._setDate(UTCDate(year, month, day));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (target.hasClass('century')){
|
||
|
|
this._trigger('changeCentury', this.viewDate);
|
||
|
|
if (this.o.minViewMode === 4){
|
||
|
|
this._setDate(UTCDate(year, month, day));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.showMode(-1);
|
||
|
|
this.fill();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this.picker.is(':visible') && this._focused_from){
|
||
|
|
$(this._focused_from).focus();
|
||
|
|
}
|
||
|
|
delete this._focused_from;
|
||
|
|
},
|
||
|
|
|
||
|
|
_toggle_multidate: function(date){
|
||
|
|
var ix = this.dates.contains(date);
|
||
|
|
if (!date){
|
||
|
|
this.dates.clear();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (ix !== -1){
|
||
|
|
if (this.o.multidate === true || this.o.multidate > 1 || this.o.toggleActive){
|
||
|
|
this.dates.remove(ix);
|
||
|
|
}
|
||
|
|
} else if (this.o.multidate === false) {
|
||
|
|
this.dates.clear();
|
||
|
|
this.dates.push(date);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.dates.push(date);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (typeof this.o.multidate === 'number')
|
||
|
|
while (this.dates.length > this.o.multidate)
|
||
|
|
this.dates.remove(0);
|
||
|
|
},
|
||
|
|
|
||
|
|
_setDate: function(date, which){
|
||
|
|
if (!which || which === 'date')
|
||
|
|
this._toggle_multidate(date && new Date(date));
|
||
|
|
if (!which || which === 'view')
|
||
|
|
this.viewDate = date && new Date(date);
|
||
|
|
|
||
|
|
this.fill();
|
||
|
|
this.setValue();
|
||
|
|
if (!which || which !== 'view') {
|
||
|
|
this._trigger('changeDate');
|
||
|
|
}
|
||
|
|
if (this.inputField){
|
||
|
|
this.inputField.change();
|
||
|
|
}
|
||
|
|
if (this.o.autoclose && (!which || which === 'date')){
|
||
|
|
this.hide();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
moveDay: function(date, dir){
|
||
|
|
var newDate = new Date(date);
|
||
|
|
newDate.setUTCDate(date.getUTCDate() + dir);
|
||
|
|
|
||
|
|
return newDate;
|
||
|
|
},
|
||
|
|
|
||
|
|
moveWeek: function(date, dir){
|
||
|
|
return this.moveDay(date, dir * 7);
|
||
|
|
},
|
||
|
|
|
||
|
|
moveMonth: function(date, dir){
|
||
|
|
if (!isValidDate(date))
|
||
|
|
return this.o.defaultViewDate;
|
||
|
|
if (!dir)
|
||
|
|
return date;
|
||
|
|
var new_date = new Date(date.valueOf()),
|
||
|
|
day = new_date.getUTCDate(),
|
||
|
|
month = new_date.getUTCMonth(),
|
||
|
|
mag = Math.abs(dir),
|
||
|
|
new_month, test;
|
||
|
|
dir = dir > 0 ? 1 : -1;
|
||
|
|
if (mag === 1){
|
||
|
|
test = dir === -1
|
||
|
|
// If going back one month, make sure month is not current month
|
||
|
|
// (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
|
||
|
|
? function(){
|
||
|
|
return new_date.getUTCMonth() === month;
|
||
|
|
}
|
||
|
|
// If going forward one month, make sure month is as expected
|
||
|
|
// (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
|
||
|
|
: function(){
|
||
|
|
return new_date.getUTCMonth() !== new_month;
|
||
|
|
};
|
||
|
|
new_month = month + dir;
|
||
|
|
new_date.setUTCMonth(new_month);
|
||
|
|
// Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
|
||
|
|
if (new_month < 0 || new_month > 11)
|
||
|
|
new_month = (new_month + 12) % 12;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
// For magnitudes >1, move one month at a time...
|
||
|
|
for (var i=0; i < mag; i++)
|
||
|
|
// ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
|
||
|
|
new_date = this.moveMonth(new_date, dir);
|
||
|
|
// ...then reset the day, keeping it in the new month
|
||
|
|
new_month = new_date.getUTCMonth();
|
||
|
|
new_date.setUTCDate(day);
|
||
|
|
test = function(){
|
||
|
|
return new_month !== new_date.getUTCMonth();
|
||
|
|
};
|
||
|
|
}
|
||
|
|
// Common date-resetting loop -- if date is beyond end of month, make it
|
||
|
|
// end of month
|
||
|
|
while (test()){
|
||
|
|
new_date.setUTCDate(--day);
|
||
|
|
new_date.setUTCMonth(new_month);
|
||
|
|
}
|
||
|
|
return new_date;
|
||
|
|
},
|
||
|
|
|
||
|
|
moveYear: function(date, dir){
|
||
|
|
return this.moveMonth(date, dir*12);
|
||
|
|
},
|
||
|
|
|
||
|
|
moveAvailableDate: function(date, dir, fn){
|
||
|
|
do {
|
||
|
|
date = this[fn](date, dir);
|
||
|
|
|
||
|
|
if (!this.dateWithinRange(date))
|
||
|
|
return false;
|
||
|
|
|
||
|
|
fn = 'moveDay';
|
||
|
|
}
|
||
|
|
while (this.dateIsDisabled(date));
|
||
|
|
|
||
|
|
return date;
|
||
|
|
},
|
||
|
|
|
||
|
|
weekOfDateIsDisabled: function(date){
|
||
|
|
return $.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1;
|
||
|
|
},
|
||
|
|
|
||
|
|
dateIsDisabled: function(date){
|
||
|
|
return (
|
||
|
|
this.weekOfDateIsDisabled(date) ||
|
||
|
|
$.grep(this.o.datesDisabled, function(d){
|
||
|
|
return isUTCEquals(date, d);
|
||
|
|
}).length > 0
|
||
|
|
);
|
||
|
|
},
|
||
|
|
|
||
|
|
dateWithinRange: function(date){
|
||
|
|
return date >= this.o.startDate && date <= this.o.endDate;
|
||
|
|
},
|
||
|
|
|
||
|
|
keydown: function(e){
|
||
|
|
if (!this.picker.is(':visible')){
|
||
|
|
if (e.keyCode === 40 || e.keyCode === 27) { // allow down to re-show picker
|
||
|
|
this.show();
|
||
|
|
e.stopPropagation();
|
||
|
|
}
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var dateChanged = false,
|
||
|
|
dir, newViewDate,
|
||
|
|
focusDate = this.focusDate || this.viewDate;
|
||
|
|
switch (e.keyCode){
|
||
|
|
case 27: // escape
|
||
|
|
if (this.focusDate){
|
||
|
|
this.focusDate = null;
|
||
|
|
this.viewDate = this.dates.get(-1) || this.viewDate;
|
||
|
|
this.fill();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
this.hide();
|
||
|
|
e.preventDefault();
|
||
|
|
e.stopPropagation();
|
||
|
|
break;
|
||
|
|
case 37: // left
|
||
|
|
case 38: // up
|
||
|
|
case 39: // right
|
||
|
|
case 40: // down
|
||
|
|
if (!this.o.keyboardNavigation || this.o.daysOfWeekDisabled.length === 7)
|
||
|
|
break;
|
||
|
|
dir = e.keyCode === 37 || e.keyCode === 38 ? -1 : 1;
|
||
|
|
if (this.viewMode === 0) {
|
||
|
|
if (e.ctrlKey){
|
||
|
|
newViewDate = this.moveAvailableDate(focusDate, dir, 'moveYear');
|
||
|
|
|
||
|
|
if (newViewDate)
|
||
|
|
this._trigger('changeYear', this.viewDate);
|
||
|
|
}
|
||
|
|
else if (e.shiftKey){
|
||
|
|
newViewDate = this.moveAvailableDate(focusDate, dir, 'moveMonth');
|
||
|
|
|
||
|
|
if (newViewDate)
|
||
|
|
this._trigger('changeMonth', this.viewDate);
|
||
|
|
}
|
||
|
|
else if (e.keyCode === 37 || e.keyCode === 39){
|
||
|
|
newViewDate = this.moveAvailableDate(focusDate, dir, 'moveDay');
|
||
|
|
}
|
||
|
|
else if (!this.weekOfDateIsDisabled(focusDate)){
|
||
|
|
newViewDate = this.moveAvailableDate(focusDate, dir, 'moveWeek');
|
||
|
|
}
|
||
|
|
} else if (this.viewMode === 1) {
|
||
|
|
if (e.keyCode === 38 || e.keyCode === 40) {
|
||
|
|
dir = dir * 4;
|
||
|
|
}
|
||
|
|
newViewDate = this.moveAvailableDate(focusDate, dir, 'moveMonth');
|
||
|
|
} else if (this.viewMode === 2) {
|
||
|
|
if (e.keyCode === 38 || e.keyCode === 40) {
|
||
|
|
dir = dir * 4;
|
||
|
|
}
|
||
|
|
newViewDate = this.moveAvailableDate(focusDate, dir, 'moveYear');
|
||
|
|
}
|
||
|
|
if (newViewDate){
|
||
|
|
this.focusDate = this.viewDate = newViewDate;
|
||
|
|
this.setValue();
|
||
|
|
this.fill();
|
||
|
|
e.preventDefault();
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case 13: // enter
|
||
|
|
if (!this.o.forceParse)
|
||
|
|
break;
|
||
|
|
focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
|
||
|
|
if (this.o.keyboardNavigation) {
|
||
|
|
this._toggle_multidate(focusDate);
|
||
|
|
dateChanged = true;
|
||
|
|
}
|
||
|
|
this.focusDate = null;
|
||
|
|
this.viewDate = this.dates.get(-1) || this.viewDate;
|
||
|
|
this.setValue();
|
||
|
|
this.fill();
|
||
|
|
if (this.picker.is(':visible')){
|
||
|
|
e.preventDefault();
|
||
|
|
e.stopPropagation();
|
||
|
|
if (this.o.autoclose)
|
||
|
|
this.hide();
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case 9: // tab
|
||
|
|
this.focusDate = null;
|
||
|
|
this.viewDate = this.dates.get(-1) || this.viewDate;
|
||
|
|
this.fill();
|
||
|
|
this.hide();
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
if (dateChanged){
|
||
|
|
if (this.dates.length)
|
||
|
|
this._trigger('changeDate');
|
||
|
|
else
|
||
|
|
this._trigger('clearDate');
|
||
|
|
if (this.inputField){
|
||
|
|
this.inputField.change();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
showMode: function(dir){
|
||
|
|
if (dir){
|
||
|
|
this.viewMode = Math.max(this.o.minViewMode, Math.min(this.o.maxViewMode, this.viewMode + dir));
|
||
|
|
}
|
||
|
|
this.picker
|
||
|
|
.children('div')
|
||
|
|
.hide()
|
||
|
|
.filter('.datepicker-' + DPGlobal.modes[this.viewMode].clsName)
|
||
|
|
.show();
|
||
|
|
this.updateNavArrows();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
var DateRangePicker = function(element, options){
|
||
|
|
$(element).data('datepicker', this);
|
||
|
|
this.element = $(element);
|
||
|
|
this.inputs = $.map(options.inputs, function(i){
|
||
|
|
return i.jquery ? i[0] : i;
|
||
|
|
});
|
||
|
|
delete options.inputs;
|
||
|
|
|
||
|
|
datepickerPlugin.call($(this.inputs), options)
|
||
|
|
.on('changeDate', $.proxy(this.dateUpdated, this));
|
||
|
|
|
||
|
|
this.pickers = $.map(this.inputs, function(i){
|
||
|
|
return $(i).data('datepicker');
|
||
|
|
});
|
||
|
|
this.updateDates();
|
||
|
|
};
|
||
|
|
DateRangePicker.prototype = {
|
||
|
|
updateDates: function(){
|
||
|
|
this.dates = $.map(this.pickers, function(i){
|
||
|
|
return i.getUTCDate();
|
||
|
|
});
|
||
|
|
this.updateRanges();
|
||
|
|
},
|
||
|
|
updateRanges: function(){
|
||
|
|
var range = $.map(this.dates, function(d){
|
||
|
|
return d.valueOf();
|
||
|
|
});
|
||
|
|
$.each(this.pickers, function(i, p){
|
||
|
|
p.setRange(range);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
dateUpdated: function(e){
|
||
|
|
// `this.updating` is a workaround for preventing infinite recursion
|
||
|
|
// between `changeDate` triggering and `setUTCDate` calling. Until
|
||
|
|
// there is a better mechanism.
|
||
|
|
if (this.updating)
|
||
|
|
return;
|
||
|
|
this.updating = true;
|
||
|
|
|
||
|
|
var dp = $(e.target).data('datepicker');
|
||
|
|
|
||
|
|
if (typeof(dp) === "undefined") {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
var new_date = dp.getUTCDate(),
|
||
|
|
i = $.inArray(e.target, this.inputs),
|
||
|
|
j = i - 1,
|
||
|
|
k = i + 1,
|
||
|
|
l = this.inputs.length;
|
||
|
|
if (i === -1)
|
||
|
|
return;
|
||
|
|
|
||
|
|
$.each(this.pickers, function(i, p){
|
||
|
|
if (!p.getUTCDate())
|
||
|
|
p.setUTCDate(new_date);
|
||
|
|
});
|
||
|
|
|
||
|
|
if (new_date < this.dates[j]){
|
||
|
|
// Date being moved earlier/left
|
||
|
|
while (j >= 0 && new_date < this.dates[j]){
|
||
|
|
this.pickers[j--].setUTCDate(new_date);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (new_date > this.dates[k]){
|
||
|
|
// Date being moved later/right
|
||
|
|
while (k < l && new_date > this.dates[k]){
|
||
|
|
this.pickers[k++].setUTCDate(new_date);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.updateDates();
|
||
|
|
|
||
|
|
delete this.updating;
|
||
|
|
},
|
||
|
|
remove: function(){
|
||
|
|
$.map(this.pickers, function(p){ p.remove(); });
|
||
|
|
delete this.element.data().datepicker;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
function opts_from_el(el, prefix){
|
||
|
|
// Derive options from element data-attrs
|
||
|
|
var data = $(el).data(),
|
||
|
|
out = {}, inkey,
|
||
|
|
replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])');
|
||
|
|
prefix = new RegExp('^' + prefix.toLowerCase());
|
||
|
|
function re_lower(_,a){
|
||
|
|
return a.toLowerCase();
|
||
|
|
}
|
||
|
|
for (var key in data)
|
||
|
|
if (prefix.test(key)){
|
||
|
|
inkey = key.replace(replace, re_lower);
|
||
|
|
out[inkey] = data[key];
|
||
|
|
}
|
||
|
|
return out;
|
||
|
|
}
|
||
|
|
|
||
|
|
function opts_from_locale(lang){
|
||
|
|
// Derive options from locale plugins
|
||
|
|
var out = {};
|
||
|
|
// Check if "de-DE" style date is available, if not language should
|
||
|
|
// fallback to 2 letter code eg "de"
|
||
|
|
if (!dates[lang]){
|
||
|
|
lang = lang.split('-')[0];
|
||
|
|
if (!dates[lang])
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var d = dates[lang];
|
||
|
|
$.each(locale_opts, function(i,k){
|
||
|
|
if (k in d)
|
||
|
|
out[k] = d[k];
|
||
|
|
});
|
||
|
|
return out;
|
||
|
|
}
|
||
|
|
|
||
|
|
var old = $.fn.datepicker;
|
||
|
|
var datepickerPlugin = function(option){
|
||
|
|
var args = Array.apply(null, arguments);
|
||
|
|
args.shift();
|
||
|
|
var internal_return;
|
||
|
|
this.each(function(){
|
||
|
|
var $this = $(this),
|
||
|
|
data = $this.data('datepicker'),
|
||
|
|
options = typeof option === 'object' && option;
|
||
|
|
if (!data){
|
||
|
|
var elopts = opts_from_el(this, 'date'),
|
||
|
|
// Preliminary otions
|
||
|
|
xopts = $.extend({}, defaults, elopts, options),
|
||
|
|
locopts = opts_from_locale(xopts.language),
|
||
|
|
// Options priority: js args, data-attrs, locales, defaults
|
||
|
|
opts = $.extend({}, defaults, locopts, elopts, options);
|
||
|
|
if ($this.hasClass('input-daterange') || opts.inputs){
|
||
|
|
$.extend(opts, {
|
||
|
|
inputs: opts.inputs || $this.find('input').toArray()
|
||
|
|
});
|
||
|
|
data = new DateRangePicker(this, opts);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
data = new Datepicker(this, opts);
|
||
|
|
}
|
||
|
|
$this.data('datepicker', data);
|
||
|
|
}
|
||
|
|
if (typeof option === 'string' && typeof data[option] === 'function'){
|
||
|
|
internal_return = data[option].apply(data, args);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
if (
|
||
|
|
internal_return === undefined ||
|
||
|
|
internal_return instanceof Datepicker ||
|
||
|
|
internal_return instanceof DateRangePicker
|
||
|
|
)
|
||
|
|
return this;
|
||
|
|
|
||
|
|
if (this.length > 1)
|
||
|
|
throw new Error('Using only allowed for the collection of a single element (' + option + ' function)');
|
||
|
|
else
|
||
|
|
return internal_return;
|
||
|
|
};
|
||
|
|
$.fn.datepicker = datepickerPlugin;
|
||
|
|
|
||
|
|
var defaults = $.fn.datepicker.defaults = {
|
||
|
|
assumeNearbyYear: false,
|
||
|
|
autoclose: false,
|
||
|
|
beforeShowDay: $.noop,
|
||
|
|
beforeShowMonth: $.noop,
|
||
|
|
beforeShowYear: $.noop,
|
||
|
|
beforeShowDecade: $.noop,
|
||
|
|
beforeShowCentury: $.noop,
|
||
|
|
calendarWeeks: false,
|
||
|
|
clearBtn: false,
|
||
|
|
toggleActive: false,
|
||
|
|
daysOfWeekDisabled: [],
|
||
|
|
daysOfWeekHighlighted: [],
|
||
|
|
datesDisabled: [],
|
||
|
|
endDate: Infinity,
|
||
|
|
forceParse: true,
|
||
|
|
format: 'mm/dd/yyyy',
|
||
|
|
keyboardNavigation: true,
|
||
|
|
language: 'en',
|
||
|
|
minViewMode: 0,
|
||
|
|
maxViewMode: 4,
|
||
|
|
multidate: false,
|
||
|
|
multidateSeparator: ',',
|
||
|
|
orientation: "auto",
|
||
|
|
rtl: false,
|
||
|
|
startDate: -Infinity,
|
||
|
|
startView: 0,
|
||
|
|
todayBtn: false,
|
||
|
|
todayHighlight: false,
|
||
|
|
weekStart: 0,
|
||
|
|
disableTouchKeyboard: false,
|
||
|
|
enableOnReadonly: true,
|
||
|
|
showOnFocus: true,
|
||
|
|
zIndexOffset: 10,
|
||
|
|
container: 'body',
|
||
|
|
immediateUpdates: false,
|
||
|
|
title: '',
|
||
|
|
templates: {
|
||
|
|
leftArrow: '«',
|
||
|
|
rightArrow: '»'
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var locale_opts = $.fn.datepicker.locale_opts = [
|
||
|
|
'format',
|
||
|
|
'rtl',
|
||
|
|
'weekStart'
|
||
|
|
];
|
||
|
|
$.fn.datepicker.Constructor = Datepicker;
|
||
|
|
var dates = $.fn.datepicker.dates = {
|
||
|
|
en: {
|
||
|
|
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
||
|
|
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
||
|
|
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
||
|
|
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||
|
|
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||
|
|
today: "Today",
|
||
|
|
clear: "Clear",
|
||
|
|
titleFormat: "MM yyyy"
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
var DPGlobal = {
|
||
|
|
modes: [
|
||
|
|
{
|
||
|
|
clsName: 'days',
|
||
|
|
navFnc: 'Month',
|
||
|
|
navStep: 1
|
||
|
|
},
|
||
|
|
{
|
||
|
|
clsName: 'months',
|
||
|
|
navFnc: 'FullYear',
|
||
|
|
navStep: 1
|
||
|
|
},
|
||
|
|
{
|
||
|
|
clsName: 'years',
|
||
|
|
navFnc: 'FullYear',
|
||
|
|
navStep: 10
|
||
|
|
},
|
||
|
|
{
|
||
|
|
clsName: 'decades',
|
||
|
|
navFnc: 'FullDecade',
|
||
|
|
navStep: 100
|
||
|
|
},
|
||
|
|
{
|
||
|
|
clsName: 'centuries',
|
||
|
|
navFnc: 'FullCentury',
|
||
|
|
navStep: 1000
|
||
|
|
}],
|
||
|
|
isLeapYear: function(year){
|
||
|
|
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
|
||
|
|
},
|
||
|
|
getDaysInMonth: function(year, month){
|
||
|
|
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
||
|
|
},
|
||
|
|
validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
|
||
|
|
nonpunctuation: /[^ -\/:-@\u5e74\u6708\u65e5\[-`{-~\t\n\r]+/g,
|
||
|
|
parseFormat: function(format){
|
||
|
|
if (typeof format.toValue === 'function' && typeof format.toDisplay === 'function')
|
||
|
|
return format;
|
||
|
|
// IE treats \0 as a string end in inputs (truncating the value),
|
||
|
|
// so it's a bad format delimiter, anyway
|
||
|
|
var separators = format.replace(this.validParts, '\0').split('\0'),
|
||
|
|
parts = format.match(this.validParts);
|
||
|
|
if (!separators || !separators.length || !parts || parts.length === 0){
|
||
|
|
throw new Error("Invalid date format.");
|
||
|
|
}
|
||
|
|
return {separators: separators, parts: parts};
|
||
|
|
},
|
||
|
|
parseDate: function(date, format, language, assumeNearby){
|
||
|
|
if (!date)
|
||
|
|
return undefined;
|
||
|
|
if (date instanceof Date)
|
||
|
|
return date;
|
||
|
|
if (typeof format === 'string')
|
||
|
|
format = DPGlobal.parseFormat(format);
|
||
|
|
if (format.toValue)
|
||
|
|
return format.toValue(date, format, language);
|
||
|
|
var part_re = /([\-+]\d+)([dmwy])/,
|
||
|
|
parts = date.match(/([\-+]\d+)([dmwy])/g),
|
||
|
|
fn_map = {
|
||
|
|
d: 'moveDay',
|
||
|
|
m: 'moveMonth',
|
||
|
|
w: 'moveWeek',
|
||
|
|
y: 'moveYear'
|
||
|
|
},
|
||
|
|
dateAliases = {
|
||
|
|
yesterday: '-1d',
|
||
|
|
today: '+0d',
|
||
|
|
tomorrow: '+1d'
|
||
|
|
},
|
||
|
|
part, dir, i, fn;
|
||
|
|
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)){
|
||
|
|
date = new Date();
|
||
|
|
for (i=0; i < parts.length; i++){
|
||
|
|
part = part_re.exec(parts[i]);
|
||
|
|
dir = parseInt(part[1]);
|
||
|
|
fn = fn_map[part[2]];
|
||
|
|
date = Datepicker.prototype[fn](date, dir);
|
||
|
|
}
|
||
|
|
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
||
|
|
}
|
||
|
|
|
||
|
|
if (typeof dateAliases[date] !== 'undefined') {
|
||
|
|
date = dateAliases[date];
|
||
|
|
parts = date.match(/([\-+]\d+)([dmwy])/g);
|
||
|
|
|
||
|
|
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)){
|
||
|
|
date = new Date();
|
||
|
|
for (i=0; i < parts.length; i++){
|
||
|
|
part = part_re.exec(parts[i]);
|
||
|
|
dir = parseInt(part[1]);
|
||
|
|
fn = fn_map[part[2]];
|
||
|
|
date = Datepicker.prototype[fn](date, dir);
|
||
|
|
}
|
||
|
|
|
||
|
|
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
parts = date && date.match(this.nonpunctuation) || [];
|
||
|
|
date = new Date();
|
||
|
|
|
||
|
|
function applyNearbyYear(year, threshold){
|
||
|
|
if (threshold === true)
|
||
|
|
threshold = 10;
|
||
|
|
|
||
|
|
// if year is 2 digits or less, than the user most likely is trying to get a recent century
|
||
|
|
if (year < 100){
|
||
|
|
year += 2000;
|
||
|
|
// if the new year is more than threshold years in advance, use last century
|
||
|
|
if (year > ((new Date()).getFullYear()+threshold)){
|
||
|
|
year -= 100;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return year;
|
||
|
|
}
|
||
|
|
|
||
|
|
var parsed = {},
|
||
|
|
setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
|
||
|
|
setters_map = {
|
||
|
|
yyyy: function(d,v){
|
||
|
|
return d.setUTCFullYear(assumeNearby ? applyNearbyYear(v, assumeNearby) : v);
|
||
|
|
},
|
||
|
|
yy: function(d,v){
|
||
|
|
return d.setUTCFullYear(assumeNearby ? applyNearbyYear(v, assumeNearby) : v);
|
||
|
|
},
|
||
|
|
m: function(d,v){
|
||
|
|
if (isNaN(d))
|
||
|
|
return d;
|
||
|
|
v -= 1;
|
||
|
|
while (v < 0) v += 12;
|
||
|
|
v %= 12;
|
||
|
|
d.setUTCMonth(v);
|
||
|
|
while (d.getUTCMonth() !== v)
|
||
|
|
d.setUTCDate(d.getUTCDate()-1);
|
||
|
|
return d;
|
||
|
|
},
|
||
|
|
d: function(d,v){
|
||
|
|
return d.setUTCDate(v);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
val, filtered;
|
||
|
|
setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
|
||
|
|
setters_map['dd'] = setters_map['d'];
|
||
|
|
date = UTCToday();
|
||
|
|
var fparts = format.parts.slice();
|
||
|
|
// Remove noop parts
|
||
|
|
if (parts.length !== fparts.length){
|
||
|
|
fparts = $(fparts).filter(function(i,p){
|
||
|
|
return $.inArray(p, setters_order) !== -1;
|
||
|
|
}).toArray();
|
||
|
|
}
|
||
|
|
// Process remainder
|
||
|
|
function match_part(){
|
||
|
|
var m = this.slice(0, parts[i].length),
|
||
|
|
p = parts[i].slice(0, m.length);
|
||
|
|
return m.toLowerCase() === p.toLowerCase();
|
||
|
|
}
|
||
|
|
if (parts.length === fparts.length){
|
||
|
|
var cnt;
|
||
|
|
for (i=0, cnt = fparts.length; i < cnt; i++){
|
||
|
|
val = parseInt(parts[i], 10);
|
||
|
|
part = fparts[i];
|
||
|
|
if (isNaN(val)){
|
||
|
|
switch (part){
|
||
|
|
case 'MM':
|
||
|
|
filtered = $(dates[language].months).filter(match_part);
|
||
|
|
val = $.inArray(filtered[0], dates[language].months) + 1;
|
||
|
|
break;
|
||
|
|
case 'M':
|
||
|
|
filtered = $(dates[language].monthsShort).filter(match_part);
|
||
|
|
val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
parsed[part] = val;
|
||
|
|
}
|
||
|
|
var _date, s;
|
||
|
|
for (i=0; i < setters_order.length; i++){
|
||
|
|
s = setters_order[i];
|
||
|
|
if (s in parsed && !isNaN(parsed[s])){
|
||
|
|
_date = new Date(date);
|
||
|
|
setters_map[s](_date, parsed[s]);
|
||
|
|
if (!isNaN(_date))
|
||
|
|
date = _date;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return date;
|
||
|
|
},
|
||
|
|
formatDate: function(date, format, language){
|
||
|
|
if (!date)
|
||
|
|
return '';
|
||
|
|
if (typeof format === 'string')
|
||
|
|
format = DPGlobal.parseFormat(format);
|
||
|
|
if (format.toDisplay)
|
||
|
|
return format.toDisplay(date, format, language);
|
||
|
|
var val = {
|
||
|
|
d: date.getUTCDate(),
|
||
|
|
D: dates[language].daysShort[date.getUTCDay()],
|
||
|
|
DD: dates[language].days[date.getUTCDay()],
|
||
|
|
m: date.getUTCMonth() + 1,
|
||
|
|
M: dates[language].monthsShort[date.getUTCMonth()],
|
||
|
|
MM: dates[language].months[date.getUTCMonth()],
|
||
|
|
yy: date.getUTCFullYear().toString().substring(2),
|
||
|
|
yyyy: date.getUTCFullYear()
|
||
|
|
};
|
||
|
|
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
||
|
|
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
||
|
|
date = [];
|
||
|
|
var seps = $.extend([], format.separators);
|
||
|
|
for (var i=0, cnt = format.parts.length; i <= cnt; i++){
|
||
|
|
if (seps.length)
|
||
|
|
date.push(seps.shift());
|
||
|
|
date.push(val[format.parts[i]]);
|
||
|
|
}
|
||
|
|
return date.join('');
|
||
|
|
},
|
||
|
|
headTemplate: '<thead>'+
|
||
|
|
'<tr>'+
|
||
|
|
'<th colspan="7" class="datepicker-title"></th>'+
|
||
|
|
'</tr>'+
|
||
|
|
'<tr>'+
|
||
|
|
'<th class="prev">«</th>'+
|
||
|
|
'<th colspan="5" class="datepicker-switch"></th>'+
|
||
|
|
'<th class="next">»</th>'+
|
||
|
|
'</tr>'+
|
||
|
|
'</thead>',
|
||
|
|
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
|
||
|
|
footTemplate: '<tfoot>'+
|
||
|
|
'<tr>'+
|
||
|
|
'<th colspan="7" class="today"></th>'+
|
||
|
|
'</tr>'+
|
||
|
|
'<tr>'+
|
||
|
|
'<th colspan="7" class="clear"></th>'+
|
||
|
|
'</tr>'+
|
||
|
|
'</tfoot>'
|
||
|
|
};
|
||
|
|
DPGlobal.template = '<div class="datepicker">'+
|
||
|
|
'<div class="datepicker-days">'+
|
||
|
|
'<table class="table-condensed">'+
|
||
|
|
DPGlobal.headTemplate+
|
||
|
|
'<tbody></tbody>'+
|
||
|
|
DPGlobal.footTemplate+
|
||
|
|
'</table>'+
|
||
|
|
'</div>'+
|
||
|
|
'<div class="datepicker-months">'+
|
||
|
|
'<table class="table-condensed">'+
|
||
|
|
DPGlobal.headTemplate+
|
||
|
|
DPGlobal.contTemplate+
|
||
|
|
DPGlobal.footTemplate+
|
||
|
|
'</table>'+
|
||
|
|
'</div>'+
|
||
|
|
'<div class="datepicker-years">'+
|
||
|
|
'<table class="table-condensed">'+
|
||
|
|
DPGlobal.headTemplate+
|
||
|
|
DPGlobal.contTemplate+
|
||
|
|
DPGlobal.footTemplate+
|
||
|
|
'</table>'+
|
||
|
|
'</div>'+
|
||
|
|
'<div class="datepicker-decades">'+
|
||
|
|
'<table class="table-condensed">'+
|
||
|
|
DPGlobal.headTemplate+
|
||
|
|
DPGlobal.contTemplate+
|
||
|
|
DPGlobal.footTemplate+
|
||
|
|
'</table>'+
|
||
|
|
'</div>'+
|
||
|
|
'<div class="datepicker-centuries">'+
|
||
|
|
'<table class="table-condensed">'+
|
||
|
|
DPGlobal.headTemplate+
|
||
|
|
DPGlobal.contTemplate+
|
||
|
|
DPGlobal.footTemplate+
|
||
|
|
'</table>'+
|
||
|
|
'</div>'+
|
||
|
|
'</div>';
|
||
|
|
|
||
|
|
$.fn.datepicker.DPGlobal = DPGlobal;
|
||
|
|
|
||
|
|
|
||
|
|
/* DATEPICKER NO CONFLICT
|
||
|
|
* =================== */
|
||
|
|
|
||
|
|
$.fn.datepicker.noConflict = function(){
|
||
|
|
$.fn.datepicker = old;
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
|
||
|
|
/* DATEPICKER VERSION
|
||
|
|
* =================== */
|
||
|
|
$.fn.datepicker.version = '1.6.4';
|
||
|
|
|
||
|
|
/* DATEPICKER DATA-API
|
||
|
|
* ================== */
|
||
|
|
|
||
|
|
$(document).on(
|
||
|
|
'focus.datepicker.data-api click.datepicker.data-api',
|
||
|
|
'[data-provide="datepicker"]',
|
||
|
|
function(e){
|
||
|
|
var $this = $(this);
|
||
|
|
if ($this.data('datepicker'))
|
||
|
|
return;
|
||
|
|
e.preventDefault();
|
||
|
|
// component click requires us to explicitly show it
|
||
|
|
datepickerPlugin.call($this, 'show');
|
||
|
|
}
|
||
|
|
);
|
||
|
|
$(function(){
|
||
|
|
datepickerPlugin.call($('[data-provide="datepicker-inline"]'));
|
||
|
|
});
|
||
|
|
|
||
|
|
}));
|
||
|
|
|
||
|
|
|