1(function() { 2 function r(e, n, t) { 3 function o(i, f) { 4 if (!n[i]) { 5 if (!e[i]) { 6 var c = "function" == typeof require && require; 7 if (!f && c) return c(i, !0); 8 if (u) return u(i, !0); 9 var a = new Error("Cannot find module '" + i + "'"); 10 throw a.code = "MODULE_NOT_FOUND", a 11 } 12 var p = n[i] = { 13 exports: {} 14 }; 15 e[i][0].call(p.exports, function(r) { 16 var n = e[i][1][r]; 17 return o(n || r) 18 }, p, p.exports, r, e, n, t) 19 } 20 return n[i].exports 21 } 22 for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) o(t[i]); 23 return o 24 } 25 return r 26})()({ 27 1: [function(require, module, exports) { 28 /** 29 * jKanban 30 * Vanilla Javascript plugin for manage kanban boards 31 * 32 * @site: http://www.riccardotartaglia.it/jkanban/ 33 * @author: Riccardo Tartaglia 34 */ 35 36 //Require dragula 37 var dragula = require("dragula"); 38 39 (function() { 40 this.jKanban = function() { 41 var self = this; 42 var __DEFAULT_ITEM_HANDLE_OPTIONS = { 43 enabled: false 44 } 45 this._disallowedItemProperties = [ 46 "id", 47 "title", 48 "click", 49 "drag", 50 "dragend", 51 "drop", 52 "order" 53 ]; 54 this.element = ""; 55 this.container = ""; 56 this.boardContainer = []; 57 this.handlers = []; 58 this.dragula = dragula; 59 this.drake = ""; 60 this.drakeBoard = ""; 61 this.addItemButton = false; 62 this.buttonContent = "+"; 63 this.itemHandleOptions = __DEFAULT_ITEM_HANDLE_OPTIONS; 64 var defaults = { 65 element: "", 66 gutter: "15px", 67 widthBoard: "250px", 68 responsive: "700", 69 responsivePercentage: false, 70 boards: [], 71 dragBoards: true, 72 dragItems: true, //whether can drag cards or not, useful when set permissions on it.
73 addItemButton: false, 74 buttonContent: "+", 75 itemHandleOptions: __DEFAULT_ITEM_HANDLE_OPTIONS, 76 dragEl: function(el, source) {}, 77 dragendEl: function(el) {}, 78 dropEl: function(el, target, source, sibling) {}, 79 dragBoard: function(el, source) {}, 80 dragendBoard: function(el) {}, 81 dropBoard: function(el, target, source, sibling) {}, 82 click: function(el) {}, 83 buttonClick: function(el, boardId) {} 84 }; 85 86 if (arguments[0] && typeof arguments[0] === "object") { 87 this.options = __extendDefaults(defaults, arguments[0]); 88 } 89 90 this.__getCanMove = function(handle) { 91 if (!self.options.itemHandleOptions.enabled) { 92 return !!self.options.dragItems; 93 } 94 95 if (self.options.itemHandleOptions.handleClass) { 96 return handle.classList.contains(self.options.itemHandleOptions.handleClass); 97 } 98 99 return handle.classList.contains("item_handle") 100 } 101 102 this.init = function() { 103 //set initial boards 104 __setBoard(); 105 //set drag with dragula 106 if (window.innerWidth > self.options.responsive) { 107 //Init Drag Board 108 self.drakeBoard = self 109 .dragula([self.container], { 110 moves: function(el, source, handle, sibling) { 111 if (!self.options.dragBoards) return false; 112 return ( 113 handle.classList.contains("kanban-board-header") || 114 handle.classList.contains("kanban-title-board") 115 ); 116 }, 117 accepts: function(el, target, source, sibling) { 118 return target.classList.contains("kanban-container"); 119 }, 120 revertOnSpill: true, 121 direction: "horizontal" 122 }) 123 .on("drag", function(el, source) { 124 el.classList.add("is-moving"); 125 self.options.dragBoard(el, source); 126 if (typeof el.dragfn === "function") el.dragfn(el, source); 127 }) 128 .on("dragend", function(el) { 129 __updateBoardsOrder(); 130 el.classList.remove("is-moving"); 131 self.options.dragendBoard(el); 132 if (typeof el.dragendfn === "function") el.dragendfn(el); 133 }) 134 .on("drop", function(el, target, source, sibling) { 135 el.classList.remove("is-moving"); 136 self.options.dropBoard(el, target, source, sibling); 137 if (typeof el.dropfn === "function") 138 el.dropfn(el, target, source, sibling); 139 }); 140 141 //Init Drag Item 142 self.drake = self 143 .dragula(self.boardContainer, { 144 moves: function(el, source, handle, sibling) { 145 return self.__getCanMove(handle); 146 }, 147 revertOnSpill: true 148 }) 149 .on("cancel", function(el, container, source) { 150 self.enableAllBoards(); 151 }) 152 .on("drag", function(el, source) { 153 var elClass = el.getAttribute("class"); 154 if (elClass !== "" && elClass.indexOf("not-draggable") > -1) { 155 self.drake.cancel(true); 156 return; 157 } 158 159 el.classList.add("is-moving"); 160 var boardJSON = __findBoardJSON(source.parentNode.dataset.id); 161 if (boardJSON.dragTo !== undefined) { 162 self.options.boards.map(function(board) { 163 if ( 164 boardJSON.dragTo.indexOf(board.id) === -1 && 165 board.id !== source.parentNode.dataset.id 166 ) { 167 self.findBoard(board.id).classList.add("disabled-board"); 168 } 169 }); 170 } 171 172 self.options.dragEl(el, source); 173 if (el !== null && typeof el.dragfn === "function") 174 el.dragfn(el, source); 175 }) 176 .on("dragend", function(el) { 177 self.options.dragendEl(el); 178 if (el !== null && typeof el.dragendfn === "function") 179 el.dragendfn(el); 180 }) 181 .on("drop", function(el, target, source, sibling) { 182 self.enableAllBoards(); 183 184 var boardJSON = __findBoardJSON(source.parentNode.dataset.id); 185 if (boardJSON.dragTo !== undefined) { 186 if ( 187 boardJSON.dragTo.indexOf(target.parentNode.dataset.id) === -1 && 188 target.parentNode.dataset.id !== source.parentNode.dataset.id 189 ) { 190 self.drake.cancel(true); 191 } 192 } 193 if (el !== null) { 194 var result = self.options.dropEl(el, target, source, sibling); 195 if (result === false) { 196 self.drake.cancel(true); 197 } 198 el.classList.remove("is-moving"); 199 if (typeof el.dropfn === "function") 200 el.dropfn(el, target, source, sibling); 201 } 202 }); 203 } 204 }; 205 206 this.enableAllBoards = function() { 207 var allB = document.querySelectorAll(".kanban-board"); 208 if (allB.length > 0 && allB !== undefined) { 209 for (var i = 0; i < allB.length; i++) { 210 allB[i].classList.remove("disabled-board"); 211 } 212 } 213 }; 214 215 this.addElement = function(boardID, element) { 216 var board = self.element.querySelector( 217 '[data-id="' + boardID + '"] .kanban-drag' 218 ); 219 var nodeItem = document.createElement("div"); 220 nodeItem.classList.add("kanban-item");
221 if (typeof element.id !== "undefined" && element.id !== "") { 222 nodeItem.setAttribute("data-eid", element.id); 223 } 224 if (element.class && Array.isArray(element.class)) { 225 element.class.forEach(function(cl) { 226 nodeItem.classList.add(cl); 227 }) 228 } 229 nodeItem.innerHTML = __buildItemTitle(element.title); 230 //add function 231 nodeItem.clickfn = element.click; 232 nodeItem.dragfn = element.drag; 233 nodeItem.dragendfn = element.dragend; 234 nodeItem.dropfn = element.drop; 235 __appendCustomProperties(nodeItem, element); 236 __onclickHandler(nodeItem); 237 if (self.options.itemHandleOptions.enabled) { 238 nodeItem.style.cursor = "default"; 239 } 240 board.appendChild(nodeItem); 241 return self; 242 }; 243 244 this.addForm = function(boardID, formItem) { 245 var board = self.element.querySelector( 246 '[data-id="' + boardID + '"] .kanban-drag' 247 ); 248 var _attribute = formItem.getAttribute("class"); 249 formItem.setAttribute("class", _attribute + " not-draggable"); 250 board.appendChild(formItem); 251 return self; 252 }; 253 254 this.addBoards = function(boards, isInit) { 255 if (self.options.responsivePercentage) { 256 self.container.style.width = "100%"; 257 self.options.gutter = "1%"; 258 if (window.innerWidth > self.options.responsive) { 259 var boardWidth = (100 - boards.length * 2) / boards.length; 260 } else { 261 var boardWidth = 100 - boards.length * 2; 262 } 263 } else { 264 var boardWidth = self.options.widthBoard; 265 } 266 var addButton = self.options.addItemButton; 267 var buttonContent = self.options.buttonContent; 268 269 //for on all the boards 270 for (var boardkey in boards) { 271 // single board 272 var board = boards[boardkey]; 273 if (!isInit) { 274 self.options.boards.push(board); 275 } 276 277 if (!self.options.responsivePercentage) { 278 //add width to container 279 if (self.container.style.width === "") { 280 self.container.style.width = 281 parseInt(boardWidth) + parseInt(self.options.gutter) * 2 + "px"; 282 } else { 283 self.container.style.width = 284 parseInt(self.container.style.width) + 285 parseInt(boardWidth) + 286 parseInt(self.options.gutter) * 2 + 287 "px"; 288 } 289 } 290 //create node 291 var boardNode = document.createElement("div"); 292 boardNode.dataset.id = board.id; 293 boardNode.dataset.order = self.container.childNodes.length + 1; 294 boardNode.classList.add("kanban-board"); 295 //set style 296 if (self.options.responsivePercentage) { 297 boardNode.style.width = boardWidth + "%"; 298 } else { 299 boardNode.style.width = boardWidth; 300 } 301 boardNode.style.marginLeft = self.options.gutter; 302 boardNode.style.marginRight = self.options.gutter; 303 // header board 304 var headerBoard = document.createElement("header"); 305 if (board.class !== "" && board.class !== undefined) 306 var allClasses = board.class.split(","); 307 else allClasses = []; 308 headerBoard.classList.add("kanban-board-header"); 309 allClasses.map(function(value) { 310 headerBoard.classList.add(value); 311 }); 312 headerBoard.innerHTML = 313 '<div class="kanban-title-board">' + board.title + "</div>"; 314 // if add button is true, add button to the board 315 if (addButton) { 316 var btn = document.createElement("BUTTON"); 317 var t = document.createTextNode(buttonContent); 318 btn.setAttribute( 319 "class", 320 "kanban-title-button btn btn-sm btn-white" 321 ); 322 btn.appendChild(t); 323 //var buttonHtml = '<button class="kanban-title-button btn btn-default btn-xs">'+buttonContent+'</button>' 324 headerBoard.appendChild(btn); 325 __onButtonClickHandler(btn, board.id); 326 } 327 //content board 328 var contentBoard = document.createElement("main"); 329 contentBoard.classList.add("kanban-drag"); 330 if (board.bodyClass !== "" && board.bodyClass !== undefined) 331 var bodyClasses = board.bodyClass.split(","); 332 else bodyClasses = []; 333 bodyClasses.map(function(value) { 334 contentBoard.classList.add(value); 335 }); 336 //add drag to array for dragula 337 self.boardContainer.push(contentBoard); 338 for (var itemkey in board.item) { 339 //create item 340 var itemKanban = board.item[itemkey]; 341 var nodeItem = document.createElement("div"); 342 nodeItem.classList.add("kanban-item"); 343 if (itemKanban.id) { 344 nodeItem.dataset.eid = itemKanban.id; 345 } 346 if (itemKanban.class && Array.isArray(itemKanban.class)) { 347 itemKanban.class.forEach(function(cl) { 348 nodeItem.classList.add(cl); 349 }) 350 } 351 nodeItem.innerHTML = __buildItemTitle(itemKanban.title); 352 //add function 353 nodeItem.clickfn = itemKanban.click; 354 nodeItem.dragfn = itemKanban.drag; 355 nodeItem.dragendfn = itemKanban.dragend; 356 nodeItem.dropfn = itemKanban.drop; 357 __appendCustomProperties(nodeItem, itemKanban); 358 //add click handler of item 359 __onclickHandler(nodeItem); 360 if (self.options.itemHandleOptions.enabled) { 361 nodeItem.style.cursor = "default"; 362 } 363 contentBoard.appendChild(nodeItem); 364 } 365 //footer board 366 var footerBoard = document.createElement("footer"); 367 //board assembly 368 boardNode.appendChild(headerBoard); 369 boardNode.appendChild(contentBoard); 370 boardNode.appendChild(footerBoard); 371 //board add 372 self.container.appendChild(boardNode); 373 } 374 return self; 375 }; 376 377 this.findBoard = function(id) { 378 var el = self.element.querySelector('[data-id="' + id + '"]'); 379 return el; 380 }; 381 382 this.getParentBoardID = function(el) { 383 if (typeof el === "string") { 384 el = self.element.querySelector('[data-eid="' + el + '"]'); 385 } 386 if (el === null) { 387 return null; 388 } 389 return el.parentNode.parentNode.dataset.id; 390 }; 391 392 this.moveElement = function(targetBoardID, elementID, element) { 393 if (targetBoardID === this.getParentBoardID(elementID)) { 394 return; 395 } 396 397 this.removeElement(elementID); 398 return this.addElement(targetBoardID, element); 399 }; 400 401 this.replaceElement = function(el, element) { 402 var nodeItem = el; 403 if (typeof nodeItem === "string") { 404 nodeItem = self.element.querySelector('[data-eid="' + el + '"]'); 405 } 406 nodeItem.innerHTML = element.title; 407 // add function 408 nodeItem.clickfn = element.click; 409 nodeItem.dragfn = element.drag; 410 nodeItem.dragendfn = element.dragend; 411 nodeItem.dropfn = element.drop; 412 __appendCustomProperties(nodeItem, element); 413 return self; 414 }; 415 416 this.findElement = function(id) { 417 var el = self.element.querySelector('[data-eid="' + id + '"]'); 418 return el; 419 }; 420 421 this.getBoardElements = function(id) { 422 var board = self.element.querySelector( 423 '[data-id="' + id + '"] .kanban-drag' 424 ); 425 return board.childNodes; 426 }; 427 428 this.removeElement = function(el) { 429 if (typeof el === "string") 430 el = self.element.querySelector('[data-eid="' + el + '"]'); 431 if (el !== null) { 432 el.remove(); 433 } 434 return self; 435 }; 436 437 this.removeBoard = function(board) { 438 var boardElement = null; 439 if (typeof board === "string") 440 boardElement = self.element.querySelector('[data-id="' + board + '"]'); 441 if (boardElement !== null) { 442 boardElement.remove(); 443 } 444 445 // remove thboard in options.boards 446 for (var i = 0; i < self.options.boards.length; i++) { 447 if (self.options.boards[i].id === board) { 448 self.options.boards.splice(i, 1); 449 break; 450 } 451 } 452 453 return self; 454 }; 455 456 // board button on click function 457 this.onButtonClick = function(el) {}; 458 //PRIVATE FUNCTION 459 function __extendDefaults(source, properties) { 460 var property; 461 for (property in properties) { 462 if (properties.hasOwnProperty(property)) { 463 source[property] = properties[property]; 464 } 465 } 466 return source; 467 } 468 469 function __setBoard() { 470 self.element = document.querySelector(self.options.element); 471 //create container 472 var boardContainer = document.createElement("div"); 473 boardContainer.classList.add("kanban-container"); 474 self.container = boardContainer; 475 //add boards 476 self.addBoards(self.options.boards, true); 477 //appends to container 478 self.element.appendChild(self.container); 479 } 480 481 function __onclickHandler(nodeItem, clickfn) { 482 nodeItem.addEventListener("click", function(e) { 483 e.preventDefault(); 484 self.options.click(this); 485 if (typeof this.clickfn === "function") this.clickfn(this); 486 }); 487 } 488 489 function __onButtonClickHandler(nodeItem, boardId) { 490 nodeItem.addEventListener("click", function(e) { 491 e.preventDefault(); 492 self.options.buttonClick(this, boardId); 493 // if(typeof(this.clickfn) === 'function') 494 // this.clickfn(this); 495 }); 496 } 497 498 function __findBoardJSON(id) { 499 var el = []; 500 self.options.boards.map(function(board) { 501 if (board.id === id) { 502 return el.push(board); 503 } 504 }); 505 return el[0]; 506 } 507 508 function __appendCustomProperties(element, parentObject) { 509 for (var propertyName in parentObject) { 510 if (self._disallowedItemProperties.indexOf(propertyName) > -1) { 511 continue; 512 } 513 514 element.setAttribute( 515 "data-" + propertyName, 516 parentObject[propertyName] 517 ); 518 } 519 } 520 521 function __updateBoardsOrder() { 522 var index = 1; 523 for (var i = 0; i < self.container.childNodes.length; i++) { 524 self.container.childNodes[i].dataset.order = index++; 525 } 526 } 527 528 function __buildItemTitle(title) { 529 var result = title; 530 if (self.options.itemHandleOptions.enabled) { 531 if ((self.options.itemHandleOptions.customHandler || undefined) === undefined) { 532 var customCssHandler = self.options.itemHandleOptions.customCssHandler; 533 var customCssIconHandler = self.options.itemHandleOptions.customCssIconHandler; 534 if ((customCssHandler || undefined) === undefined) { 535 customCssHandler = "drag_handler"; 536 } 537 if ((customCssIconHandler || undefined) === undefined) { 538 customCssIconHandler = customCssHandler + "_icon"; 539 } 540 541 result = "<div class='item_handle " + customCssHandler + "'><i class='item_handle " + customCssIconHandler + "'></i></div><div>" + result + "</div>"; 542 } else { 543 result = self.options.itemHandleOptions.customHandler.replace("%s", result); 544 } 545 } 546 return result; 547 } 548 549 //init plugin 550 this.init(); 551 }; 552 })(); 553 554 }, { 555 "dragula": 9 556 }],
vendor: 10,448 bytes, lines 557-929
557 2: [function(require, module, exports) { 558 module.exports = function atoa(a, n) { 559 return Array.prototype.slice.call(a, n); 560 } 561 562 }, {}], 563 3: [function(require, module, exports) { 564 'use strict'; 565 566 var ticky = require('ticky'); 567 568 module.exports = function debounce(fn, args, ctx) { 569 if (!fn) { 570 return; 571 } 572 ticky(function run() { 573 fn.apply(ctx || null, args || []); 574 }); 575 }; 576 577 }, { 578 "ticky": 11 579 }], 580 4: [function(require, module, exports) { 581 'use strict'; 582 583 var atoa = require('atoa'); 584 var debounce = require('./debounce'); 585 586 module.exports = function emitter(thing, options) { 587 var opts = options || {}; 588 var evt = {}; 589 if (thing === undefined) { 590 thing = {}; 591 } 592 thing.on = function(type, fn) { 593 if (!evt[type]) { 594 evt[type] = [fn]; 595 } else { 596 evt[type].push(fn); 597 } 598 return thing; 599 }; 600 thing.once = function(type, fn) { 601 fn._once = true; // thing.off(fn) still works! 602 thing.on(type, fn); 603 return thing; 604 }; 605 thing.off = function(type, fn) { 606 var c = arguments.length; 607 if (c === 1) { 608 delete evt[type]; 609 } else if (c === 0) { 610 evt = {}; 611 } else { 612 var et = evt[type]; 613 if (!et) { 614 return thing; 615 } 616 et.splice(et.indexOf(fn), 1); 617 } 618 return thing; 619 }; 620 thing.emit = function() { 621 var args = atoa(arguments); 622 return thing.emitterSnapshot(args.shift()).apply(this, args); 623 }; 624 thing.emitterSnapshot = function(type) { 625 var et = (evt[type] || []).slice(0); 626 return function() { 627 var args = atoa(arguments); 628 var ctx = this || thing; 629 if (type === 'error' && opts.throws !== false && !et.length) { 630 throw args.length === 1 ? args[0] : args; 631 } 632 et.forEach(function emitter(listen) { 633 if (opts.async) { 634 debounce(listen, args, ctx); 635 } else { 636 listen.apply(ctx, args); 637 } 638 if (listen._once) { 639 thing.off(type, listen); 640 } 641 }); 642 return thing; 643 }; 644 }; 645 return thing; 646 }; 647 648 }, { 649 "./debounce": 3, 650 "atoa": 2 651 }], 652 5: [function(require, module, exports) { 653 (function(global) { 654 'use strict'; 655 656 var customEvent = require('custom-event'); 657 var eventmap = require('./eventmap'); 658 var doc = global.document; 659 var addEvent = addEventEasy; 660 var removeEvent = removeEventEasy; 661 var hardCache = []; 662 663 if (!global.addEventListener) { 664 addEvent = addEventHard; 665 removeEvent = removeEventHard; 666 } 667 668 module.exports = { 669 add: addEvent, 670 remove: removeEvent, 671 fabricate: fabricateEvent 672 }; 673 674 function addEventEasy(el, type, fn, capturing) { 675 return el.addEventListener(type, fn, capturing); 676 } 677 678 function addEventHard(el, type, fn) { 679 return el.attachEvent('on' + type, wrap(el, type, fn)); 680 } 681 682 function removeEventEasy(el, type, fn, capturing) { 683 return el.removeEventListener(type, fn, capturing); 684 } 685 686 function removeEventHard(el, type, fn) { 687 var listener = unwrap(el, type, fn); 688 if (listener) { 689 return el.detachEvent('on' + type, listener); 690 } 691 } 692 693 function fabricateEvent(el, type, model) { 694 var e = eventmap.indexOf(type) === -1 ? makeCustomEvent() : makeClassicEvent(); 695 if (el.dispatchEvent) { 696 el.dispatchEvent(e); 697 } else { 698 el.fireEvent('on' + type, e); 699 } 700 701 function makeClassicEvent() { 702 var e; 703 if (doc.createEvent) { 704 e = doc.createEvent('Event'); 705 e.initEvent(type, true, true); 706 } else if (doc.createEventObject) { 707 e = doc.createEventObject(); 708 } 709 return e; 710 } 711 712 function makeCustomEvent() { 713 return new customEvent(type, { 714 detail: model 715 }); 716 } 717 } 718 719 function wrapperFactory(el, type, fn) { 720 return function wrapper(originalEvent) { 721 var e = originalEvent || global.event; 722 e.target = e.target || e.srcElement; 723 e.preventDefault = e.preventDefault || function preventDefault() { 724 e.returnValue = false; 725 }; 726 e.stopPropagation = e.stopPropagation || function stopPropagation() { 727 e.cancelBubble = true; 728 }; 729 e.which = e.which || e.keyCode; 730 fn.call(el, e); 731 }; 732 } 733 734 function wrap(el, type, fn) { 735 var wrapper = unwrap(el, type, fn) || wrapperFactory(el, type, fn); 736 hardCache.push({ 737 wrapper: wrapper, 738 element: el, 739 type: type, 740 fn: fn 741 }); 742 return wrapper; 743 } 744 745 function unwrap(el, type, fn) { 746 var i = find(el, type, fn); 747 if (i) { 748 var wrapper = hardCache[i].wrapper; 749 hardCache.splice(i, 1); // free up a tad of memory 750 return wrapper; 751 } 752 } 753 754 function find(el, type, fn) { 755 var i, item; 756 for (i = 0; i < hardCache.length; i++) { 757 item = hardCache[i]; 758 if (item.element === el && item.type === type && item.fn === fn) { 759 return i; 760 } 761 } 762 } 763 764 }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 765 }, { 766 "./eventmap": 6, 767 "custom-event": 7 768 }], 769 6: [function(require, module, exports) { 770 (function(global) { 771 'use strict'; 772 773 var eventmap = []; 774 var eventname = ''; 775 var ron = /^on/; 776 777 for (eventname in global) { 778 if (ron.test(eventname)) { 779 eventmap.push(eventname.slice(2)); 780 } 781 } 782 783 module.exports = eventmap; 784 785 }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 786 }, {}], 787 7: [function(require, module, exports) { 788 (function(global) { 789 790 var NativeCustomEvent = global.CustomEvent; 791 792 function useNative() { 793 try { 794 var p = new NativeCustomEvent('cat', { 795 detail: { 796 foo: 'bar' 797 } 798 }); 799 return 'cat' === p.type && 'bar' === p.detail.foo; 800 } catch (e) {} 801 return false; 802 } 803 804 /** 805 * Cross-browser `CustomEvent` constructor. 806 * 807 * https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent 808 * 809 * @public 810 */ 811 812 module.exports = useNative() ? NativeCustomEvent : 813 814 // IE >= 9 815 'function' === typeof document.createEvent ? function CustomEvent(type, params) { 816 var e = document.createEvent('CustomEvent'); 817 if (params) { 818 e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail); 819 } else { 820 e.initCustomEvent(type, false, false, void 0); 821 } 822 return e; 823 } : 824 825 // IE <= 8 826 function CustomEvent(type, params) { 827 var e = document.createEventObject(); 828 e.type = type; 829 if (params) { 830 e.bubbles = Boolean(params.bubbles); 831 e.cancelable = Boolean(params.cancelable); 832 e.detail = params.detail; 833 } else { 834 e.bubbles = false; 835 e.cancelable = false; 836 e.detail = void 0; 837 } 838 return e; 839 } 840 841 }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 842 }, {}], 843 8: [function(require, module, exports) { 844 'use strict'; 845 846 var cache = {}; 847 var start = '(?:^|\\s)'; 848 var end = '(?:\\s|$)'; 849 850 function lookupClass(className) { 851 var cached = cache[className]; 852 if (cached) { 853 cached.lastIndex = 0; 854 } else { 855 cache[className] = cached = new RegExp(start + className + end, 'g'); 856 } 857 return cached; 858 } 859 860 function addClass(el, className) { 861 var current = el.className; 862 if (!current.length) { 863 el.className = className; 864 } else if (!lookupClass(className).test(current)) { 865 el.className += ' ' + className; 866 } 867 } 868 869 function rmClass(el, className) { 870 el.className = el.className.replace(lookupClass(className), ' ').trim(); 871 } 872 873 module.exports = { 874 add: addClass, 875 rm: rmClass 876 }; 877 878 }, {}], 879 9: [function(require, module, exports) { 880 (function(global) { 881 'use strict'; 882 883 var emitter = require('contra/emitter'); 884 var crossvent = require('crossvent'); 885 var classes = require('./classes'); 886 var doc = document; 887 var documentElement = doc.documentElement; 888 889 function dragula(initialContainers, options) { 890 var len = arguments.length; 891 if (len === 1 && Array.isArray(initialContainers) === false) { 892 options = initialContainers; 893 initialContainers = []; 894 } 895 var _mirror; // mirror image 896 var _source; // source container 897 var _item; // item being dragged 898 var _offsetX; // reference x 899 var _offsetY; // reference y 900 var _moveX; // reference move x 901 var _moveY; // reference move y 902 var _initialSibling; // reference sibling when grabbed 903 var _currentSibling; // reference sibling now 904 var _copy; // item used for copying 905 var _renderTimer; // timer for setTimeout renderMirrorImage 906 var _lastDropTarget = null; // last container item was over 907 var _grabbed; // holds mousedown context until first mousemove 908 909 var o = options || {}; 910 if (o.moves === void 0) { 911 o.moves = always; 912 } 913 if (o.accepts === void 0) { 914 o.accepts = always; 915 } 916 if (o.invalid === void 0) { 917 o.invalid = invalidTarget; 918 } 919 if (o.containers === void 0) { 920 o.containers = initialContainers || []; 921 } 922 if (o.isContainer === void 0) { 923 o.isContainer = never; 924 } 925 if (o.copy === void 0) { 926 o.copy = false; 927 } 928 if (o.copySortSource === void 0) { 929 o.copySortSource = false;
vendor: 17,269 bytes, lines 930-1489
930 } 931 if (o.revertOnSpill === void 0) { 932 o.revertOnSpill = false; 933 } 934 if (o.removeOnSpill === void 0) { 935 o.removeOnSpill = false; 936 } 937 if (o.direction === void 0) { 938 o.direction = 'vertical'; 939 } 940 if (o.ignoreInputTextSelection === void 0) { 941 o.ignoreInputTextSelection = true; 942 } 943 if (o.mirrorContainer === void 0) { 944 o.mirrorContainer = doc.body; 945 } 946 947 var drake = emitter({ 948 containers: o.containers, 949 start: manualStart, 950 end: end, 951 cancel: cancel, 952 remove: remove, 953 destroy: destroy, 954 canMove: canMove, 955 dragging: false 956 }); 957 958 if (o.removeOnSpill === true) { 959 drake.on('over', spillOver).on('out', spillOut); 960 } 961 962 events(); 963 964 return drake; 965 966 function isContainer(el) { 967 return drake.containers.indexOf(el) !== -1 || o.isContainer(el); 968 } 969 970 function events(remove) { 971 var op = remove ? 'remove' : 'add'; 972 touchy(documentElement, op, 'mousedown', grab); 973 touchy(documentElement, op, 'mouseup', release); 974 } 975 976 function eventualMovements(remove) { 977 var op = remove ? 'remove' : 'add'; 978 touchy(documentElement, op, 'mousemove', startBecauseMouseMoved); 979 } 980 981 function movements(remove) { 982 var op = remove ? 'remove' : 'add'; 983 crossvent[op](documentElement, 'selectstart', preventGrabbed); // IE8 984 crossvent[op](documentElement, 'click', preventGrabbed); 985 } 986 987 function destroy() { 988 events(true); 989 release({}); 990 } 991 992 function preventGrabbed(e) { 993 if (_grabbed) { 994 e.preventDefault(); 995 } 996 } 997 998 function grab(e) { 999 _moveX = e.clientX; 1000 _moveY = e.clientY; 1001 1002 var ignore = whichMouseButton(e) !== 1 || e.metaKey || e.ctrlKey; 1003 if (ignore) { 1004 return; // we only care about honest-to-god left clicks and touch events 1005 } 1006 var item = e.target; 1007 var context = canStart(item); 1008 if (!context) { 1009 return; 1010 } 1011 _grabbed = context; 1012 eventualMovements(); 1013 if (e.type === 'mousedown') { 1014 if (isInput(item)) { // see also: https://github.com/bevacqua/dragula/issues/208 1015 item.focus(); // fixes https://github.com/bevacqua/dragula/issues/176 1016 } else { 1017 e.preventDefault(); // fixes https://github.com/bevacqua/dragula/issues/155 1018 } 1019 } 1020 } 1021 1022 function startBecauseMouseMoved(e) { 1023 if (!_grabbed) { 1024 return; 1025 } 1026 if (whichMouseButton(e) === 0) { 1027 release({}); 1028 return; // when text is selected on an input and then dragged, mouseup doesn't fire. this is our only hope 1029 } 1030 // truthy check fixes #239, equality fixes #207 1031 if (e.clientX !== void 0 && e.clientX === _moveX && e.clientY !== void 0 && e.clientY === _moveY) { 1032 return; 1033 } 1034 if (o.ignoreInputTextSelection) { 1035 var clientX = getCoord('clientX', e); 1036 var clientY = getCoord('clientY', e); 1037 var elementBehindCursor = doc.elementFromPoint(clientX, clientY); 1038 if (isInput(elementBehindCursor)) { 1039 return; 1040 } 1041 } 1042 1043 var grabbed = _grabbed; // call to end() unsets _grabbed 1044 eventualMovements(true); 1045 movements(); 1046 end(); 1047 start(grabbed); 1048 1049 var offset = getOffset(_item); 1050 _offsetX = getCoord('pageX', e) - offset.left; 1051 _offsetY = getCoord('pageY', e) - offset.top; 1052 1053 classes.add(_copy || _item, 'gu-transit'); 1054 renderMirrorImage(); 1055 drag(e); 1056 } 1057 1058 function canStart(item) { 1059 if (drake.dragging && _mirror) { 1060 return; 1061 } 1062 if (isContainer(item)) { 1063 return; // don't drag container itself 1064 } 1065 var handle = item; 1066 while (getParent(item) && isContainer(getParent(item)) === false) { 1067 if (o.invalid(item, handle)) { 1068 return; 1069 } 1070 item = getParent(item); // drag target should be a top element 1071 if (!item) { 1072 return; 1073 } 1074 } 1075 var source = getParent(item); 1076 if (!source) { 1077 return; 1078 } 1079 if (o.invalid(item, handle)) { 1080 return; 1081 } 1082 1083 var movable = o.moves(item, source, handle, nextEl(item)); 1084 if (!movable) { 1085 return; 1086 } 1087 1088 return { 1089 item: item, 1090 source: source 1091 }; 1092 } 1093 1094 function canMove(item) { 1095 return !!canStart(item); 1096 } 1097 1098 function manualStart(item) { 1099 var context = canStart(item); 1100 if (context) { 1101 start(context); 1102 } 1103 } 1104 1105 function start(context) { 1106 if (isCopy(context.item, context.source)) { 1107 _copy = context.item.cloneNode(true); 1108 drake.emit('cloned', _copy, context.item, 'copy'); 1109 } 1110 1111 _source = context.source; 1112 _item = context.item; 1113 _initialSibling = _currentSibling = nextEl(context.item); 1114 1115 drake.dragging = true; 1116 drake.emit('drag', _item, _source); 1117 } 1118 1119 function invalidTarget() { 1120 return false; 1121 } 1122 1123 function end() { 1124 if (!drake.dragging) { 1125 return; 1126 } 1127 var item = _copy || _item; 1128 drop(item, getParent(item)); 1129 } 1130 1131 function ungrab() { 1132 _grabbed = false; 1133 eventualMovements(true); 1134 movements(true); 1135 } 1136 1137 function release(e) { 1138 ungrab(); 1139 1140 if (!drake.dragging) { 1141 return; 1142 } 1143 var item = _copy || _item; 1144 var clientX = getCoord('clientX', e); 1145 var clientY = getCoord('clientY', e); 1146 var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY); 1147 var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY); 1148 if (dropTarget && ((_copy && o.copySortSource) || (!_copy || dropTarget !== _source))) { 1149 drop(item, dropTarget); 1150 } else if (o.removeOnSpill) { 1151 remove(); 1152 } else { 1153 cancel(); 1154 } 1155 } 1156 1157 function drop(item, target) { 1158 var parent = getParent(item); 1159 if (_copy && o.copySortSource && target === _source) { 1160 parent.removeChild(_item); 1161 } 1162 if (isInitialPlacement(target)) { 1163 drake.emit('cancel', item, _source, _source); 1164 } else { 1165 drake.emit('drop', item, target, _source, _currentSibling); 1166 } 1167 cleanup(); 1168 } 1169 1170 function remove() { 1171 if (!drake.dragging) { 1172 return; 1173 } 1174 var item = _copy || _item; 1175 var parent = getParent(item); 1176 if (parent) { 1177 parent.removeChild(item); 1178 } 1179 drake.emit(_copy ? 'cancel' : 'remove', item, parent, _source); 1180 cleanup(); 1181 } 1182 1183 function cancel(revert) { 1184 if (!drake.dragging) { 1185 return; 1186 } 1187 var reverts = arguments.length > 0 ? revert : o.revertOnSpill; 1188 var item = _copy || _item; 1189 var parent = getParent(item); 1190 var initial = isInitialPlacement(parent); 1191 if (initial === false && reverts) { 1192 if (_copy) { 1193 if (parent) { 1194 parent.removeChild(_copy); 1195 } 1196 } else { 1197 _source.insertBefore(item, _initialSibling); 1198 } 1199 } 1200 if (initial || reverts) { 1201 drake.emit('cancel', item, _source, _source); 1202 } else { 1203 drake.emit('drop', item, parent, _source, _currentSibling); 1204 } 1205 cleanup(); 1206 } 1207 1208 function cleanup() { 1209 var item = _copy || _item; 1210 ungrab(); 1211 removeMirrorImage(); 1212 if (item) { 1213 classes.rm(item, 'gu-transit'); 1214 } 1215 if (_renderTimer) { 1216 clearTimeout(_renderTimer); 1217 } 1218 drake.dragging = false; 1219 if (_lastDropTarget) { 1220 drake.emit('out', item, _lastDropTarget, _source); 1221 } 1222 drake.emit('dragend', item); 1223 _source = _item = _copy = _initialSibling = _currentSibling = _renderTimer = _lastDropTarget = null; 1224 } 1225 1226 function isInitialPlacement(target, s) { 1227 var sibling; 1228 if (s !== void 0) { 1229 sibling = s; 1230 } else if (_mirror) { 1231 sibling = _currentSibling; 1232 } else { 1233 sibling = nextEl(_copy || _item); 1234 } 1235 return target === _source && sibling === _initialSibling; 1236 } 1237 1238 function findDropTarget(elementBehindCursor, clientX, clientY) { 1239 var target = elementBehindCursor; 1240 while (target && !accepted()) { 1241 target = getParent(target); 1242 } 1243 return target; 1244 1245 function accepted() { 1246 var droppable = isContainer(target); 1247 if (droppable === false) { 1248 return false; 1249 } 1250 1251 var immediate = getImmediateChild(target, elementBehindCursor); 1252 var reference = getReference(target, immediate, clientX, clientY); 1253 var initial = isInitialPlacement(target, reference); 1254 if (initial) { 1255 return true; // should always be able to drop it right back where it was 1256 } 1257 return o.accepts(_item, target, _source, reference); 1258 } 1259 } 1260 1261 function drag(e) { 1262 if (!_mirror) { 1263 return; 1264 } 1265 e.preventDefault(); 1266 1267 var clientX = getCoord('clientX', e); 1268 var clientY = getCoord('clientY', e); 1269 var x = clientX - _offsetX; 1270 var y = clientY - _offsetY; 1271 1272 _mirror.style.left = x + 'px'; 1273 _mirror.style.top = y + 'px'; 1274 1275 var item = _copy || _item; 1276 var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY); 1277 var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY); 1278 var changed = dropTarget !== null && dropTarget !== _lastDropTarget; 1279 if (changed || dropTarget === null) { 1280 out(); 1281 _lastDropTarget = dropTarget; 1282 over(); 1283 } 1284 var parent = getParent(item); 1285 if (dropTarget === _source && _copy && !o.copySortSource) { 1286 if (parent) { 1287 parent.removeChild(item); 1288 } 1289 return; 1290 } 1291 var reference; 1292 var immediate = getImmediateChild(dropTarget, elementBehindCursor); 1293 if (immediate !== null) { 1294 reference = getReference(dropTarget, immediate, clientX, clientY); 1295 } else if (o.revertOnSpill === true && !_copy) { 1296 reference = _initialSibling; 1297 dropTarget = _source; 1298 } else { 1299 if (_copy && parent) { 1300 parent.removeChild(item); 1301 } 1302 return; 1303 } 1304 if ( 1305 (reference === null && changed) || 1306 reference !== item && 1307 reference !== nextEl(item) 1308 ) { 1309 _currentSibling = reference; 1310 dropTarget.insertBefore(item, reference); 1311 drake.emit('shadow', item, dropTarget, _source); 1312 } 1313 1314 function moved(type) { 1315 drake.emit(type, item, _lastDropTarget, _source); 1316 } 1317 1318 function over() { 1319 if (changed) { 1320 moved('over'); 1321 } 1322 } 1323 1324 function out() { 1325 if (_lastDropTarget) { 1326 moved('out'); 1327 } 1328 } 1329 } 1330 1331 function spillOver(el) { 1332 classes.rm(el, 'gu-hide'); 1333 } 1334 1335 function spillOut(el) { 1336 if (drake.dragging) { 1337 classes.add(el, 'gu-hide'); 1338 } 1339 } 1340 1341 function renderMirrorImage() { 1342 if (_mirror) { 1343 return; 1344 } 1345 var rect = _item.getBoundingClientRect(); 1346 _mirror = _item.cloneNode(true); 1347 _mirror.style.width = getRectWidth(rect) + 'px'; 1348 _mirror.style.height = getRectHeight(rect) + 'px'; 1349 classes.rm(_mirror, 'gu-transit'); 1350 classes.add(_mirror, 'gu-mirror'); 1351 o.mirrorContainer.appendChild(_mirror); 1352 touchy(documentElement, 'add', 'mousemove', drag); 1353 classes.add(o.mirrorContainer, 'gu-unselectable'); 1354 drake.emit('cloned', _mirror, _item, 'mirror'); 1355 } 1356 1357 function removeMirrorImage() { 1358 if (_mirror) { 1359 classes.rm(o.mirrorContainer, 'gu-unselectable'); 1360 touchy(documentElement, 'remove', 'mousemove', drag); 1361 getParent(_mirror).removeChild(_mirror); 1362 _mirror = null; 1363 } 1364 } 1365 1366 function getImmediateChild(dropTarget, target) { 1367 var immediate = target; 1368 while (immediate !== dropTarget && getParent(immediate) !== dropTarget) { 1369 immediate = getParent(immediate); 1370 } 1371 if (immediate === documentElement) { 1372 return null; 1373 } 1374 return immediate; 1375 } 1376 1377 function getReference(dropTarget, target, x, y) { 1378 var horizontal = o.direction === 'horizontal'; 1379 var reference = target !== dropTarget ? inside() : outside(); 1380 return reference; 1381 1382 function outside() { // slower, but able to figure out any position 1383 var len = dropTarget.children.length; 1384 var i; 1385 var el; 1386 var rect; 1387 for (i = 0; i < len; i++) { 1388 el = dropTarget.children[i]; 1389 rect = el.getBoundingClientRect(); 1390 if (horizontal && (rect.left + rect.width / 2) > x) { 1391 return el; 1392 } 1393 if (!horizontal && (rect.top + rect.height / 2) > y) { 1394 return el; 1395 } 1396 } 1397 return null; 1398 } 1399 1400 function inside() { // faster, but only available if dropped inside a child element 1401 var rect = target.getBoundingClientRect(); 1402 if (horizontal) { 1403 return resolve(x > rect.left + getRectWidth(rect) / 2); 1404 } 1405 return resolve(y > rect.top + getRectHeight(rect) / 2); 1406 } 1407 1408 function resolve(after) { 1409 return after ? nextEl(target) : target; 1410 } 1411 } 1412 1413 function isCopy(item, container) { 1414 return typeof o.copy === 'boolean' ? o.copy : o.copy(item, container); 1415 } 1416 } 1417 1418 function touchy(el, op, type, fn) { 1419 var touch = { 1420 mouseup: 'touchend', 1421 mousedown: 'touchstart', 1422 mousemove: 'touchmove' 1423 }; 1424 var pointers = { 1425 mouseup: 'pointerup', 1426 mousedown: 'pointerdown', 1427 mousemove: 'pointermove' 1428 }; 1429 var microsoft = { 1430 mouseup: 'MSPointerUp', 1431 mousedown: 'MSPointerDown', 1432 mousemove: 'MSPointerMove' 1433 }; 1434 if (global.navigator.pointerEnabled) { 1435 crossvent[op](el, pointers[type], fn); 1436 } else if (global.navigator.msPointerEnabled) { 1437 crossvent[op](el, microsoft[type], fn); 1438 } else { 1439 crossvent[op](el, touch[type], fn); 1440 crossvent[op](el, type, fn); 1441 } 1442 } 1443 1444 function whichMouseButton(e) { 1445 if (e.touches !== void 0) { 1446 return e.touches.length; 1447 } 1448 if (e.which !== void 0 && e.which !== 0) { 1449 return e.which; 1450 } // see https://github.com/bevacqua/dragula/issues/261 1451 if (e.buttons !== void 0) { 1452 return e.buttons; 1453 } 1454 var button = e.button; 1455 if (button !== void 0) { // see https://github.com/jquery/jquery/blob/99e8ff1baa7ae341e94bb89c3e84570c7c3ad9ea/src/event.js#L573-L575 1456 return button & 1 ? 1 : button & 2 ? 3 : (button & 4 ? 2 : 0); 1457 } 1458 } 1459 1460 function getOffset(el) { 1461 var rect = el.getBoundingClientRect(); 1462 return { 1463 left: rect.left + getScroll('scrollLeft', 'pageXOffset'), 1464 top: rect.top + getScroll('scrollTop', 'pageYOffset') 1465 }; 1466 } 1467 1468 function getScroll(scrollProp, offsetProp) { 1469 if (typeof global[offsetProp] !== 'undefined') { 1470 return global[offsetProp]; 1471 } 1472 if (documentElement.clientHeight) { 1473 return documentElement[scrollProp]; 1474 } 1475 return doc.body[scrollProp]; 1476 } 1477 1478 function getElementBehindPoint(point, x, y) { 1479 var p = point || {}; 1480 var state = p.className; 1481 var el; 1482 p.className += ' gu-hide'; 1483 el = doc.elementFromPoint(x, y); 1484 p.className = state; 1485 return el; 1486 } 1487 1488 function never() { 1489 return false;
vendor: 10,757 bytes, lines 1490-1849
1490 } 1491 1492 function always() { 1493 return true; 1494 } 1495 1496 function getRectWidth(rect) { 1497 return rect.width || (rect.right - rect.left); 1498 } 1499 1500 function getRectHeight(rect) { 1501 return rect.height || (rect.bottom - rect.top); 1502 } 1503 1504 function getParent(el) { 1505 return el.parentNode === doc ? null : el.parentNode; 1506 } 1507 1508 function isInput(el) { 1509 return el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.tagName === 'SELECT' || isEditable(el); 1510 } 1511 1512 function isEditable(el) { 1513 if (!el) { 1514 return false; 1515 } // no parents were editable 1516 if (el.contentEditable === 'false') { 1517 return false; 1518 } // stop the lookup 1519 if (el.contentEditable === 'true') { 1520 return true; 1521 } // found a contentEditable element in the chain 1522 return isEditable(getParent(el)); // contentEditable is set to 'inherit' 1523 } 1524 1525 function nextEl(el) { 1526 return el.nextElementSibling || manually(); 1527 1528 function manually() { 1529 var sibling = el; 1530 do { 1531 sibling = sibling.nextSibling; 1532 } while (sibling && sibling.nodeType !== 1); 1533 return sibling; 1534 } 1535 } 1536 1537 function getEventHost(e) { 1538 // on touchend event, we have to use `e.changedTouches` 1539 // see http://stackoverflow.com/questions/7192563/touchend-event-properties 1540 // see https://github.com/bevacqua/dragula/issues/34 1541 if (e.targetTouches && e.targetTouches.length) { 1542 return e.targetTouches[0]; 1543 } 1544 if (e.changedTouches && e.changedTouches.length) { 1545 return e.changedTouches[0]; 1546 } 1547 return e; 1548 } 1549 1550 function getCoord(coord, e) { 1551 var host = getEventHost(e); 1552 var missMap = { 1553 pageX: 'clientX', // IE8 1554 pageY: 'clientY' // IE8 1555 }; 1556 if (coord in missMap && !(coord in host) && missMap[coord] in host) { 1557 coord = missMap[coord]; 1558 } 1559 return host[coord]; 1560 } 1561 1562 module.exports = dragula; 1563 1564 }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1565 }, { 1566 "./classes": 8, 1567 "contra/emitter": 4, 1568 "crossvent": 5 1569 }], 1570 10: [function(require, module, exports) { 1571 // shim for using process in browser 1572 var process = module.exports = {}; 1573 1574 // cached from whatever global is present so that test runners that stub it 1575 // don't break things. But we need to wrap it in a try catch in case it is 1576 // wrapped in strict mode code which doesn't define any globals. It's inside a 1577 // function because try/catches deoptimize in certain engines. 1578 1579 var cachedSetTimeout; 1580 var cachedClearTimeout; 1581 1582 function defaultSetTimout() { 1583 throw new Error('setTimeout has not been defined'); 1584 } 1585 1586 function defaultClearTimeout() { 1587 throw new Error('clearTimeout has not been defined'); 1588 } 1589 (function() { 1590 try { 1591 if (typeof setTimeout === 'function') { 1592 cachedSetTimeout = setTimeout; 1593 } else { 1594 cachedSetTimeout = defaultSetTimout; 1595 } 1596 } catch (e) { 1597 cachedSetTimeout = defaultSetTimout; 1598 } 1599 try { 1600 if (typeof clearTimeout === 'function') { 1601 cachedClearTimeout = clearTimeout; 1602 } else { 1603 cachedClearTimeout = defaultClearTimeout; 1604 } 1605 } catch (e) { 1606 cachedClearTimeout = defaultClearTimeout; 1607 } 1608 }()) 1609 1610 function runTimeout(fun) { 1611 if (cachedSetTimeout === setTimeout) { 1612 //normal enviroments in sane situations 1613 return setTimeout(fun, 0); 1614 } 1615 // if setTimeout wasn't available but was latter defined 1616 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 1617 cachedSetTimeout = setTimeout; 1618 return setTimeout(fun, 0); 1619 } 1620 try { 1621 // when when somebody has screwed with setTimeout but no I.E. maddness 1622 return cachedSetTimeout(fun, 0); 1623 } catch (e) { 1624 try { 1625 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 1626 return cachedSetTimeout.call(null, fun, 0); 1627 } catch (e) { 1628 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error 1629 return cachedSetTimeout.call(this, fun, 0); 1630 } 1631 } 1632 1633 1634 } 1635 1636 function runClearTimeout(marker) { 1637 if (cachedClearTimeout === clearTimeout) { 1638 //normal enviroments in sane situations 1639 return clearTimeout(marker); 1640 } 1641 // if clearTimeout wasn't available but was latter defined 1642 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 1643 cachedClearTimeout = clearTimeout; 1644 return clearTimeout(marker); 1645 } 1646 try { 1647 // when when somebody has screwed with setTimeout but no I.E. maddness 1648 return cachedClearTimeout(marker); 1649 } catch (e) { 1650 try { 1651 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 1652 return cachedClearTimeout.call(null, marker); 1653 } catch (e) { 1654 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. 1655 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 1656 return cachedClearTimeout.call(this, marker); 1657 } 1658 } 1659 1660 1661 1662 } 1663 var queue = []; 1664 var draining = false; 1665 var currentQueue; 1666 var queueIndex = -1; 1667 1668 function cleanUpNextTick() { 1669 if (!draining || !currentQueue) { 1670 return; 1671 } 1672 draining = false; 1673 if (currentQueue.length) { 1674 queue = currentQueue.concat(queue); 1675 } else { 1676 queueIndex = -1; 1677 } 1678 if (queue.length) { 1679 drainQueue(); 1680 } 1681 } 1682 1683 function drainQueue() { 1684 if (draining) { 1685 return; 1686 } 1687 var timeout = runTimeout(cleanUpNextTick); 1688 draining = true; 1689 1690 var len = queue.length; 1691 while (len) { 1692 currentQueue = queue; 1693 queue = []; 1694 while (++queueIndex < len) { 1695 if (currentQueue) { 1696 currentQueue[queueIndex].run(); 1697 } 1698 } 1699 queueIndex = -1; 1700 len = queue.length; 1701 } 1702 currentQueue = null; 1703 draining = false; 1704 runClearTimeout(timeout); 1705 } 1706 1707 process.nextTick = function(fun) { 1708 var args = new Array(arguments.length - 1); 1709 if (arguments.length > 1) { 1710 for (var i = 1; i < arguments.length; i++) { 1711 args[i - 1] = arguments[i]; 1712 } 1713 } 1714 queue.push(new Item(fun, args)); 1715 if (queue.length === 1 && !draining) { 1716 runTimeout(drainQueue); 1717 } 1718 }; 1719 1720 // v8 likes predictible objects 1721 function Item(fun, array) { 1722 this.fun = fun; 1723 this.array = array; 1724 } 1725 Item.prototype.run = function() { 1726 this.fun.apply(null, this.array); 1727 }; 1728 process.title = 'browser'; 1729 process.browser = true; 1730 process.env = {}; 1731 process.argv = []; 1732 process.version = ''; // empty string to avoid regexp issues 1733 process.versions = {}; 1734 1735 function noop() {} 1736 1737 process.on = noop; 1738 process.addListener = noop; 1739 process.once = noop; 1740 process.off = noop; 1741 process.removeListener = noop; 1742 process.removeAllListeners = noop; 1743 process.emit = noop; 1744 process.prependListener = noop; 1745 process.prependOnceListener = noop; 1746 1747 process.listeners = function(name) { 1748 return [] 1749 } 1750 1751 process.binding = function(name) { 1752 throw new Error('process.binding is not supported'); 1753 }; 1754 1755 process.cwd = function() { 1756 return '/' 1757 }; 1758 process.chdir = function(dir) { 1759 throw new Error('process.chdir is not supported'); 1760 }; 1761 process.umask = function() { 1762 return 0; 1763 }; 1764 1765 }, {}], 1766 11: [function(require, module, exports) { 1767 (function(setImmediate) { 1768 var si = typeof setImmediate === 'function', 1769 tick; 1770 if (si) { 1771 tick = function(fn) { 1772 setImmediate(fn); 1773 }; 1774 } else { 1775 tick = function(fn) { 1776 setTimeout(fn, 0); 1777 }; 1778 } 1779 1780 module.exports = tick; 1781 }).call(this, require("timers").setImmediate) 1782 }, { 1783 "timers": 12 1784 }], 1785 12: [function(require, module, exports) { 1786 (function(setImmediate, clearImmediate) { 1787 var nextTick = require('process/browser.js').nextTick; 1788 var apply = Function.prototype.apply; 1789 var slice = Array.prototype.slice; 1790 var immediateIds = {}; 1791 var nextImmediateId = 0; 1792 1793 // DOM APIs, for completeness 1794 1795 exports.setTimeout = function() { 1796 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); 1797 }; 1798 exports.setInterval = function() { 1799 return new Timeout(apply.call(setInterval, window, arguments), clearInterval); 1800 }; 1801 exports.clearTimeout = 1802 exports.clearInterval = function(timeout) { 1803 timeout.close(); 1804 }; 1805 1806 function Timeout(id, clearFn) { 1807 this._id = id; 1808 this._clearFn = clearFn; 1809 } 1810 Timeout.prototype.unref = Timeout.prototype.ref = function() {}; 1811 Timeout.prototype.close = function() { 1812 this._clearFn.call(window, this._id); 1813 }; 1814 1815 // Does not start the time, just sets up the members needed. 1816 exports.enroll = function(item, msecs) { 1817 clearTimeout(item._idleTimeoutId); 1818 item._idleTimeout = msecs; 1819 }; 1820 1821 exports.unenroll = function(item) { 1822 clearTimeout(item._idleTimeoutId); 1823 item._idleTimeout = -1; 1824 }; 1825 1826 exports._unrefActive = exports.active = function(item) { 1827 clearTimeout(item._idleTimeoutId); 1828 1829 var msecs = item._idleTimeout; 1830 if (msecs >= 0) { 1831 item._idleTimeoutId = setTimeout(function onTimeout() { 1832 if (item._onTimeout) 1833 item._onTimeout(); 1834 }, msecs); 1835 } 1836 }; 1837 1838 // That's not how node.js implements it but the exposed api is the same. 1839 exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { 1840 var id = nextImmediateId++; 1841 var args = arguments.length < 2 ? false : slice.call(arguments, 1); 1842 1843 immediateIds[id] = true; 1844 1845 nextTick(function onNextTick() { 1846 if (immediateIds[id]) { 1847 // fn.call() is faster so we optimize for the common use-case 1848 // @see http://jsperf.com/call-apply-segu 1849 if (args) {
1850 fn.apply(null, args); 1851 } else { 1852 fn.call(null); 1853 } 1854 // Prevent ids from leaking 1855 exports.clearImmediate(id); 1856 } 1857 }); 1858 1859 return id; 1860 }; 1861 1862 exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { 1863 delete immediateIds[id]; 1864 }; 1865 }).call(this, require("timers").setImmediate, require("timers").clearImmediate) 1866 }, { 1867 "process/browser.js": 10, 1868 "timers": 12 1869 }] 1870}, {}, [1]);
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.