",options:{disabled:!1,create:null},_createWidget:function(t,i){i=e(i||this.defaultElement||this)[0],this.element=e(i),this.uuid=s++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),i!==this&&(e.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===i&&this.destroy()}}),this.document=e(i.style?i.ownerDocument:i.document||i),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var s,n,a,o=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(o={},s=t.split("."),t=s.shift(),s.length){for(n=o[t]=e.widget.extend({},this.options[t]),a=0;s.length-1>a;a++)n[s[a]]=n[s[a]]||{},n=n[s[a]];if(t=s.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=i}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=i}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!t),t&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(t,i,s){var n,a=this;"boolean"!=typeof t&&(s=i,i=t,t=!1),s?(i=n=e(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),e.each(s,function(s,o){function r(){return t||a.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(r.guid=o.guid=o.guid||r.guid||e.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+a.eventNamespace,u=h[2];u?n.delegate(u,l,r):i.bind(l,r)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,o=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(o)&&o.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var o,r=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),o=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),o&&e.effects&&e.effects.effect[r]?s[t](n):r!==t&&s[r]?s[r](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}}),e.widget;var a=!1;e(document).mouseup(function(){a=!1}),e.widget("ui.mouse",{version:"1.11.0",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(i){return!0===e.data(i.target,t.widgetName+".preventClickEvent")?(e.removeData(i.target,t.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(!a){this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var i=this,s=1===t.which,n="string"==typeof this.options.cancel&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;return s&&!n&&this._mouseCapture(t)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(t)!==!1,!this._mouseStarted)?(t.preventDefault(),!0):(!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return i._mouseMove(e)},this._mouseUpDelegate=function(e){return i._mouseUp(e)},this.document.bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),a=!0,!0)):!0}},_mouseMove:function(t){return e.ui.ie&&(!document.documentMode||9>document.documentMode)&&!t.button?this._mouseUp(t):t.which?this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted):this._mouseUp(t)},_mouseUp:function(t){return this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),a=!1,!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),e.widget("ui.draggable",e.ui.mouse,{version:"1.11.0",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"!==this.options.helper||/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._setHandleClassName(),this._mouseInit()},_setOption:function(e,t){this._super(e,t),"handle"===e&&this._setHandleClassName()},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(t){var i=this.document[0],s=this.options;try{i.activeElement&&"body"!==i.activeElement.nodeName.toLowerCase()&&e(i.activeElement).blur()}catch(n){}return this.helper||s.disabled||e(t.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(t),this.handle?(e(s.iframeFix===!0?"iframe":s.iframeFix).each(function(){e("
").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var i=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offsetParent=this.helper.offsetParent(),this.offsetParentCssPosition=this.offsetParent.css("position"),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},this.offset.scroll=!1,e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t,!1),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,i){if("fixed"===this.offsetParentCssPosition&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(t,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",t,s)===!1)return this._mouseUp({}),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var i=this,s=!1;return e.ui.ddmanager&&!this.options.dropBehaviour&&(s=e.ui.ddmanager.drop(this,t)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",t)!==!1&&i._clear()}):this._trigger("stop",t)!==!1&&this._clear(),!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),this.element.focus(),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){return this.options.handle?!!e(t.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this._removeHandleClassName(),e(this.options.handle||this.element).addClass("ui-draggable-handle")},_removeHandleClassName:function(){this.element.find(".ui-draggable-handle").addBack().removeClass("ui-draggable-handle")},_createHelper:function(t){var i=this.options,s=e.isFunction(i.helper)?e(i.helper.apply(this.element[0],[t])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return s.parents("body").length||s.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s[0]===this.element[0]||/(fixed|absolute)/.test(s.css("position"))||s.css("position","absolute"),s},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_isRootNode:function(e){return/(html|body)/i.test(e.tagName)||e===this.document[0]},_getParentOffset:function(){var t=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var e=this.element.position(),t=this._isRootNode(this.scrollParent[0]);return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+(t?0:this.scrollParent.scrollTop()),left:e.left-(parseInt(this.helper.css("left"),10)||0)+(t?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,i,s,n=this.options,a=this.document[0];return this.relative_container=null,n.containment?"window"===n.containment?(this.containment=[e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,e(window).scrollLeft()+e(window).width()-this.helperProportions.width-this.margins.left,e(window).scrollTop()+(e(window).height()||a.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,e(a).width()-this.helperProportions.width-this.margins.left,(e(a).height()||a.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=e(n.containment),s=i[0],s&&(t="hidden"!==i.css("overflow"),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(t?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=i),void 0):(this.containment=null,void 0)},_convertPositionTo:function(e,t){t||(t=this.position);var i="absolute"===e?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:t.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:t.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}},_generatePosition:function(e,t){var i,s,n,a,o=this.options,r=this._isRootNode(this.scrollParent[0]),h=e.pageX,l=e.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),t&&(this.containment&&(this.relative_container?(s=this.relative_container.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,e.pageX-this.offset.click.left
i[2]&&(h=i[2]+this.offset.click.left),e.pageY-this.offset.click.top>i[3]&&(l=i[3]+this.offset.click.top)),o.grid&&(n=o.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/o.grid[1])*o.grid[1]:this.originalPageY,l=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-o.grid[1]:n+o.grid[1]:n,a=o.grid[0]?this.originalPageX+Math.round((h-this.originalPageX)/o.grid[0])*o.grid[0]:this.originalPageX,h=i?a-this.offset.click.left>=i[0]||a-this.offset.click.left>i[2]?a:a-this.offset.click.left>=i[0]?a-o.grid[0]:a+o.grid[0]:a),"y"===o.axis&&(h=this.originalPageX),"x"===o.axis&&(l=this.originalPageY)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(t,i,s){return s=s||this._uiHash(),e.ui.plugin.call(this,t,[i,s,this],!0),"drag"===t&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,i,s){var n=s.options,a=e.extend({},i,{item:s.element});s.sortables=[],e(n.connectToSortable).each(function(){var i=e(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push({instance:i,shouldRevert:i.options.revert}),i.refreshPositions(),i._trigger("activate",t,a))})},stop:function(t,i,s){var n=e.extend({},i,{item:s.element});e.each(s.sortables,function(){this.instance.isOver?(this.instance.isOver=0,s.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=this.shouldRevert),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,"original"===s.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,n))})},drag:function(t,i,s){var n=this;e.each(s.sortables,function(){var a=!1,o=this;this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(a=!0,e.each(s.sortables,function(){return this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this!==o&&this.instance._intersectsWith(this.instance.containerCache)&&e.contains(o.instance.element[0],this.instance.element[0])&&(a=!1),a})),a?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(n).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return i.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=s.offset.click.top,this.instance.offset.click.left=s.offset.click.left,this.instance.offset.parent.left-=s.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=s.offset.parent.top-this.instance.offset.parent.top,s._trigger("toSortable",t),s.dropped=this.instance.element,s.currentItem=s.element,this.instance.fromOutside=s),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),s._trigger("fromSortable",t),s.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(t,i,s){var n=e("body"),a=s.options;n.css("cursor")&&(a._cursor=n.css("cursor")),n.css("cursor",a.cursor)},stop:function(t,i,s){var n=s.options;n._cursor&&e("body").css("cursor",n._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,i,s){var n=e(i.helper),a=s.options;n.css("opacity")&&(a._opacity=n.css("opacity")),n.css("opacity",a.opacity)},stop:function(t,i,s){var n=s.options;n._opacity&&e(i.helper).css("opacity",n._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(e,t,i){i.scrollParent[0]!==i.document[0]&&"HTML"!==i.scrollParent[0].tagName&&(i.overflowOffset=i.scrollParent.offset())},drag:function(t,i,s){var n=s.options,a=!1,o=s.document[0];s.scrollParent[0]!==o&&"HTML"!==s.scrollParent[0].tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+s.scrollParent[0].offsetHeight-t.pageY=0;c--)h=s.snapElements[c].left,l=h+s.snapElements[c].width,u=s.snapElements[c].top,d=u+s.snapElements[c].height,h-m>v||g>l+m||u-m>b||y>d+m||!e.contains(s.snapElements[c].item.ownerDocument,s.snapElements[c].item)?(s.snapElements[c].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,t,e.extend(s._uiHash(),{snapItem:s.snapElements[c].item})),s.snapElements[c].snapping=!1):("inner"!==f.snapMode&&(n=m>=Math.abs(u-b),a=m>=Math.abs(d-y),o=m>=Math.abs(h-v),r=m>=Math.abs(l-g),n&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top-s.margins.top),a&&(i.position.top=s._convertPositionTo("relative",{top:d,left:0}).top-s.margins.top),o&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left-s.margins.left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left-s.margins.left)),p=n||a||o||r,"outer"!==f.snapMode&&(n=m>=Math.abs(u-y),a=m>=Math.abs(d-b),o=m>=Math.abs(h-g),r=m>=Math.abs(l-v),n&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top-s.margins.top),a&&(i.position.top=s._convertPositionTo("relative",{top:d-s.helperProportions.height,left:0}).top-s.margins.top),o&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left-s.margins.left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left-s.margins.left)),!s.snapElements[c].snapping&&(n||a||o||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,t,e.extend(s._uiHash(),{snapItem:s.snapElements[c].item})),s.snapElements[c].snapping=n||a||o||r||p)}}),e.ui.plugin.add("draggable","stack",{start:function(t,i,s){var n,a=s.options,o=e.makeArray(e(a.stack)).sort(function(t,i){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(i).css("zIndex"),10)||0)});o.length&&(n=parseInt(e(o[0]).css("zIndex"),10)||0,e(o).each(function(t){e(this).css("zIndex",n+t)}),this.css("zIndex",n+o.length))}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,i,s){var n=e(i.helper),a=s.options;n.css("zIndex")&&(a._zIndex=n.css("zIndex")),n.css("zIndex",a.zIndex)},stop:function(t,i,s){var n=s.options;n._zIndex&&e(i.helper).css("zIndex",n._zIndex)}}),e.ui.draggable});
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 2011–2014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);
// Main JS goes here
var base = {
init: function() {
this.bindUI();
},
bindUI: function() {
var self = this;
// ----- WEBKIT CHECK ----- //
Modernizr.testProp('webkitAppearance');
Modernizr.addTest('webkit-appearance', function() {
return Modernizr.testProp('webkitAppearance');
});
// ----- CHOSEN SELECT ----- //
var chosenSupported = function() {
if (/iP(ad|od|hone)/.test(window.navigator.userAgent))
return false;
if (/Android/.test(window.navigator.userAgent) && /Mobile/.test(window.navigator.userAgent))
return false;
if (/IEMobile/.test(window.navigator.userAgent))
return false;
if (/Windows Phone/.test(window.navigator.userAgent))
return false;
if (/BlackBerry/.test(window.navigator.userAgent))
return false;
if (/BB10/.test(window.navigator.userAgent))
return false;
if (window.navigator.appName === "Microsoft Internet Explorer") {
return document.documentMode >= 8;
}
return true;
};
if (chosenSupported() === true) {
$('select').not('.chosenified').addClass('chosenified').chosen({
disable_search_threshold: 20,
placeholder_text_single: 'Select'
});
}
// If screens tall enough start out mobile menu with products sublist open
if (Modernizr.mq('(min-height: 580px)') && $('.menu-btn').is(':visible')) {
$('.mobile-menu__item [data-toggle="+ ul"]').eq(0).addClass('active-toggle').next('ul').show();
}
// ----- HEADER SEARCH ----- //
$('.no-touchevents .usertools__link--search').on('click', function() {
setTimeout(function(){
$('.header-search__input').focus();
}, 100);
});
if (!$('body').is('.admin-product-sort')) {
var mySettings = {
animation: 'fade',
productList: '.products > li',
productImage: '.products__image--main',
quickview: '.quickview',
onchange: function(tile) {
var img = tile.find('.products__image--main'),
alternate = tile.find('.swatches .active').data('alternate');
// Add the new alternate background image and toggle the alternate class
if (alternate !== undefined) {
tile.toggleClass('alternate', alternate !== undefined);
tile.find('.products__image--alt').attr('src', alternate);
}
tile.addClass('no-transition');
var transition = setInterval(function() {
if (img.css('opacity') == 1) {
img.css('opacity', '');
tile.removeClass('no-transition');
clearInterval(transition);
}
}, 100);
}
};
var myProductTile = _.extend(ProductTile, {});
myProductTile.init(mySettings);
} else {
$(window).on('load', function() {
$('.products__tile').each(function() {
$(this).find('button').wrapAll('');
});
});
}
// Quickview:
var QuickviewSettings = {
close: '[data-quickview-close]',
iframe: '' +
'' +
'' +
'' +
'' +
'',
};
Quickview.init(QuickviewSettings);
// ----- MINICART ----- //
Minicart.init({
empty: 'Nothing in your bag yet.
',
cartWrapper: '.usertools__item--cart',
remove: '[data-minicart-remove]',
miniCart: '.usertools__drop--cart',
itemWrapper: 'li[data-minicart-item]',
onadd: function() {
// Close quick view when item is added to cart
parent.top.$('html').removeClass('quickview-active');
},
});
// ----- FIX IOS CLICK DELAYS ----- //
FastClick.attach(document.body);
// Accordion Toggles
$('[data-accordion] h2').on('click', function() {
$(this).toggleClass('active').next(':not([data-no-toggle])').slideToggle('fast');
});
// ----- MANTLE CAROUSELS ----- //
$('[data-flex]').each(function() {
var slide = $(this).find('.slides > li');
if (slide.length > 1) {
$(this).flexslider({
// animation: 'fade', // Fade is the default value
pauseOnHover: true,
directionNav: true,
controlNav: true,
useCSS: true,
video: true,
start: function(slider) {
slider.removeClass('flexslider--loading');
}
});
}
});
// ----- REVIEWS ----- //
var bindRatings = function() {
$('#reviewform .rating span').on('click', function() {
$(this).addClass('active').siblings().removeClass('active');
var selected = $(this).index();
$('#reviewform .rating input[type=radio]').prop('checked', false).eq(selected).prop('checked', true);
});
};
$('.product-detail .rating-holder a').on('click', function() {
if ($('.product-detail .rating-holder .rating').length < 1) {
$('#reviewform').show();
}
bindRatings();
$('html, body').animate({
scrollTop: $('#reviews').offset().top - parseInt($('body').css('padding-top'))
}, 750);
return false;
});
$('[data-review-toggle]').on('click', function() {
$('#reviewform').slideToggle('normal', function() {
bindRatings();
});
return false;
});
// ----- PRODUCT DETAIL CAROUSELS ----- //
$('[data-detail-flex]').each(function() {
var slide = $(this).find('.slides > li');
if (slide.length > 1) {
$(this).addClass('flexslider--loading').flexslider({
animation: "slide",
controlNav: true,
manualControls: ".slide-thumbs img",
pauseOnHover: true,
pausePlay: false,
pauseText: "",
playText: "",
slideshow: false,
slideshowSpeed: 3000,
useCSS: false,
video: true,
start: function(slider) {
slider.removeClass('flexslider--loading');
}
});
} else {
slide.show();
}
});
// Product detail:
if ($('body').is('.detail-landing')) {
var ProductDetailSettings = {
// alternates: '[data-product-thumb]',
alternates: '.flex-control-thumbs > li',
activeClass: 'product__thumb-item--active',
arrows: true,
arrowsButton: '[data-product-thumbs-nav]',
animationSpeed: 200,
container: '[data-product-imagery]',
// productImage: '[data-product-image]'
productImage: '.detail-slider-carousel__image'
}
ProductDetail.init(ProductDetailSettings);
// Zoom():
Zoom.build = function() {
$('body')
.append(this.template.html())
// Change the close button markup to match rest of project
.find('.zoom-close').addClass('icon--cancel');
}
Zoom.init('[data-zoom-trigger]', true, '[data-detail-flex]', true);
}
// ----- RELATED PRODUCTS SLIDER ----- //
var relatedProductSlider = null;
$('[data-slider-flex]').each(function() {
var slide = $(this).find('ol > li');
if (slide.length > 1) {
$(this).addClass('flexslider--loading').flexslider({
animation: "slide",
animationLoop: false,
directionNav: true,
controlNav: false,
itemWidth: 345,
itemMargin: 15,
minItems: self.getGridSize(),
maxItems: self.getGridSize(),
pauseOnHover: true,
pausePlay: false,
pauseText: "",
playText: "",
slideshow: false,
slideshowSpeed: 3000,
useCSS: false,
video: false,
start: function(slider) {
slider.removeClass('flexslider--loading');
relatedProductSlider = slider;
$(window).on('resize', function() {
self.recountSliderItems(relatedProductSlider);
});
$(window).resize();
}
});
} else {
slide.show();
}
});
// ----- BLOG GALLERY ----- //
// make the markup match the race detail gallery
var blogGallery = $('section.blog-gallery');
if (blogGallery !== 'undefined') {
blogGallery.addClass('gallery__container').attr('data-gallery-container', '')
.find('.slides').addClass('gallery__slides')
.wrapAll('')
.find('img').attr('data-gallery-image', '');
blogGallery.find('.gallery-controls .viewing').attr('data-gallery-viewing', '');
blogGallery.find('.total').attr('data-gallery-total', '');
}
if ($('[data-gallery]').length > 0) {
var flexslider = '[data-gallery]',
gallery = $(flexslider),
images = gallery.find('[data-gallery-image]'),
slides = gallery.find('[data-gallery-slides]'),
item = gallery.find('[data-gallery-item]'),
galleryContainer = $('[data-gallery-container]'),
navNext = galleryContainer.find('[data-gallery-nav="next"], .next'),
navPrev = galleryContainer.find('[data-gallery-nav="prev"], .prev'),
thumbsItem = galleryContainer.find('[data-gallery-thumbs-item]'),
thumbsList = galleryContainer.find('[data-gallery-thumbs-list]'),
viewing = galleryContainer.find('[data-gallery-viewing]');
gallery.flexslider({
animation: 'fade',
aspectRatio: true,
manualControls: '[data-gallery-thumbs-item], .gallery-thumbs li',
slideshow: false,
before: function(slider) {
viewing.text(slider.animatingTo + 1);
},
start: function(slider) {
setTimeout(function() {
slider.removeClass('loading');
}, 1);
}
});
navNext.on('click', function() {
gallery.find('.flex-next').trigger('click');
});
navPrev.on('click', function() {
gallery.find('.flex-prev').trigger('click');
});
galleryContainer.find('.all').on('click', function(){
$('body').toggleClass('gallery-thumbs--active');
});
// Move thumbs below the controls
galleryContainer.append(galleryContainer.find('.gallery-thumbs'));
}
// ----- TABS ----- //
$('[data-tabs]').each(function() {
var tabs = $(this);
// Set active class on first item in tabs
if (tabs.find('[data-tab].active').length < 1) {
tabs.find('[data-tab]:first-of-type, [data-activate-tab]:first-of-type').addClass('active');
}
/*if(tabs.find('[data-team-back]')) {
tabs.parent().siblings('.side-nav').addClass('side-nav--right');
}*/
});
$('body').on('click', '[data-video-close]', function(e) {
e.preventDefault();
var button = $(this),
container = button.closest('[data-video-container]'),
video = container.find('[data-video-player]');
container.removeClass('video--active');
video.attr('src', '');
});
$('body').on('click', '[data-video-url]', function(e) {
e.preventDefault();
var btn = $(this),
container = btn.closest('[data-video-container]'),
url = btn.data('video-url'),
videoPlayer = url.indexOf("vimeo") > -1 ? 'vimeo' : url.indexOf("yout") > -1 ? 'youtube' : false,
embedUrl = videoPlayer === 'vimeo' ? 'https://player.vimeo.com/video/' : videoPlayer === 'youtube' ? 'https://www.youtube.com/embed/' : false,
key = videoPlayer === 'vimeo' ? url.split('.com/')[1] : videoPlayer === 'youtube' ? url.split('=')[1] : '',
video = container.find('[data-video-player]');
// create the video by adding the src to the iframe
// btn.addClass('video--active');
container.addClass('video--active');
container.find('[data-video-player]').attr('src', embedUrl+key+'?autoplay=1');
});
// Toggle Tabs with nav button clicks
$('body').on('click', '[data-activate-tab]', function() {
var btn = $(this),
container = btn.closest('[data-tabs]'),
element = container.find('[data-tab="' + btn.data('activate-tab') + '"]'),
link = container.find('[data-activate-tab="' + btn.data('activate-tab') + '"]');
if ($('[data-tab-title]').length > 0) {
$('[data-tab-title]').addClass('active-title').text(btn.text());
$('[data-tabs]').addClass('tabs-active');
$('.tabs-nav').slideUp();
}
// Activate the button and tab content
btn.add(element).addClass('active').siblings().removeClass('active');
// Activate link
link.addClass('active').siblings().removeClass('active');
// Stop the page from jumping
return false;
});
// ----- MANTLE DATA VIDEO LINKS ----- //
$('.mantles a[href*="youtube.com"], .mantles a[href*="youtu.be"], .mantles a[href*="vimeo.com"]').each(function() {
var $this = $(this),
href = $this.attr('href');
if (typeof($this.attr('data-video')) === 'undefined') {
$this.attr('data-video', href).data('video', href);
}
});
// ----- VIDEO LIGHTBOXES ----- //
$('[data-video]').on('click', function() {
$.fancybox({
padding : 15,
aspectRatio : true,
nextEffect : 'none',
prevEffect : 'none',
title : $(this).data('title'),
href : $(this).data('video') + '&rel=0&autoplay=1',
type : 'iframe',
helpers: {
media: {},
title: {
type: 'inside'
}
},
beforeLoad : function() {
this.width = $(window).width() * 0.85;
this.height = Math.round( (this.width / 16) * 9 );
}
});
return false;
});
// ----- IMAGE LIGHTBOXES ----- //
$('.gallery-tile').on('click', function() {
$.fancybox({
padding : 15,
aspectRatio : true,
nextEffect : 'none',
prevEffect : 'none',
//title : $(this).data('title'),
href : $(this).find('img:first').attr('src')
});
return false;
});
// ----- NEWSLETTER POPUP ----- //
$('[data-newsletter-form-wrapper-popup]').each(function() {
var newsletter = $(this),
active = false,
cookieId = 'newsletter';
// Is there a cookie
if ($.cookie(cookieId) === 'active') {
active = true;
}
/*if (active !== true) {
// Trigger popup
$(window).on('load', function() {
setTimeout(function() {
$('html').addClass('newsletter-popup--active');
// Create session cookie
$.cookie(cookieId, 'active', { path: '/', expires: 30 });
}, 1000);
});
}*/
// Form handling
$('[data-newsletter-form-popup]').on('submit', function() {
var form = $(this),
container = form.closest('[data-newsletter-form-wrapper-popup]'),
params = form.serialize() + '&source=popup',
thankyou = container.find('[data-newsletter-thankyou-popup]');
form.addClass('loading');
$.post($(this).attr('action'), params, function(data) {
if (!data.success) {
thankyou.text('Sorry, we could not subscribe you right now!');
thankyou.addClass('active');
} else {
thankyou.text('Thanks for signing up!');
thankyou.addClass('active');
form.removeClass('loading');
setTimeout(function() {
$('html').removeClass('newsletter-popup--active');
// Cookie will expire in 1 year
$.cookie(cookieId, 'active', { path: '/', expires: 30 });
}, 8000);
setTimeout(function() {
thankyou.removeClass('active');
}, 8500);
}
});
return false;
});
$(window).on('load resize', function() {
var popupHeight = newsletter.outerHeight(),
popupWidth = newsletter.outerWidth(),
popupMarginLeft = parseInt(popupWidth / 2),
popupMarginTop = parseInt(popupHeight / 2);
// Position popup
newsletter.css({ marginLeft : -popupMarginLeft, marginTop : -popupMarginTop });
// Set wrapper height for scrollbar
popupHeight = newsletter.height();
var wrapper = $('.newsletter-popup-wrap'),
wrapperHeight = wrapper.outerHeight();
if (wrapperHeight > popupHeight) {
wrapper.css('height', popupHeight);
} else {
wrapper.css('height', '');
}
}).resize();
});
// ----- FOOTER NEWSLETTER ----- //
$('[data-newsletter-form]').on('submit', function() {
var form = $(this),
container = form.closest('[data-newsletter-form-wrapper]'),
params = form.serialize() + '&source=footer',
thankyou = $('[data-newsletter-thankyou-popup]');
form.addClass('loading');
$.post(form.attr('action'), params, function(data) {
$('html').addClass("newsletter-popup--active");
if (!data.success) {
form[0].reset();
thankyou.text('Sorry, we could not subscribe you right now!');
thankyou.addClass('active');
} else {
form[0].reset();
thankyou.text('Thanks for signing up!');
setTimeout(function () {
$('html').removeClass("newsletter-popup--active");
}, 5000);
thankyou.addClass('active');
form.removeClass('loading');
setTimeout(function () {
thankyou.removeClass('active');
}, 8000);
}
});
return false;
});
// ----- TOGGLE ----- //
$('[data-toggle-class]').on('click', function(e) {
// e.preventDefault();
var element = $(this),
className = element.data('toggle-class'),
// You can override by setting data-toggle-class-on='any-element'
target = typeof(element.data('toggle-class-on')) === 'undefined' ? $('html') : $(element.data('toggle-class-on'));
if (element.data('toggle-max-width')) var toggleClassMaxWidth = element.data('toggle-max-width');
// Toggle if under the data-toggle-max-width, or if there is no data-toggle-max-width set
if (toggleClassMaxWidth && self.getBreakpoint() < toggleClassMaxWidth || typeof(toggleClassMaxWidth) === 'undefined') {
target.toggleClass(className);
}
return false;
});
$('[data-toggle]').on('click', function() {
// Check if theres a data-toggle-max-width
if ($(this).data('toggle-max-width')) var toggleMaxWidth = $(this).data('toggle-max-width');
// Toggle if under the data=toggle-max-width, or if there is no data-toggle-max-width set
if (toggleMaxWidth && self.getBreakpoint() < toggleMaxWidth || typeof(toggleMaxWidth) === 'undefined') {
self.dataToggle($(this));
return false;
}
});
// Scroll element smoothly into view
scrollIntoView('data-scroll-into-view', $('.header'), 500);
// Scroll any element into view smoothly
// Any selector works (element, ID, class, attribute selector, etc)
// Use fragment id in anchor for no-js fallbacks. EG:
or (back to top button)
function scrollIntoView(scrollTriggerAttr, header, speed, cb) {
var header = typeof header !== 'undefined' ? header : $('.header'),
speed = speed || 900,
scrolled = false; // since we have to use html, body to work in diff browser, but only want the callback to fire once
$('[' + scrollTriggerAttr + ']').click(function(e) {
e.preventDefault()
var btn = $(this),
item = $(btn.attr(scrollTriggerAttr)),
scrollY = item.offset().top - header.outerHeight(true);
$("html, body").animate({scrollTop: scrollY}, speed, function() {
if (cb && !scrolled) {
cb();
}
scrolled = true;
});
});
}
// ----- CART LOGIN ----- //
$('[data-login]').on('click', function() {
var cartLogin = $('#cart-login'),
offset = self.getBreakpoint() > 1024 ? 80 : 0;
$(this).prop('disabled', true);
cartLogin.slideDown();
cartLogin.addClass('active')
$('body, html').animate({
scrollTop: cartLogin.offset().top - offset
}, 300);
});
// ----- LOGIN PLACEHOLDERS ----- //
$('body.login input').each(function() {
var input = $(this),
label = $(this).prev('label');
if (label.length) {
input.attr('placeholder', label.text().replace(':',''));
label.hide();
}
});
// ----- CHECKOUT ----- //
if ($('.checkout').length) {
$('[data-toggle]').unbind();
$('html, body').animate({ scrollTop: 0 }, 0);
}
// ----- THANK YOU ----- //
$('[data-print-order]').on('click', function() {
window.print();
return false;
});
// ----- REDIRECT ----- //
//redirect through js since link inside and existing a href with link
$('[data-href]').on('click', function() {
window.location = $(this).data("href");
return false; //stop parent anchor to trigger
});
// ----- STOCK NOTIFICATIONS ----- //
$('body').on('submit', '.product-request__form', function(e){
var $this = $(this);
e.preventDefault();
$.post($(this).attr('action'), $(this).serialize(), function(data){
if(data.success) {
var wrapper = $this.closest('[data-product-request]');
wrapper.addClass('thank-you-active');
setTimeout(function() {
$('.product-request--overlay, .detail-slider-info__email').removeClass('active');
wrapper.removeClass('thank-you-active');
}, 5000);
}
});
});
$('[data-product-tile]').on('click', '[data-stock-notify]', function(e){
e.preventDefault();
$('.product-request--overlay').addClass('active');
var product_tile = $(this).parent().parent();
$('.product-request--overlay .product-tile__link').attr('href', product_tile.attr('href'));
$('.product-request--overlay .product-tile__image').attr('src', product_tile.find('.tile__image').attr('src'));
$('.product-request--overlay .product-tile__name').html(product_tile.find('.product-tile__name').html());
$('.product-request--overlay .product-tile__color').html(product_tile.find('.product-tile__color').html());
$('.product-request--overlay .product-tile__price').html(product_tile.find('[data-product-price]').html());
$('.product-request--overlay [name=stock_id]').val($(this).data('stock-id'));
});
// ----- STORE LOCATOR ----- //
if($('body').hasClass('storelocator')){
// if tracks is in the url prepare form and auto check the filter
if(window.location.href.indexOf("/tracks") > -1) {
$('#id_tracks').prop('checked', true);
$('form[data-locator-form]').prop('action', $('form[data-locator-form]').data('default_action') + 'tracks/');
}
$('body').on('change','#id_tracks', function(){
if($(this).is(':checked')){
$('form[data-locator-form]').prop('action', $('form[data-locator-form]').data('default_action') + 'tracks/');
} else {
$('form[data-locator-form]').prop('action', $('form[data-locator-form]').data('default_action'));
}
if($('[data-locations-container] li').length > 0) {
$('form[data-locator-form]').trigger('submit');
}
});
function showDetails(loc){
$('.locator__map-detail-list').html('');
if (loc.description) {
$('.locator__map-copy').html(loc.description);
$('.locator__map-description').show();
} else {
$('.locator__map-description').hide();
}
var excluded_categories = ['Tamiya Dealer', 'Product Line','TADA User', 'TADA Prospect', 'Tamiya Retailer','Specialty Account', 'Exlude from e-mails','TADA Customer','Tamiya E-Tailer'];
$.each(loc.categories, function(index, category){
if (!arrayContains(category.category_name, excluded_categories)){
var productLineMarkup = '' +
'' +
'
' +
'
'+
'' + category.category_name + '' +
'';
$('.locator__map-detail-list').append(productLineMarkup);
}
});
if(!$('[dealer-map-details]').hasClass('active')){
$('[dealer-map-details]').addClass('active');
}
}
var settings = {
locationClick: showDetails
};
storelocator.init(settings, {});
}
if($('body').hasClass('distributor-locator')){
storelocator.init();
}
if($('body').hasClass('discover-bs--about')){
var label = $('label[for="id_image"]'),
label_text = label.text();
$('.discover-bs #id_image').change(function() {
label.html(label_text + ' ' + $(this).val().split("\\").pop() + '');
});
}
// ----- TEMPLATE ADD TO CART ----- //
$('.template-add-to-cart').click(function(e) {
e.preventDefault();
var $this = $(this);
var $form = $this.closest('form');
var $tr = $this.closest('tr');
$form.find('input[name=item_id]').val($tr.data('item-id'));
$form.find('input[name=product_id]').val($tr.data('product-id'));
$form.find('input[name=quantity]').val($tr.find('.template__input-qty').val())
$form.submit();
return true;
});
// ----- SET UP DEFAULT JQUERY AJAX SETTINGS ----- //
$.ajaxSetup({
crossDomain: false, // obviates need for sameOrigin test
beforeSend: function(xhr, settings) {
if (!self.csrfSafeMethod(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", self.getCookie('csrftoken'));
}
}
});
$('.locator__map-details-close').click(function(){
$('.locator__map-details').removeClass('active');
});
if($('.hide--mobile').css('display') == 'none') {
$('.usertools__item--account').click(function(){
if($('.usertools__drop--account').is(':visible')) {
$('.usertools__drop--account').hide();
$('.usertools__drop--account').css('visibility', 'hidden');
$('.usertools__drop--account').css('opacity', 0);
} else {
$('.usertools__drop--account').show();
$('.usertools__drop--account').css('visibility', 'visible');
$('.usertools__drop--account').css('opacity', 1);
}
});
}
// ----- BACK TO TOP ----- //
$('[data-back-to-top]').each(function() {
$(window).on('load resize scroll', function() {
var documentHeight = $(document).height(),
scrollDistance = $(document).scrollTop(),
windowHeight = $(window).height();
if (documentHeight > windowHeight * 2) {
if (scrollDistance + windowHeight > documentHeight / 2) {
$('html').addClass('back-to-top-active');
} else {
$('html').removeClass('back-to-top-active');
}
}
});
$(this).on('click', function() {
$('html,body').animate({scrollTop: 0}, {duration: 'slow'});
});
});
},
csrfSafeMethod: function(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
},
dataToggle: function(e) {
var speed = 300,
toggleData = e.data('toggle'),
container = e.closest(':has('+toggleData+')');
// Toggle siblings (if [data-siblings] is set)
if (e.data('toggle-siblings')) {
var siblings = e.closest(e.data('toggle-siblings')).siblings().find(toggleData);
siblings.slideUp(speed).closest('.active-toggle').removeClass('active-toggle');
}
// Toggle element
e.closest(container).toggleClass('active-toggle').find(toggleData).slideToggle(speed);
},
getBreakpoint: function() {
var breakpoint;
if (window.getComputedStyle) {
breakpoint = window.getComputedStyle(
document.querySelector('body'), ':before'
).getPropertyValue('content');
breakpoint = parseInt(breakpoint.replace("'","").replace('"',''));
} else { // IE8 fallback
breakpoint = $(window).width();
}
return breakpoint;
},
getCookie: function(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
},
getGridSize: function() {
var w = window.innerWidth;
return (w < 480) ? 1 :
(w < 768) ? 2 :
(w < 1024) ? 3 : 4;
},
scrollToContent: function(page, contents, breakpoint) {
var gutter = (breakpoint >= 768 ? 90 : 50);
$.each(contents, function() {
if(page.scrollTop() >= $(this).offset().top && page.scrollTop() <= ($(this).offset().top + $(this).outerHeight(true) - gutter)) {
var target = $('[data-activate-tab="' + $(this).attr("id") + '"]');
target.parent().find('> .active').removeClass('active');
target.addClass('active');
return false;
}
});
},
recountSliderItems: function(relatedProductSlider) {
relatedProductSlider.vars.minItems = base.getGridSize();
relatedProductSlider.vars.maxItems = base.getGridSize();
}
};
// One Page Checkout
function applyCustomSelect() {
base.init();
}
$(function() {
base.init();
});
function arrayContains(needle, arrhaystack) {
return (arrhaystack.indexOf(needle) > -1);
}