1// Generated by CoffeeScript 1.10.0 2(function() { 3 var $, OriDomi, addStyle, anchorList, anchorListH, anchorListV, baseName, capitalize, cloneEl, createEl, css, defaults, defer, elClasses, getGradient, hideEl, isSupported, k, libName, noOp, prefixList, prep, ref, showEl, styleBuffer, supportWarning, testEl, testProp, v, 4 bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 5 indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, 6 slice = [].slice; 7 8 libName = 'OriDomi'; 9 10 isSupported = true; 11 12 supportWarning = function(prop) { 13 if (typeof console !== "undefined" && console !== null) { 14 console.warn(libName + ": Missing support for `" + prop + "`."); 15 } 16 return isSupported = false; 17 }; 18 19 testProp = function(prop) { 20 var full, j, len1, prefix; 21 for (j = 0, len1 = prefixList.length; j < len1; j++) { 22 prefix = prefixList[j]; 23 if ((full = prefix + capitalize(prop)) in testEl.style) { 24 return full; 25 } 26 } 27 if (prop in testEl.style) { 28 return prop; 29 } 30 return false; 31 }; 32 33 addStyle = function(selector, rules) { 34 var prop, style, val; 35 style = "." + selector + "{"; 36 for (prop in rules) { 37 val = rules[prop]; 38 if (prop in css) { 39 prop = css[prop]; 40 if (prop.match(/^(webkit|moz|ms)/i)) { 41 prop = '-' + prop; 42 } 43 } 44 style += (prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()) + ":" + val + ";"; 45 } 46 return styleBuffer += style + '}'; 47 }; 48 49 getGradient = function(anchor) { 50 return css.gradientProp + "(" + anchor + ", rgba(0, 0, 0, .5) 0%, rgba(255, 255, 255, .35) 100%)"; 51 }; 52 53 capitalize = function(s) { 54 return s[0].toUpperCase() + s.slice(1); 55 }; 56 57 createEl = function(className) { 58 var el; 59 el = document.createElement('div'); 60 el.className = elClasses[className]; 61 return el; 62 }; 63 64 cloneEl = function(parent, deep, className) { 65 var el; 66 el = parent.cloneNode(deep); 67 el.classList.add(elClasses[className]); 68 return el; 69 }; 70 71 hideEl = function(el) { 72 return el.style[css.transform] = 'translate3d(-99999px, 0, 0)'; 73 }; 74 75 showEl = function(el) { 76 return el.style[css.transform] = 'translate3d(0, 0, 0)'; 77 }; 78 79 prep = function(fn) { 80 return function() { 81 var a0, a1, a2, anchor, angle, opt; 82 if (this._touchStarted) { 83 return fn.apply(this, arguments); 84 } else { 85 a0 = arguments[0], a1 = arguments[1], a2 = arguments[2]; 86 opt = {}; 87 angle = anchor = null; 88 switch (fn.length) { 89 case 1: 90 opt.callback = a0; 91 break; 92 case 2: 93 if (typeof a0 === 'function') { 94 opt.callback = a0; 95 } else { 96 anchor = a0; 97 opt.callback = a1; 98 } 99 break; 100 case 3: 101 angle = a0; 102 if (arguments.length === 2) { 103 if (typeof a1 === 'object') { 104 opt = a1; 105 } else if (typeof a1 === 'function') { 106 opt.callback = a1; 107 } else { 108 anchor = a1; 109 } 110 } else if (arguments.length === 3) { 111 anchor = a1; 112 if (typeof a2 === 'object') { 113 opt = a2; 114 } else if (typeof a2 === 'function') { 115 opt.callback = a2; 116 } 117 } 118 } 119 if (angle == null) { 120 angle = this._lastOp.angle || 0; 121 } 122 anchor || (anchor = this._lastOp.anchor); 123 this._queue.push([fn, this._normalizeAngle(angle), this._getLonghandAnchor(anchor), opt]); 124 this._step(); 125 return this; 126 } 127 }; 128 }; 129 130 defer = function(fn) { 131 return setTimeout(fn, 0); 132 }; 133 134 noOp = function() {}; 135 136 $ = (typeof window !== "undefined" && window !== null ? (ref = window.$) != null ? ref.data : void 0 : void 0) ? window.$ : null; 137 138 anchorList = ['left', 'right', 'top', 'bottom']; 139 140 anchorListV = anchorList.slice(0, 2); 141 142 anchorListH = anchorList.slice(2); 143 144 testEl = document.createElement('div'); 145 146 styleBuffer = ''; 147 148 //prefixList = ['Webkit', 'Moz', 'ms']; 149 prefixList = ['Webkit', 'ms']; 150 151 baseName = libName.toLowerCase(); 152 153 elClasses = { 154 active: 'active', 155 clone: 'clone', 156 holder: 'holder', 157 stage: 'stage', 158 stageLeft: 'stage-left', 159 stageRight: 'stage-right', 160 stageTop: 'stage-top', 161 stageBottom: 'stage-bottom', 162 content: 'content', 163 mask: 'mask', 164 maskH: 'mask-h', 165 maskV: 'mask-v', 166 panel: 'panel', 167 panelH: 'panel-h', 168 panelV: 'panel-v', 169 shader: 'shader', 170 shaderLeft: 'shader-left', 171 shaderRight: 'shader-right', 172 shaderTop: 'shader-top', 173 shaderBottom: 'shader-bottom' 174 }; 175 176 for (k in elClasses) { 177 v = elClasses[k]; 178 elClasses[k] = baseName + "-" + v; 179 } 180 181 css = new function() { 182 var j, key, len1, ref1; 183 ref1 = ['transform', 'transformOrigin', 'transformStyle', 'transitionProperty', 'transitionDuration', 'transitionDelay', 'transitionTimingFunction', 'perspective', 'perspectiveOrigin', 'backfaceVisibility', 'boxSizing', 'mask']; 184 for (j = 0, len1 = ref1.length; j < len1; j++) { 185 key = ref1[j]; 186 this[key] = key; 187 } 188 return this; 189 }; 190 191 (function() { 192 var key, p3d, prefix, ref1, styleEl, value; 193 for (key in css) { 194 value = css[key]; 195 css[key] = testProp(value); 196 if (!css[key]) { 197 return supportWarning(value); 198 } 199 } 200 p3d = 'preserve-3d'; 201 testEl.style[css.transformStyle] = p3d; 202 if (testEl.style[css.transformStyle] !== p3d) { 203 return supportWarning(p3d); 204 } 205 css.gradientProp = (function() { 206 var hyphenated, j, len1, prefix; 207 for (j = 0, len1 = prefixList.length; j < len1; j++) { 208 prefix = prefixList[j]; 209 hyphenated = "-" + (prefix.toLowerCase()) + "-linear-gradient"; 210 testEl.style.backgroundImage = hyphenated + "(left, #000, #fff)"; 211 if (testEl.style.backgroundImage.indexOf('gradient') !== -1) { 212 return hyphenated; 213 } 214 } 215 return 'linear-gradient'; 216 })(); 217 ref1 = (function() { 218 var grabValue, j, len1, plainGrab, prefix; 219 for (j = 0, len1 = prefixList.length; j < len1; j++) { 220 prefix = prefixList[j]; 221 plainGrab = 'grab'; 222 testEl.style.cursor = (grabValue = "-" + (prefix.toLowerCase()) + "-" + plainGrab); 223 if (testEl.style.cursor === grabValue) { 224 return [grabValue, "-" + (prefix.toLowerCase()) + "-grabbing"]; 225 } 226 } 227 testEl.style.cursor = plainGrab; 228 if (testEl.style.cursor === plainGrab) { 229 return [plainGrab, 'grabbing']; 230 } else { 231 return ['move', 'move']; 232 } 233 })(), css.grab = ref1[0], css.grabbing = ref1[1]; 234 css.transformProp = (prefix = css.transform.match(/(\w+)Transform/i)) ? "-" + (prefix[1].toLowerCase()) + "-transform" : 'transform'; 235 css.transitionEnd = (function() { 236 switch (css.transitionProperty.toLowerCase()) { 237 case 'transitionproperty': 238 return 'transitionEnd'; 239 case 'webkittransitionproperty': 240 return 'webkitTransitionEnd'; 241 case 'moztransitionproperty': 242 return 'transitionend'; 243 case 'mstransitionproperty': 244 return 'msTransitionEnd'; 245 } 246 })(); 247 (function(i) { 248 var anchor, j, len1, ref2; 249 addStyle(elClasses.active, { 250 backgroundColor: i('transparent'), 251 backgroundImage: i('none'), 252 boxSizing: i('border-box'), 253 border: i('none'), 254 outline: i('none'), 255 padding: i('0'), 256 transformStyle: i(p3d), 257 mask: i('none'), 258 position: 'relative' 259 }); 260 addStyle(elClasses.clone, { 261 margin: i('0'), 262 boxSizing: i('border-box'), 263 overflow: i('hidden'), 264 display: i('block') 265 }); 266 addStyle(elClasses.holder, { 267 width: '100%', 268 position: 'absolute', 269 top: '0', 270 bottom: '0', 271 transformStyle: p3d 272 }); 273 addStyle(elClasses.stage, { 274 width: '100%', 275 height: '100%', 276 position: 'absolute', 277 transform: 'translate3d(-9999px, 0, 0)', 278 margin: '0', 279 padding: '0', 280 transformStyle: p3d 281 }); 282 ref2 = { 283 Left: '0% 50%', 284 Right: '100% 50%', 285 Top: '50% 0%', 286 Bottom: '50% 100%' 287 }; 288 for (k in ref2) { 289 v = ref2[k]; 290 addStyle(elClasses['stage' + k], { 291 perspectiveOrigin: v 292 }); 293 } 294 addStyle(elClasses.shader, { 295 width: '100%', 296 height: '100%', 297 position: 'absolute', 298 opacity: '0', 299 top: '0', 300 left: '0', 301 pointerEvents: 'none', 302 transitionProperty: 'opacity' 303 }); 304 for (j = 0, len1 = anchorList.length; j < len1; j++) { 305 anchor = anchorList[j]; 306 addStyle(elClasses['shader' + capitalize(anchor)], { 307 background: getGradient(anchor) 308 }); 309 } 310 addStyle(elClasses.content, { 311 margin: i('0'), 312 position: i('relative'), 313 float: i('none'), 314 boxSizing: i('border-box'), 315 overflow: i('hidden') 316 }); 317 addStyle(elClasses.mask, { 318 width: '100%', 319 height: '100%', 320 position: 'absolute', 321 overflow: 'hidden', 322 transform: 'translate3d(0, 0, 0)', 323 outline: '1px solid transparent' 324 }); 325 addStyle(elClasses.panel, { 326 width: '100%', 327 height: '100%', 328 padding: '0', 329 position: 'absolute', 330 transitionProperty: css.transformProp, 331 transformOrigin: 'left', 332 transformStyle: p3d 333 }); 334 addStyle(elClasses.panelH, {
335 transformOrigin: 'top' 336 }); 337 addStyle(elClasses.stageRight + " ." + elClasses.panel, { 338 transformOrigin: 'right' 339 }); 340 return addStyle(elClasses.stageBottom + " ." + elClasses.panel, { 341 transformOrigin: 'bottom' 342 }); 343 })(function(s) { 344 return s + ' !important'; 345 }); 346 styleEl = document.createElement('style'); 347 styleEl.type = 'text/css'; 348 if (styleEl.styleSheet) { 349 styleEl.styleSheet.cssText = styleBuffer; 350 } else { 351 styleEl.appendChild(document.createTextNode(styleBuffer)); 352 } 353 return document.head.appendChild(styleEl); 354 })(); 355 356 defaults = { 357 vPanels: 3, 358 hPanels: 3, 359 perspective: 1000, 360 shading: 'hard', 361 speed: 700, 362 maxAngle: 90, 363 ripple: 0, 364 oriDomiClass: libName.toLowerCase(), 365 shadingIntensity: 1, 366 easingMethod: '', 367 gapNudge: 1.5, 368 touchEnabled: true, 369 touchSensitivity: .25, 370 touchStartCallback: noOp, 371 touchMoveCallback: noOp, 372 touchEndCallback: noOp 373 }; 374 375 OriDomi = (function() { 376 function OriDomi(el1, options) { 377 var a, anchor, anchorSet, axis, classSuffix, content, contentHolder, count, i, index, j, l, len1, len2, len3, len4, len5, len6, len7, len8, m, mask, maskProto, metric, o, offsets, panel, panelConfig, panelKey, panelN, panelProto, percent, prev, proto, q, r, ref1, ref2, ref3, rightOrBottom, shaderProto, shaderProtos, side, stageProto, t, u, w; 378 this.el = el1; 379 if (options == null) { 380 options = {}; 381 } 382 this._onMouseOut = bind(this._onMouseOut, this); 383 this._onTouchLeave = bind(this._onTouchLeave, this); 384 this._onTouchEnd = bind(this._onTouchEnd, this); 385 this._onTouchMove = bind(this._onTouchMove, this); 386 this._onTouchStart = bind(this._onTouchStart, this); 387 this._stageReset = bind(this._stageReset, this); 388 this._conclude = bind(this._conclude, this); 389 this._onTransitionEnd = bind(this._onTransitionEnd, this); 390 this._step = bind(this._step, this); 391 if (!isSupported) { 392 return; 393 } 394 if (!(this instanceof OriDomi)) { 395 return new OriDomi(this.el, options); 396 } 397 if (typeof this.el === 'string') { 398 this.el = document.querySelector(this.el); 399 } 400 if (!(this.el && this.el.nodeType === 1)) { 401 if (typeof console !== "undefined" && console !== null) { 402 console.warn(libName + ": First argument must be a DOM element"); 403 } 404 return; 405 } 406 this._config = new function() { 407 for (k in defaults) { 408 v = defaults[k]; 409 if (k in options) { 410 this[k] = options[k]; 411 } else { 412 this[k] = v; 413 } 414 } 415 return this; 416 }; 417 this._config.ripple = Number(this._config.ripple); 418 this._queue = []; 419 this._panels = {}; 420 this._stages = {}; 421 this._lastOp = { 422 anchor: anchorList[0] 423 }; 424 this._shading = this._config.shading; 425 if (this._shading === true) { 426 this._shading = 'hard'; 427 } 428 if (this._shading) { 429 this._shaders = {}; 430 shaderProtos = {}; 431 shaderProto = createEl('shader'); 432 shaderProto.style[css.transitionDuration] = this._config.speed + 'ms'; 433 shaderProto.style[css.transitionTimingFunction] = this._config.easingMethod; 434 } 435 stageProto = createEl('stage'); 436 stageProto.style[css.perspective] = this._config.perspective + 'px'; 437 for (j = 0, len1 = anchorList.length; j < len1; j++) { 438 anchor = anchorList[j]; 439 this._panels[anchor] = []; 440 this._stages[anchor] = cloneEl(stageProto, false, 'stage' + capitalize(anchor)); 441 if (this._shading) { 442 this._shaders[anchor] = {}; 443 if (indexOf.call(anchorListV, anchor) >= 0) { 444 for (l = 0, len2 = anchorListV.length; l < len2; l++) { 445 side = anchorListV[l]; 446 this._shaders[anchor][side] = []; 447 } 448 } else { 449 for (m = 0, len3 = anchorListH.length; m < len3; m++) { 450 side = anchorListH[m]; 451 this._shaders[anchor][side] = []; 452 } 453 } 454 shaderProtos[anchor] = cloneEl(shaderProto, false, 'shader' + capitalize(anchor)); 455 } 456 } 457 contentHolder = cloneEl(this.el, true, 'content'); 458 maskProto = createEl('mask'); 459 maskProto.appendChild(contentHolder); 460 panelProto = createEl('panel'); 461 panelProto.style[css.transitionDuration] = this._config.speed + 'ms'; 462 panelProto.style[css.transitionTimingFunction] = this._config.easingMethod; 463 offsets = { 464 left: [], 465 top: [] 466 }; 467 ref1 = ['x', 'y']; 468 for (o = 0, len4 = ref1.length; o < len4; o++) { 469 axis = ref1[o]; 470 if (axis === 'x') { 471 anchorSet = anchorListV; 472 metric = 'width'; 473 classSuffix = 'V'; 474 } else { 475 anchorSet = anchorListH; 476 metric = 'height';
477 classSuffix = 'H'; 478 } 479 panelConfig = this._config[panelKey = classSuffix.toLowerCase() + 'Panels']; 480 if (typeof panelConfig === 'number') { 481 count = Math.abs(parseInt(panelConfig, 10)); 482 percent = 100 / count; 483 panelConfig = this._config[panelKey] = (function() { 484 var q, ref2, results; 485 results = []; 486 for (q = 0, ref2 = count; 0 <= ref2 ? q < ref2 : q > ref2; 0 <= ref2 ? q++ : q--) { 487 results.push(percent); 488 } 489 return results; 490 })(); 491 } else { 492 count = panelConfig.length; 493 if (!((99 <= (ref2 = panelConfig.reduce(function(p, c) { 494 return p + c; 495 })) && ref2 <= 100.1))) { 496 throw new Error(libName + ": Panel percentages do not sum to 100"); 497 } 498 } 499 mask = cloneEl(maskProto, true, 'mask' + classSuffix); 500 if (this._shading) { 501 for (q = 0, len5 = anchorSet.length; q < len5; q++) { 502 anchor = anchorSet[q]; 503 mask.appendChild(shaderProtos[anchor]); 504 } 505 } 506 proto = cloneEl(panelProto, false, 'panel' + classSuffix); 507 proto.appendChild(mask); 508 for (rightOrBottom = r = 0, len6 = anchorSet.length; r < len6; rightOrBottom = ++r) { 509 anchor = anchorSet[rightOrBottom]; 510 for (panelN = t = 0, ref3 = count; 0 <= ref3 ? t < ref3 : t > ref3; panelN = 0 <= ref3 ? ++t : --t) { 511 panel = proto.cloneNode(true); 512 content = panel.children[0].children[0]; 513 content.style.width = content.style.height = '100%'; 514 if (rightOrBottom) { 515 panel.style[css.origin] = anchor; 516 index = panelConfig.length - panelN - 1; 517 prev = index + 1; 518 } else { 519 index = panelN; 520 prev = index - 1; 521 if (panelN === 0) { 522 offsets[anchor].push(0); 523 } else { 524 offsets[anchor].push((offsets[anchor][prev] - 100) * (panelConfig[prev] / panelConfig[index])); 525 } 526 } 527 if (panelN === 0) { 528 panel.style[anchor] = '0'; 529 panel.style[metric] = panelConfig[index] + '%'; 530 } else { 531 panel.style[anchor] = '100%'; 532 panel.style[metric] = panelConfig[index] / panelConfig[prev] * 100 + '%'; 533 } 534 if (this._shading) { 535 for (i = u = 0, len7 = anchorSet.length; u < len7; i = ++u) { 536 a = anchorSet[i]; 537 this._shaders[anchor][a][panelN] = panel.children[0].children[i + 1]; 538 } 539 } 540 content.style[metric] = content.style['max' + capitalize(metric)] = (count / panelConfig[index] * 10000 / count) + '%'; 541 content.style[anchorSet[0]] = offsets[anchorSet[0]][index] + '%'; 542 this._transformPanel(panel, 0, anchor); 543 this._panels[anchor][panelN] = panel; 544 if (panelN !== 0) { 545 this._panels[anchor][panelN - 1].appendChild(panel); 546 } 547 } 548 this._stages[anchor].appendChild(this._panels[anchor][0]); 549 } 550 } 551 this._stageHolder = createEl('holder'); 552 this._stageHolder.setAttribute('aria-hidden', 'true'); 553 for (w = 0, len8 = anchorList.length; w < len8; w++) { 554 anchor = anchorList[w]; 555 this._stageHolder.appendChild(this._stages[anchor]); 556 } 557 if (window.getComputedStyle(this.el).position === 'absolute') { 558 this.el.style.position = 'absolute'; 559 } 560 this.el.classList.add(elClasses.active); 561 showEl(this._stages.left); 562 this._cloneEl = cloneEl(this.el, true, 'clone'); 563 this._cloneEl.classList.remove(elClasses.active); 564 hideEl(this._cloneEl); 565 this.el.innerHTML = ''; 566 this.el.appendChild(this._cloneEl); 567 this.el.appendChild(this._stageHolder); 568 this.el.parentNode.style[css.transformStyle] = 'preserve-3d'; 569 this.accordion(0); 570 if (this._config.ripple) { 571 this.setRipple(this._config.ripple); 572 } 573 if (this._config.touchEnabled) { 574 this.enableTouch(); 575 } 576 } 577 578 OriDomi.prototype._step = function() { 579 var anchor, angle, fn, next, options, ref1; 580 if (this._inTrans || !this._queue.length) { 581 return; 582 } 583 this._inTrans = true; 584 ref1 = this._queue.shift(), fn = ref1[0], angle = ref1[1], anchor = ref1[2], options = ref1[3]; 585 if (this.isFrozen) { 586 this.unfreeze(); 587 } 588 next = (function(_this) { 589 return function() { 590 var args; 591 _this._setCallback({ 592 angle: angle, 593 anchor: anchor, 594 options: options, 595 fn: fn 596 }); 597 args = [angle, anchor, options]; 598 if (fn.length < 3) { 599 args.shift(); 600 } 601 return fn.apply(_this, args); 602 }; 603 })(this); 604 if (this.isFoldedUp) { 605 if (fn.length === 2) { 606 return next(); 607 } else { 608 return this._unfold(next); 609 } 610 } else if (anchor !== this._lastOp.anchor) { 611 return this._stageReset(anchor, next); 612 } else { 613 return next(); 614 } 615 }; 616 617 OriDomi.prototype._isIdenticalOperation = function(op) { 618 var j, key, len1, ref1, ref2; 619 if (!this._lastOp.fn) { 620 return true; 621 } 622 if (this._lastOp.reset) { 623 return false;
624 } 625 ref1 = ['angle', 'anchor', 'fn']; 626 for (j = 0, len1 = ref1.length; j < len1; j++) { 627 key = ref1[j]; 628 if (this._lastOp[key] !== op[key]) { 629 return false; 630 } 631 } 632 ref2 = op.options; 633 for (k in ref2) { 634 v = ref2[k]; 635 if (v !== this._lastOp.options[k] && k !== 'callback') { 636 return false; 637 } 638 } 639 return true; 640 }; 641 642 OriDomi.prototype._setCallback = function(operation) { 643 if (!this._config.speed || this._isIdenticalOperation(operation)) { 644 this._conclude(operation.options.callback); 645 } else { 646 this._panels[this._lastOp.anchor][0].addEventListener(css.transitionEnd, this._onTransitionEnd, false); 647 } 648 return (this._lastOp = operation).reset = false; 649 }; 650 651 OriDomi.prototype._onTransitionEnd = function(e) { 652 e.currentTarget.removeEventListener(css.transitionEnd, this._onTransitionEnd, false); 653 return this._conclude(this._lastOp.options.callback, e); 654 }; 655 656 OriDomi.prototype._conclude = function(cb, event) { 657 return defer((function(_this) { 658 return function() { 659 _this._inTrans = false; 660 _this._step(); 661 return typeof cb === "function" ? cb(event, _this) : void 0; 662 }; 663 })(this)); 664 }; 665 666 OriDomi.prototype._transformPanel = function(el, angle, anchor, fracture) { 667 var transPrefix, x, y, z; 668 x = y = z = 0; 669 switch (anchor) { 670 case 'left': 671 y = angle; 672 transPrefix = 'X(-'; 673 break; 674 case 'right': 675 y = -angle; 676 transPrefix = 'X('; 677 break; 678 case 'top': 679 x = -angle; 680 transPrefix = 'Y(-'; 681 break; 682 case 'bottom': 683 x = angle; 684 transPrefix = 'Y('; 685 } 686 if (fracture) { 687 x = y = z = angle; 688 } 689 return el.style[css.transform] = "rotateX(" + x + "deg) rotateY(" + y + "deg) rotateZ(" + z + "deg) translate" + transPrefix + this._config.gapNudge + "px)"; 690 }; 691 692 OriDomi.prototype._normalizeAngle = function(angle) { 693 var max; 694 angle = parseFloat(angle, 10); 695 max = this._config.maxAngle; 696 if (isNaN(angle)) { 697 return 0; 698 } else if (angle > max) { 699 return max; 700 } else if (angle < -max) { 701 return -max; 702 } else { 703 return angle; 704 } 705 }; 706 707 OriDomi.prototype._setTrans = function(duration, delay, anchor) { 708 if (anchor == null) { 709 anchor = this._lastOp.anchor; 710 } 711 return this._iterate(anchor, (function(_this) { 712 return function(panel, i, len) { 713 return _this._setPanelTrans.apply(_this, [anchor].concat(slice.call(arguments), [duration], [delay])); 714 }; 715 })(this)); 716 }; 717 718 OriDomi.prototype._setPanelTrans = function(anchor, panel, i, len, duration, delay) { 719 var delayMs, j, len1, ref1, shader, side; 720 delayMs = (function() { 721 switch (delay) { 722 case 0: 723 return 0; 724 case 1: 725 return this._config.speed / len * i; 726 case 2: 727 return this._config.speed / len * (len - i - 1); 728 } 729 }).call(this); 730 panel.style[css.transitionDuration] = duration + 'ms'; 731 panel.style[css.transitionDelay] = delayMs + 'ms'; 732 if (this._shading) { 733 ref1 = (indexOf.call(anchorListV, anchor) >= 0 ? anchorListV : anchorListH); 734 for (j = 0, len1 = ref1.length; j < len1; j++) { 735 side = ref1[j]; 736 shader = this._shaders[anchor][side][i]; 737 shader.style[css.transitionDuration] = duration + 'ms'; 738 shader.style[css.transitionDelay] = delayMs + 'ms'; 739 } 740 } 741 return delayMs; 742 }; 743 744 OriDomi.prototype._setShader = function(n, anchor, angle) { 745 var a, abs, b, opacity; 746 abs = Math.abs(angle); 747 opacity = abs / 90 * this._config.shadingIntensity; 748 if (this._shading === 'hard') { 749 opacity *= .15; 750 if (this._lastOp.angle < 0) { 751 angle = abs; 752 } else { 753 angle = -abs; 754 } 755 } else { 756 opacity *= .4; 757 } 758 if (indexOf.call(anchorListV, anchor) >= 0) { 759 if (angle < 0) { 760 a = opacity; 761 b = 0; 762 } else { 763 a = 0; 764 b = opacity; 765 } 766 this._shaders[anchor].left[n].style.opacity = a; 767 return this._shaders[anchor].right[n].style.opacity = b; 768 } else { 769 if (angle < 0) { 770 a = 0; 771 b = opacity; 772 } else { 773 a = opacity; 774 b = 0; 775 } 776 this._shaders[anchor].top[n].style.opacity = a; 777 return this._shaders[anchor].bottom[n].style.opacity = b; 778 } 779 }; 780 781 OriDomi.prototype._showStage = function(anchor) { 782 if (anchor !== this._lastOp.anchor) { 783 hideEl(this._stages[this._lastOp.anchor]); 784 this._lastOp.anchor = anchor; 785 this._lastOp.reset = true;
786 return this._stages[anchor].style[css.transform] = 'translate3d(' + (function() { 787 switch (anchor) { 788 case 'left': 789 return '0, 0, 0)'; 790 case 'right': 791 return '0, 0, 0)'; 792 case 'top': 793 return '0, 0, 0)'; 794 case 'bottom': 795 return '0, 0, 0)'; 796 } 797 }).call(this); 798 } 799 }; 800 801 OriDomi.prototype._stageReset = function(anchor, cb) { 802 var fn; 803 fn = (function(_this) { 804 return function(e) { 805 if (e) { 806 e.currentTarget.removeEventListener(css.transitionEnd, fn, false); 807 } 808 _this._showStage(anchor); 809 return defer(cb); 810 }; 811 })(this); 812 if (this._lastOp.angle === 0) { 813 return fn(); 814 } 815 this._panels[this._lastOp.anchor][0].addEventListener(css.transitionEnd, fn, false); 816 return this._iterate(this._lastOp.anchor, (function(_this) { 817 return function(panel, i) { 818 _this._transformPanel(panel, 0, _this._lastOp.anchor); 819 if (_this._shading) { 820 return _this._setShader(i, _this._lastOp.anchor, 0); 821 } 822 }; 823 })(this)); 824 }; 825 826 OriDomi.prototype._getLonghandAnchor = function(shorthand) { 827 switch (shorthand.toString()) { 828 case 'left': 829 case 'l': 830 case '4': 831 return 'left'; 832 case 'right': 833 case 'r': 834 case '2': 835 return 'right'; 836 case 'top': 837 case 't': 838 case '1': 839 return 'top'; 840 case 'bottom': 841 case 'b': 842 case '3': 843 return 'bottom'; 844 default: 845 return 'left'; 846 } 847 }; 848 849 OriDomi.prototype._setCursor = function(bool) { 850 if (bool == null) { 851 bool = this._touchEnabled; 852 } 853 if (bool) { 854 return this.el.style.cursor = css.grab; 855 } else { 856 return this.el.style.cursor = 'default'; 857 } 858 }; 859 860 OriDomi.prototype._setTouch = function(toggle) { 861 var eString, eventPair, eventPairs, j, l, len1, len2, listenFn, mouseLeaveSupport; 862 if (toggle) { 863 if (this._touchEnabled) { 864 return this; 865 } 866 listenFn = 'addEventListener'; 867 } else { 868 if (!this._touchEnabled) { 869 return this; 870 } 871 listenFn = 'removeEventListener'; 872 } 873 this._touchEnabled = toggle; 874 this._setCursor(); 875 eventPairs = [['TouchStart', 'MouseDown'], ['TouchEnd', 'MouseUp'], ['TouchMove', 'MouseMove'], ['TouchLeave', 'MouseLeave']]; 876 mouseLeaveSupport = 'onmouseleave' in window; 877 for (j = 0, len1 = eventPairs.length; j < len1; j++) { 878 eventPair = eventPairs[j]; 879 for (l = 0, len2 = eventPair.length; l < len2; l++) { 880 eString = eventPair[l]; 881 if (!(eString === 'TouchLeave' && !mouseLeaveSupport)) { 882 this.el[listenFn](eString.toLowerCase(), this['_on' + eventPair[0]], false); 883 } else { 884 this.el[listenFn]('mouseout', this._onMouseOut, false); 885 break; 886 } 887 } 888 } 889 return this; 890 }; 891 892 OriDomi.prototype._onTouchStart = function(e) { 893 var axis1, ref1; 894 if (!this._touchEnabled || this.isFoldedUp) { 895 return; 896 } 897 e.preventDefault(); 898 this.emptyQueue(); 899 this._touchStarted = true; 900 this.el.style.cursor = css.grabbing; 901 this._setTrans(0, 0); 902 this._touchAxis = (ref1 = this._lastOp.anchor, indexOf.call(anchorListV, ref1) >= 0) ? 'x' : 'y'; 903 this["_" + this._touchAxis + "Last"] = this._lastOp.angle; 904 axis1 = "_" + this._touchAxis + "1"; 905 if (e.type === 'mousedown') { 906 this[axis1] = e["page" + (this._touchAxis.toUpperCase())]; 907 } else { 908 this[axis1] = e.targetTouches[0]["page" + (this._touchAxis.toUpperCase())]; 909 } 910 return this._config.touchStartCallback(this[axis1], e); 911 }; 912 913 OriDomi.prototype._onTouchMove = function(e) { 914 var current, delta, distance; 915 if (!(this._touchEnabled && this._touchStarted)) { 916 return; 917 } 918 e.preventDefault(); 919 if (e.type === 'mousemove') { 920 current = e["page" + (this._touchAxis.toUpperCase())]; 921 } else { 922 current = e.targetTouches[0]["page" + (this._touchAxis.toUpperCase())]; 923 } 924 distance = (current - this["_" + this._touchAxis + "1"]) * this._config.touchSensitivity; 925 if (this._lastOp.angle < 0) { 926 if (this._lastOp.anchor === 'right' || this._lastOp.anchor === 'bottom') { 927 delta = this["_" + this._touchAxis + "Last"] - distance; 928 } else { 929 delta = this["_" + this._touchAxis + "Last"] + distance; 930 } 931 if (delta > 0) { 932 delta = 0; 933 } 934 } else { 935 if (this._lastOp.anchor === 'right' || this._lastOp.anchor === 'bottom') { 936 delta = this["_" + this._touchAxis + "Last"] + distance; 937 } else { 938 delta = this["_" + this._touchAxis + "Last"] - distance; 939 } 940 if (delta < 0) { 941 delta = 0; 942 } 943 } 944 this._lastOp.angle = delta = this._normalizeAngle(delta); 945 this._lastOp.fn.call(this, delta, this._lastOp.anchor, this._lastOp.options); 946 return this._config.touchMoveCallback(delta, e); 947 }; 948 949 OriDomi.prototype._onTouchEnd = function(e) { 950 if (!this._touchEnabled) { 951 return; 952 } 953 this._touchStarted = this._inTrans = false;
954 this.el.style.cursor = css.grab; 955 this._setTrans(this._config.speed, this._config.ripple); 956 return this._config.touchEndCallback(this["_" + this._touchAxis + "Last"], e); 957 }; 958 959 OriDomi.prototype._onTouchLeave = function(e) { 960 if (!(this._touchEnabled && this._touchStarted)) { 961 return; 962 } 963 return this._onTouchEnd(e); 964 }; 965 966 OriDomi.prototype._onMouseOut = function(e) { 967 if (!(this._touchEnabled && this._touchStarted)) { 968 return; 969 } 970 if (e.toElement && !this.el.contains(e.toElement)) { 971 return this._onTouchEnd(e); 972 } 973 }; 974 975 OriDomi.prototype._unfold = function(callback) { 976 var anchor; 977 this._inTrans = true; 978 anchor = this._lastOp.anchor; 979 return this._iterate(anchor, (function(_this) { 980 return function(panel, i, len) { 981 var delay; 982 delay = _this._setPanelTrans.apply(_this, [anchor].concat(slice.call(arguments), [_this._config.speed], [1])); 983 return (function(panel, i, delay) { 984 return defer(function() { 985 _this._transformPanel(panel, 0, anchor); 986 if (_this._shading) { 987 _this._setShader(i, anchor, 0); 988 } 989 return setTimeout(function() { 990 showEl(panel.children[0]); 991 if (i === len - 1) { 992 _this._inTrans = _this.isFoldedUp = false; 993 if (typeof callback === "function") { 994 callback(); 995 } 996 _this._lastOp.fn = _this.accordion; 997 _this._lastOp.angle = 0; 998 } 999 return defer(function() { 1000 return panel.style[css.transitionDuration] = _this._config.speed; 1001 }); 1002 }, delay + _this._config.speed * .25); 1003 }); 1004 })(panel, i, delay); 1005 }; 1006 })(this)); 1007 }; 1008 1009 OriDomi.prototype._iterate = function(anchor, fn) { 1010 var i, j, len1, panel, panels, ref1, results; 1011 ref1 = panels = this._panels[anchor]; 1012 results = []; 1013 for (i = j = 0, len1 = ref1.length; j < len1; i = ++j) { 1014 panel = ref1[i]; 1015 results.push(fn.call(this, panel, i, panels.length)); 1016 } 1017 return results; 1018 }; 1019 1020 OriDomi.prototype.enableTouch = function() { 1021 return this._setTouch(true); 1022 }; 1023 1024 OriDomi.prototype.disableTouch = function() { 1025 return this._setTouch(false); 1026 }; 1027 1028 OriDomi.prototype.setSpeed = function(speed) { 1029 var anchor, j, len1; 1030 for (j = 0, len1 = anchorList.length; j < len1; j++) { 1031 anchor = anchorList[j]; 1032 this._setTrans((this._config.speed = speed), this._config.ripple, anchor); 1033 } 1034 return this; 1035 }; 1036 1037 OriDomi.prototype.freeze = function(callback) { 1038 if (this.isFrozen) { 1039 if (typeof callback === "function") { 1040 callback(); 1041 } 1042 } else { 1043 this._stageReset(this._lastOp.anchor, (function(_this) { 1044 return function() { 1045 _this.isFrozen = true; 1046 hideEl(_this._stageHolder); 1047 showEl(_this._cloneEl); 1048 _this._setCursor(false); 1049 return typeof callback === "function" ? callback() : void 0; 1050 }; 1051 })(this)); 1052 } 1053 return this; 1054 }; 1055 1056 OriDomi.prototype.unfreeze = function() { 1057 if (this.isFrozen) { 1058 this.isFrozen = false; 1059 hideEl(this._cloneEl); 1060 showEl(this._stageHolder); 1061 this._setCursor(); 1062 this._lastOp.angle = 0; 1063 } 1064 return this; 1065 }; 1066 1067 OriDomi.prototype.destroy = function(callback) { 1068 this.freeze((function(_this) { 1069 return function() { 1070 _this._setTouch(false); 1071 if ($) { 1072 $.data(_this.el, baseName, null); 1073 } 1074 _this.el.innerHTML = _this._cloneEl.innerHTML; 1075 _this.el.classList.remove(elClasses.active); 1076 return typeof callback === "function" ? callback() : void 0; 1077 }; 1078 })(this)); 1079 return null; 1080 }; 1081 1082 OriDomi.prototype.emptyQueue = function() { 1083 this._queue = []; 1084 defer((function(_this) { 1085 return function() { 1086 return _this._inTrans = false;
1087 }; 1088 })(this)); 1089 return this; 1090 }; 1091 1092 OriDomi.prototype.setRipple = function(dir) { 1093 if (dir == null) { 1094 dir = 1; 1095 } 1096 this._config.ripple = Number(dir); 1097 this.setSpeed(this._config.speed); 1098 return this; 1099 }; 1100 1101 OriDomi.prototype.constrainAngle = function(angle) { 1102 this._config.maxAngle = parseFloat(angle, 10) || defaults.maxAngle; 1103 return this; 1104 }; 1105 1106 OriDomi.prototype.wait = function(ms) { 1107 var fn; 1108 fn = (function(_this) { 1109 return function() { 1110 return setTimeout(_this._conclude, ms); 1111 }; 1112 })(this); 1113 if (this._inTrans) { 1114 this._queue.push([fn, this._lastOp.angle, this._lastOp.anchor, this._lastOp.options]); 1115 } else { 1116 fn(); 1117 } 1118 return this; 1119 }; 1120 1121 OriDomi.prototype.modifyContent = function(fn) { 1122 var anchor, i, j, l, len1, len2, panel, ref1, selectors, set; 1123 if (typeof fn !== 'function') { 1124 selectors = fn; 1125 set = function(el, content, style) { 1126 var key, value; 1127 if (content) { 1128 el.innerHTML = content; 1129 } 1130 if (style) { 1131 for (key in style) { 1132 value = style[key]; 1133 el.style[key] = value; 1134 } 1135 return null; 1136 } 1137 }; 1138 fn = function(el) { 1139 var content, j, len1, match, ref1, selector, style, value; 1140 for (selector in selectors) { 1141 value = selectors[selector]; 1142 content = style = null; 1143 if (typeof value === 'string') { 1144 content = value; 1145 } else { 1146 content = value.content, style = value.style; 1147 } 1148 if (selector === '') { 1149 set(el, content, style); 1150 continue; 1151 } 1152 ref1 = el.querySelectorAll(selector); 1153 for (j = 0, len1 = ref1.length; j < len1; j++) { 1154 match = ref1[j]; 1155 set(match, content, style); 1156 } 1157 } 1158 return null; 1159 }; 1160 } 1161 for (j = 0, len1 = anchorList.length; j < len1; j++) { 1162 anchor = anchorList[j]; 1163 ref1 = this._panels[anchor]; 1164 for (i = l = 0, len2 = ref1.length; l < len2; i = ++l) { 1165 panel = ref1[i]; 1166 fn(panel.children[0].children[0], i, anchor); 1167 } 1168 } 1169 return this; 1170 }; 1171 1172 OriDomi.prototype.accordion = prep(function(angle, anchor, options) { 1173 return this._iterate(anchor, (function(_this) { 1174 return function(panel, i) { 1175 var deg; 1176 if (i % 2 !== 0 && !options.twist) { 1177 deg = -angle; 1178 } else { 1179 deg = angle; 1180 } 1181 if (options.sticky) { 1182 if (i === 0) { 1183 deg = 0; 1184 } else if (i > 1 || options.stairs) { 1185 deg *= 2; 1186 } 1187 } else { 1188 if (i !== 0) { 1189 deg *= 2; 1190 } 1191 } 1192 if (options.stairs) { 1193 deg *= -1; 1194 } 1195 _this._transformPanel(panel, deg, anchor, options.fracture); 1196 if (_this._shading) { 1197 if (options.twist || options.fracture || (i === 0 && options.sticky)) { 1198 return _this._setShader(i, anchor, 0); 1199 } else if (Math.abs(deg) !== 180) { 1200 return _this._setShader(i, anchor, deg); 1201 } 1202 } 1203 }; 1204 })(this)); 1205 }); 1206 1207 OriDomi.prototype.curl = prep(function(angle, anchor, options) { 1208 angle /= indexOf.call(anchorListV, anchor) >= 0 ? this._config.vPanels.length : this._config.hPanels.length; 1209 return this._iterate(anchor, (function(_this) { 1210 return function(panel, i) { 1211 _this._transformPanel(panel, angle, anchor); 1212 if (_this._shading) { 1213 return _this._setShader(i, anchor, 0); 1214 } 1215 }; 1216 })(this)); 1217 }); 1218 1219 OriDomi.prototype.ramp = prep(function(angle, anchor, options) { 1220 this._transformPanel(this._panels[anchor][1], angle, anchor); 1221 return this._iterate(anchor, (function(_this) { 1222 return function(panel, i) { 1223 if (i !== 1) { 1224 _this._transformPanel(panel, 0, anchor); 1225 } 1226 if (_this._shading) { 1227 return _this._setShader(i, anchor, 0); 1228 } 1229 }; 1230 })(this)); 1231 }); 1232 1233 OriDomi.prototype.foldUp = prep(function(anchor, callback) { 1234 if (this.isFoldedUp) { 1235 return typeof callback === "function" ? callback() : void 0; 1236 } 1237 return this._stageReset(anchor, (function(_this) { 1238 return function() { 1239 _this._inTrans = _this.isFoldedUp = true; 1240 return _this._iterate(anchor, function(panel, i, len) { 1241 var delay, duration; 1242 duration = _this._config.speed; 1243 if (i === 0) { 1244 duration /= 2; 1245 }
1246 delay = _this._setPanelTrans.apply(_this, [anchor].concat(slice.call(arguments), [duration], [2])); 1247 return (function(panel, i, delay) { 1248 return defer(function() { 1249 _this._transformPanel(panel, (i === 0 ? 90 : 170), anchor); 1250 return setTimeout(function() { 1251 if (i === 0) { 1252 _this._inTrans = false; 1253 return typeof callback === "function" ? callback() : void 0; 1254 } else { 1255 return hideEl(panel.children[0]); 1256 } 1257 }, delay + _this._config.speed * .25); 1258 }); 1259 })(panel, i, delay); 1260 }); 1261 }; 1262 })(this)); 1263 }); 1264 1265 OriDomi.prototype.unfold = prep(OriDomi.prototype._unfold); 1266 1267 OriDomi.prototype.map = function(fn) { 1268 return prep((function(_this) { 1269 return function(angle, anchor, options) { 1270 return _this._iterate(anchor, function(panel, i, len) { 1271 return _this._transformPanel(panel, fn(angle, i, len), anchor, options.fracture); 1272 }); 1273 }; 1274 })(this)).bind(this); 1275 }; 1276 1277 OriDomi.prototype.reset = function(callback) { 1278 return this.accordion(0, { 1279 callback: callback 1280 }); 1281 }; 1282 1283 OriDomi.prototype.reveal = function(angle, anchor, options) { 1284 if (options == null) { 1285 options = {}; 1286 } 1287 options.sticky = true; 1288 return this.accordion(angle, anchor, options); 1289 }; 1290 1291 OriDomi.prototype.stairs = function(angle, anchor, options) { 1292 if (options == null) { 1293 options = {}; 1294 } 1295 options.stairs = options.sticky = true; 1296 return this.accordion(angle, anchor, options); 1297 }; 1298 1299 OriDomi.prototype.fracture = function(angle, anchor, options) { 1300 if (options == null) { 1301 options = {}; 1302 } 1303 options.fracture = true; 1304 return this.accordion(angle, anchor, options); 1305 }; 1306 1307 OriDomi.prototype.twist = function(angle, anchor, options) { 1308 if (options == null) { 1309 options = {}; 1310 } 1311 options.fracture = options.twist = true; 1312 return this.accordion(angle / 10, anchor, options); 1313 }; 1314 1315 OriDomi.prototype.collapse = function(anchor, options) { 1316 if (options == null) { 1317 options = {}; 1318 } 1319 options.sticky = false; 1320 return this.accordion(-this._config.maxAngle, anchor, options); 1321 }; 1322 1323 OriDomi.prototype.collapseAlt = function(anchor, options) { 1324 if (options == null) { 1325 options = {}; 1326 } 1327 options.sticky = false; 1328 return this.accordion(this._config.maxAngle, anchor, options); 1329 }; 1330 1331 OriDomi.VERSION = '1.1.5'; 1332 1333 OriDomi.isSupported = isSupported; 1334 1335 return OriDomi; 1336 1337 })(); 1338 1339 if (typeof module !== "undefined" && module !== null ? module.exports : void 0) { 1340 module.exports = OriDomi; 1341 } else if (typeof define !== "undefined" && define !== null ? define.amd : void 0) { 1342 define(function() { 1343 return OriDomi; 1344 }); 1345 } else { 1346 window.OriDomi = OriDomi; 1347 } 1348 1349 if (!$) { 1350 return; 1351 } 1352 1353 $.prototype.oriDomi = function(options) { 1354 var el, instance, j, l, len1, len2, method, methodName; 1355 if (!isSupported) { 1356 return this; 1357 } 1358 if (options === true) { 1359 return $.data(this[0], baseName); 1360 } 1361 if (typeof options === 'string') { 1362 methodName = options; 1363 if (typeof (method = OriDomi.prototype[methodName]) !== 'function') { 1364 if (typeof console !== "undefined" && console !== null) { 1365 console.warn(libName + ": No such method `" + methodName + "`"); 1366 } 1367 return this; 1368 } 1369 for (j = 0, len1 = this.length; j < len1; j++) { 1370 el = this[j]; 1371 if (!(instance = $.data(el, baseName))) { 1372 instance = $.data(el, baseName, new OriDomi(el, options)); 1373 } 1374 method.apply(instance, Array.prototype.slice.call(arguments).slice(1)); 1375 } 1376 } else { 1377 for (l = 0, len2 = this.length; l < len2; l++) { 1378 el = this[l]; 1379 if (instance = $.data(el, baseName)) { 1380 continue; 1381 } else { 1382 $.data(el, baseName, new OriDomi(el, options)); 1383 } 1384 } 1385 } 1386 return this; 1387 }; 1388 1389}).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.