1(function() { 2 (function(e, t, n) { 3 var r, i, s; 4 s = "shapeshift"; 5 i = { 6 selector: "*", 7 enableDrag: true, 8 enableCrossDrop: true, 9 enableResize: true, 10 enableTrash: false, 11 align: "center", 12 colWidth: null, 13 columns: null, 14 minColumns: 1, 15 autoHeight: true, 16 maxHeight: null, 17 minHeight: 100, 18 gutterX: 10, 19 gutterY: 10, 20 paddingX: 10, 21 paddingY: 10, 22 animated: true, 23 animateOnInit: false, 24 animationSpeed: 225, 25 animationThreshold: 100, 26 dragClone: false, 27 deleteClone: true, 28 dragRate: 100, 29 dragWhitelist: "*", 30 crossDropWhitelist: "*", 31 cutoffStart: null, 32 cutoffEnd: null, 33 handle: false, 34 cloneClass: "ss-cloned-child", 35 activeClass: "ss-active-child", 36 draggedClass: "ss-dragged-child", 37 placeholderClass: "ss-placeholder-child", 38 originalContainerClass: "ss-original-container", 39 currentContainerClass: "ss-current-container", 40 previousContainerClass: "ss-previous-container" 41 }; 42 r = function() { 43 function n(t, n) { 44 this.element = t; 45 this.options = e.extend({}, i, n); 46 this.globals = {}; 47 this.$container = e(t); 48 if (this.errorCheck()) { 49 this.init() 50 } 51 } 52 n.prototype.errorCheck = function() { 53 var e, t, n, r; 54 r = this.options; 55 n = false; 56 t = "Shapeshift ERROR:"; 57 if (r.colWidth === null) { 58 e = this.$container.children(r.selector); 59 if (e.length === 0) { 60 n = true; 61 console.error("" + t + " option colWidth must be specified if Shapeshift is initialized with no active children.") 62 } 63 } 64 return !n 65 }; 66 n.prototype.init = function() { 67 this.createEvents(); 68 this.setGlobals(); 69 this.setIdentifier(); 70 this.setActiveChildren(); 71 this.enableFeatures(); 72 this.gridInit(); 73 this.render(); 74 return this.afterInit() 75 }; 76 n.prototype.createEvents = function() { 77 var e, t, n = this; 78 t = this.options; 79 e = this.$container; 80 e.off("ss-arrange").on("ss-arrange", function(e, t) { 81 if (t == null) { 82 t = false 83 } 84 return n.render(false, t) 85 }); 86 e.off("ss-rearrange").on("ss-rearrange", function() { 87 return n.render(true) 88 }); 89 e.off("ss-setTargetPosition").on("ss-setTargetPosition", function() { 90 return n.setTargetPosition() 91 }); 92 return e.off("ss-destroy").on("ss-destroy", function() { 93 return n.destroy() 94 }) 95 }; 96 n.prototype.setGlobals = function() {
97 return this.globals.animated = this.options.animateOnInit 98 }; 99 n.prototype.afterInit = function() { 100 return this.globals.animated = this.options.animated 101 }; 102 n.prototype.setIdentifier = function() { 103 this.identifier = "shapeshifted_container_" + Math.random().toString(36).substring(7); 104 return this.$container.addClass(this.identifier) 105 }; 106 n.prototype.enableFeatures = function() { 107 if (this.options.enableResize) { 108 this.enableResize() 109 } 110 if (this.options.enableDrag || this.options.enableCrossDrop) { 111 return this.enableDragNDrop() 112 } 113 }; 114 n.prototype.setActiveChildren = function() { 115 var t, n, r, i, s, o, u, a, f, l, c, h; 116 u = this.options; 117 t = this.$container.children(u.selector); 118 n = u.activeClass; 119 a = t.length; 120 for (s = f = 0; 0 <= a ? f < a : f > a; s = 0 <= a ? ++f : --f) { 121 e(t[s]).addClass(n) 122 } 123 this.setParsedChildren(); 124 i = u.columns; 125 h = []; 126 for (s = l = 0, c = this.parsedChildren.length; 0 <= c ? l < c : l > c; s = 0 <= c ? ++l : --l) { 127 r = this.parsedChildren[s].colspan; 128 o = u.minColumns; 129 if (r > i && r > o) { 130 u.minColumns = r; 131 h.push(console.error("Shapeshift ERROR: There are child elements that have a larger colspan than the minimum columns set through options.\noptions.minColumns has been set to " + r)) 132 } else { 133 h.push(void 0) 134 } 135 } 136 return h 137 }; 138 n.prototype.setParsedChildren = function() { 139 var t, n, r, i, s, o, u; 140 n = this.$container.find("." + this.options.activeClass).filter(":visible"); 141 o = n.length; 142 s = []; 143 for (i = u = 0; 0 <= o ? u < o : u > o; i = 0 <= o ? ++u : --u) { 144 t = e(n[i]); 145 r = { 146 i: i, 147 el: t, 148 colspan: parseInt(t.attr("data-ss-colspan")) || 1, 149 height: t.outerHeight() 150 }; 151 s.push(r) 152 } 153 return this.parsedChildren = s 154 }; 155 n.prototype.gridInit = function() { 156 var e, t, n, r, i; 157 r = this.options.gutterX; 158 if (!(this.options.colWidth >= 1)) { 159 n = this.parsedChildren[0]; 160 t = n.el.outerWidth(); 161 e = n.colspan; 162 i = (t - (e - 1) * r) / e; 163 return this.globals.col_width = i + r 164 } else { 165 return this.globals.col_width = this.options.colWidth + r 166 } 167 }; 168 n.prototype.render = function(e, t) { 169 if (e == null) { 170 e = false 171 } 172 this.setGridColumns(); 173 return this.arrange(e, t) 174 }; 175 n.prototype.setGridColumns = function() { 176 var e, t, n, r, i, s, o, u, a, f; 177 r = this.globals; 178 a = this.options; 179 t = r.col_width; 180 s = a.gutterX; 181 f = a.paddingX; 182 o = this.$container.innerWidth() - f * 2; 183 u = a.minColumns; 184 n = a.columns || Math.floor((o + s) / t); 185 if (u && u > n) { 186 n = u 187 } 188 r.columns = n; 189 e = this.parsedChildren.length; 190 if (n > e) { 191 n = e 192 } 193 r.child_offset = f; 194 switch (a.align) { 195 case "center": 196 i = n * t - s; 197 return r.child_offset += (o - i) / 2; 198 case "right": 199 i = n * t - s; 200 return r.child_offset += o - i 201 } 202 }; 203 n.prototype.arrange = function(e, t) { 204 var n, r, i, s, o, u, a, f, l, c, h, p, d, v, m, g, y, b; 205 if (e) { 206 this.setParsedChildren() 207 } 208 l = this.globals; 209 v = this.options; 210 r = this.$container; 211 u = this.getPositions(); 212 m = this.parsedChildren; 213 y = m.length; 214 i = l.animated && y <= v.animationThreshold; 215 s = v.animationSpeed; 216 f = v.draggedClass; 217 for (c = b = 0; 0 <= y ? b < y : b > y; c = 0 <= y ? ++b : --b) { 218 n = m[c].el; 219 o = u[c]; 220 h = n.hasClass(f); 221 if (h) { 222 g = v.placeholderClass; 223 n = n.siblings("." + g) 224 } 225 if (i && !h) { 226 n.stop(true, false).animate(o, s, function() {}) 227 } else { 228 n.css(o) 229 } 230 } 231 if (t) { 232 if (i) { 233 setTimeout(function() { 234 return r.trigger("ss-drop-complete") 235 }, s) 236 } else { 237 r.trigger("ss-drop-complete") 238 } 239 } 240 r.trigger("ss-arranged"); 241 if (v.autoHeight) { 242 a = l.container_height; 243 p = v.maxHeight; 244 d = v.minHeight; 245 if (d && a < d) { 246 a = d 247 } else if (p && a > p) { 248 a = p 249 } 250 return r.height(a) 251 } 252 }; 253 n.prototype.getPositions = function(e) { 254 var t, n, r, i, s, o, u, a, f, l, c, h, p, d, v, m, g, y, b = this; 255 if (e == null) { 256 e = true 257 } 258 s = this.globals; 259 f = this.options; 260 u = f.gutterY; 261 l = f.paddingY; 262 i = f.draggedClass; 263 c = this.parsedChildren; 264 m = c.length; 265 t = []; 266 for (a = g = 0, y = s.columns; 0 <= y ? g < y : g > y; a = 0 <= y ? ++g : --g) { 267 t.push(l) 268 } 269 d = function(e) { 270 var n, r, i, o, a, f, l; 271 n = e.col; 272 r = e.colspan; 273 o = e.col * s.col_width + s.child_offset; 274 a = t[n]; 275 h[e.i] = { 276 left: o, 277 top: a 278 }; 279 t[n] += e.height + u; 280 if (r >= 1) { 281 l = []; 282 for (i = f = 1; 1 <= r ? f < r : f > r; i = 1 <= r ? ++f : --f) { 283 l.push(t[n + i] = t[n]) 284 } 285 return l 286 } 287 }; 288 n = function(e) { 289 var n, r, i, s, o, u, a, f, l, c, h, p; 290 l = t.length - e.colspan + 1; 291 f = t.slice(0).splice(0, l); 292 n = void 0; 293 for (a = h = 0; 0 <= l ? h < l : h > l; a = 0 <= l ? ++h : --h) { 294 r = b.lowestCol(f, a); 295 i = e.colspan; 296 s = t[r]; 297 o = true; 298 for (c = p = 1; 1 <= i ? p < i : p > i;
298 c = 1 <= i ? ++p : --p) { 299 u = t[r + c]; 300 if (s < u) { 301 o = false; 302 break 303 } 304 } 305 if (o) { 306 n = r; 307 break 308 } 309 } 310 return n 311 }; 312 v = []; 313 p = function() { 314 var e, t, r, i, s, o, u, a, f, l; 315 s = []; 316 for (i = o = 0, a = v.length; 0 <= a ? o < a : o > a; i = 0 <= a ? ++o : --o) { 317 r = v[i]; 318 r.col = n(r); 319 if (r.col >= 0) { 320 d(r); 321 s.push(i) 322 } 323 } 324 l = []; 325 for (t = u = f = s.length - 1; u >= 0; t = u += -1) { 326 e = s[t]; 327 l.push(v.splice(e, 1)) 328 } 329 return l 330 }; 331 h = []; 332 (r = function() { 333 var r, s, o; 334 o = []; 335 for (a = s = 0; 0 <= m ? s < m : s > m; a = 0 <= m ? ++s : --s) { 336 r = c[a]; 337 if (!(!e && r.el.hasClass(i))) { 338 if (r.colspan > 1) { 339 r.col = n(r) 340 } else { 341 r.col = b.lowestCol(t) 342 } if (r.col === void 0) { 343 v.push(r) 344 } else { 345 d(r) 346 } 347 o.push(p()) 348 } else { 349 o.push(void 0) 350 } 351 } 352 return o 353 })(); 354 if (f.autoHeight) { 355 o = t[this.highestCol(t)] - u; 356 s.container_height = o + l 357 } 358 return h 359 }; 360 n.prototype.enableDragNDrop = function() { 361 var n, r, i, s, o, u, a, f, l, c, h, p, d, v, m, g, y, b, w = this; 362 d = this.options; 363 r = this.$container; 364 o = d.activeClass; 365 h = d.draggedClass; 366 m = d.placeholderClass; 367 v = d.originalContainerClass; 368 a = d.currentContainerClass; 369 g = d.previousContainerClass; 370 f = d.deleteClone; 371 c = d.dragRate; 372 l = d.dragClone; 373 u = d.cloneClass; 374 s = i = n = b = y = null; 375 p = false; 376 if (d.enableDrag) { 377 r.children("." + o).filter(d.dragWhitelist).draggable({ 378 addClasses: false, 379 containment: "document", 380 handle: d.handle, 381 zIndex: 9999, 382 start: function(t, r) { 383 var o; 384 s = e(t.target); 385 if (l) { 386 n = s.clone(true).insertBefore(s).addClass(u) 387 } 388 s.addClass(h); 389 o = s.prop("tagName"); 390 i = e("<" + o + " class='" + m + "' style='height: " + s.height() + "px; width: " + s.width() + "px'></" + o + ">"); 391 s.parent().addClass(v).addClass(a); 392 b = s.outerHeight() / 2; 393 return y = s.outerWidth() / 2 394 }, 395 drag: function(n, r) { 396 if (!p && !(l && f && e("." + a)[0] === e("." + v)[0])) { 397 i.remove().appendTo("." + a); 398 e("." + a).trigger("ss-setTargetPosition"); 399 p = true; 400 t.setTimeout(function() { 401 return p = false 402 }, c) 403 } 404 r.position.left = n.pageX - s.parent().offset().left - y; 405 return r.position.top = n.pageY - s.parent().offset().top - b 406 }, 407 stop: function() { 408 var t, r, o; 409 r = e("." + v); 410 t = e("." + a); 411 o = e("." + g); 412 s.removeClass(h); 413 e("." + m).remove(); 414 if (l) { 415 if (f && e("." + a)[0] === e("." + v)[0]) { 416 n.remove(); 417 e("." + a).trigger("ss-rearrange") 418 } else { 419 n.removeClass(u) 420 } 421 } 422 if (r[0] === t[0]) { 423 t.trigger("ss-rearranged", s) 424 } else { 425 r.trigger("ss-removed", s); 426 t.trigger("ss-added", s) 427 } 428 r.trigger("ss-arrange").removeClass(v); 429 t.trigger("ss-arrange", true).removeClass(a); 430 o.trigger("ss-arrange").removeClass(g); 431 return s = i = null 432 } 433 }) 434 } 435 if (d.enableCrossDrop) { 436 return r.droppable({ 437 accept: d.crossDropWhitelist, 438 tolerance: "intersect", 439 over: function(t) { 440 e("." + g).removeClass(g); 441 e("." + a).removeClass(a).addClass(g); 442 return e(t.target).addClass(a) 443 }, 444 drop: function(t, n) { 445 var r, i, o; 446 if (w.options.enableTrash) { 447 i = e("." + v); 448 r = e("." + a); 449 o = e("." + g); 450 s = e(n.helper); 451 r.trigger("ss-trashed", s); 452 s.remove(); 453 i.trigger("ss-rearrange").removeClass(v); 454 r.trigger("ss-rearrange").removeClass(a); 455 return o.trigger("ss-arrange").removeClass(g) 456 } 457 } 458 }) 459 } 460 }; 461 n.prototype.setTargetPosition = function() { 462 var t, n, r, i, s, o, u, a, f, l, c, h, p, d, v, m, g, y, b, w, E, S; 463 l = this.options; 464 if (!l.enableTrash) { 465 f = l.draggedClass; 466 t = e("." + f); 467 n = t.parent(); 468 c = this.parsedChildren; 469 s = this.getPositions(false); 470 b = s.length; 471 v = t.offset().left - n.offset().left + this.globals.col_width / 2; 472 m = t.offset().top - n.offset().top + t.height() / 2; 473 g = 9999999; 474 y = 0; 475 if (b > 1) { 476 u = l.cutoffStart + 1 || 0; 477 o = l.cutoffEnd || b; 478 for (p = S = u; u <= o ? S < o : S > o; p = u <= o ? ++S : --S) { 479 i = s[p]; 480 if (i) { 481 E = v - i.left; 482 w = m - i.top; 483 if (E > 0 && w > 0) { 484 a = Math.sqrt(w * w + E * E); 485 if (a < g) { 486 g = a; 487 y = p; 488 if (p === b - 1) { 489 if (E > c[p].height / 2) { 490 y++ 491 } 492 } 493 } 494 } 495 } 496 } 497 if (y === c.length) { 498 r = c[y - 1].el; 499 t.insertAfter(r) 500 } else { 501 r = c[y].el; 502 t.insertBefore(r) 503 } 504 } else { 505 if (b === 1) { 506 i = s[0]; 507 if (i.left < v) { 508 this.$container.append(t) 509 } else { 510 this.$container.prepend(t) 511 } 512 } else { 513 this.$container.append(t) 514 } 515 } 516 this.arrange(true); 517 if (n[0] !== t.parent()[0]) { 518 d = l.previousContainerClass; 519 return e("." + d).trigger("ss-rearrange") 520 } 521 } else { 522 h = this.options.placeholderClass; 523 return e("." + h).remove() 524 } 525 }; 526 n.prototype.enableResize = function() { 527 var n, r, i, s = this; 528 n = this.options.animationSpeed; 529 i = false;
530 r = "resize." + this.identifier; 531 return e(t).on(r, function() { 532 if (!i) { 533 i = true; 534 setTimeout(function() { 535 return s.render() 536 }, n / 3); 537 setTimeout(function() { 538 return s.render() 539 }, n / 3); 540 return setTimeout(function() { 541 i = false; 542 return s.render() 543 }, n / 3) 544 } 545 }) 546 }; 547 n.prototype.lowestCol = function(e, t) { 548 var n, r, i, s; 549 if (t == null) { 550 t = 0 551 } 552 i = e.length; 553 n = []; 554 for (r = s = 0; 0 <= i ? s < i : s > i; r = 0 <= i ? ++s : --s) { 555 n.push([e[r], r]) 556 } 557 n.sort(function(e, t) { 558 var n; 559 n = e[0] - t[0]; 560 if (n === 0) { 561 n = e[1] - t[1] 562 } 563 return n 564 }); 565 return n[t][1] 566 }; 567 n.prototype.highestCol = function(n) { 568 return e.inArray(Math.max.apply(t, n), n) 569 }; 570 n.prototype.destroy = function() { 571 var e, t, n; 572 t = this.$container; 573 t.off("ss-arrange"); 574 t.off("ss-rearrange"); 575 t.off("ss-setTargetPosition"); 576 t.off("ss-destroy"); 577 n = this.options.activeClass; 578 e = t.find("." + n); 579 if (this.options.enableDrag) { 580 e.draggable("destroy") 581 } 582 if (this.options.enableCrossDrop) { 583 t.droppable("destroy") 584 } 585 e.removeClass(n); 586 return t.removeClass(this.identifier) 587 }; 588 return n 589 }(); 590 return e.fn[s] = function(n) { 591 return this.each(function() { 592 var i, o, u; 593 o = (u = e(this).attr("class").match(/shapeshifted_container_\w+/)) != null ? u[0] : void 0; 594 if (o) { 595 i = "resize." + o; 596 e(t).off(i); 597 e(this).removeClass(o) 598 } 599 return e.data(this, "plugin_" + s, new r(this, n)) 600 }) 601 } 602 })(jQuery, window, document) 603}).call(this)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.