UNPKG

gridifier

Version:

Library for grid layout sort/filter/drag and drop

1,068 lines (1,067 loc) 222 kB
/* Gridifier v2.~.~ source file for custom build. * Async Responsive HTML Grids * http://gridifier.io * * Gridifier is dual-licensed: * Non-commercial license - https://creativecommons.org/licenses/by-nc-sa/4.0/. * Commercial license - http://gridifier.io/license (Commercial license). * Read http://gridifier.io/license for details. * Copyright 2015 nTech */ !function(t, e) { "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports && exports ? module.exports = e() : t.Gridifier = e(); }(this, function() { var t = function(t, e) { var n = function(t, e) { for (var n in e) t.prototype[n] = e[n]; }, i = function(t, e) { for (var n in e) !function(t, n) { Qt[t] = function() { return e[t].apply(n, arguments); }; }(n, t); }, r = function(t) { throw new Error(N.ERR + t); }, s = function() { return function() {}; }, o = function(t, e) { return function() { return e[t].apply(e, arguments); }; }, a = s(), u = s(), c = function() { return { isScheduled: function() { return !1; } }; }, l = s(), h = s(), f = s(), d = s(), g = s(), _ = s(), p = (s(), s()), m = s(), v = s(), C = s(), T = s(), y = s(), A = s(), E = s(), x = s(), I = s(), D = function() { return { getCoordsChanger: s() }; }, R = s(), S = s(), O = s(), P = s(), F = s(), N = { DATA: "data-gridifier", OWCACHED: "-cached-per-ow", OHCACHED: "-cached-per-oh", ERR: "Gridifier error: ", NOT_NATIVE: "is not jQuery/Native DOM object.", IS_ACTIVE: "-toggle-is-active" }, w = { SRM: { CACHED_PER_OW_ITEM_GUID_DATA: N.DATA + N.OWCACHED + "-guid", CACHED_PER_OH_ITEM_GUID_DATA: N.DATA + N.OHCACHED + "-guid", CACHED_PER_OW_DATA: N.DATA + N.OWCACHED, CACHED_PER_OH_DATA: N.DATA + N.OHCACHED, EMPTY_DATA: "e" }, COLL: { SORT_INDEX_DATA: N.DATA + "-orig-sort-index", NOT_COLLECTABLE_DATA: N.DATA + "-not-collectable" }, ITEM: { IS_CONNECTED_DATA: N.DATA + "-connected" }, REND: { CN_RENDERED_DATA: N.DATA + "-cn-rendered", SCH_TO_HIDE_DATA: N.DATA + "-sch-to-hide", SILENT_DATA: N.DATA + "-sch-for-silentr" }, DRAGIFIER_REPOS_DELAY: 20, DRAGIFIER_DISCR_REPOS_DELAY: 100, IS_DRAGGABLE_DATA: N.DATA + "-is-draggable", GUID_DATA: N.DATA + "-guid", RANGE_SIZE: 500, REFLOW_FIX_DELAY: 0, UPDATE_Z_DELAY: 100, INSERT_QUEUE_DELAY: 100, INSERT_BATCH_DELAY: 100, RENDER_QUEUE_DELAY: 20, RENDER_DEF_DELAY: 40, DISC_TYPES: { SOFT: 0, HARD: 1 }, DISC_BATCH: 12, DISC_DELAY: 60, RSORT_REPOS_DELAY: 20, MAX_Z: "16777271" }, L = { IS_ACTIVE: N.DATA + N.IS_ACTIVE, IS_ACTIVE_WITH_CC: N.DATA + N.IS_ACTIVE + "-with-cc", SYNCER_DATA: N.DATA + "-toggle-syncer-id" }, b = { MATRICES: { X: "1, 0, 0, ", Y: "0, 1, 0, ", Z: "0, 0, 1, ", XY: "1, 1, 0, ", XZ: "1, 0, 1, ", YZ: "0, 1, 1, ", XYZ: "1, 1, 1, " }, FNS: { X: "rotateX", Y: "rotateY", Z: "rotateZ" }, FADES: { NONE: 0, FULL: 1, ON_HIDE_MIDDLE: 2 }, GUID_DATA: N.DATA + "rotate-guid", SCENE_CLASS_PREFIX: "gridifierRotateSceneId" }, B = { INITIAL_GUID: -1, SHIFTED: 8, APPEND: { DEF: 0, REV: 1 }, PREPEND: { DEF: 2, REV: 3 }, LEFT: { TOP: 0, BOTTOM: 1 }, BOTTOM: { RIGHT: 2, LEFT: 3 }, RIGHT: { TOP: 4, BOTTOM: 5 }, TOP: { LEFT: 6, RIGHT: 7 }, CLEANERS: { INSIDE: 0, INSIDE_OR_BEFORE: 1 } }, M = { PREPEND: 0, REV_PREPEND: 1, APPEND: 2, REV_APPEND: 3, MIR_PREPEND: 4, INS_BEFORE: 5, INS_AFTER: 6, SIL_APPEND: 7 }, H = { SHOW: 0, HIDE: 1, RENDER: 2, DEL_RENDER: 3 }, G = { FILTER: "filter", SORT: "sort", TOGGLE: "toggle", DRAG: "drag", RSORT: "rsort", COORDSCHANGER: "coordsChanger" }, V = { NOT_NATIVE: "one of items " + N.NOT_NATIVE, GRID_NOT_NATIVE: "grid " + N.NOT_NATIVE, NO_CNS: "no inserted items", CANT_FIND_CN: "can't find conn. by item", WRONG_IBA_ITEM: "wrong insertBefore/After targetItem", TOO_BIG_ITEM: "too wide(ver.grid)/too tall(hor.grid) item" }, Y = { SHOW: "Show", HIDE: "Hide", GRID_RESIZE: "GridResize", CSS_CHANGE: "CssChange", REPOSITION_END: "RepositionEnd", REPOSITION: "Reposition", DISCONNECT: "Disconnect", INSERT: "Insert", DRAG_END: "DragEnd" }, U = { REPOSITION_END_FOR_DRAG: "RepositionEndForDrag", BEFORE_SHOW_FOR_RSORT: "BeforeShowForRsort", SET_SETTING_FOR_NZER: "SetSettingForNzer", RSORT_CHANGE: "RsortChange" }, q = { getComputedCSS: null, _getProps: { forOw: [ "paddingLeft", "paddingRight", "marginLeft", "marginRight", "borderLeftWidth", "borderRightWidth" ], forOh: [ "paddingTop", "paddingBottom", "marginTop", "marginBottom", "borderTopWidth", "borderBottomWidth" ], forPosLeft: [ "marginLeft" ], forPosTop: [ "marginTop" ] }, _prefixedProps: { boxSizing: null }, _borderBoxType: null, _borderBoxTypes: { OUTER: 0, INNER: 1 }, _ptValsCalcType: null, _ptValsCalcTypes: { BROWSER: 0, RECALC: 1 }, recalcPtWidthFn: function(t, e, n, i) { return this.outerWidth(t, e, n, i); }, recalcPtHeightFn: function(t, e, n, i) { return this.outerHeight(t, e, n, i); }, _lastRawWidth: null, _lastRawHeight: null, _lastBorderWidth: null, _lastBorderHeight: null, _hasLastBorderBox: !1, init: function() { this.getComputedCSS = this._getComputedCSSFn(), this._findPrefixedProps(), this._findBorderBoxType(W.div()), this._findPtValsCalcType(W.div(), W.div()); }, clearRecursiveSubcallsData: function() { this._lastRawWidth = null, this._lastRawHeight = null, this._lastBorderWidth = null, this._lastBorderHeight = null, this._hasLastBorderBox = !1; }, _areBrowserPtVals: function() { return this._ptValsCalcType == this._ptValsCalcTypes.BROWSER; }, _areRecalcPtVals: function() { return this._ptValsCalcType == this._ptValsCalcTypes.RECALC; }, getUncomputedCSS: function(t) { var e = t.parentNode.cloneNode(), n = t.cloneNode(); e.appendChild(n), e.style.display = "none"; var i = "HTML" == t.parentNode.nodeName ? t.parentNode : t.parentNode.parentNode; i.appendChild(e); for (var r = this.getComputedCSS(n), s = {}, o = [ "paddingLeft", "paddingRight", "paddingTop", "paddingBottom", "marginLeft", "marginRight", "marginTop", "marginBottom", "width", "height" ], a = 0; a < o.length; a++) s[o[a]] = r[o[a]]; return i.removeChild(e), s; }, _ensureHasParentNode: function(t) { null != t.parentNode && W.hasOwnProp(t.parentNode, "innerHTML") || r("no parentNode"); }, _ensureHasComputedProp: function(t, e) { e in t || r("no prop " + e); }, _hasPtCSSVal: function(t, e, n) { var i = function(t, e, n) { this._ensureHasParentNode(e), n = n || this.getUncomputedCSS(e), this._ensureHasComputedProp(n, t); var i = new RegExp("(.*\\d)%$"); return i.test(n[t]); }; if (W.isArray(t)) { for (var r = 0; r < t.length; r++) if (i.call(this, t[r], e, n)) return !0; return !1; } return i.call(this, t, e, n); }, _getPtCSSVal: function(t, e, n) { return this._ensureHasParentNode(e), n = n || this.getUncomputedCSS(e), this._ensureHasComputedProp(n, t), n[t]; }, _recalcPtVal: function(t, e, n, i) { var r = parseFloat(this._getPtCSSVal(i, t, n)); return e / 100 * r; }, _recalcTwoSidePropPtVals: function(t, e, n, i, r, s) { var o = r + (s ? "Top" : "Left"), a = r + (s ? "Bottom" : "Right"), u = n[o], c = n[a]; return this._hasPtCSSVal(o, t, i) && (u = this._recalcPtVal(t, e, i, o)), this._hasPtCSSVal(a, t, i) && (c = this._recalcPtVal(t, e, i, a)), u + c; }, _isDefBoxSizing: function(t) { var e = this._prefixedProps.boxSizing; return e && t[e] && "border-box" === t[e] ? !0 : !1; }, _isOuterBoxSizing: function() { return this._borderBoxType === this._borderBoxTypes.OUTER; }, _isCascadedCSSVal: function(t) { return window.getComputedStyle || -1 !== t.indexOf("px") ? !1 : !0; }, _cascadedToComputed: function(t, e, n) { var i = new RegExp("(?=.*\\d)"); if (!i.test(e)) return e; var r = t.style, s = t.runtimeStyle, o = r.left, a = s && s.left; return a && (s.left = n.left), r.left = e, e = r.pixelLeft, r.left = o, a && (s.left = a), e; }, _normalizeComputedCSS: function(t) { var e = parseFloat(t), n = -1 === t.indexOf("%") && !isNaN(e); return n ? e : !1; }, _getComputedProps: function(t, e, n) { for (var i = {}, r = 0; r < this._getProps[t].length; r++) { var s = this._getProps[t][r], o = e[s]; this._isCascadedCSSVal(o) && (o = this._cascadedToComputed(n, o, e)), o = parseFloat(o), o = isNaN(o) ? 0 : o, i[s] = o; } return i; }, positionLeft: function(t) { var e = this.getComputedCSS(t); if ("none" == e.display) return 0; var n = this._getComputedProps("forPosLeft", e, t); return t.offsetLeft - n.marginLeft; }, positionTop: function(t) { var e = this.getComputedCSS(t); if ("none" == e.display) return 0; var n = this._getComputedProps("forPosTop", e, t); return t.offsetTop - n.marginTop; }, offsetLeft: function(t) { var e = t.getBoundingClientRect(), n = window.pageXOffset || document.documentElement.scrollLeft; return e.left + n; }, offsetTop: function(t) { var e = t.getBoundingClientRect(), n = window.pageYOffset || document.documentElement.scrollTop; return e.top + n; }, cloneComputedStyle: function(t, e) { var n = function(t) { return t.replace(/-+(.)?/g, function(t, e) { return e ? e.toUpperCase() : ""; }); }, i = this.getComputedCSS(t); for (var r in i) if ("cssText" != r) { var s = n(r); e.style[s] != i[s] && (e.style[s] = i[s]); } this._reclone(i, e); }, _reclone: function(t, e) { for (var n = [ "font", "fontSize", "fontWeight", "lineHeight" ], i = [ "Width", "Color", "Style" ], r = [ "Left", "Right", "Top", "Bottom" ], s = 0; s < i.length; s++) for (var o = 0; o < r.length; o++) n.push("border" + r[o] + i[s]); for (var s = 0; s < n.length; s++) { var a = n[s]; "undefined" != typeof t[a] && e.style[a] != t[a] && (e.style[a] = t[a]); } } }; q._getComputedCSSFn = function() { return window.getComputedStyle ? function(t) { return window.getComputedStyle(t, null); } : function(t) { return t.currentStyle; }; }, q._findPrefixedProps = function() { this._prefixedProps.boxSizing = k.get("boxSizing"); }, q._findBorderBoxType = function(t) { W.css.set(t, { width: "100px", padding: "10px 20px", borderWidth: "10px 20px", borderStyle: "solid" }); var e = this._prefixedProps.boxSizing; t.style[e] = "border-box"; var n = document.body || document.documentElement; n.appendChild(t); var i = this.getComputedCSS(t); 100 === this._normalizeComputedCSS(i.width) ? this._borderBoxType = this._borderBoxTypes.OUTER : this._borderBoxType = this._borderBoxTypes.INNER, n.removeChild(t); }, q._findPtValsCalcType = function(t, e, n) { W.css.set(t, { width: "1178px", height: "300px", position: "absolute", left: "-9000px", top: "0px", visibility: "hidden" }); var i = document.body || document.documentElement; i.appendChild(t), W.css.set(e, { width: "10%", height: "200px" }), t.appendChild(e); var r = 117.796875.toFixed(1), s = parseFloat(this.outerWidth(e, !0, !0)).toFixed(1); this._ptValsCalcType = r == s ? this._ptValsCalcTypes.BROWSER : this._ptValsCalcTypes.RECALC, i.removeChild(t); }, q.outerWidth = function(t, e, n, i) { var e = e || !1, n = n || !1, i = i || !1, r = this.getComputedCSS(t); if (n || this._areBrowserPtVals()) var s = !1; else if (this._areRecalcPtVals()) { this._ensureHasParentNode(t); var s = this._hasPtCSSVal("width", t); } if ("none" === r.display) return 0; var o = this._getComputedProps("forOw", r, t), a = o.paddingLeft + o.paddingRight, u = o.marginLeft + o.marginRight, c = o.borderLeftWidth + o.borderRightWidth, l = 0, h = this._normalizeComputedCSS(r.width); h !== !1 && (l = h); var f = null, d = null; return s && (f = this.getUncomputedCSS(t), d = this.recalcPtWidthFn.call(this, t.parentNode, !1, "HTML" == t.parentNode.nodeName, !0), this._hasLastBorderBox && this._hasPtCSSVal("width", t, f) && (d -= this._lastBorderWidth)), s && this._hasPtCSSVal([ "paddingLeft", "paddingRight" ], t, f) && (a = this._recalcTwoSidePropPtVals(t, d, o, f, "padding")), s && this._hasPtCSSVal("width", t, f) && (l = this._recalcPtVal(t, d, f, "width")), !this._isDefBoxSizing(r) || this._isDefBoxSizing(r) && !this._isOuterBoxSizing() ? (this._lastRawWidth = l, l += a, i || (l += c), this._hasLastBorderBox = !1) : (this._hasLastBorderBox = !0, this._lastRawWidth = l, this._lastBorderWidth = c), e && (s && this._hasPtCSSVal([ "marginLeft", "marginRight" ], t, f) && (u = this._recalcTwoSidePropPtVals(t, d, o, f, "margin")), l += u), l; }, q.outerHeight = function(t, e, n, i) { var e = e || !1, n = n || !1, i = i || !1, r = this.getComputedCSS(t); if (n || this._areBrowserPtVals()) var s = !1; else if (this._areRecalcPtVals()) { this._ensureHasParentNode(t); var s = this._hasPtCSSVal("height", t); } if ("none" === r.display) return 0; var o = this._getComputedProps("forOh", r, t), a = o.paddingTop + o.paddingBottom, u = o.marginTop + o.marginBottom, c = o.borderTopWidth + o.borderBottomWidth, l = 0, h = this._normalizeComputedCSS(r.height); h !== !1 && (l = h); var f = null, d = null, g = null; return s && (f = this.getUncomputedCSS(t), d = this.recalcPtWidthFn.call(this, t.parentNode, !1, "HTML" == t.parentNode.nodeName, !0), this._hasLastBorderBox && (d -= this._lastBorderWidth), g = this.recalcPtHeightFn.call(this, t.parentNode, !1, "HTML" == t.parentNode.nodeName, !0), this._hasLastBorderBox && this._hasPtCSSVal("height", t, f) && (g -= this._lastBorderHeight)), s && this._hasPtCSSVal([ "paddingTop", "paddingBottom" ], t, f) && (a = this._recalcTwoSidePropPtVals(t, d, o, f, "padding", !0)), s && this._hasPtCSSVal("height", t, f) && (l = this._recalcPtVal(t, g, f, "height")), !this._isDefBoxSizing(r) || this._isDefBoxSizing(r) && !this._isOuterBoxSizing() ? (this._lastRawHeight = l, l += a, i || (l += c), this._hasLastBorderBox = !1) : (this._hasLastBorderBox = !0, this._lastRawHeight = l, this._lastBorderHeight = c), e && (s && this._hasPtCSSVal([ "marginTop", "marginBottom" ], t, f) && (u = this._recalcTwoSidePropPtVals(t, d, o, f, "margin", !0)), l += u), l; }; var X = function() { function t(t) { if (t = t || window.event, t.isFixed) return t; if (t.isFixed = !0, t.preventDefault = t.preventDefault || function() { this.returnValue = !1; }, t.stopPropagation = t.stopPropagation || function() { this.cancelBubble = !0; }, t.target || (t.target = t.srcElement), !t.relatedTarget && t.fromElement && (t.relatedTarget = t.fromElement == t.target ? t.toElement : t.fromElement), null == t.pageX && null != t.clientX) { var e = document.documentElement, n = document.body; t.pageX = t.clientX + (e && e.scrollLeft || n && n.scrollLeft || 0) - (e.clientLeft || 0), t.pageY = t.clientY + (e && e.scrollTop || n && n.scrollTop || 0) - (e.clientTop || 0); } return !t.which && t.button && (t.which = 1 & t.button ? 1 : 2 & t.button ? 3 : 4 & t.button ? 2 : 0), t; } function e(e) { e = t(e); var i = this[n][e.type]; for (var r in i) { var s = i[r].call(this, e); if (s === !1 ? (e.preventDefault(), e.stopPropagation()) : void 0 !== s && (e.result = s), e.stopNow) break; } } var n = "gridifierEvents", i = "gridifierHandle", r = function() { var t = new Date().getTime(); return "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, function(e) { var n = (t + 16 * Math.random()) % 16 | 0; return t = Math.floor(t / 16), ("x" == e ? n : 3 & n | 8).toString(16); }); }; return { add: function(t, s, o) { t.setInterval && t != window && !t.frameElement && (t = window), o.guid || (o.guid = r()), t[n] || (t[n] = {}, t[i] = function(n) { return "undefined" != typeof X ? e.call(t, n) : void 0; }), t[n][s] || (t[n][s] = {}, t.addEventListener ? t.addEventListener(s, t[i], !1) : t.attachEvent && t.attachEvent("on" + s, t[i])), t[n][s][o.guid] = o; }, rm: function(t, e, r) { var s = t[n] && t[n][e]; if (s) if (r) { delete s[r.guid]; for (var o in s) return; t.removeEventListener ? t.removeEventListener(e, t[i], !1) : t.detachEvent && t.detachEvent("on" + e, t[i]), delete t[n][e]; for (var o in t[n]) return; try { delete t[i], delete t[n]; } catch (a) { t.removeAttribute(i), t.removeAttribute(n); } } else for (var u in s) delete t[n][e][u]; } }; }(), k = { _prefixes: [ "Moz", "Webkit", "ms", "Ms", "Khtml", "O" ], _getter: function(t, e, n) { e = e || document.documentElement; var i = e.style; if ("string" == typeof i[t]) return t; for (var r = t, t = t.charAt(0).toUpperCase() + t.slice(1), s = 0; s < this._prefixes.length; s++) { var o = this._prefixes[s] + t; if ("string" == typeof i[o]) return n(o, r, s); } }, get: function(t, e) { return this._getter(t, e, function(t) { return t; }); }, getForCss: function(t, e) { var n = this; return this._getter(t, e, function(t, e, i) { return "-" + n._prefixes[i].toLowerCase() + "-" + e; }); } }, W = { init: function() { this._createTrimFunction(), this._createHasOwnPropFn(), this._checkIfHasTransitions(W.div()), this.browsers.init(), this.css3.init(); }, _createTrimFunction: function() { "function" != typeof String.prototype.gridifierTrim && (String.prototype.gridifierTrim = function() { return this.replace(/^\s+|\s+$/g, ""); }); }, _createHasOwnPropFn: function() { var t = W.div(), e = document.body || document.documentElement; e.appendChild(t), Object.prototype.hasOwnProperty.call(t, "innerHTML") ? this._hasOwnPropFn = function(t, e) { return Object.prototype.hasOwnProperty.call(t, e); } : this._hasOwnPropFn = function(t, e) { for (var n in t) if (n == e) return !0; return !1; }, e.removeChild(t); }, _checkIfHasTransitions: function(t) { var e = [ "WebkitTransition", "MozTransition", "OTransition", "msTransition", "MsTransition", "transition" ]; this._hasTransitions = !1; for (var n = 0; n < e.length; n++) void 0 !== t.style[e[n]] && (this._hasTransitions = !0); }, get: function(t, e) { return t.getAttribute(e); }, set: function(t, e, n) { if (this.isArray(e)) for (var i = 0; i < e.length; i++) t.setAttribute(e[i][0], e[i][1]); else t.setAttribute(e, n); }, rm: function(t, e) { t.removeAttribute(e); }, rmIfHas: function(t, e) { if (this.isArray(e)) for (var n in e) this.has(t, e[n]) && this.rm(t, e[n]); else this.has(t, e) && this.rm(t, e); }, has: function(t, e) { return null === t.getAttribute(e) || "" === t.getAttribute(e) ? !1 : !0; }, "int": function(t) { return parseInt(t, 10); }, isJquery: function(t) { return "undefined" == typeof jQuery ? !1 : t && t instanceof jQuery; }, isNative: function(t) { return "undefined" != typeof t && "undefined" != typeof t.tagName && "undefined" != typeof t.nodeName && "undefined" != typeof t.ownerDocument && "undefined" != typeof t.removeAttribute ? !0 : !1; }, isArray: function(t) { return "[object Array]" == Object.prototype.toString.call(t); }, isObj: function(t) { return "object" == typeof t && null !== t; }, isChildOf: function(t, e) { if (t == e) return !1; for (var n = t.parentNode; void 0 != n; ) { if (n == e) return !0; if (n == document.body) break; n = n.parentNode; } return !1; }, hasTransitions: function() { return this._hasTransitions; }, hasVal: function(t, e) { for (var n in t) if (t[n] == e) return !0; return !1; }, hasOwnProp: function(t, e) { return this._hasOwnPropFn(t, e); }, hasAnyProp: function(t, e) { for (var n = 0; n < e.length; n++) if (this._hasOwnPropFn(t, e[n])) return !0; return !1; }, toFixed: function(t, e) { return parseFloat(+(Math.round(+(t.toString() + "e" + e)).toString() + "e" + -e)); }, areRoundedOrFlooredEq: function(t, e) { return Math.round(t) == Math.round(e) || Math.floor(t) == Math.floor(e); }, areRoundedOrCeiledEq: function(t, e) { return Math.round(t) == Math.round(e) || Math.ceil(t) == Math.ceil(e); }, filter: function(t, e, n) { for (var n = n || window, i = [], r = 0; r < t.length; r++) e.call(n, t[r]) && i.push(t[r]); return i; }, show: function(t) { t.style.visibility = "visible"; }, hide: function(t) { t.style.visibility = "hidden"; }, div: function() { return document.createElement("div"); }, browsers: { _navigator: null, init: function() { this._navigator = "undefined" != typeof navigator ? navigator.userAgent : ""; }, isAndroid: function() { return /android/i.test(this._navigator); }, isAndroidFirefox: function() { return this.isAndroid() ? /firefox|iceweasel/i.test(this._navigator) : !1; }, isAndroidUC: function() { return this.isAndroid() ? /UCBrowser/i.test(this._navigator) : !1; } }, css: { set: function(t, e) { W.isNative(t) || r("Error: not DOM."); for (var n in e) t.style[n] = e[n]; }, set4: function(t, e, n) { for (var i = [ "Left", "Right", "Top", "Bottom" ], r = 0; r < i.length; r++) t.style[e + i[r]] = W.isObj(n) ? n[e + i[r]] : n; }, hasClass: function(t, e) { var n = t.getAttribute("class"); if (null == n || 0 == n.length) return !1; n = n.split(" "); for (var i = 0; i < n.length; i++) if (n[i] = n[i].gridifierTrim(), n[i] == e) return !0; return !1; }, addClass: function(t, e) { var n = t.getAttribute("class"); if (null == n || 0 == n.length) var i = e; else var i = n + " " + e; W.set(t, "class", i); }, removeClass: function(t, e) { for (var n = t.getAttribute("class").split(" "), i = "", r = 0; r < n.length; r++) n[r].gridifierTrim() != e && (i += n[r] + " "); i = i.substring(0, i.length - 1), W.set(t, "class", i); } }, css3: { _opacityProps: [ "opacity" ], _perspectiveProps: [ "perspective" ], _transformStyleProps: [ "transformStyle" ], _backfaceVisibilityProps: [ "backfaceVisibility" ], _transformOriginProps: [ "transformOrigin" ], init: function() { for (var t = [ [ "Webkit", "Moz" ], [ "webkit", "moz", "o", "ms" ] ], e = 0; e < t[0].length; e++) { var n = t[0][e]; this._opacityProps.push(n + "Opacity"), this._perspectiveProps.push(n + "Perspective"), this._transformStyleProps.push(n + "TransformStyle"), this._backfaceVisibilityProps.push(n + "BackfaceVisibility"); } for (var e = 0; e < t[1].length; e++) this._transformOriginProps.push(t[1][e] + "TransformOrigin"); }, transition: function(t, e) { t.style[k.get("transition", t)] = e; }, transitionProperty: function(t, e) { var n = t.style[k.get("transition", t)]; if (0 == n.length) return void (t.style[k.get("transition", t)] = e); var i = function(t) { return t.replace(/cubic-bezier\([^\)]+/g, function(t) { return t.replace(/,/g, ";"); }); }, r = function(t) { return t.replace(/cubic-bezier\([^\)]+/g, function(t) { return t.replace(/;/g, ","); }); }, s = i(e); n = i(n); for (var o = n.split(","), a = 0; a < o.length; a++) { var u = o[a].gridifierTrim(); if (0 != u.length) { var c = u.split(" "), l = c[0]; -1 === s.search(l) && (s += ", " + u); } } t.style[k.get("transition", t)] = r(s).gridifierTrim(); }, transform: function(t, e) { t.style[k.get("transform", t)] = e; }, transformProperty: function(t, e, n) { var i = t.style[k.get("transform", t)]; if (0 == i.length) return void (t.style[k.get("transform", t)] = e + "(" + n + ")"); for (var r = "", s = i.split(/\)/), o = !1, a = 0; a < s.length; a++) { var u = s[a].gridifierTrim(); 0 != u.length && (-1 !== u.search(e) ? (r += " " + e + "(" + n + ")", o = !0) : r += " " + u + ")"); } o || (r += " " + e + "(" + n + ")"), t.style[k.get("transform", t)] = r.gridifierTrim(); }, style: function(t, e, n) { for (var i = 0; i < e.length; i++) t.style[e[i]] = n; }, opacity: function(t, e) { this.style(t, this._opacityProps, e); }, perspective: function(t, e) { this.style(t, this._perspectiveProps, e); }, transformStyle: function(t, e) { this.style(t, this._transformStyleProps, e); }, backfaceVisibility: function(t, e) { this.style(t, this._backfaceVisibilityProps, e); }, transformOrigin: function(t, e) { for (var n = 0; n < this._transformOriginProps.length; n++) "undefined" != typeof t.style[this._transformOriginProps[n]] && (t.style[this._transformOriginProps[n]] = e); } }, find: { byId: function(t) { return document.getElementById(t); }, byClass: function(t, e) { return t.querySelectorAll("." + e); }, byQuery: function(t, e) { var n = e.gridifierTrim()[0]; if (">" == n) { for (var i = e.substr(2, e.length - 1), r = t.querySelectorAll(i), s = [], o = 0; o < r.length; o++) r[o].parentNode == t && s.push(r[o]); return s; } return t.querySelectorAll(e); } }, remove: { byQuery: function(t, e) { for (var n = W.find.byQuery(t, e), i = 0; i < n.length; i++) { var r = n[i]; r.parentNode.removeChild(r); } } } }, z = function() {}; n(z, { find: function(t, e) { var e = e || !1, n = me.get(); e || 0 != n.length || r(V.NO_CNS); for (var i = ie.get(t), s = null, o = 0; o < n.length; o++) if (i == n[o].itemGUID) { s = n[o]; break; } if (null == s && !Be.isEmpty()) for (var a = Be.getQueued(), o = 0; o < a.length; o++) if (i == a[o].cn.itemGUID) { s = a[o].cn; break; } return e || null != s || r(V.CANT_FIND_CN), s; }, create: function(t, e) { for (var n = [ "x1", "x2", "y1", "y2" ], i = 0; i < n.length; i++) { var r = n[i], s = e[r]; e[r] = W.toFixed(e[r], 2), isNaN(e[r]) && (e[r] = s); } return e.item = t, e.itemGUID = ie.get(t), e.hOffset = W.hasOwnProp(e, "hOffset") ? e.hOffset : 0, e.vOffset = W.hasOwnProp(e, "vOffset") ? e.vOffset : 0, e.restrictCollect = W.hasOwnProp(e, "restrictCollect") ? e.restrictCollect : !1, jt.isConnected(t) || jt.markAsConnected(t), e; }, rm: function(t, e) { for (var n = 0; n < t.length; n++) if (ie.get(e.item) == ie.get(t[n].item)) return void t.splice(n, 1); }, _remapGUIDS: function(t) { for (var e = 0; e < t.length; e++) t[e].itemGUID = ie.markForAppend(t[e].item); }, remapAllGUIDS: function() { ie.reinit(), this._remapGUIDS(ye.sortForReappend(me.get())); }, remapGUIDSIn: function(t) { this._remapGUIDS(t); }, getByGUIDS: function(t) { for (var e = me.get(), n = [], i = 0; i < e.length; i++) for (var r = 0; r < t.length; r++) if (e[i].itemGUID == t[r]) { n.push(e[i]); break; } return n; }, syncParams: function(t) { for (var e = me.get(), n = [ "x1", "x2", "y1", "y2", "hOffset", "vOffset", "restrictCollect" ], i = 0; i < t.length; i++) for (var r = 0; r < e.length; r++) if (t[i].itemGUID == e[r].itemGUID) { for (var s = 0; s < n.length; s++) e[r][n[s]] = t[i][n[s]]; break; } }, _getMinSize: function(t, e, n, i) { var r = me.get(); if (0 == r.length) return 0; for (var s = function(s) { return r[s][t] >= r[s][e] || r[s][t] < 0 || r[s][e] > n ? Zt["outer" + i](r[s].item, !0) : r[s][e] - r[s][t] + 1; }, o = s(0), a = 1; a < r.length; a++) { var u = s(a); o > u && (o = u); } return o; }, getMinWidth: function() { return this._getMinSize("x1", "x2", Jt.x2(), "Width"); }, getMinHeight: function() { return this._getMinSize("y1", "y2", Jt.y2(), "Height"); }, _compareGUIDS: function(t, e, n) { for (var i = ie.get(e), r = 0; r < t.length; r++) if (n(ie.get(t[r].item), i)) return !0; return !1; }, isAnyGUIDSmallerThan: function(t, e) { return this._compareGUIDS(t, e, function(t, e) { return e > t; }); }, isAnyGUIDBiggerThan: function(t, e) { return this._compareGUIDS(t, e, function(t, e) { return t > e; }); }, getMaxY: function() { for (var t = me.get(), e = 0, n = 0; n < t.length; n++) t[n].y2 > e && (e = t[n].y2); return e; }, restoreOnSortDispersion: function(t, e, n) { var i = ye.sortForReappend(me.get()), r = i[i.length - 1], s = function(t, e, n) { t.x1 = e, t.x2 = e, t.y1 = n, t.y2 = n; }; Kt.eq("append", "default") ? e(t, r, s) : n(t, r, s); }, getAllBACoord: function(t, e) { for (var n = me.get(), i = [], r = 0; r < n.length; r++) Kt.eq("sortDispersion", !1) && e(n[r], t) && i.push(n[r]); return i; }, fixAllXYPosAfterPrepend: function(t, e, n, i, r) { if (t[i] >= 0) return !1; var s = Math.round(Math.abs(t[i])); t[r] = Math.abs(t[i] - t[r]), t[i] = 0; for (var o = me.get(), a = 0; a < o.length; a++) t.itemGUID != o[a].itemGUID && (o[a][i] += s, o[a][r] += s); for (var a = 0; a < e.length; a++) e[a][n] += s; return Te.incAllBy(s, i, r), Te.createPrepended(t[i], t[r], i, r), !0; } }); var Q = function() {}; n(Q, { isIntersectingAny: function(t, e) { for (var n = 0; n < t.length; n++) { var i = t[n], r = e.y1 < i.y1 && e.y2 < i.y1, s = e.y1 > i.y2 && e.y2 > i.y2, o = e.x1 < i.x1 && e.x2 < i.x1, a = e.x1 > i.x2 && e.x2 > i.x2; if (!(r || s || o || a)) return !0; } return !1; }, getAllWithIntersectedCenter: function(t) { for (var e = me.get(), n = [], i = 0; i < e.length; i++) { var r = e[i].x2 - e[i].x1 + 1, s = e[i].y2 - e[i].y1 + 1, o = e[i].x1 + r / 2, a = e[i].y1 + s / 2, u = { x1: o, x2: o, y1: a, y2: a }; this.isIntersectingAny([ u ], t) && n.push(e[i]); } return n; }, _findAllMaybeIntCns: function(t, e) { for (var n = me.get(), i = [], r = 0; r < n.length; r++) e(t, n[r]) || i.push(n[r]); return i; }, findAllMaybeIntOnVgAppend: function(t) { return this._findAllMaybeIntCns(t, function(t, e) { return t.y > e.y2; }); }, findAllMaybeIntOnVgPrepend: function(t) { return this._findAllMaybeIntCns(t, function(t, e) { return t.y < e.y1; }); }, findAllMaybeIntOnHgAppend: function(t) { return this._findAllMaybeIntCns(t, function(t, e) { return t.x > e.x2; }); }, findAllMaybeIntOnHgPrepend: function(t) { return this._findAllMaybeIntCns(t, function(t, e) { return t.x < e.x1; }); } }); var Z = function() { this._ranges = null, Kt.eq("grid", "vertical") ? this.init("y1", "y2") : this.init("x1", "x2"); }; n(Z, { init: function(t, e) { var n = { cnIndexes: [] }; n[t] = -1, n[e] = w.RANGE_SIZE - 1, this._ranges = [ n ], this._attachAllCns(t, e); }, incAllBy: function(t, e, n) { for (var i = 0; i < this._ranges.length; i++) this._ranges[i][e] += t, this._ranges[i][n] += t; }, createPrepended: function(t, e, n, i) { var r = { cnIndexes: [] }; r[n] = -1, r[i] = e, this._ranges.unshift(r); }, _createNext: function(t, e) { var n = this._ranges[this._ranges.length - 1][e] + 1, i = { cnIndexes: [] }; i[t] = n, i[e] = n + w.RANGE_SIZE - 1, this._ranges.push(i); }, attachCn: function(t, e, n, i) { for (;t[i] + 1 > this._ranges[this._ranges.length - 1][i]; ) this._createNext(n, i); for (var s = !1, o = 0; o < this._ranges.length; o++) { var a = t[i] < this._ranges[o][n], u = t[n] > this._ranges[o][i]; a || u || (this._ranges[o].cnIndexes.push(e), s = !0); } s || r("Range for cn NF"); }, _attachAllCns: function(t, e) { for (var n = me.get(), i = 0; i < n.length; i++) this.attachCn(n[i], i, t, e); }, mapAllIntAndSideCns: function(t, e, n, i, r, s, o, a) { for (var u = this._ranges, c = r(u), l = [], h = 0; h < t.length; h++) { for (var f = !1, d = c != r(u); !f; ) { if (c > s(u) || 0 > c) { c = r(u); break; } t[h][e] >= u[c][n] && t[h][e] <= u[c][i] ? f = !0 : (c = a(c), d = !1); } d || (l = o(c, u)), t[h].cnIndexes = l; } return t; }, firstRngIndexFn: function() { return function(t) { return 0; }; }, lastRngIndexFn: function() { return function(t) { return t.length - 1; }; }, lowerCrCnIndexesFn: function() { return function(t, e) { for (var n = [], i = t; i >= 0; i--) n.push(e[i].cnIndexes); return n; }; }, upperCrCnIndexesFn: function() { return function(t, e) { for (var n = [], i = t; i < e.length; i++) n.push(e[i].cnIndexes); return n; }; }, incFn: function() { return function(t) { return ++t; }; }, decFn: function() { return function(t) { return --t; }; }, getAllCnsFromIntRange: function(t, e, n) { for (var i = this._ranges, r = 0; r < i.length; r++) if (t >= i[r][e] && t <= i[r][n]) return i[r].cnIndexes; for (var s = function(t, e) { for (var n = 0; n < t.length; n++) if (t[n] == e) return !0; return !1; }, o = [], r = 0; r < i.length; r++) for (var a = 0; a < i[r].cnIndexes.length; a++) s(o, i[r].cnIndexes[a]) || o.push(i[r].cnIndexes[a]); return o; }, getAllCnsFromIntAndTLSideRgs: function(t, e, n) { for (var i = this._ranges, r = [], s = null, o = i.length - 1; o >= 0; o--) if (t >= i[o][e] && t <= i[o][n]) { s = o; break; } null == s && (s = i.length - 1); for (var o = s; o >= 0; o--) r.push(i[o].cnIndexes); return r; }, getAllCnsFromIntAndRBSideRgs: function(t, e, n) { for (var i = this._ranges, r = [], s = null, o = 0; o < i.length; o++) if (t >= i[o][e] && t <= i[o][n]) { s = o; break; } null == s && (s = 0); for (var o = s; o < i.length; o++) r.push(i[o].cnIndexes); return r; } }); var j = function() {}; n(j, { _sortForReappend: function(t, e, n, i) { if (Kt.eq("sortDispersion", !1)) t.sort(function(t, e) { return ie.get(t.item) > ie.get(e.item) ? 1 : -1; }); else { Kt.eq("append", "default") ? t.sort(function(t, i) { return W.areRoundedOrFlooredEq(t[e], i[e]) ? t[n] < i[n] ? -1 : 1 : t[e] < i[e] ? -1 : 1; }) : t.sort(function(t, n) { return W.areRoundedOrFlooredEq(t[e], n[e]) ? t[i] > n[i] ? -1 : 1 : t[e] < n[e] ? -1 : 1; }); var r = Kt.getApi("rsort"); t = r(t); } return t; }, sortForReappend: function(t) { return Kt.eq("grid", "vertical") ? this._sortForReappend(t, "y1", "x1", "x2") : this._sortForReappend(t, "x1", "y2", "y1"); } }); var J = function() { this._lastXYExpandedCns = []; }; n(J, { _isBefore: function(t, e, n, i) { return t[n] < e[n] && t[i] < e[n]; }, _isAfter: function(t, e, n, i) { return t[n] > e[i] && t[i] > e[i]; }, getLastXYExpandedCns: function() { return this._lastXYExpandedCns; }, isIntMoreThanOneCnXY: function(t, e, n) { for (var i = this, r = me.get(), s = [], o = function(t) { if (0 == s.length) return !1; for (var o = 0; o < s.length; o++) { var a = r[s[o]], u = a[e], c = a[n]; a[e] = Math.ceil(a[e]), a[n] = Math.floor(a[n]); var l = i._isBefore(t, a, e, n), h = i._isAfter(t, a, e, n); if (a[e] = u, a[n] = c, !l && !h) return !0; } return !1; }, a = 0, u = 0; u < r.length; u++) i._isBefore(t, r[u], e, n) || i._isAfter(t, r[u], e, n) || o(r[u]) || (s.push(u), a++); return a > 1; }, getMostBigFromAllXYIntCns: function(t, e, n) { for (var i = me.get(), r = null, s = 0; s < i.length; s++) if (!this._isBefore(t, i[s], e, n) && !this._isAfter(t, i[s], e, n)) if (null == r) r = i[s]; else { var o = Math.abs(i[s][n] - i[s][e]), a = Math.abs(r[n] - r[e]); o > a && (r = i[s]); } return r; }, getAllXYIntCns: function(t, e, n) { for (var i = me.get(), r = [], s = 0; s < i.length; s++) this._isBefore(t, i[s], e, n) || this._isAfter(t, i[s], e, n) || r.push(i[s]); return r; }, expandXYAllCnsToMostBig: function(t, e, n, i, r) { var s = o("eq", Kt), a = this.getMostBigFromAllXYIntCns(t, e, n); if (null != a) { for (var u = this.getAllXYIntCns(t, e, n), c = [], l = 0; l < u.length; l++) if (u[l][e] = a[e], u[l][n] = a[n], s("align", "left") || s("align", "top")) 0 != u[l][i] && c.push(u[l]), u[l][i] = 0; else { var h = Zt["outer" + r](u[l].item, !0); if (s("align", "center")) var f = Math.abs(u[l][n] - u[l][e] + 1) / 2 - h / 2; else var f = Math.abs(u[l][n] - u[l][e] + 1) - h; u[l][i] != f && (u[l][i] = f, c.push(u[l])); } this._lastXYExpandedCns = c; } } }); var $ = function() { this._cleaner = null; }; n($, { _updateCleaner: function() { var t = B.CLEANERS; this._cleaner = Kt.eq("sortDispersion", !1) ? t.INSIDE_OR_BEFORE : t.INSIDE; }, _isInsideCleaner: function() {