text: !function(){for(var t,i=function(){},e=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],s=e.length,r=window.console=window.console||{};s--;)t=e[s],r[t]||(r[t]=i)}(),void 0===jQuery.when.all&&(jQuery.when.all=function(t){var i=new jQuery.Deferred;return $.when.apply(jQuery,t).then(function(){i.resolve(Array.prototype.slice.call(arguments))},function(){i.fail(Array.prototype.slice.call(arguments))}),i}),function(t){function i(t){var i="100%",e="0px",s={top:e,bottom:i,left:e,right:i};return s[t]||t}var e="background-position",s=t.camelCase;t.each(["x","y"],function(r,o){var n=s(e+"-"+o);t.cssHooks[n]={get:function(s){var o=t.css(s,e).split(/\s+/,2);return i(o[r])},set:function(s,o){var n=t.css(s,e).split(/\s+/,2);n[r]=i(o),t.style(s,e,n.join(" "))}},t.fx.step[n]=function(i){t.style(i.elem,i.prop,i.now)}})}(jQuery),function(t,i){"use strict";var e,s=t.document;e=function(){var e,r,o,n,a,h,l,d,c,_,u,p,g,f,y={},m={},w=!1,v={ENTER:13,ESC:27,SPACE:32},b=[];return m={buttons:{holder:'<nav class="alertify-buttons">{{buttons}}</nav>',submit:'<button type="submit" class="button green" id="alertify-ok">{{ok}}</button>',ok:'<button class="button green" id="alertify-ok">{{ok}}</button>',cancel:'<button class="button red" id="alertify-cancel">{{cancel}}</button>',bookmark:'<button class="button yellow" id="alertify-bookmark">BOOKMARK</button>'},input:'<div class="alertify-text-wrapper"><input type="text" class="alertify-text" id="alertify-text"></div>',message:'<p class="alertify-message">{{message}}</p>',log:'<article class="alertify-log{{class}}">{{message}}</article>'},f=function(){var t,e,r=!1,o=s.createElement("fakeelement"),n={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"};for(t in n)if(o.style[t]!==i){e=n[t],r=!0;break}return{type:e,supported:r}},e=function(t){return s.getElementById(t)},y={labels:{ok:"OK",cancel:"Cancel"},delay:5e3,buttonReverse:!1,buttonFocus:"ok",transition:i,addListeners:function(t){var i,e,l,d,c,_,u="undefined"!=typeof o,p="undefined"!=typeof r,f="undefined"!=typeof n,y="undefined"!=typeof g,m="",w=this;i=function(i){return"undefined"!=typeof i.preventDefault&&i.preventDefault(),d(i),"undefined"!=typeof g&&(m=g.value),"function"==typeof t&&("undefined"!=typeof g?t(!0,m):t(!0)),!1},l=function(){var t=window.location,i=JSON.stringify(MKON.LAYOUT.currentLayout),e="http://"+t+"#"+i;return console.log(e),MKON.FNC.bookmark("MKON Layout",e),!1},e=function(i){return"undefined"!=typeof i.preventDefault&&i.preventDefault(),d(i),"function"==typeof t&&t(!1),!1},d=function(){w.hide(),w.unbind(s.body,"keyup",c),w.unbind(a,"focus",_),u&&w.unbind(o,"click",i),p&&w.unbind(r,"click",e),f&&w.unbind(n,"click",l)},c=function(t){var s=t.keyCode;(s===v.SPACE&&!y||y&&s===v.ENTER)&&i(t),s===v.ESC&&p&&e(t)},_=function(){y?g.focus():!p||w.buttonReverse?o.focus():r.focus()},this.bind(a,"focus",_),this.bind(h,"focus",_),u&&this.bind(o,"click",i),p&&this.bind(r,"click",e),f&&this.bind(n,"click",l),this.bind(s.body,"keyup",c),this.transition.supported||this.setFocus()},bind:function(t,i,e){"function"==typeof t.addEventListener?t.addEventListener(i,e,!1):t.attachEvent&&t.attachEvent("on"+i,e)},handleErrors:function(){if("undefined"!=typeof t.onerror){var i=this;return t.onerror=function(t,e,s){i.error("["+t+" on line "+s+" of "+e+"]",0)},!0}return!1},appendButtons:function(t,i){return this.buttonReverse?i+t:t+i},build:function(t){var i="",e=t.type,s=t.message,r=t.cssClass||"";switch(i+='<div class="alertify-dialog">',i+='<a id="alertify-resetFocusBack" class="alertify-resetFocus" href="#">Reset Focus</a>',"none"===y.buttonFocus&&(i+='<a href="#" id="alertify-noneFocus" class="alertify-hidden"></a>'),"prompt"===e&&(i+='<div id="alertify-form">'),i+='<article class="alertify-inner">',i+=m.message.replace("{{message}}",s),"prompt"===e&&(i+=m.input),i+=m.buttons.holder,i+="</article>","prompt"===e&&(i+="</div>"),i+='<a id="alertify-resetFocus" class="alertify-resetFocus" href="#">Reset Focus</a>',i+="</div>",e){case"confirm":i=i.replace("{{buttons}}",this.appendButtons(m.buttons.cancel,m.buttons.ok)),i=i.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"prompt":i=i.replace("{{buttons}}",this.appendButtons(m.buttons.cancel,m.buttons.submit)),i=i.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"alert":i=i.replace("{{buttons}}",m.buttons.ok),i=i.replace("{{ok}}",this.labels.ok)}return _.className="alertify alertify-"+e+" "+r,c.className="alertify-cover",i},close:function(t,i){var e,s,r=i&&!isNaN(i)?+i:this.delay,o=this;this.bind(t,"click",function(){e(t)}),s=function(t){t.stopPropagation(),o.unbind(this,o.transition.type,s),u.removeChild(this),u.hasChildNodes()||(u.className+=" alertify-logs-hidden")},e=function(t){"undefined"!=typeof t&&t.parentNode===u&&(o.transition.supported?(o.bind(t,o.transition.type,s),t.className+=" alertify-log-hide"):(u.removeChild(t),u.hasChildNodes()||(u.className+=" alertify-logs-hidden")))},0!==i&&setTimeout(function(){e(t)},r)},dialog:function(t,i,e,r,o){d=s.activeElement;var n=function(){u&&null!==u.scrollTop&&c&&null!==c.scrollTop||n()};if("string"!=typeof t)throw new Error("message must be a string");if("string"!=typeof i)throw new Error("type must be a string");if("undefined"!=typeof e&&"function"!=typeof e)throw new Error("fn must be a function");return this.init(),n(),b.push({type:i,message:t,callback:e,placeholder:r,cssClass:o}),w||this.setup(),this},extend:function(t){if("string"!=typeof t)throw new Error("extend method must have exactly one paramter");return function(i,e){return this.log(i,t,e),this}},hide:function(){var t,i=this;b.splice(0,1),b.length>0?this.setup(!0):(w=!1,t=function(e){e.stopPropagation(),i.unbind(_,i.transition.type,t)},this.transition.supported?(this.bind(_,this.transition.type,t),_.className="alertify alertify-hide alertify-hidden"):_.className="alertify alertify-hide alertify-hidden alertify-isHidden",c.className="alertify-cover alertify-cover-hidden",d.focus())},init:function(){s.createElement("nav"),s.createElement("article"),s.createElement("section"),null==e("alertify-cover")&&(c=s.createElement("div"),c.setAttribute("id","alertify-cover"),c.className="alertify-cover alertify-cover-hidden",s.body.appendChild(c)),null==e("alertify")&&(w=!1,b=[],_=s.createElement("section"),_.setAttribute("id","alertify"),_.className="alertify alertify-hidden",s.body.appendChild(_)),null==e("alertify-logs")&&(u=s.createElement("section"),u.setAttribute("id","alertify-logs"),u.className="alertify-logs alertify-logs-hidden",s.body.appendChild(u)),s.body.setAttribute("tabindex","0"),this.transition=f()},log:function(t,i,e){var s=function(){u&&null!==u.scrollTop||s()};return this.init(),s(),u.className="alertify-logs",this.notify(t,i,e),this},notify:function(t,i,e){var r=s.createElement("article");r.className="alertify-log"+("string"==typeof i&&""!==i?" alertify-log-"+i:""),r.innerHTML=t,u.appendChild(r),setTimeout(function(){r.className=r.className+" alertify-log-show"},50),this.close(r,e)},set:function(t){var i;if("object"!=typeof t&&t instanceof Array)throw new Error("args must be an object");for(i in t)t.hasOwnProperty(i)&&(this[i]=t[i])},setFocus:function(){g?(g.focus(),g.select()):l.focus()},setup:function(t){var s,d=b[0],c=this;w=!0,s=function(t){t.stopPropagation(),c.setFocus(),c.unbind(_,c.transition.type,s)},this.transition.supported&&!t&&this.bind(_,this.transition.type,s),_.innerHTML=this.build(d),a=e("alertify-resetFocus"),h=e("alertify-resetFocusBack"),o=e("alertify-ok")||i,r=e("alertify-cancel")||i,n=e("alertify-bookmark")||i,l="cancel"===y.buttonFocus?r:"none"===y.buttonFocus?e("alertify-noneFocus"):o,g=e("alertify-text")||i,p=e("alertify-form")||i,"string"==typeof d.placeholder&&""!==d.placeholder&&(g.value=d.placeholder),t&&this.setFocus(),this.addListeners(d.callback)},unbind:function(t,i,e){"function"==typeof t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent&&t.detachEvent("on"+i,e)}},{alert:function(t,i,e){return y.dialog(t,"alert",i,"",e),this},confirm:function(t,i,e){return y.dialog(t,"confirm",i,"",e),this},extend:y.extend,init:y.init,log:function(t,i,e){return y.log(t,i,e),this},prompt:function(t,i,e,s){return y.dialog(t,"prompt",i,e,s),this},success:function(t,i){return y.log(t,"success",i),this},error:function(t,i){return y.log(t,"error",i),this},set:function(t){y.set(t)},labels:y.labels,debug:y.handleErrors}},"function"==typeof define?define([],function(){return new e}):"undefined"==typeof t.alertify&&(t.alertify=new e)}(this),function(){function t(t,i,e,s){if(t.addEventListener)return t.addEventListener(i,e,s),{destroy:function(){t.removeEventListener(i,e,s)}};var r=function(){e.handleEvent(window.event,e)};return t.attachEvent("on"+i,r),{destroy:function(){t.detachEvent("on"+i,r)}}}var e="ontouchstart"in window;this.FastButton=function(i,s,r){this.events=[],this.touchEvents=[],this.element=i,this.handler=s,this.useCapture=r,e&&this.events.push(t(i,"touchstart",this,this.useCapture)),this.events.push(t(i,"click",this,this.useCapture))},this.FastButton.prototype.destroy=function(){for(i=this.events.length-1;i>=0;i-=1)this.events[i].destroy();this.events=this.touchEvents=this.element=this.handler=this.fastButton=null},this.FastButton.prototype.handleEvent=function(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onClick(t);break;case"click":this.onClick(t)}},this.FastButton.prototype.onTouchStart=function(i){i.stopPropagation?i.stopPropagation():i.cancelBubble=!0,this.touchEvents.push(t(this.element,"touchend",this,this.useCapture)),this.touchEvents.push(t(document.body,"touchmove",this,this.useCapture)),this.startX=i.touches[0].clientX,this.startY=i.touches[0].clientY},this.FastButton.prototype.onTouchMove=function(t){(Math.abs(t.touches[0].clientX-this.startX)>10||Math.abs(t.touches[0].clientY-this.startY)>10)&&this.reset()},this.FastButton.prototype.onClick=function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,this.reset();var i=this.handler.call(this.element,t);return"touchend"==t.type&&clickbuster.preventGhostClick(this.startX,this.startY),i},this.FastButton.prototype.reset=function(){for(i=this.touchEvents.length-1;i>=0;i-=1)this.touchEvents[i].destroy();this.touchEvents=[]},this.clickbuster=function(){},this.clickbuster.preventGhostClick=function(t,i){clickbuster.coordinates.push(t,i),window.setTimeout(clickbuster.pop,2500)},this.clickbuster.pop=function(){clickbuster.coordinates.splice(0,2)},this.clickbuster.onClick=function(t){for(var i=0;i<clickbuster.coordinates.length;i+=2){var e=clickbuster.coordinates[i],s=clickbuster.coordinates[i+1];Math.abs(t.clientX-e)<25&&Math.abs(t.clientY-s)<25&&(t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,t.preventDefault?t.preventDefault():t.returnValue=!1)}},e&&(document.addEventListener("click",clickbuster.onClick,!0),clickbuster.coordinates=[])}(this),function(t){t.fn.tclick=function(t){return this.bind("touchstart",function(i){t.call(this,i),i.stopPropagation(),i.preventDefault()}),this.bind("click",function(i){t.call(this,i)}),this}}(jQuery),function(t){t.event.special.fastClick={setup:function(){t(this).data("fastClick",new FastButton(this,t.event.special.fastClick.handler))},teardown:function(){t(this).data("fastClick").destroy(),t(this).removeData("fastClick")},handler:function(i){i=t.event.fix(i),i.type="fastClick",t.event.dispatch.apply(this,arguments)}},t.fn.fastClick=function(i){return t(this).each(function(){return i?t(this).bind("fastClick",i):t(this).trigger("fastClick")})}}(jQuery),function(t){t.extend({gracefulWebSocket:function(i,e){function s(){function i(){return d.previousRequest=d.currentRequest,d.currentRequest=(new Date).getTime(),t.extend({previousRequest:d.previousRequest,currentRequest:d.currentRequest},r.fallbackPollParams)}function e(t){var i={data:t};d.onmessage(i)}function s(){t.ajax({type:r.fallbackPollMethod,url:r.fallbackPollURL,dataType:"text",data:i(),success:e,error:function(){t(d).triggerHandler("error")}})}const o=0,n=1,a=3;var h,l,d={readyState:o,bufferedAmount:0,send:function(s){var o=!0;return t.ajax({async:!1,type:r.fallbackSendMethod,url:r.fallbackSendURL+"?"+t.param(i()),data:s,dataType:"text",contentType:"application/x-www-form-urlencoded; charset=utf-8",success:e,error:function(){o=!1,t(d).triggerHandler("error")}}),o},close:function(){clearTimeout(l),clearInterval(h),this.readyState=a,t(d).triggerHandler("close")},onopen:function(){},onmessage:function(){},onerror:function(){},onclose:function(){},previousRequest:null,currentRequest:null};return l=setTimeout(function(){d.readyState=n,t(d).triggerHandler("open"),s(),h=setInterval(s,r.fallbackPollInterval)},r.fallbackOpenDelay),d}this.defaults={keepAlive:!1,autoReconnect:!1,fallback:!0,fallbackSendURL:i.replace("ws:","http:").replace("wss:","https:"),fallbackSendMethod:"POST",fallbackPollURL:i.replace("ws:","http:").replace("wss:","https:"),fallbackPollMethod:"GET",fallbackOpenDelay:100,fallbackPollInterval:3e3,fallbackPollParams:{}};var r=t.extend({},this.defaults,e),o=window.WebSocket?new WebSocket(i):new s;return t(window).unload(function(){o.close(),o=null}),o}})}(jQuery),function(t,i){function e(t,i,e){return t.addEventListener?(t.addEventListener(i,e,!1),void 0):(t.attachEvent("on"+i,e),void 0)}function s(t){if("keypress"==t.type){var i=String.fromCharCode(t.which);return t.shiftKey||(i=i.toLowerCase()),i}return $[t.which]?$[t.which]:k[t.which]?k[t.which]:String.fromCharCode(t.which).toLowerCase()}function r(t,i){return t.sort().join(",")===i.sort().join(",")}function o(t){t=t||{};var i,e=!1;for(i in A)t[i]?e=!0:A[i]=0;e||(F=!1)}function n(t,i,e,s,o,n){var a,h,l=[],d=e.type;if(!M[t])return[];for("keyup"==d&&u(t)&&(i=[t]),a=0;a<M[t].length;++a)if(h=M[t][a],(s||!h.seq||A[h.seq]==h.level)&&d==h.action&&("keypress"==d&&!e.metaKey&&!e.ctrlKey||r(i,h.modifiers))){var c=!s&&h.combo==o,_=s&&h.seq==s&&h.level==n;(c||_)&&M[t].splice(a,1),l.push(h)}return l}function a(t){var i=[];return t.shiftKey&&i.push("shift"),t.altKey&&i.push("alt"),t.ctrlKey&&i.push("ctrl"),t.metaKey&&i.push("meta"),i}function h(t){return t.preventDefault?(t.preventDefault(),void 0):(t.returnValue=!1,void 0)}function l(t){return t.stopPropagation?(t.stopPropagation(),void 0):(t.cancelBubble=!0,void 0)}function d(t,i,e,s){L.stopCallback(i,i.target||i.srcElement,e,s)||t(i,e)===!1&&(h(i),l(i))}function c(t,i,e){var s,r=n(t,i,e),a={},h=0,l=!1;for(s=0;s<r.length;++s)r[s].seq&&(h=Math.max(h,r[s].level));for(s=0;s<r.length;++s)if(r[s].seq){if(r[s].level!=h)continue;l=!0,a[r[s].seq]=1,d(r[s].callback,e,r[s].combo,r[s].seq)}else l||d(r[s].callback,e,r[s].combo);var c="keypress"==e.type&&P;e.type!=F||u(t)||c||o(a),P=l&&"keydown"==e.type}function _(t){"number"!=typeof t.which&&(t.which=t.keyCode);var i=s(t);if(i)return"keyup"==t.type&&N===i?(N=!1,void 0):(L.handleKey(i,a(t),t),void 0)}function u(t){return"shift"==t||"ctrl"==t||"alt"==t||"meta"==t}function p(){clearTimeout(x),x=setTimeout(o,1e3)}function g(){if(!z){z={};for(var t in $)t>95&&112>t||$.hasOwnProperty(t)&&(z[$[t]]=t)}return z}function f(t,i,e){return e||(e=g()[t]?"keydown":"keypress"),"keypress"==e&&i.length&&(e="keydown"),e}function y(t,i,e,r){function n(i){return function(){F=i,++A[t],p()}}function a(i){d(e,i,t),"keyup"!==r&&(N=s(i)),setTimeout(o,10)}A[t]=0;for(var h=0;h<i.length;++h){var l=h+1===i.length,c=l?a:n(r||w(i[h+1]).action);v(i[h],c,r,t,h)}}function m(t){return"+"===t?["+"]:t.split("+")}function w(t,i){var e,s,r,o=[];for(e=m(t),r=0;r<e.length;++r)s=e[r],E[s]&&(s=E[s]),i&&"keypress"!=i&&C[s]&&(s=C[s],o.push("shift")),u(s)&&o.push(s);return i=f(s,o,i),{key:s,modifiers:o,action:i}}function v(t,i,e,s,r){T[t+":"+e]=i,t=t.replace(/\s+/g," ");var o,a=t.split(" ");return a.length>1?(y(t,a,i,e),void 0):(o=w(t,e),M[o.key]=M[o.key]||[],n(o.key,o.modifiers,{type:o.action},s,t,r),M[o.key][s?"unshift":"push"]({callback:i,modifiers:o.modifiers,action:o.action,seq:s,level:r,combo:t}),void 0)}function b(t,i,e){for(var s=0;s<t.length;++s)v(t[s],i,e)}for(var z,x,$={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},k={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},C={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},E={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},M={},T={},A={},N=!1,P=!1,F=!1,S=1;20>S;++S)$[111+S]="f"+S;for(S=0;9>=S;++S)$[S+96]=S;e(i,"keypress",_),e(i,"keydown",_),e(i,"keyup",_);var L={bind:function(t,i,e){return t=t instanceof Array?t:[t],b(t,i,e),this},unbind:function(t,i){return L.bind(t,function(){},i)},trigger:function(t,i){return T[t+":"+i]&&T[t+":"+i]({},t),this},reset:function(){return M={},T={},this},stopCallback:function(t,i){return(" "+i.className+" ").indexOf(" mousetrap ")>-1?!1:"INPUT"==i.tagName||"SELECT"==i.tagName||"TEXTAREA"==i.tagName||i.isContentEditable},handleKey:c};t.Mousetrap=L,"function"==typeof define&&define.amd&&define(L)}(window,document),function(){var t=new $.Event("remove"),i=$.fn.remove;$.fn.remove=function(){return $(this).trigger(t),i.apply(this,arguments)}}(),function(t){t.fn.drags=function(i){if(i=t.extend(t.fn.drags.defaults,i),""===i.handle)var e=this;else var e=this.find(i.handle);var s=!1;return e.css("cursor",i.cursor).on("mousedown",function(r){if(s=!0,i.condition()){if(""===i.handle)var o=t(this).addClass("drags");else var o=t(this).addClass("active-handle").parent().addClass("drags");i.start(t("drags"));var n=o.css("z-index"),a=o.outerHeight(),h=o.outerWidth(),l=r.pageX,d=r.pageY,c=o.offset().top+a-d;pos_x=o.offset().left+h-l,o.css("z-index",1e3).parent().on("mousemove",function(r){if(d="y"==i.axis?r.pageY:d,l="X"==i.axis?r.pageY:l,null!=i.boundary&&""!=i.boundary){var o=i.boundary.offset().top,_=i.boundary.offset().top+i.boundary.outerHeight();o>d?(d=o,e.trigger("mouseup")):d>_&&(d=_,e.trigger("mouseup"))}s&&i.move(t(".drags")),t(".drags").offset({top:d+c-a,left:l+pos_x-h}).on("mouseup",function(){t(this).removeClass("drags").css("z-index",n)})}),r.preventDefault()}}).on("mouseup",function(){s=!1,""===i.handle?t(this).removeClass("drags"):t(this).removeClass("active-handle").parent().removeClass("drags"),i.stop()})},t.fn.drags.defaults={handle:"",cursor:"move",axis:null,condition:function(){return!0},move:function(){return!0},start:function(){return!0},stop:function(){return!0},boundary:null}}(jQuery),function(t){function i(i){return i[0]&&t.isPlainObject(i[0])?this.data=i[0]:this.el=i,this.isCoords=!0,this.coords={},this.init(),this}var e=i.prototype;e.init=function(){this.set(),this.original_coords=this.get()},e.set=function(t,i){var e=this.el;if(e&&!t&&(this.data=e.offset(),this.data.width=e.width(),this.data.height=e.height()),e&&t&&!i){var s=e.offset();this.data.top=s.top,this.data.left=s.left}var r=this.data;return"undefined"==typeof r.left&&(r.left=r.x1),"undefined"==typeof r.top&&(r.top=r.y1),this.coords.x1=r.left,this.coords.y1=r.top,this.coords.x2=r.left+r.width,this.coords.y2=r.top+r.height,this.coords.cx=r.left+r.width/2,this.coords.cy=r.top+r.height/2,this.coords.width=r.width,this.coords.height=r.height,this.coords.el=e||!1,this},e.update=function(i){if(!i&&!this.el)return this;if(i){var e=t.extend({},this.data,i);return this.data=e,this.set(!0,!0)}return this.set(!0),this},e.get=function(){return this.coords},e.destroy=function(){this.el.removeData("coords"),delete this.el},t.fn.coords=function(){if(this.data("coords"))return this.data("coords");var t=new i(this,arguments[0]);return this.data("coords",t),t}}(jQuery,window,document),function(t,i,e){function s(i,e,s){this.options=t.extend(r,s),this.$element=i,this.last_colliders=[],this.last_colliders_coords=[],this.set_colliders(e),this.init()}var r={colliders_context:e.body,overlapping_region:"C"},o=s.prototype;o.init=function(){this.find_collisions()},o.overlaps=function(t,i){var e=!1,s=!1;return(i.x1>=t.x1&&i.x1<=t.x2||i.x2>=t.x1&&i.x2<=t.x2||t.x1>=i.x1&&t.x2<=i.x2)&&(e=!0),(i.y1>=t.y1&&i.y1<=t.y2||i.y2>=t.y1&&i.y2<=t.y2||t.y1>=i.y1&&t.y2<=i.y2)&&(s=!0),e&&s},o.detect_overlapping_region=function(t,i){var e="",s="";return t.y1>i.cy&&t.y1<i.y2&&(e="N"),t.y2>i.y1&&t.y2<i.cy&&(e="S"),t.x1>i.cx&&t.x1<i.x2&&(s="W"),t.x2>i.x1&&t.x2<i.cx&&(s="E"),e+s||"C"},o.calculate_overlapped_area_coords=function(i,e){var s=Math.max(i.x1,e.x1),r=Math.max(i.y1,e.y1),o=Math.min(i.x2,e.x2),n=Math.min(i.y2,e.y2);return t({left:s,top:r,width:o-s,height:n-r}).coords().get()},o.calculate_overlapped_area=function(t){return t.width*t.height},o.manage_colliders_start_stop=function(i,e,s){for(var r=this.last_colliders_coords,o=0,n=r.length;n>o;o++)-1===t.inArray(r[o],i)&&e.call(this,r[o]);for(var a=0,h=i.length;h>a;a++)-1===t.inArray(i[a],r)&&s.call(this,i[a])},o.find_collisions=function(i){for(var e=this,s=this.options.overlapping_region,r=[],o=[],n=this.colliders||this.$colliders,a=n.length,h=e.$element.coords().update(i||!1).get();a--;){var l=e.$colliders?t(n[a]):n[a],d=l.isCoords?l:l.coords(),c=d.get(),_=e.overlaps(h,c);if(_){var u=e.detect_overlapping_region(h,c);if(u===s||"all"===s){var p=e.calculate_overlapped_area_coords(h,c),g=e.calculate_overlapped_area(p),f={area:g,area_coords:p,region:u,coords:c,player_coords:h,el:l};e.options.on_overlap&&e.options.on_overlap.call(this,f),r.push(d),o.push(f)}}}return(e.options.on_overlap_stop||e.options.on_overlap_start)&&this.manage_colliders_start_stop(r,e.options.on_overlap_start,e.options.on_overlap_stop),this.last_colliders_coords=r,o},o.get_closest_colliders=function(t){var i=this.find_collisions(t);return i.sort(function(t,i){return"C"===t.region&&"C"===i.region?t.coords.y1<i.coords.y1||t.coords.x1<i.coords.x1?-1:1:t.area<i.area?1:1}),i},o.set_colliders=function(i){"string"==typeof i||i instanceof t?this.$colliders=t(i,this.options.colliders_context).not(this.$element):this.colliders=t(i)},t.fn.collision=function(t,i){return new s(this,t,i)}}(jQuery,window,document),function(t){t.delay=function(t,i){var e=Array.prototype.slice.call(arguments,2);return setTimeout(function(){return t.apply(null,e)},i)},t.debounce=function(t,i,e){var s;return function(){var r=this,o=arguments,n=function(){s=null,e||t.apply(r,o)};e&&!s&&t.apply(r,o),clearTimeout(s),s=setTimeout(n,i)}},t.throttle=function(t,i){var e,s,r,o,n,a,h=debounce(function(){n=o=!1},i);return function(){e=this,s=arguments;var l=function(){r=null,n&&t.apply(e,s),h()};return r||(r=setTimeout(l,i)),o?n=!0:a=t.apply(e,s),h(),o=!0,a}}}(window),function(t,i,e){function s(i,s){this.options=t.extend({},r,s),this.$body=t(e.body),this.$container=t(i),this.$dragitems=t(this.options.items,this.$container),this.is_dragging=!1,this.player_min_left=0+this.options.offset_left,this.init()}var r={items:"li",distance:1,limit:!0,offset_left:0,autoscroll:!0,ignore_dragging:["INPUT","TEXTAREA","SELECT","BUTTON"],handle:null,container_width:0,move_element:!0,helper:!1,remove_helper:!0},o=t(i),n={x:"left",y:"top"},a=!!("ontouchstart"in i),h={start:a?"touchstart.gridster-draggable":"mousedown.gridster-draggable",move:a?"touchmove.gridster-draggable":"mousemove.gridster-draggable",end:a?"touchend.gridster-draggable":"mouseup.gridster-draggable"},l=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},d=s.prototype;d.init=function(){var e=this.$container.css("position");this.calculate_dimensions(),this.$container.css("position","static"===e?"relative":e),this.disabled=!1,this.events(),t(i).bind("resize.gridster-draggable",throttle(t.proxy(this.calculate_dimensions,this),200))},d.events=function(){this.$container.on("selectstart.gridster-draggable",t.proxy(this.on_select_start,this)),this.$container.on(h.start,this.options.items,t.proxy(this.drag_handler,this)),this.$body.on(h.end,t.proxy(function(t){this.is_dragging=!1,this.disabled||(this.$body.off(h.move),this.drag_start&&this.on_dragstop(t))},this))},d.get_actual_pos=function(t){var i=t.position();return i},d.get_mouse_pos=function(t){if(a){var i=t.originalEvent;t=i.touches.length?i.touches[0]:i.changedTouches[0]}return{left:t.clientX,top:t.clientY}},d.get_offset=function(t){t.preventDefault();var i=this.get_mouse_pos(t),e=Math.round(i.left-this.mouse_init_pos.left),s=Math.round(i.top-this.mouse_init_pos.top),r=Math.round(this.el_init_offset.left+e-this.baseX+this.scroll_offset_x),o=Math.round(this.el_init_offset.top+s-this.baseY+this.scroll_offset_y);return this.options.limit&&(r>this.player_max_left?r=this.player_max_left:r<this.player_min_left&&(r=this.player_min_left)),{position:{left:r,top:o},pointer:{left:i.left,top:i.top,diff_left:e+this.scroll_offset_x,diff_top:s+this.scroll_offset_y}}},d.get_drag_data=function(t){var i=this.get_offset(t);return i.$player=this.$player,i.$helper=this.helper?this.$helper:this.$player,i},d.set_limits=function(t){return t||(t=this.$container.width()),this.player_max_left=t-this.player_width+-this.options.offset_left,this.options.container_width=t,this},d.scroll_in=function(i,s){var r,a=n[i],h=50,d=30,c="x"===i,_=c?this.window_width:this.window_height,u=c?t(e).width():t(e).height(),p=c?this.$player.width():this.$player.height(),g=o["scroll"+l(a)](),f=g,y=f+_,m=y-h,w=f+h,v=f+s.pointer[a],b=u-_+p;return v>=m&&(r=g+d,b>r&&(o["scroll"+l(a)](r),this["scroll_offset_"+i]+=d)),w>=v&&(r=g-d,r>0&&(o["scroll"+l(a)](r),this["scroll_offset_"+i]-=d)),this},d.manage_scroll=function(t){this.scroll_in("x",t),this.scroll_in("y",t)},d.calculate_dimensions=function(){this.window_height=o.height(),this.window_width=o.width()},d.drag_handler=function(i){i.target.nodeName;if(!this.disabled&&(1===i.which||a)&&!this.ignore_drag(i)){var e=this,s=!0;return this.$player=t(i.currentTarget),this.el_init_pos=this.get_actual_pos(this.$player),this.mouse_init_pos=this.get_mouse_pos(i),this.offsetY=this.mouse_init_pos.top-this.el_init_pos.top,this.$body.on(h.move,function(t){var i=e.get_mouse_pos(t),r=Math.abs(i.left-e.mouse_init_pos.left),o=Math.abs(i.top-e.mouse_init_pos.top);return r>e.options.distance||o>e.options.distance?s?(s=!1,e.on_dragstart.call(e,t),!1):(e.is_dragging===!0&&e.on_dragmove.call(e,t),!1):!1}),a?void 0:!1}},d.on_dragstart=function(t){if(t.preventDefault(),this.is_dragging)return this;this.drag_start=this.is_dragging=!0;var i=this.$container.offset();return this.baseX=Math.round(i.left),this.baseY=Math.round(i.top),this.initial_container_width=this.options.container_width||this.$container.width(),"clone"===this.options.helper?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.scroll_offset_y=0,this.scroll_offset_x=0,this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.player_height=this.$player.height(),this.set_limits(this.options.container_width),this.options.start&&this.options.start.call(this.$player,t,this.get_drag_data(t)),!1},d.on_dragmove=function(t){var i=this.get_drag_data(t);this.options.autoscroll&&this.manage_scroll(i),this.options.move_element&&(this.helper?this.$helper:this.$player).css({position:"absolute",left:i.position.left,top:i.position.top});var e=this.last_position||i.position;return i.prev_position=e,this.options.drag&&this.options.drag.call(this.$player,t,i),this.last_position=i.position,!1},d.on_dragstop=function(t){var i=this.get_drag_data(t);return this.drag_start=!1,this.options.stop&&this.options.stop.call(this.$player,t,i),this.helper&&this.options.remove_helper&&this.$helper.remove(),!1},d.on_select_start=function(t){return this.disabled||this.ignore_drag(t)?void 0:!1},d.enable=function(){this.disabled=!1},d.disable=function(){this.disabled=!0},d.destroy=function(){this.disable(),this.$container.off(".gridster-draggable"),this.$body.off(".gridster-draggable"),t(i).off(".gridster-draggable"),t.removeData(this.$container,"drag")},d.ignore_drag=function(i){return this.options.handle?!t(i.target).is(this.options.handle):t.isFunction(this.options.ignore_dragging)?this.options.ignore_dragging(i):t(i.target).is(this.options.ignore_dragging.join(", "))},t.fn.drag=function(t){return new s(this,t)}}(jQuery,window,document),function(t,i,e){function s(i,e){this.options=t.extend(!0,{},r,e),this.$el=t(i),this.$wrapper=this.$el.parent(),this.$widgets=this.$el.children(this.options.widget_selector).addClass("gs-w"),this.widgets=[],this.$changed=t([]),this.wrapper_width=this.$wrapper.width(),this.min_widget_width=2*this.options.widget_margins[0]+this.options.widget_base_dimensions[0],this.min_widget_height=2*this.options.widget_margins[1]+this.options.widget_base_dimensions[1],this.generated_stylesheets=[],this.$style_tags=t([]),this.init()}var r={namespace:"",widget_selector:"li",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,max_cols:1/0,min_rows:15,max_size_x:!1,autogrow_cols:!1,autogenerate_stylesheet:!0,avoid_overlapped_widgets:!0,serialize_params:function(t,i){return{col:i.col,row:i.row,size_x:i.size_x,size_y:i.size_y}},collision:{},draggable:{items:".gs-w",distance:4},resize:{enabled:!1,axes:["both"],handle_append_to:"",handle_class:"gs-resize-handle",max_size:[1/0,1/0],min_size:[1,1]}};s.generated_stylesheets=[];var o=s.prototype;o.init=function(){this.options.resize.enabled&&this.setup_resize(),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this.set_dom_grid_width(),this.$wrapper.addClass("ready"),this.draggable(),this.options.resize.enabled&&this.resizable(),t(i).bind("resize.gridster",throttle(t.proxy(this.recalculate_faux_grid,this),200))},o.disable=function(){return this.$wrapper.find(".player-revert").removeClass("player-revert"),this.drag_api.disable(),this},o.enable=function(){return this.drag_api.enable(),this},o.disable_resize=function(){return this.$el.addClass("gs-resize-disabled"),this.resize_api.disable(),this},o.enable_resize=function(){return this.$el.removeClass("gs-resize-disabled"),this.resize_api.enable(),this},o.add_widget=function(i,e,s,r,o,n,a){var h;e||(e=1),s||(s=1),!r&!o?h=this.next_position(e,s):(h={col:r,row:o},this.empty_cells(r,o,e,s));var l=t(i).attr({"data-col":h.col,"data-row":h.row,"data-sizex":e,"data-sizey":s}).addClass("gs-w").appendTo(this.$el).hide();return this.$widgets=this.$widgets.add(l),this.register_widget(l),this.add_faux_rows(h.size_y),n&&this.set_widget_max_size(l,n),a&&this.set_widget_min_size(l,a),this.set_dom_grid_width(),this.set_dom_grid_height(),this.drag_api.set_limits(this.cols*this.min_widget_width),l.fadeIn()},o.set_widget_min_size=function(t,i){if(t="number"==typeof t?this.$widgets.eq(t):t,!t.length)return this;var e=t.data("coords").grid;return e.min_size_x=i[0],e.min_size_y=i[1],this},o.set_widget_max_size=function(t,i){if(t="number"==typeof t?this.$widgets.eq(t):t,!t.length)return this;var e=t.data("coords").grid;return e.max_size_x=i[0],e.max_size_y=i[1],this},o.add_resize_handle=function(i){var e=this.options.resize.handle_append_to;return t(this.resize_handle_tpl).appendTo(e?t(e,i):i),this},o.resize_widget=function(t,i,e,s){var r=t.coords().grid,o=r.col,n=this.options.max_cols,a=r.size_y,h=r.col,l=h;i||(i=r.size_x),e||(e=r.size_y),1/0!==n&&(i=Math.min(i,n-o+1)),e>a&&this.add_faux_rows(Math.max(e-a,0));var d=o+i-1;d>this.cols&&this.add_faux_cols(d-this.cols);var c={col:l,row:r.row,size_x:i,size_y:e};return this.mutate_widget_in_gridmap(t,r,c),this.set_dom_grid_height(),this.set_dom_grid_width(),s&&s.call(this,c.size_x,c.size_y),t},o.mutate_widget_in_gridmap=function(i,e,s){var r=(e.size_x,e.size_y),o=this.get_cells_occupied(e),n=this.get_cells_occupied(s),a=[];
  t.each(o.cols,function(i,e){-1===t.inArray(e,n.cols)&&a.push(e)});var h=[];t.each(n.cols,function(i,e){-1===t.inArray(e,o.cols)&&h.push(e)});var l=[];t.each(o.rows,function(i,e){-1===t.inArray(e,n.rows)&&l.push(e)});var d=[];if(t.each(n.rows,function(i,e){-1===t.inArray(e,o.rows)&&d.push(e)}),this.remove_from_gridmap(e),h.length){var c=[s.col,s.row,s.size_x,Math.min(r,s.size_y),i];this.empty_cells.apply(this,c)}if(d.length){var _=[s.col,s.row,s.size_x,s.size_y,i];this.empty_cells.apply(this,_)}if(e.col=s.col,e.row=s.row,e.size_x=s.size_x,e.size_y=s.size_y,this.add_to_gridmap(s,i),i.removeClass("player-revert"),i.data("coords").update({width:s.size_x*this.options.widget_base_dimensions[0]+(s.size_x-1)*this.options.widget_margins[0]*2,height:s.size_y*this.options.widget_base_dimensions[1]+(s.size_y-1)*this.options.widget_margins[1]*2}),i.attr({"data-col":s.col,"data-row":s.row,"data-sizex":s.size_x,"data-sizey":s.size_y}),a.length){var u=[a[0],s.row,a.length,Math.min(r,s.size_y),i];this.remove_empty_cells.apply(this,u)}if(l.length){var p=[s.col,s.row,s.size_x,s.size_y,i];this.remove_empty_cells.apply(this,p)}return this.move_widget_up(i),this},o.empty_cells=function(i,e,s,r,o){var n=this.widgets_below({col:i,row:e-r,size_x:s,size_y:r});return n.not(o).each(t.proxy(function(i,s){var o=t(s).coords().grid;if(o.row<=e+r-1){var n=e+r-o.row;this.move_widget_down(t(s),n)}},this)),this.set_dom_grid_height(),this},o.remove_empty_cells=function(i,e,s,r,o){var n=this.widgets_below({col:i,row:e,size_x:s,size_y:r});return n.not(o).each(t.proxy(function(i,e){this.move_widget_up(t(e),r)},this)),this.set_dom_grid_height(),this},o.next_position=function(t,i){t||(t=1),i||(i=1);for(var e,s=this.gridmap,r=s.length,o=[],n=1;r>n;n++){e=s[n].length;for(var a=1;e>=a;a++){var h=this.can_move_to({size_x:t,size_y:i},n,a);h&&o.push({col:n,row:a,size_y:i,size_x:t})}}return o.length?this.sort_by_row_and_col_asc(o)[0]:!1},o.remove_widget=function(i,e,s){var r=i instanceof t?i:t(i),o=r.coords().grid;t.isFunction(e)&&(s=e,e=!1),this.cells_occupied_by_placeholder={},this.$widgets=this.$widgets.not(r);var n=this.widgets_below(r);return this.remove_from_gridmap(o),r.fadeOut(t.proxy(function(){r.remove(),e||n.each(t.proxy(function(i,e){this.move_widget_up(t(e),o.size_y)},this)),this.set_dom_grid_height(),s&&s.call(this,i)},this)),this},o.remove_all_widgets=function(i){return this.$widgets.each(t.proxy(function(t,e){this.remove_widget(e,!0,i)},this)),this},o.serialize=function(i){i||(i=this.$widgets);var e=[];return i.each(t.proxy(function(i,s){e.push(this.options.serialize_params(t(s),t(s).coords().grid))},this)),e},o.serialize_changed=function(){return this.serialize(this.$changed)},o.register_widget=function(i){var e={col:parseInt(i.attr("data-col"),10),row:parseInt(i.attr("data-row"),10),size_x:parseInt(i.attr("data-sizex"),10),size_y:parseInt(i.attr("data-sizey"),10),max_size_x:parseInt(i.attr("data-max-sizex"),10)||!1,max_size_y:parseInt(i.attr("data-max-sizey"),10)||!1,min_size_x:parseInt(i.attr("data-min-sizex"),10)||!1,min_size_y:parseInt(i.attr("data-min-sizey"),10)||!1,el:i};return this.options.avoid_overlapped_widgets&&!this.can_move_to({size_x:e.size_x,size_y:e.size_y},e.col,e.row)&&(t.extend(e,this.next_position(e.size_x,e.size_y)),i.attr({"data-col":e.col,"data-row":e.row,"data-sizex":e.size_x,"data-sizey":e.size_y})),i.data("coords",i.coords()),i.data("coords").grid=e,this.add_to_gridmap(e,i),this.options.resize.enabled&&this.add_resize_handle(i),this},o.update_widget_position=function(t,i){return this.for_each_cell_occupied(t,function(t,e){return this.gridmap[t]?(this.gridmap[t][e]=i,void 0):this}),this},o.remove_from_gridmap=function(t){return this.update_widget_position(t,!1)},o.add_to_gridmap=function(i,e){if(this.update_widget_position(i,e||i.el),i.el){var s=this.widgets_below(i.el);s.each(t.proxy(function(i,e){this.move_widget_up(t(e))},this))}},o.draggable=function(){var i=this,e=t.extend(!0,{},this.options.draggable,{offset_left:this.options.widget_margins[0],offset_top:this.options.widget_margins[1],container_width:this.cols*this.min_widget_width,limit:!0,ignore_dragging:["INPUT","TEXTAREA","SELECT","BUTTON","."+this.options.resize.handle_class],start:function(e,s){i.$widgets.filter(".player-revert").removeClass("player-revert"),i.$player=t(this),i.$helper=t(s.$helper),i.helper=!i.$helper.is(i.$player),i.on_start_drag.call(i,e,s),i.$el.trigger("gridster:dragstart")},stop:function(t,e){i.on_stop_drag.call(i,t,e),i.$el.trigger("gridster:dragstop")},drag:throttle(function(t,e){i.on_drag.call(i,t,e),i.$el.trigger("gridster:drag")},60)});return this.drag_api=this.$el.drag(e),this},o.resizable=function(){return this.resize_api=this.$el.drag({items:"."+this.options.resize.handle_class,offset_left:this.options.widget_margins[0],container_width:this.container_width,move_element:!1,resize:!0,limit:this.options.autogrow_cols?!1:!0,start:t.proxy(this.on_start_resize,this),stop:t.proxy(function(i,e){delay(t.proxy(function(){this.on_stop_resize(i,e)},this),120)},this),drag:throttle(t.proxy(this.on_resize,this),60)}),this},o.setup_resize=function(){this.resize_handle_class=this.options.resize.handle_class;var i=this.options.resize.axes,e='<span class="'+this.resize_handle_class+" "+this.resize_handle_class+'-{type}" />';return this.resize_handle_tpl=t.map(i,function(t){return e.replace("{type}",t)}).join(""),this},o.on_start_drag=function(i,e){this.$helper.add(this.$player).add(this.$wrapper).addClass("dragging"),this.highest_col=this.get_highest_occupied_cell().col,this.$player.addClass("player"),this.player_grid_data=this.$player.coords().grid,this.placeholder_grid_data=t.extend({},this.player_grid_data),this.set_dom_grid_height(this.$el.height()+this.player_grid_data.size_y*this.min_widget_height),this.set_dom_grid_width(this.cols);var s=this.player_grid_data.size_x,r=this.cols-this.highest_col;this.options.autogrow_cols&&s>=r&&this.add_faux_cols(Math.min(s-r,1));var o=this.faux_grid,n=this.$player.data("coords").coords;this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data),this.last_cols=[],this.last_rows=[],this.collision_api=this.$helper.collision(o,this.options.collision),this.$preview_holder=t("<"+this.$player.get(0).tagName+" />",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:n.width,height:n.height}}).appendTo(this.$el),this.options.draggable.start&&this.options.draggable.start.call(this,i,e)},o.on_drag=function(t,i){if(null===this.$player)return!1;var e={left:i.position.left+this.baseX,top:i.position.top+this.baseY};if(this.options.autogrow_cols){var s=this.placeholder_grid_data.col+this.placeholder_grid_data.size_x-1;s>=this.cols-1&&this.options.max_cols>=this.cols+1&&(this.add_faux_cols(1),this.set_dom_grid_width(this.cols+1),this.drag_api.set_limits(this.container_width)),this.collision_api.set_colliders(this.faux_grid)}this.colliders_data=this.collision_api.get_closest_colliders(e),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.helper&&this.$player&&this.$player.css({left:i.position.left,top:i.position.top}),this.options.draggable.drag&&this.options.draggable.drag.call(this,t,i)},o.on_stop_drag=function(t,i){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging"),i.position.left=i.position.left+this.baseX,i.position.top=i.position.top+this.baseY,this.colliders_data=this.collision_api.get_closest_colliders(i.position),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.$player.addClass("player-revert").removeClass("player").attr({"data-col":this.placeholder_grid_data.col,"data-row":this.placeholder_grid_data.row}).css({left:"",top:""}),this.$changed=this.$changed.add(this.$player),this.cells_occupied_by_player=this.get_cells_occupied(this.placeholder_grid_data),this.set_cells_player_occupies(this.placeholder_grid_data.col,this.placeholder_grid_data.row),this.$player.coords().grid.row=this.placeholder_grid_data.row,this.$player.coords().grid.col=this.placeholder_grid_data.col,this.options.draggable.stop&&this.options.draggable.stop.call(this,t,i),this.$preview_holder.remove(),this.$player=null,this.$helper=null,this.placeholder_grid_data={},this.player_grid_data={},this.cells_occupied_by_placeholder={},this.cells_occupied_by_player={},this.set_dom_grid_height(),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width)},o.on_start_resize=function(i,e){this.$resized_widget=e.$player.closest(".gs-w"),this.resize_coords=this.$resized_widget.coords(),this.resize_wgd=this.resize_coords.grid,this.resize_initial_width=this.resize_coords.coords.width,this.resize_initial_height=this.resize_coords.coords.height,this.resize_initial_sizex=this.resize_coords.grid.size_x,this.resize_initial_sizey=this.resize_coords.grid.size_y,this.resize_initial_col=this.resize_coords.grid.col,this.resize_last_sizex=this.resize_initial_sizex,this.resize_last_sizey=this.resize_initial_sizey,this.resize_max_size_x=Math.min(this.resize_wgd.max_size_x||this.options.resize.max_size[0],this.options.max_cols-this.resize_initial_col+1),this.resize_max_size_y=this.resize_wgd.max_size_y||this.options.resize.max_size[1],this.resize_min_size_x=this.resize_wgd.min_size_x||this.options.resize.min_size[0]||1,this.resize_min_size_y=this.resize_wgd.min_size_y||this.options.resize.min_size[1]||1,this.resize_initial_last_col=this.get_highest_occupied_cell().col,this.set_dom_grid_width(this.cols),this.resize_dir={right:e.$player.is("."+this.resize_handle_class+"-x"),bottom:e.$player.is("."+this.resize_handle_class+"-y")},this.$resized_widget.css({"min-width":this.options.widget_base_dimensions[0],"min-height":this.options.widget_base_dimensions[1]});var s=this.$resized_widget.get(0).tagName;this.$resize_preview_holder=t("<"+s+" />",{"class":"preview-holder resize-preview-holder","data-row":this.$resized_widget.attr("data-row"),"data-col":this.$resized_widget.attr("data-col"),css:{width:this.resize_initial_width,height:this.resize_initial_height}}).appendTo(this.$el),this.$resized_widget.addClass("resizing"),this.options.resize.start&&this.options.resize.start.call(this,i,e,this.$resized_widget),this.$el.trigger("gridster:resizestart")},o.on_stop_resize=function(i,e){this.$resized_widget.removeClass("resizing").css({width:"",height:""}),delay(t.proxy(function(){this.$resize_preview_holder.remove().css({"min-width":"","min-height":""}),this.options.resize.stop&&this.options.resize.stop.call(this,i,e,this.$resized_widget),this.$el.trigger("gridster:resizestop")},this),300),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width)},o.on_resize=function(t,i){var e,s=i.pointer.diff_left,r=i.pointer.diff_top,o=this.options.widget_base_dimensions[0],n=this.options.widget_base_dimensions[1],a=this.options.widget_margins[0],h=this.options.widget_margins[1],l=this.resize_max_size_x,d=this.resize_min_size_x,c=this.resize_max_size_y,_=this.resize_min_size_y,u=this.options.autogrow_cols,p=1/0,g=1/0,f=Math.ceil(s/(o+2*a)-.2),y=Math.ceil(r/(n+2*h)-.2),m=Math.max(1,this.resize_initial_sizex+f),w=Math.max(1,this.resize_initial_sizey+y),v=this.container_width/this.min_widget_width-this.resize_initial_col+1,b=v*this.min_widget_width-2*a;if(m=Math.max(Math.min(m,l),d),m=Math.min(v,m),e=l*o+(m-1)*a*2,p=Math.min(e,b),min_width=d*o+(m-1)*a*2,w=Math.max(Math.min(w,c),_),g=c*n+(w-1)*h*2,min_height=_*n+(w-1)*h*2,this.resize_dir.right?w=this.resize_initial_sizey:this.resize_dir.bottom&&(m=this.resize_initial_sizex),u){var z=this.resize_initial_col+m-1;u&&this.resize_initial_last_col<=z&&(this.set_dom_grid_width(Math.max(z+1,this.cols)),this.cols<z&&this.add_faux_cols(z-this.cols))}var x={};!this.resize_dir.bottom&&(x.width=Math.max(Math.min(this.resize_initial_width+s,p),min_width)),!this.resize_dir.right&&(x.height=Math.max(Math.min(this.resize_initial_height+r,g),min_height)),this.$resized_widget.css(x),(m!==this.resize_last_sizex||w!==this.resize_last_sizey)&&(this.resize_widget(this.$resized_widget,m,w),this.set_dom_grid_width(this.cols),this.$resize_preview_holder.css({width:"",height:""}).attr({"data-row":this.$resized_widget.attr("data-row"),"data-sizex":m,"data-sizey":w})),this.options.resize.resize&&this.options.resize.resize.call(this,t,i,this.$resized_widget),this.$el.trigger("gridster:resize"),this.resize_last_sizex=m,this.resize_last_sizey=w},o.on_overlapped_column_change=function(i,e){if(!this.colliders_data.length)return this;var s,r=this.get_targeted_columns(this.colliders_data[0].el.data.col),o=this.last_cols.length,n=r.length;for(s=0;n>s;s++)-1===t.inArray(r[s],this.last_cols)&&(i||t.noop).call(this,r[s]);for(s=0;o>s;s++)-1===t.inArray(this.last_cols[s],r)&&(e||t.noop).call(this,this.last_cols[s]);return this.last_cols=r,this},o.on_overlapped_row_change=function(i,e){if(!this.colliders_data.length)return this;var s,r=this.get_targeted_rows(this.colliders_data[0].el.data.row),o=this.last_rows.length,n=r.length;for(s=0;n>s;s++)-1===t.inArray(r[s],this.last_rows)&&(i||t.noop).call(this,r[s]);for(s=0;o>s;s++)-1===t.inArray(this.last_rows[s],r)&&(e||t.noop).call(this,this.last_rows[s]);this.last_rows=r},o.set_player=function(t,i,e){var s=this;e||this.empty_cells_player_occupies();var r=e?{col:t}:s.colliders_data[0].el.data,o=r.col,n=i||r.row;this.player_grid_data={col:o,row:n,size_y:this.player_grid_data.size_y,size_x:this.player_grid_data.size_x},this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data);var a=this.get_widgets_overlapped(this.player_grid_data),h=this.widgets_constraints(a);if(this.manage_movements(h.can_go_up,o,n),this.manage_movements(h.can_not_go_up,o,n),!a.length){var l=this.can_go_player_up(this.player_grid_data);l!==!1&&(n=l),this.set_placeholder(o,n)}return{col:o,row:n}},o.widgets_constraints=function(i){var e,s=t([]),r=[],o=[];return i.each(t.proxy(function(i,e){var n=t(e),a=n.coords().grid;this.can_go_widget_up(a)?(s=s.add(n),r.push(a)):o.push(a)},this)),e=i.not(s),{can_go_up:this.sort_by_row_asc(r),can_not_go_up:this.sort_by_row_desc(o)}},o.sort_by_row_asc=function(i){return i=i.sort(function(i,e){return i.row||(i=t(i).coords().grid,e=t(e).coords().grid),i.row>e.row?1:-1})},o.sort_by_row_and_col_asc=function(t){return t=t.sort(function(t,i){return t.row>i.row||t.row===i.row&&t.col>i.col?1:-1})},o.sort_by_col_asc=function(t){return t=t.sort(function(t,i){return t.col>i.col?1:-1})},o.sort_by_row_desc=function(t){return t=t.sort(function(t,i){return t.row+t.size_y<i.row+i.size_y?1:-1})},o.manage_movements=function(i,e,s){return t.each(i,t.proxy(function(t,i){var r=i,o=r.el,n=this.can_go_widget_up(r);if(n)this.move_widget_to(o,n),this.set_placeholder(e,n+r.size_y);else{var a=this.can_go_player_up(this.player_grid_data);if(!a){var h=s+this.player_grid_data.size_y-r.row;this.move_widget_down(o,h),this.set_placeholder(e,s)}}},this)),this},o.is_player=function(t,i){if(i&&!this.gridmap[t])return!1;var e=i?this.gridmap[t][i]:t;return e&&(e.is(this.$player)||e.is(this.$helper))},o.is_player_in=function(i,e){var s=this.cells_occupied_by_player||{};return t.inArray(i,s.cols)>=0&&t.inArray(e,s.rows)>=0},o.is_placeholder_in=function(i,e){var s=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(i)&&t.inArray(e,s.rows)>=0},o.is_placeholder_in_col=function(i){var e=this.cells_occupied_by_placeholder||[];return t.inArray(i,e.cols)>=0},o.is_empty=function(t,i){return"undefined"!=typeof this.gridmap[t]?"undefined"!=typeof this.gridmap[t][i]&&this.gridmap[t][i]===!1?!0:!1:!0},o.is_occupied=function(t,i){return this.gridmap[t]?this.gridmap[t][i]?!0:!1:!1},o.is_widget=function(t,i){var e=this.gridmap[t];return e?(e=e[i],e?e:!1):!1},o.is_widget_under_player=function(t,i){return this.is_widget(t,i)?this.is_player_in(t,i):!1},o.get_widgets_under_player=function(i){i||(i=this.cells_occupied_by_player||{cols:[],rows:[]});var e=t([]);return t.each(i.cols,t.proxy(function(s,r){t.each(i.rows,t.proxy(function(t,i){this.is_widget(r,i)&&(e=e.add(this.gridmap[r][i]))},this))},this)),e},o.set_placeholder=function(i,e){var s=t.extend({},this.placeholder_grid_data),r=this.widgets_below({col:s.col,row:s.row,size_y:s.size_y,size_x:s.size_x}),o=i+s.size_x-1;o>this.cols&&(i-=o-i);var n=this.placeholder_grid_data.row<e,a=this.placeholder_grid_data.col!==i;this.placeholder_grid_data.col=i,this.placeholder_grid_data.row=e,this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data),this.$preview_holder.attr({"data-row":e,"data-col":i}),(n||a)&&r.each(t.proxy(function(e,r){this.move_widget_up(t(r),this.placeholder_grid_data.col-i+s.size_y)},this));var h=this.get_widgets_under_player(this.cells_occupied_by_placeholder);h.length&&h.each(t.proxy(function(i,r){var o=t(r);this.move_widget_down(o,e+s.size_y-o.data("coords").grid.row)},this))},o.can_go_player_up=function(t){var i=t.row+t.size_y-1,e=!0,s=[],r=1e4,o=this.get_widgets_under_player();return this.for_each_column_occupied(t,function(t){var n=this.gridmap[t],a=i+1;for(s[t]=[];--a>0&&(this.is_empty(t,a)||this.is_player(t,a)||this.is_widget(t,a)&&n[a].is(o));)s[t].push(a),r=r>a?a:r;return 0===s[t].length?(e=!1,!0):(s[t].sort(function(t,i){return t-i}),void 0)}),e?this.get_valid_rows(t,s,r):!1},o.can_go_widget_up=function(t){var i=t.row+t.size_y-1,e=!0,s=[],r=1e4;return this.for_each_column_occupied(t,function(o){var n=this.gridmap[o];s[o]=[];for(var a=i+1;--a>0&&(!this.is_widget(o,a)||this.is_player_in(o,a)||n[a].is(t.el));)this.is_player(o,a)||this.is_placeholder_in(o,a)||this.is_player_in(o,a)||s[o].push(a),r>a&&(r=a);return 0===s[o].length?(e=!1,!0):(s[o].sort(function(t,i){return t-i}),void 0)}),e?this.get_valid_rows(t,s,r):!1},o.get_valid_rows=function(i,e,s){for(var r=i.row,o=i.row+i.size_y-1,n=i.size_y,a=s-1,h=[];++a<=o;){var l=!0;if(t.each(e,function(i,e){t.isArray(e)&&-1===t.inArray(a,e)&&(l=!1)}),l===!0&&(h.push(a),h.length===n))break}var d=!1;return 1===n?h[0]!==r&&(d=h[0]||!1):h[0]!==r&&(d=this.get_consecutive_numbers_index(h,n)),d},o.get_consecutive_numbers_index=function(t,i){for(var e=t.length,s=[],r=!0,o=-1,n=0;e>n;n++){if(r||t[n]===o+1){if(s.push(n),s.length===i)break;r=!1}else s=[],r=!0;o=t[n]}return s.length>=i?t[s[0]]:!1},o.get_widgets_overlapped=function(){var i=t([]),e=[],s=this.cells_occupied_by_player.rows.slice(0);return s.reverse(),t.each(this.cells_occupied_by_player.cols,t.proxy(function(r,o){t.each(s,t.proxy(function(s,r){if(!this.gridmap[o])return!0;var n=this.gridmap[o][r];this.is_occupied(o,r)&&!this.is_player(n)&&-1===t.inArray(n,e)&&(i=i.add(n),e.push(n))},this))},this)),i},o.on_start_overlapping_column=function(t){this.set_player(t,!1)},o.on_start_overlapping_row=function(t){this.set_player(!1,t)},o.on_stop_overlapping_column=function(t){this.set_player(t,!1);var i=this;this.for_each_widget_below(t,this.cells_occupied_by_player.rows[0],function(){i.move_widget_up(this,i.player_grid_data.size_y)})},o.on_stop_overlapping_row=function(t){this.set_player(!1,t);for(var i=this,e=this.cells_occupied_by_player.cols,s=0,r=e.length;r>s;s++)this.for_each_widget_below(e[s],t,function(){i.move_widget_up(this,i.player_grid_data.size_y)})},o.move_widget_to=function(i,e){var s=this,r=i.coords().grid,o=(e-r.row,this.widgets_below(i)),n=this.can_move_to(r,r.col,e,i);return n===!1?!1:(this.remove_from_gridmap(r),r.row=e,this.add_to_gridmap(r),i.attr("data-row",e),this.$changed=this.$changed.add(i),o.each(function(i,e){var r=t(e),o=r.coords().grid,n=s.can_go_widget_up(o);n&&n!==o.row&&s.move_widget_to(r,n)}),this)},o.move_widget_up=function(i,e){var s=i.coords().grid,r=s.row,o=[];return e||(e=1),this.can_go_up(i)?(this.for_each_column_occupied(s,function(s){if(-1===t.inArray(i,o)){var n=i.coords().grid,a=r-e;if(a=this.can_go_up_to_row(n,s,a),!a)return!0;var h=this.widgets_below(i);this.remove_from_gridmap(n),n.row=a,this.add_to_gridmap(n),i.attr("data-row",n.row),this.$changed=this.$changed.add(i),o.push(i),h.each(t.proxy(function(i,s){this.move_widget_up(t(s),e)},this))}}),void 0):!1},o.move_widget_down=function(i,e){var s,r,o,n;if(0>=e)return!1;if(s=i.coords().grid,r=s.row,o=[],n=e,!i)return!1;if(-1===t.inArray(i,o)){var a=i.coords().grid,h=r+e,l=this.widgets_below(i);this.remove_from_gridmap(a),l.each(t.proxy(function(i,e){var s=t(e),r=s.coords().grid,o=this.displacement_diff(r,a,n);o>0&&this.move_widget_down(s,o)},this)),a.row=h,this.update_widget_position(a,i),i.attr("data-row",a.row),this.$changed=this.$changed.add(i),o.push(i)}},o.can_go_up_to_row=function(i,e,s){var r,o=this.gridmap,n=!0,a=[],h=i.row;if(this.for_each_column_occupied(i,function(t){o[t];for(a[t]=[],r=h;r--&&this.is_empty(t,r)&&!this.is_placeholder_in(t,r);)a[t].push(r);return a[t].length?void 0:(n=!1,!0)}),!n)return!1;for(r=s,r=1;h>r;r++){for(var l=!0,d=0,c=a.length;c>d;d++)a[d]&&-1===t.inArray(r,a[d])&&(l=!1);if(l===!0){n=r;break}}return n},o.displacement_diff=function(t,i,e){var s=t.row,r=[],o=i.row+i.size_y;this.for_each_column_occupied(t,function(t){for(var i=0,e=o;s>e;e++)this.is_empty(t,e)&&(i+=1);r.push(i)});var n=Math.max.apply(Math,r);return e-=n,e>0?e:0},o.widgets_below=function(i){var e=t.isPlainObject(i)?i:i.coords().grid,s=this,r=(this.gridmap,e.row+e.size_y-1),o=t([]);return this.for_each_column_occupied(e,function(i){s.for_each_widget_below(i,r,function(){return s.is_player(this)||-1!==t.inArray(this,o)?void 0:(o=o.add(this),!0)})}),this.sort_by_row_asc(o)},o.set_cells_player_occupies=function(t,i){return this.remove_from_gridmap(this.placeholder_grid_data),this.placeholder_grid_data.col=t,this.placeholder_grid_data.row=i,this.add_to_gridmap(this.placeholder_grid_data,this.$player),this},o.empty_cells_player_occupies=function(){return this.remove_from_gridmap(this.placeholder_grid_data),this},o.can_go_up=function(t){var i=t.coords().grid,e=i.row,s=e-1,r=(this.gridmap,!0);return 1===e?!1:(this.for_each_column_occupied(i,function(t){this.is_widget(t,s);return this.is_occupied(t,s)||this.is_player(t,s)||this.is_placeholder_in(t,s)||this.is_player_in(t,s)?(r=!1,!0):void 0}),r)},o.can_move_to=function(t,i,e,s){var r=(this.gridmap,t.el),o={size_y:t.size_y,size_x:t.size_x,col:i,row:e},n=!0,a=i+t.size_x-1;return a>this.cols?!1:s&&s<e+t.size_y-1?!1:(this.for_each_cell_occupied(o,function(i,e){var s=this.is_widget(i,e);!s||t.el&&!s.is(r)||(n=!1)}),n)},o.get_targeted_columns=function(t){for(var i=(t||this.player_grid_data.col)+(this.player_grid_data.size_x-1),e=[],s=t;i>=s;s++)e.push(s);return e},o.get_targeted_rows=function(t){for(var i=(t||this.player_grid_data.row)+(this.player_grid_data.size_y-1),e=[],s=t;i>=s;s++)e.push(s);return e},o.get_cells_occupied=function(i){var e,s={cols:[],rows:[]};for(arguments[1]instanceof t&&(i=arguments[1].coords().grid),e=0;e<i.size_x;e++){var r=i.col+e;s.cols.push(r)}for(e=0;e<i.size_y;e++){var o=i.row+e;s.rows.push(o)}return s},o.for_each_cell_occupied=function(t,i){return this.for_each_column_occupied(t,function(e){this.for_each_row_occupied(t,function(t){i.call(this,e,t)})}),this},o.for_each_column_occupied=function(t,i){for(var e=0;e<t.size_x;e++){var s=t.col+e;i.call(this,s,t)}},o.for_each_row_occupied=function(t,i){for(var e=0;e<t.size_y;e++){var s=t.row+e;i.call(this,s,t)}},o._traversing_widgets=function(i,e,s,r,o){var n=this.gridmap;if(n[s]){var a,h,l=i+"/"+e;if(arguments[2]instanceof t){var d=arguments[2].coords().grid;s=d.col,r=d.row,o=arguments[3]}var c=[],_=r,u={"for_each/above":function(){for(;_--&&!(_>0&&this.is_widget(s,_)&&-1===t.inArray(n[s][_],c)&&(a=o.call(n[s][_],s,_),c.push(n[s][_]),a)););},"for_each/below":function(){for(_=r+1,h=n[s].length;h>_&&(!this.is_widget(s,_)||-1!==t.inArray(n[s][_],c)||(a=o.call(n[s][_],s,_),c.push(n[s][_]),!a));_++);}};u[l]&&u[l].call(this)}},o.for_each_widget_above=function(t,i,e){return this._traversing_widgets("for_each","above",t,i,e),this},o.for_each_widget_below=function(t,i,e){return this._traversing_widgets("for_each","below",t,i,e),this},o.get_highest_occupied_cell=function(){for(var t,i=this.gridmap,e=i[1].length,s=[],r=[],o=i.length-1;o>=1;o--)for(t=e-1;t>=1;t--)if(this.is_widget(o,t)){s.push(t),r.push(o);break}return{col:Math.max.apply(Math,r),row:Math.max.apply(Math,s)}},o.get_widgets_from=function(i,e){var s=(this.gridmap,t());return i&&(s=s.add(this.$widgets.filter(function(){var e=t(this).attr("data-col");return e===i||e>i}))),e&&(s=s.add(this.$widgets.filter(function(){var i=t(this).attr("data-row");return i===e||i>e}))),s},o.set_dom_grid_height=function(t){if("undefined"==typeof t){var i=this.get_highest_occupied_cell().row;t=i*this.min_widget_height}return this.container_height=t,this.$el.css("height",this.container_height),this},o.set_dom_grid_width=function(t){"undefined"==typeof t&&(t=this.get_highest_occupied_cell().col);var i=this.options.autogrow_cols?this.options.max_cols:this.cols;return t=Math.min(i,Math.max(t,this.options.min_cols)),this.container_width=t*this.min_widget_width,this.$el.css("width",this.container_width),this},o.generate_stylesheet=function(i){var e,r="",o=this.options.max_size_x||this.cols;i||(i={}),i.cols||(i.cols=this.cols),i.rows||(i.rows=this.rows),i.namespace||(i.namespace=this.options.namespace),i.widget_base_dimensions||(i.widget_base_dimensions=this.options.widget_base_dimensions),i.widget_margins||(i.widget_margins=this.options.widget_margins),i.min_widget_width=2*i.widget_margins[0]+i.widget_base_dimensions[0],i.min_widget_height=2*i.widget_margins[1]+i.widget_base_dimensions[1];var n=t.param(i);if(t.inArray(n,s.generated_stylesheets)>=0)return!1;for(this.generated_stylesheets.push(n),s.generated_stylesheets.push(n),e=i.cols;e>=0;e--)r+=i.namespace+' [data-col="'+(e+1)+'"] { left:'+(e*i.widget_base_dimensions[0]+e*i.widget_margins[0]+(e+1)*i.widget_margins[0])+"px; }\n";for(e=i.rows;e>=0;e--)r+=i.namespace+' [data-row="'+(e+1)+'"] { top:'+(e*i.widget_base_dimensions[1]+e*i.widget_margins[1]+(e+1)*i.widget_margins[1])+"px; }\n";for(var a=1;a<=i.rows;a++)r+=i.namespace+' [data-sizey="'+a+'"] { height:'+(a*i.widget_base_dimensions[1]+2*(a-1)*i.widget_margins[1])+"px; }\n";for(var h=1;o>=h;h++)r+=i.namespace+' [data-sizex="'+h+'"] { width:'+(h*i.widget_base_dimensions[0]+2*(h-1)*i.widget_margins[0])+"px; }\n";return this.add_style_tag(r)},o.add_style_tag=function(t){var i=e,s=i.createElement("style");return i.getElementsByTagName("head")[0].appendChild(s),s.setAttribute("type","text/css"),s.styleSheet?s.styleSheet.cssText=t:s.appendChild(e.createTextNode(t)),this.$style_tags=this.$style_tags.add(s),this},o.remove_style_tags=function(){var i=s.generated_stylesheets,e=this.generated_stylesheets;this.$style_tags.remove(),s.generated_stylesheets=t.map(i,function(i){return-1===t.inArray(i,e)?i:void 0})},o.generate_faux_grid=function(t,i){this.faux_grid=[],this.gridmap=[];var e,s;for(e=i;e>0;e--)for(this.gridmap[e]=[],s=t;s>0;s--)this.add_faux_cell(s,e);return this},o.add_faux_cell=function(i,e){var s=t({left:this.baseX+(e-1)*this.min_widget_width,top:this.baseY+(i-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:e,row:i,original_col:e,original_row:i}).coords();return t.isArray(this.gridmap[e])||(this.gridmap[e]=[]),this.gridmap[e][i]=!1,this.faux_grid.push(s),this},o.add_faux_rows=function(t){for(var i=this.rows,e=i+(t||1),s=e;s>i;s--)for(var r=this.cols;r>=1;r--)this.add_faux_cell(s,r);return this.rows=e,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},o.add_faux_cols=function(t){var i=this.cols,e=i+(t||1);e=Math.min(e,this.options.max_cols);for(var s=i+1;e>=s;s++)for(var r=this.rows;r>=1;r--)this.add_faux_cell(r,s);return this.cols=e,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},o.recalculate_faux_grid=function(){var e=this.$wrapper.width();return this.baseX=(t(i).width()-e)/2,this.baseY=this.$wrapper.offset().top,t.each(this.faux_grid,t.proxy(function(t,i){this.faux_grid[t]=i.update({left:this.baseX+(i.data.col-1)*this.min_widget_width,top:this.baseY+(i.data.row-1)*this.min_widget_height})},this)),this},o.get_widgets_from_DOM=function(){return this.$widgets.each(t.proxy(function(i,e){this.register_widget(t(e))},this)),this},o.generate_grid_and_stylesheet=function(){var e=this.$wrapper.width(),s=this.options.max_cols,r=Math.floor(e/this.min_widget_width)+this.options.extra_cols,o=this.$widgets.map(function(){return t(this).attr("data-col")}).get();o.length||(o=[0]);var n=Math.max.apply(Math,o);this.cols=Math.max(n,r,this.options.min_cols),1/0!==s&&s>=n&&s<this.cols&&(this.cols=s);var a=this.options.extra_rows;return this.$widgets.each(function(i,e){a+=+t(e).attr("data-sizey")}),this.rows=Math.max(a,this.options.min_rows),this.baseX=(t(i).width()-e)/2,this.baseY=this.$wrapper.offset().top,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this.generate_faux_grid(this.rows,this.cols)},o.destroy=function(e){return this.$el.removeData("gridster"),t(i).unbind(".gridster"),this.drag_api&&this.drag_api.destroy(),this.remove_style_tags(),e&&this.$el.remove(),this},t.fn.gridster=function(i){return this.each(function(){t(this).data("gridster")||t(this).data("gridster",new s(this,i))})},t.Gridster=o}(jQuery,window,document);