homepage/misc/twatch-config/slate.min.js

2 lines
41 KiB
JavaScript
Raw Normal View History

2015-11-22 08:27:58 -07:00
!function(t){"use strict";"function"==typeof define&&define.amd?define(t):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=t():"undefined"!=typeof Package?Sortable=t():window.Sortable=t()}(function(){"use strict";function t(t,e){this.el=t,this.options=e=v({},e),t[P]=this;var i={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(t.nodeName)?"li":">*",ghostClass:"sortable-ghost",ignore:"a, img",filter:null,animation:0,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0};for(var r in i)!(r in e)&&(e[r]=i[r]);var o=e.group;o&&"object"==typeof o||(o=e.group={name:o}),["pull","put"].forEach(function(t){t in o||(o[t]=!0)}),e.groups=" "+o.name+(o.put.join?" "+o.put.join(" "):"")+" ";for(var s in this)"_"===s.charAt(0)&&(this[s]=n(this,this[s]));a(t,"mousedown",this._onTapStart),a(t,"touchstart",this._onTapStart),a(t,"dragover",this),a(t,"dragenter",this),z.push(this._onDragOver),e.store&&this.sort(e.store.get(this))}function e(t){b&&b.state!==t&&(c(b,"display",t?"none":""),!t&&b.state&&x.insertBefore(b,g),b.state=t)}function n(t,e){var n=$.call(arguments,2);return e.bind?e.bind.apply(e,[t].concat(n)):function(){return e.apply(t,n.concat($.call(arguments)))}}function i(t,e,n){if(t){n=n||k,e=e.split(".");var i=e.shift().toUpperCase(),r=new RegExp("\\s("+e.join("|")+")\\s","g");do if(">*"===i&&t.parentNode===n||(""===i||t.nodeName.toUpperCase()==i)&&(!e.length||((" "+t.className+" ").match(r)||[]).length==e.length))return t;while(t!==n&&(t=t.parentNode))}return null}function r(t){t.dataTransfer.dropEffect="move",t.preventDefault()}function a(t,e,n){t.addEventListener(e,n,!1)}function o(t,e,n){t.removeEventListener(e,n,!1)}function s(t,e,n){if(t)if(t.classList)t.classList[n?"add":"remove"](e);else{var i=(" "+t.className+" ").replace(O," ").replace(" "+e+" "," ");t.className=(i+(n?" "+e:"")).replace(O," ")}}function c(t,e,n){var i=t&&t.style;if(i){if(void 0===n)return k.defaultView&&k.defaultView.getComputedStyle?n=k.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];e in i||(e="-webkit-"+e),i[e]=n+("string"==typeof n?"":"px")}}function l(t,e,n){if(t){var i=t.getElementsByTagName(e),r=0,a=i.length;if(n)for(;a>r;r++)n(i[r],r);return i}return[]}function u(t){t.draggable=!1}function f(){B=!1}function h(t,e){var n=t.lastElementChild,i=n.getBoundingClientRect();return e.clientY-(i.top+i.height)>5&&n}function d(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,i=0;n--;)i+=e.charCodeAt(n);return i.toString(36)}function p(t){for(var e=0;t&&(t=t.previousElementSibling);)"TEMPLATE"!==t.nodeName.toUpperCase()&&e++;return e}function m(t,e){var n,i;return function(){void 0===n&&(n=arguments,i=this,setTimeout(function(){1===n.length?t.call(i,n[0]):t.apply(i,n),n=void 0},e))}}function v(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var g,y,b,x,A,w,F,E,C,S,T,D,_,N,j={},O=/\s+/g,P="Sortable"+(new Date).getTime(),L=window,k=L.document,R=L.parseInt,M=!!("draggable"in k.createElement("div")),B=!1,Z=function(t,e,n,i,r,a,o){var s=k.createEvent("Event"),c=(t||e[P]).options,l="on"+n.charAt(0).toUpperCase()+n.substr(1);s.initEvent(n,!0,!0),s.item=i||e,s.from=r||e,s.clone=b,s.oldIndex=a,s.newIndex=o,c[l]&&c[l].call(t,s),e.dispatchEvent(s)},I=Math.abs,$=[].slice,z=[],Y=m(function(t,e,n){if(n&&e.scroll){var i,r,a,o,s=e.scrollSensitivity,c=e.scrollSpeed,l=t.clientX,u=t.clientY,f=window.innerWidth,h=window.innerHeight;if(F!==n&&(w=e.scroll,F=n,w===!0)){w=n;do if(w.offsetWidth<w.scrollWidth||w.offsetHeight<w.scrollHeight)break;while(w=w.parentNode)}w&&(i=w,r=w.getBoundingClientRect(),a=(I(r.right-l)<=s)-(I(r.left-l)<=s),o=(I(r.bottom-u)<=s)-(I(r.top-u)<=s)),a||o||(a=(s>=f-l)-(s>=l),o=(s>=h-u)-(s>=u),(a||o)&&(i=L)),(j.vx!==a||j.vy!==o||j.el!==i)&&(j.el=i,j.vx=a,j.vy=o,clearInterval(j.pid),i&&(j.pid=setInterval(function(){i===L?L.scrollTo(L.pageXOffset+a*c,L.pageYOffset+o*c):(o&&(i.scrollTop+=o*c),a&&(i.scrollL
type:"GET",beforeSend:l,success:l,error:l,complete:l,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:w,xml:"application/xml, text/xml",html:F,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},t.ajax=function(e){var n,r=t.extend({},e||{}),c=t.Deferred&&t.Deferred();for(m in t.ajaxSettings)void 0===r[m]&&(r[m]=t.ajaxSettings[m]);i(r),r.crossDomain||(n=y.createElement("a"),n.href=r.url,n.href=n.href,r.crossDomain=C.protocol+"//"+C.host!=n.protocol+"//"+n.host),r.url||(r.url=window.location.toString()),h(r);var d=r.dataType,p=/\?.+=\?/.test(r.url);if(p&&(d="jsonp"),r.cache!==!1&&(e&&e.cache===!0||"script"!=d&&"jsonp"!=d)||(r.url=f(r.url,"_="+Date.now())),"jsonp"==d)return p||(r.url=f(r.url,r.jsonp?r.jsonp+"=?":r.jsonp===!1?"":"callback=?")),t.ajaxJSONP(r,c);var g,b=r.accepts[d],x={},A=function(t,e){x[t.toLowerCase()]=[t,e]},w=/^([\w-]+:)\/\//.test(r.url)?RegExp.$1:window.location.protocol,F=r.xhr(),S=F.setRequestHeader;if(c&&c.promise(F),r.crossDomain||A("X-Requested-With","XMLHttpRequest"),A("Accept",b||"*/*"),(b=r.mimeType||b)&&(b.indexOf(",")>-1&&(b=b.split(",",2)[0]),F.overrideMimeType&&F.overrideMimeType(b)),(r.contentType||r.contentType!==!1&&r.data&&"GET"!=r.type.toUpperCase())&&A("Content-Type",r.contentType||"application/x-www-form-urlencoded"),r.headers)for(v in r.headers)A(v,r.headers[v]);if(F.setRequestHeader=A,F.onreadystatechange=function(){if(4==F.readyState){F.onreadystatechange=l,clearTimeout(g);var e,n=!1;if(F.status>=200&&F.status<300||304==F.status||0==F.status&&"file:"==w){d=d||u(r.mimeType||F.getResponseHeader("content-type")),e=F.responseText;try{"script"==d?(1,eval)(e):"xml"==d?e=F.responseXML:"json"==d&&(e=E.test(e)?null:t.parseJSON(e))}catch(i){n=i}n?s(n,"parsererror",F,r,c):o(e,F,r,c)}else s(F.statusText||null,F.status?"error":"abort",F,r,c)}},a(F,r)===!1)return F.abort(),s(null,"abort",F,r,c),F;if(r.xhrFields)for(v in r.xhrFields)F[v]=r.xhrFields[v];var T="async"in r?r.async:!0;F.open(r.type,r.url,T,r.username,r.password);for(v in x)S.apply(F,x[v]);return r.timeout>0&&(g=setTimeout(function(){F.onreadystatechange=l,F.abort(),s(null,"timeout",F,r,c)},r.timeout)),F.send(r.data?r.data:null),F},t.get=function(){return t.ajax(d.apply(null,arguments))},t.post=function(){var e=d.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=d.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,n,i){if(!this.length)return this;var r,a=this,o=e.split(/\s/),s=d(e,n,i),c=s.success;return o.length>1&&(s.url=o[0],r=o[1]),s.success=function(e){a.html(r?t("<div>").html(e.replace(b,"")).find(r):e),c&&c.apply(a,arguments)},t.ajax(s),this};var S=encodeURIComponent;t.param=function(e,n){var i=[];return i.add=function(e,n){t.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(S(e)+"="+S(n))},p(i,e,n),i.join("&").replace(/%20/g,"+")}}(Zepto),function(t){t.fn.serializeArray=function(){var e,n,i=[],r=function(t){return t.forEach?t.forEach(r):void i.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(i,a){n=a.type,e=a.name,e&&"fieldset"!=a.nodeName.toLowerCase()&&!a.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||a.checked)&&r(t(a).val())}),i},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(Zepto),function(t){"__proto__"in{}||t.extend(t.zepto,{Z:function(e,n){return e=e||[],t.extend(e,t.fn),e.selector=n||"",e.__Z=!0,e},isZ:function(e){return"array"===t.type(e)&&"__Z"in e}});try{getComputedStyle(void 0)}catch(e){var n=getComputedStyle;window.getComputedStyle=function(t){try{return n(t)}catch(e){return null}}}}(Zepto),function(t,e){var n={COLOR:{EMPTY:"transparent"}};t.extend(t.fn,{itemTogg