vendor: 13,345 bytes, lines 1-326
1/* 2 * # Semantic UI - 2.2.12 3 * https://github.com/Semantic-Org/Semantic-UI 4 * http://www.semantic-ui.com/ 5 * 6 * Copyright 2014 Contributors 7 * Released under the MIT license 8 * http://opensource.org/licenses/MIT 9 * 10 */ 11/*! 12 * # Semantic UI 2.2.12 - Site 13 * http://github.com/semantic-org/semantic-ui/ 14 * 15 * 16 * Released under the MIT license 17 * http://opensource.org/licenses/MIT 18 * 19 */ 20 21;(function ($, window, document, undefined) { 22 23 $.site = $.fn.site = function(parameters) { 24 var 25 time = new Date().getTime(), 26 performance = [], 27 28 query = arguments[0], 29 methodInvoked = (typeof query == 'string'), 30 queryArguments = [].slice.call(arguments, 1), 31 32 settings = ( $.isPlainObject(parameters) ) 33 ? $.extend(true, {}, $.site.settings, parameters) 34 : $.extend({}, $.site.settings), 35 36 namespace = settings.namespace, 37 error = settings.error, 38 39 eventNamespace = '.' + namespace, 40 moduleNamespace = 'module-' + namespace, 41 42 $document = $(document), 43 $module = $document, 44 element = this, 45 instance = $module.data(moduleNamespace), 46 47 module, 48 returnedValue 49 ; 50 module = { 51 52 initialize: function() { 53 module.instantiate(); 54 }, 55 56 instantiate: function() { 57 module.verbose('Storing instance of site', module); 58 instance = module; 59 $module 60 .data(moduleNamespace, module) 61 ; 62 }, 63 64 normalize: function() { 65 module.fix.console(); 66 module.fix.requestAnimationFrame(); 67 }, 68 69 fix: { 70 console: function() { 71 module.debug('Normalizing window.console'); 72 if (console === undefined || console.log === undefined) { 73 module.verbose('Console not available, normalizing events'); 74 module.disable.console(); 75 } 76 if (typeof console.group == 'undefined' || typeof console.groupEnd == 'undefined' || typeof console.groupCollapsed == 'undefined') { 77 module.verbose('Console group not available, normalizing events'); 78 window.console.group = function() {}; 79 window.console.groupEnd = function() {}; 80 window.console.groupCollapsed = function() {}; 81 } 82 if (typeof console.markTimeline == 'undefined') { 83 module.verbose('Mark timeline not available, normalizing events'); 84 window.console.markTimeline = function() {}; 85 } 86 }, 87 consoleClear: function() { 88 module.debug('Disabling programmatic console clearing'); 89 window.console.clear = function() {}; 90 }, 91 requestAnimationFrame: function() { 92 module.debug('Normalizing requestAnimationFrame'); 93 if(window.requestAnimationFrame === undefined) { 94 module.debug('RequestAnimationFrame not available, normalizing event'); 95 window.requestAnimationFrame = window.requestAnimationFrame 96 || window.mozRequestAnimationFrame 97 || window.webkitRequestAnimationFrame 98 || window.msRequestAnimationFrame 99 || function(callback) { setTimeout(callback, 0); } 100 ; 101 } 102 } 103 }, 104 105 moduleExists: function(name) { 106 return ($.fn[name] !== undefined && $.fn[name].settings !== undefined); 107 }, 108 109 enabled: { 110 modules: function(modules) { 111 var 112 enabledModules = [] 113 ; 114 modules = modules || settings.modules; 115 $.each(modules, function(index, name) { 116 if(module.moduleExists(name)) { 117 enabledModules.push(name); 118 } 119 }); 120 return enabledModules; 121 } 122 }, 123 124 disabled: { 125 modules: function(modules) { 126 var 127 disabledModules = [] 128 ; 129 modules = modules || settings.modules; 130 $.each(modules, function(index, name) { 131 if(!module.moduleExists(name)) { 132 disabledModules.push(name); 133 } 134 }); 135 return disabledModules; 136 } 137 }, 138 139 change: { 140 setting: function(setting, value, modules, modifyExisting) { 141 modules = (typeof modules === 'string') 142 ? (modules === 'all') 143 ? settings.modules 144 : [modules] 145 : modules || settings.modules 146 ; 147 modifyExisting = (modifyExisting !== undefined) 148 ? modifyExisting 149 : true 150 ; 151 $.each(modules, function(index, name) { 152 var 153 namespace = (module.moduleExists(name)) 154 ? $.fn[name].settings.namespace || false 155 : true, 156 $existingModules 157 ; 158 if(module.moduleExists(name)) { 159 module.verbose('Changing default setting', setting, value, name); 160 $.fn[name].settings[setting] = value; 161 if(modifyExisting && namespace) { 162 $existingModules = $(':data(module-' + namespace + ')'); 163 if($existingModules.length > 0) { 164 module.verbose('Modifying existing settings', $existingModules); 165 $existingModules[name]('setting', setting, value); 166 } 167 } 168 } 169 }); 170 }, 171 settings: function(newSettings, modules, modifyExisting) { 172 modules = (typeof modules === 'string') 173 ? [modules] 174 : modules || settings.modules 175 ; 176 modifyExisting = (modifyExisting !== undefined) 177 ? modifyExisting 178 : true 179 ; 180 $.each(modules, function(index, name) { 181 var 182 $existingModules 183 ; 184 if(module.moduleExists(name)) { 185 module.verbose('Changing default setting', newSettings, name); 186 $.extend(true, $.fn[name].settings, newSettings); 187 if(modifyExisting && namespace) { 188 $existingModules = $(':data(module-' + namespace + ')'); 189 if($existingModules.length > 0) { 190 module.verbose('Modifying existing settings', $existingModules); 191 $existingModules[name]('setting', newSettings); 192 } 193 } 194 } 195 }); 196 } 197 }, 198 199 enable: { 200 console: function() { 201 module.console(true); 202 }, 203 debug: function(modules, modifyExisting) { 204 modules = modules || settings.modules; 205 module.debug('Enabling debug for modules', modules); 206 module.change.setting('debug', true, modules, modifyExisting); 207 }, 208 verbose: function(modules, modifyExisting) { 209 modules = modules || settings.modules; 210 module.debug('Enabling verbose debug for modules', modules); 211 module.change.setting('verbose', true, modules, modifyExisting); 212 } 213 }, 214 disable: { 215 console: function() { 216 module.console(false); 217 }, 218 debug: function(modules, modifyExisting) { 219 modules = modules || settings.modules; 220 module.debug('Disabling debug for modules', modules); 221 module.change.setting('debug', false, modules, modifyExisting); 222 }, 223 verbose: function(modules, modifyExisting) { 224 modules = modules || settings.modules; 225 module.debug('Disabling verbose debug for modules', modules); 226 module.change.setting('verbose', false, modules, modifyExisting); 227 } 228 }, 229 230 console: function(enable) { 231 if(enable) { 232 if(instance.cache.console === undefined) { 233 module.error(error.console); 234 return; 235 } 236 module.debug('Restoring console function'); 237 window.console = instance.cache.console; 238 } 239 else { 240 module.debug('Disabling console function'); 241 instance.cache.console = window.console; 242 window.console = { 243 clear : function(){}, 244 error : function(){}, 245 group : function(){}, 246 groupCollapsed : function(){}, 247 groupEnd : function(){}, 248 info : function(){}, 249 log : function(){}, 250 markTimeline : function(){}, 251 warn : function(){} 252 }; 253 } 254 }, 255 256 destroy: function() { 257 module.verbose('Destroying previous site for', $module); 258 $module 259 .removeData(moduleNamespace) 260 ; 261 }, 262 263 cache: {}, 264 265 setting: function(name, value) { 266 if( $.isPlainObject(name) ) { 267 $.extend(true, settings, name); 268 } 269 else if(value !== undefined) { 270 settings[name] = value; 271 } 272 else { 273 return settings[name]; 274 } 275 }, 276 internal: function(name, value) { 277 if( $.isPlainObject(name) ) { 278 $.extend(true, module, name); 279 } 280 else if(value !== undefined) { 281 module[name] = value; 282 } 283 else { 284 return module[name]; 285 } 286 }, 287 debug: function() { 288 if(settings.debug) { 289 if(settings.performance) { 290 module.performance.log(arguments); 291 } 292 else { 293 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 294 module.debug.apply(console, arguments); 295 } 296 } 297 }, 298 verbose: function() { 299 if(settings.verbose && settings.debug) { 300 if(settings.performance) { 301 module.performance.log(arguments); 302 } 303 else { 304 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 305 module.verbose.apply(console, arguments); 306 } 307 } 308 }, 309 error: function() { 310 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 311 module.error.apply(console, arguments); 312 }, 313 performance: { 314 log: function(message) { 315 var 316 currentTime, 317 executionTime, 318 previousTime 319 ; 320 if(settings.performance) { 321 currentTime = new Date().getTime(); 322 previousTime = time || currentTime; 323 executionTime = currentTime - previousTime; 324 time = currentTime; 325 performance.push({ 326 'Element' : element,
vendor: 10,297 bytes, lines 327-629
327 'Name' : message[0], 328 'Arguments' : [].slice.call(message, 1) || '', 329 'Execution Time' : executionTime 330 }); 331 } 332 clearTimeout(module.performance.timer); 333 module.performance.timer = setTimeout(module.performance.display, 500); 334 }, 335 display: function() { 336 var 337 title = settings.name + ':', 338 totalTime = 0 339 ; 340 time = false; 341 clearTimeout(module.performance.timer); 342 $.each(performance, function(index, data) { 343 totalTime += data['Execution Time']; 344 }); 345 title += ' ' + totalTime + 'ms'; 346 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 347 console.groupCollapsed(title); 348 if(console.table) { 349 console.table(performance); 350 } 351 else { 352 $.each(performance, function(index, data) { 353 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 354 }); 355 } 356 console.groupEnd(); 357 } 358 performance = []; 359 } 360 }, 361 invoke: function(query, passedArguments, context) { 362 var 363 object = instance, 364 maxDepth, 365 found, 366 response 367 ; 368 passedArguments = passedArguments || queryArguments; 369 context = element || context; 370 if(typeof query == 'string' && object !== undefined) { 371 query = query.split(/[\. ]/); 372 maxDepth = query.length - 1; 373 $.each(query, function(depth, value) { 374 var camelCaseValue = (depth != maxDepth) 375 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 376 : query 377 ; 378 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 379 object = object[camelCaseValue]; 380 } 381 else if( object[camelCaseValue] !== undefined ) { 382 found = object[camelCaseValue]; 383 return false; 384 } 385 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 386 object = object[value]; 387 } 388 else if( object[value] !== undefined ) { 389 found = object[value]; 390 return false; 391 } 392 else { 393 module.error(error.method, query); 394 return false; 395 } 396 }); 397 } 398 if ( $.isFunction( found ) ) { 399 response = found.apply(context, passedArguments); 400 } 401 else if(found !== undefined) { 402 response = found; 403 } 404 if($.isArray(returnedValue)) { 405 returnedValue.push(response); 406 } 407 else if(returnedValue !== undefined) { 408 returnedValue = [returnedValue, response]; 409 } 410 else if(response !== undefined) { 411 returnedValue = response; 412 } 413 return found; 414 } 415 }; 416 417 if(methodInvoked) { 418 if(instance === undefined) { 419 module.initialize(); 420 } 421 module.invoke(query); 422 } 423 else { 424 if(instance !== undefined) { 425 module.destroy(); 426 } 427 module.initialize(); 428 } 429 return (returnedValue !== undefined) 430 ? returnedValue 431 : this 432 ; 433 }; 434 435 $.site.settings = { 436 437 name : 'Site', 438 namespace : 'site', 439 440 error : { 441 console : 'Console cannot be restored, most likely it was overwritten outside of module', 442 method : 'The method you called is not defined.' 443 }, 444 445 debug : false, 446 verbose : false, 447 performance : true, 448 449 modules: [ 450 'accordion', 451 'api', 452 'checkbox', 453 'dimmer', 454 'dropdown', 455 'embed', 456 'form', 457 'modal', 458 'nag', 459 'popup', 460 'rating', 461 'shape', 462 'sidebar', 463 'state', 464 'sticky', 465 'tab', 466 'transition', 467 'visit', 468 'visibility' 469 ], 470 471 siteNamespace : 'site', 472 namespaceStub : { 473 cache : {}, 474 config : {}, 475 sections : {}, 476 section : {}, 477 utilities : {} 478 } 479 480 }; 481 482// allows for selection of elements with data attributes 483 $.extend($.expr[ ":" ], { 484 data: ($.expr.createPseudo) 485 ? $.expr.createPseudo(function(dataName) { 486 return function(elem) { 487 return !!$.data(elem, dataName); 488 }; 489 }) 490 : function(elem, i, match) { 491 // support: jQuery < 1.8 492 return !!$.data(elem, match[ 3 ]); 493 } 494 }); 495 496 497})( jQuery, window, document ); 498 499/*! 500 * # Semantic UI 2.2.12 - Form Validation 501 * http://github.com/semantic-org/semantic-ui/ 502 * 503 * 504 * Released under the MIT license 505 * http://opensource.org/licenses/MIT 506 * 507 */ 508 509;(function ($, window, document, undefined) { 510 511 "use strict"; 512 513 window = (typeof window != 'undefined' && window.Math == Math) 514 ? window 515 : (typeof self != 'undefined' && self.Math == Math) 516 ? self 517 : Function('return this')() 518 ; 519 520 $.fn.form = function(parameters) { 521 var 522 $allModules = $(this), 523 moduleSelector = $allModules.selector || '', 524 525 time = new Date().getTime(), 526 performance = [], 527 528 query = arguments[0], 529 legacyParameters = arguments[1], 530 methodInvoked = (typeof query == 'string'), 531 queryArguments = [].slice.call(arguments, 1), 532 returnedValue 533 ; 534 $allModules 535 .each(function() { 536 var 537 $module = $(this), 538 element = this, 539 540 formErrors = [], 541 keyHeldDown = false, 542 543 // set at run-time 544 $field, 545 $group, 546 $message, 547 $prompt, 548 $submit, 549 $clear, 550 $reset, 551 552 settings, 553 validation, 554 555 metadata, 556 selector, 557 className, 558 regExp, 559 error, 560 561 namespace, 562 moduleNamespace, 563 eventNamespace, 564 565 instance, 566 module 567 ; 568 569 module = { 570 571 initialize: function() { 572 573 // settings grabbed at run time 574 module.get.settings(); 575 if(methodInvoked) { 576 if(instance === undefined) { 577 module.instantiate(); 578 } 579 module.invoke(query); 580 } 581 else { 582 if(instance !== undefined) { 583 instance.invoke('destroy'); 584 } 585 module.verbose('Initializing form validation', $module, settings); 586 module.bindEvents(); 587 module.set.defaults(); 588 module.instantiate(); 589 } 590 }, 591 592 instantiate: function() { 593 module.verbose('Storing instance of module', module); 594 instance = module; 595 $module 596 .data(moduleNamespace, module) 597 ; 598 }, 599 600 destroy: function() { 601 module.verbose('Destroying previous module', instance); 602 module.removeEvents(); 603 $module 604 .removeData(moduleNamespace) 605 ; 606 }, 607 608 refresh: function() { 609 module.verbose('Refreshing selector cache'); 610 $field = $module.find(selector.field); 611 $group = $module.find(selector.group); 612 $message = $module.find(selector.message); 613 $prompt = $module.find(selector.prompt); 614 615 $submit = $module.find(selector.submit); 616 $clear = $module.find(selector.clear); 617 $reset = $module.find(selector.reset); 618 }, 619 620 submit: function() { 621 module.verbose('Submitting form', $module); 622 $module 623 .submit() 624 ; 625 }, 626 627 attachEvents: function(selector, action) { 628 action = action || 'submit'; 629 $(selector)
vendor: 10,998 bytes, lines 630-845
630 .on('click' + eventNamespace, function(event) { 631 module[action](); 632 event.preventDefault(); 633 }) 634 ; 635 }, 636 637 bindEvents: function() { 638 module.verbose('Attaching form events'); 639 $module 640 .on('submit' + eventNamespace, module.validate.form) 641 .on('blur' + eventNamespace, selector.field, module.event.field.blur) 642 .on('click' + eventNamespace, selector.submit, module.submit) 643 .on('click' + eventNamespace, selector.reset, module.reset) 644 .on('click' + eventNamespace, selector.clear, module.clear) 645 ; 646 if(settings.keyboardShortcuts) { 647 $module 648 .on('keydown' + eventNamespace, selector.field, module.event.field.keydown) 649 ; 650 } 651 $field 652 .each(function() { 653 var 654 $input = $(this), 655 type = $input.prop('type'), 656 inputEvent = module.get.changeEvent(type, $input) 657 ; 658 $(this) 659 .on(inputEvent + eventNamespace, module.event.field.change) 660 ; 661 }) 662 ; 663 }, 664 665 clear: function() { 666 $field 667 .each(function () { 668 var 669 $field = $(this), 670 $element = $field.parent(), 671 $fieldGroup = $field.closest($group), 672 $prompt = $fieldGroup.find(selector.prompt), 673 defaultValue = $field.data(metadata.defaultValue) || '', 674 isCheckbox = $element.is(selector.uiCheckbox), 675 isDropdown = $element.is(selector.uiDropdown), 676 isErrored = $fieldGroup.hasClass(className.error) 677 ; 678 if(isErrored) { 679 module.verbose('Resetting error on field', $fieldGroup); 680 $fieldGroup.removeClass(className.error); 681 $prompt.remove(); 682 } 683 if(isDropdown) { 684 module.verbose('Resetting dropdown value', $element, defaultValue); 685 $element.dropdown('clear'); 686 } 687 else if(isCheckbox) { 688 $field.prop('checked', false); 689 } 690 else { 691 module.verbose('Resetting field value', $field, defaultValue); 692 $field.val(''); 693 } 694 }) 695 ; 696 }, 697 698 reset: function() { 699 $field 700 .each(function () { 701 var 702 $field = $(this), 703 $element = $field.parent(), 704 $fieldGroup = $field.closest($group), 705 $prompt = $fieldGroup.find(selector.prompt), 706 defaultValue = $field.data(metadata.defaultValue), 707 isCheckbox = $element.is(selector.uiCheckbox), 708 isDropdown = $element.is(selector.uiDropdown), 709 isErrored = $fieldGroup.hasClass(className.error) 710 ; 711 if(defaultValue === undefined) { 712 return; 713 } 714 if(isErrored) { 715 module.verbose('Resetting error on field', $fieldGroup); 716 $fieldGroup.removeClass(className.error); 717 $prompt.remove(); 718 } 719 if(isDropdown) { 720 module.verbose('Resetting dropdown value', $element, defaultValue); 721 $element.dropdown('restore defaults'); 722 } 723 else if(isCheckbox) { 724 module.verbose('Resetting checkbox value', $element, defaultValue); 725 $field.prop('checked', defaultValue); 726 } 727 else { 728 module.verbose('Resetting field value', $field, defaultValue); 729 $field.val(defaultValue); 730 } 731 }) 732 ; 733 }, 734 735 determine: { 736 isValid: function() { 737 var 738 allValid = true 739 ; 740 $.each(validation, function(fieldName, field) { 741 if( !( module.validate.field(field, fieldName, true) ) ) { 742 allValid = false; 743 } 744 }); 745 return allValid; 746 } 747 }, 748 749 is: { 750 bracketedRule: function(rule) { 751 return (rule.type && rule.type.match(settings.regExp.bracket)); 752 }, 753 shorthandFields: function(fields) { 754 var 755 fieldKeys = Object.keys(fields), 756 firstRule = fields[fieldKeys[0]] 757 ; 758 return module.is.shorthandRules(firstRule); 759 }, 760 // duck type rule test 761 shorthandRules: function(rules) { 762 return (typeof rules == 'string' || $.isArray(rules)); 763 }, 764 empty: function($field) { 765 if(!$field || $field.length === 0) { 766 return true; 767 } 768 else if($field.is('input[type="checkbox"]')) { 769 return !$field.is(':checked'); 770 } 771 else { 772 return module.is.blank($field); 773 } 774 }, 775 blank: function($field) { 776 return $.trim($field.val()) === ''; 777 }, 778 valid: function(field) { 779 var 780 allValid = true 781 ; 782 if(field) { 783 module.verbose('Checking if field is valid', field); 784 return module.validate.field(validation[field], field, false); 785 } 786 else { 787 module.verbose('Checking if form is valid'); 788 $.each(validation, function(fieldName, field) { 789 if( !module.is.valid(fieldName) ) { 790 allValid = false; 791 } 792 }); 793 return allValid; 794 } 795 } 796 }, 797 798 removeEvents: function() { 799 $module 800 .off(eventNamespace) 801 ; 802 $field 803 .off(eventNamespace) 804 ; 805 $submit 806 .off(eventNamespace) 807 ; 808 $field 809 .off(eventNamespace) 810 ; 811 }, 812 813 event: { 814 field: { 815 keydown: function(event) { 816 var 817 $field = $(this), 818 key = event.which, 819 isInput = $field.is(selector.input), 820 isCheckbox = $field.is(selector.checkbox), 821 isInDropdown = ($field.closest(selector.uiDropdown).length > 0), 822 keyCode = { 823 enter : 13, 824 escape : 27 825 } 826 ; 827 if( key == keyCode.escape) { 828 module.verbose('Escape key pressed blurring field'); 829 $field 830 .blur() 831 ; 832 } 833 if(!event.ctrlKey && key == keyCode.enter && isInput && !isInDropdown && !isCheckbox) { 834 if(!keyHeldDown) { 835 $field 836 .one('keyup' + eventNamespace, module.event.field.keyup) 837 ; 838 module.submit(); 839 module.debug('Enter pressed on input submitting form'); 840 } 841 keyHeldDown = true; 842 } 843 }, 844 keyup: function() { 845 keyHeldDown = false;
vendor: 11,328 bytes, lines 846-1044
846 }, 847 blur: function(event) { 848 var 849 $field = $(this), 850 $fieldGroup = $field.closest($group), 851 validationRules = module.get.validation($field) 852 ; 853 if( $fieldGroup.hasClass(className.error) ) { 854 module.debug('Revalidating field', $field, validationRules); 855 if(validationRules) { 856 module.validate.field( validationRules ); 857 } 858 } 859 else if(settings.on == 'blur' || settings.on == 'change') { 860 if(validationRules) { 861 module.validate.field( validationRules ); 862 } 863 } 864 }, 865 change: function(event) { 866 var 867 $field = $(this), 868 $fieldGroup = $field.closest($group), 869 validationRules = module.get.validation($field) 870 ; 871 if(validationRules && (settings.on == 'change' || ( $fieldGroup.hasClass(className.error) && settings.revalidate) )) { 872 clearTimeout(module.timer); 873 module.timer = setTimeout(function() { 874 module.debug('Revalidating field', $field, module.get.validation($field)); 875 module.validate.field( validationRules ); 876 }, settings.delay); 877 } 878 } 879 } 880 881 }, 882 883 get: { 884 ancillaryValue: function(rule) { 885 if(!rule.type || (!rule.value && !module.is.bracketedRule(rule))) { 886 return false; 887 } 888 return (rule.value !== undefined) 889 ? rule.value 890 : rule.type.match(settings.regExp.bracket)[1] + '' 891 ; 892 }, 893 ruleName: function(rule) { 894 if( module.is.bracketedRule(rule) ) { 895 return rule.type.replace(rule.type.match(settings.regExp.bracket)[0], ''); 896 } 897 return rule.type; 898 }, 899 changeEvent: function(type, $input) { 900 if(type == 'checkbox' || type == 'radio' || type == 'hidden' || $input.is('select')) { 901 return 'change'; 902 } 903 else { 904 return module.get.inputEvent(); 905 } 906 }, 907 inputEvent: function() { 908 return (document.createElement('input').oninput !== undefined) 909 ? 'input' 910 : (document.createElement('input').onpropertychange !== undefined) 911 ? 'propertychange' 912 : 'keyup' 913 ; 914 }, 915 fieldsFromShorthand: function(fields) { 916 var 917 fullFields = {} 918 ; 919 $.each(fields, function(name, rules) { 920 if(typeof rules == 'string') { 921 rules = [rules]; 922 } 923 fullFields[name] = { 924 rules: [] 925 }; 926 $.each(rules, function(index, rule) { 927 fullFields[name].rules.push({ type: rule }); 928 }); 929 }); 930 return fullFields; 931 }, 932 prompt: function(rule, field) { 933 var 934 ruleName = module.get.ruleName(rule), 935 ancillary = module.get.ancillaryValue(rule), 936 prompt = rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule, 937 requiresValue = (prompt.search('{value}') !== -1), 938 requiresName = (prompt.search('{name}') !== -1), 939 $label, 940 $field, 941 name 942 ; 943 if(requiresName || requiresValue) { 944 $field = module.get.field(field.identifier); 945 } 946 if(requiresValue) { 947 prompt = prompt.replace('{value}', $field.val()); 948 } 949 if(requiresName) { 950 $label = $field.closest(selector.group).find('label').eq(0); 951 name = ($label.length == 1) 952 ? $label.text() 953 : $field.prop('placeholder') || settings.text.unspecifiedField 954 ; 955 prompt = prompt.replace('{name}', name); 956 } 957 prompt = prompt.replace('{identifier}', field.identifier); 958 prompt = prompt.replace('{ruleValue}', ancillary); 959 if(!rule.prompt) { 960 module.verbose('Using default validation prompt for type', prompt, ruleName); 961 } 962 return prompt; 963 }, 964 settings: function() { 965 if($.isPlainObject(parameters)) { 966 var 967 keys = Object.keys(parameters), 968 isLegacySettings = (keys.length > 0) 969 ? (parameters[keys[0]].identifier !== undefined && parameters[keys[0]].rules !== undefined) 970 : false, 971 ruleKeys 972 ; 973 if(isLegacySettings) { 974 // 1.x (ducktyped) 975 settings = $.extend(true, {}, $.fn.form.settings, legacyParameters); 976 validation = $.extend({}, $.fn.form.settings.defaults, parameters); 977 module.error(settings.error.oldSyntax, element); 978 module.verbose('Extending settings from legacy parameters', validation, settings); 979 } 980 else { 981 // 2.x 982 if(parameters.fields && module.is.shorthandFields(parameters.fields)) { 983 parameters.fields = module.get.fieldsFromShorthand(parameters.fields); 984 } 985 settings = $.extend(true, {}, $.fn.form.settings, parameters); 986 validation = $.extend({}, $.fn.form.settings.defaults, settings.fields); 987 module.verbose('Extending settings', validation, settings); 988 } 989 } 990 else { 991 settings = $.fn.form.settings; 992 validation = $.fn.form.settings.defaults; 993 module.verbose('Using default form validation', validation, settings); 994 } 995 996 // shorthand 997 namespace = settings.namespace; 998 metadata = settings.metadata; 999 selector = settings.selector; 1000 className = settings.className; 1001 regExp = settings.regExp; 1002 error = settings.error; 1003 moduleNamespace = 'module-' + namespace; 1004 eventNamespace = '.' + namespace; 1005 1006 // grab instance 1007 instance = $module.data(moduleNamespace); 1008 1009 // refresh selector cache 1010 module.refresh(); 1011 }, 1012 field: function(identifier) { 1013 module.verbose('Finding field with identifier', identifier); 1014 identifier = module.escape.string(identifier); 1015 if($field.filter('#' + identifier).length > 0 ) { 1016 return $field.filter('#' + identifier); 1017 } 1018 else if( $field.filter('[name="' + identifier +'"]').length > 0 ) { 1019 return $field.filter('[name="' + identifier +'"]'); 1020 } 1021 else if( $field.filter('[name="' + identifier +'[]"]').length > 0 ) { 1022 return $field.filter('[name="' + identifier +'[]"]'); 1023 } 1024 else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').length > 0 ) { 1025 return $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]'); 1026 } 1027 return $('<input/>'); 1028 }, 1029 fields: function(fields) { 1030 var 1031 $fields = $() 1032 ; 1033 $.each(fields, function(index, name) { 1034 $fields = $fields.add( module.get.field(name) ); 1035 }); 1036 return $fields; 1037 }, 1038 validation: function($field) { 1039 var 1040 fieldValidation, 1041 identifier 1042 ; 1043 if(!validation) { 1044 return false;
vendor: 27,075 bytes, lines 1045-1567
1045 } 1046 $.each(validation, function(fieldName, field) { 1047 identifier = field.identifier || fieldName; 1048 if( module.get.field(identifier)[0] == $field[0] ) { 1049 field.identifier = identifier; 1050 fieldValidation = field; 1051 } 1052 }); 1053 return fieldValidation || false; 1054 }, 1055 value: function (field) { 1056 var 1057 fields = [], 1058 results 1059 ; 1060 fields.push(field); 1061 results = module.get.values.call(element, fields); 1062 return results[field]; 1063 }, 1064 values: function (fields) { 1065 var 1066 $fields = $.isArray(fields) 1067 ? module.get.fields(fields) 1068 : $field, 1069 values = {} 1070 ; 1071 $fields.each(function(index, field) { 1072 var 1073 $field = $(field), 1074 type = $field.prop('type'), 1075 name = $field.prop('name'), 1076 value = $field.val(), 1077 isCheckbox = $field.is(selector.checkbox), 1078 isRadio = $field.is(selector.radio), 1079 isMultiple = (name.indexOf('[]') !== -1), 1080 isChecked = (isCheckbox) 1081 ? $field.is(':checked') 1082 : false 1083 ; 1084 if(name) { 1085 if(isMultiple) { 1086 name = name.replace('[]', ''); 1087 if(!values[name]) { 1088 values[name] = []; 1089 } 1090 if(isCheckbox) { 1091 if(isChecked) { 1092 values[name].push(value || true); 1093 } 1094 else { 1095 values[name].push(false); 1096 } 1097 } 1098 else { 1099 values[name].push(value); 1100 } 1101 } 1102 else { 1103 if(isRadio) { 1104 if(values[name] === undefined) { 1105 values[name] = (isChecked) 1106 ? true 1107 : false 1108 ; 1109 } 1110 } 1111 else if(isCheckbox) { 1112 if(isChecked) { 1113 values[name] = value || true; 1114 } 1115 else { 1116 values[name] = false; 1117 } 1118 } 1119 else { 1120 values[name] = value; 1121 } 1122 } 1123 } 1124 }); 1125 return values; 1126 } 1127 }, 1128 1129 has: { 1130 1131 field: function(identifier) { 1132 module.verbose('Checking for existence of a field with identifier', identifier); 1133 identifier = module.escape.string(identifier); 1134 if(typeof identifier !== 'string') { 1135 module.error(error.identifier, identifier); 1136 } 1137 if($field.filter('#' + identifier).length > 0 ) { 1138 return true; 1139 } 1140 else if( $field.filter('[name="' + identifier +'"]').length > 0 ) { 1141 return true; 1142 } 1143 else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').length > 0 ) { 1144 return true; 1145 } 1146 return false; 1147 } 1148 1149 }, 1150 1151 escape: { 1152 string: function(text) { 1153 text = String(text); 1154 return text.replace(regExp.escape, '\\$&'); 1155 } 1156 }, 1157 1158 add: { 1159 // alias 1160 rule: function(name, rules) { 1161 module.add.field(name, rules); 1162 }, 1163 field: function(name, rules) { 1164 var 1165 newValidation = {} 1166 ; 1167 if(module.is.shorthandRules(rules)) { 1168 rules = $.isArray(rules) 1169 ? rules 1170 : [rules] 1171 ; 1172 newValidation[name] = { 1173 rules: [] 1174 }; 1175 $.each(rules, function(index, rule) { 1176 newValidation[name].rules.push({ type: rule }); 1177 }); 1178 } 1179 else { 1180 newValidation[name] = rules; 1181 } 1182 validation = $.extend({}, validation, newValidation); 1183 module.debug('Adding rules', newValidation, validation); 1184 }, 1185 fields: function(fields) { 1186 var 1187 newValidation 1188 ; 1189 if(fields && module.is.shorthandFields(fields)) { 1190 newValidation = module.get.fieldsFromShorthand(fields); 1191 } 1192 else { 1193 newValidation = fields; 1194 } 1195 validation = $.extend({}, validation, newValidation); 1196 }, 1197 prompt: function(identifier, errors) { 1198 var 1199 $field = module.get.field(identifier), 1200 $fieldGroup = $field.closest($group), 1201 $prompt = $fieldGroup.children(selector.prompt), 1202 promptExists = ($prompt.length !== 0) 1203 ; 1204 errors = (typeof errors == 'string') 1205 ? [errors] 1206 : errors 1207 ; 1208 module.verbose('Adding field error state', identifier); 1209 $fieldGroup 1210 .addClass(className.error) 1211 ; 1212 if(settings.inline) { 1213 if(!promptExists) { 1214 $prompt = settings.templates.prompt(errors); 1215 $prompt 1216 .appendTo($fieldGroup) 1217 ; 1218 } 1219 $prompt 1220 .html(errors[0]) 1221 ; 1222 if(!promptExists) { 1223 if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { 1224 module.verbose('Displaying error with css transition', settings.transition); 1225 $prompt.transition(settings.transition + ' in', settings.duration); 1226 } 1227 else { 1228 module.verbose('Displaying error with fallback javascript animation'); 1229 $prompt 1230 .fadeIn(settings.duration) 1231 ; 1232 } 1233 } 1234 else { 1235 module.verbose('Inline errors are disabled, no inline error added', identifier); 1236 } 1237 } 1238 }, 1239 errors: function(errors) { 1240 module.debug('Adding form error messages', errors); 1241 module.set.error(); 1242 $message 1243 .html( settings.templates.error(errors) ) 1244 ; 1245 } 1246 }, 1247 1248 remove: { 1249 rule: function(field, rule) { 1250 var 1251 rules = $.isArray(rule) 1252 ? rule 1253 : [rule] 1254 ; 1255 if(rule == undefined) { 1256 module.debug('Removed all rules'); 1257 validation[field].rules = []; 1258 return; 1259 } 1260 if(validation[field] == undefined || !$.isArray(validation[field].rules)) { 1261 return; 1262 } 1263 $.each(validation[field].rules, function(index, rule) { 1264 if(rules.indexOf(rule.type) !== -1) { 1265 module.debug('Removed rule', rule.type); 1266 validation[field].rules.splice(index, 1); 1267 } 1268 }); 1269 }, 1270 field: function(field) { 1271 var 1272 fields = $.isArray(field) 1273 ? field 1274 : [field] 1275 ; 1276 $.each(fields, function(index, field) { 1277 module.remove.rule(field); 1278 }); 1279 }, 1280 // alias 1281 rules: function(field, rules) { 1282 if($.isArray(field)) { 1283 $.each(fields, function(index, field) { 1284 module.remove.rule(field, rules); 1285 }); 1286 } 1287 else { 1288 module.remove.rule(field, rules); 1289 } 1290 }, 1291 fields: function(fields) { 1292 module.remove.field(fields); 1293 }, 1294 prompt: function(identifier) { 1295 var 1296 $field = module.get.field(identifier), 1297 $fieldGroup = $field.closest($group), 1298 $prompt = $fieldGroup.children(selector.prompt) 1299 ; 1300 $fieldGroup 1301 .removeClass(className.error) 1302 ; 1303 if(settings.inline && $prompt.is(':visible')) { 1304 module.verbose('Removing prompt for field', identifier); 1305 if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { 1306 $prompt.transition(settings.transition + ' out', settings.duration, function() { 1307 $prompt.remove(); 1308 }); 1309 } 1310 else { 1311 $prompt 1312 .fadeOut(settings.duration, function(){ 1313 $prompt.remove(); 1314 }) 1315 ; 1316 } 1317 } 1318 } 1319 }, 1320 1321 set: { 1322 success: function() { 1323 $module 1324 .removeClass(className.error) 1325 .addClass(className.success) 1326 ; 1327 }, 1328 defaults: function () { 1329 $field 1330 .each(function () { 1331 var 1332 $field = $(this), 1333 isCheckbox = ($field.filter(selector.checkbox).length > 0), 1334 value = (isCheckbox) 1335 ? $field.is(':checked') 1336 : $field.val() 1337 ; 1338 $field.data(metadata.defaultValue, value); 1339 }) 1340 ; 1341 }, 1342 error: function() { 1343 $module 1344 .removeClass(className.success) 1345 .addClass(className.error) 1346 ; 1347 }, 1348 value: function (field, value) { 1349 var 1350 fields = {} 1351 ; 1352 fields[field] = value; 1353 return module.set.values.call(element, fields); 1354 }, 1355 values: function (fields) { 1356 if($.isEmptyObject(fields)) { 1357 return; 1358 } 1359 $.each(fields, function(key, value) { 1360 var 1361 $field = module.get.field(key), 1362 $element = $field.parent(), 1363 isMultiple = $.isArray(value), 1364 isCheckbox = $element.is(selector.uiCheckbox), 1365 isDropdown = $element.is(selector.uiDropdown), 1366 isRadio = ($field.is(selector.radio) && isCheckbox), 1367 fieldExists = ($field.length > 0), 1368 $multipleField 1369 ; 1370 if(fieldExists) { 1371 if(isMultiple && isCheckbox) { 1372 module.verbose('Selecting multiple', value, $field); 1373 $element.checkbox('uncheck'); 1374 $.each(value, function(index, value) { 1375 $multipleField = $field.filter('[value="' + value + '"]'); 1376 $element = $multipleField.parent(); 1377 if($multipleField.length > 0) { 1378 $element.checkbox('check'); 1379 } 1380 }); 1381 } 1382 else if(isRadio) { 1383 module.verbose('Selecting radio value', value, $field); 1384 $field.filter('[value="' + value + '"]') 1385 .parent(selector.uiCheckbox) 1386 .checkbox('check') 1387 ; 1388 } 1389 else if(isCheckbox) { 1390 module.verbose('Setting checkbox value', value, $element); 1391 if(value === true) { 1392 $element.checkbox('check'); 1393 } 1394 else { 1395 $element.checkbox('uncheck'); 1396 } 1397 } 1398 else if(isDropdown) { 1399 module.verbose('Setting dropdown value', value, $element); 1400 $element.dropdown('set selected', value); 1401 } 1402 else { 1403 module.verbose('Setting field value', value, $field); 1404 $field.val(value); 1405 } 1406 } 1407 }); 1408 } 1409 }, 1410 1411 validate: { 1412 1413 form: function(event, ignoreCallbacks) { 1414 var 1415 values = module.get.values(), 1416 apiRequest 1417 ; 1418 1419 // input keydown event will fire submit repeatedly by browser default 1420 if(keyHeldDown) { 1421 return false; 1422 } 1423 1424 // reset errors 1425 formErrors = []; 1426 if( module.determine.isValid() ) { 1427 module.debug('Form has no validation errors, submitting'); 1428 module.set.success(); 1429 if(ignoreCallbacks !== true) { 1430 return settings.onSuccess.call(element, event, values); 1431 } 1432 } 1433 else { 1434 module.debug('Form has errors'); 1435 module.set.error(); 1436 if(!settings.inline) { 1437 module.add.errors(formErrors); 1438 } 1439 // prevent ajax submit 1440 if($module.data('moduleApi') !== undefined) { 1441 event.stopImmediatePropagation(); 1442 } 1443 if(ignoreCallbacks !== true) { 1444 return settings.onFailure.call(element, formErrors, values); 1445 } 1446 } 1447 }, 1448 1449 // takes a validation object and returns whether field passes validation 1450 field: function(field, fieldName, showErrors) { 1451 showErrors = (showErrors !== undefined) 1452 ? showErrors 1453 : true 1454 ; 1455 if(typeof field == 'string') { 1456 module.verbose('Validating field', field); 1457 fieldName = field; 1458 field = validation[field]; 1459 } 1460 var 1461 identifier = field.identifier || fieldName, 1462 $field = module.get.field(identifier), 1463 $dependsField = (field.depends) 1464 ? module.get.field(field.depends) 1465 : false, 1466 fieldValid = true, 1467 fieldErrors = [] 1468 ; 1469 if(!field.identifier) { 1470 module.debug('Using field name as identifier', identifier); 1471 field.identifier = identifier; 1472 } 1473 if($field.prop('disabled')) { 1474 module.debug('Field is disabled. Skipping', identifier); 1475 fieldValid = true; 1476 } 1477 else if(field.optional && module.is.blank($field)){ 1478 module.debug('Field is optional and blank. Skipping', identifier); 1479 fieldValid = true; 1480 } 1481 else if(field.depends && module.is.empty($dependsField)) { 1482 module.debug('Field depends on another value that is not present or empty. Skipping', $dependsField); 1483 fieldValid = true; 1484 } 1485 else if(field.rules !== undefined) { 1486 $.each(field.rules, function(index, rule) { 1487 if( module.has.field(identifier) && !( module.validate.rule(field, rule) ) ) { 1488 module.debug('Field is invalid', identifier, rule.type); 1489 fieldErrors.push(module.get.prompt(rule, field)); 1490 fieldValid = false; 1491 } 1492 }); 1493 } 1494 if(fieldValid) { 1495 if(showErrors) { 1496 module.remove.prompt(identifier, fieldErrors); 1497 settings.onValid.call($field); 1498 } 1499 } 1500 else { 1501 if(showErrors) { 1502 formErrors = formErrors.concat(fieldErrors); 1503 module.add.prompt(identifier, fieldErrors); 1504 settings.onInvalid.call($field, fieldErrors); 1505 } 1506 return false; 1507 } 1508 return true; 1509 }, 1510 1511 // takes validation rule and returns whether field passes rule 1512 rule: function(field, rule) { 1513 var 1514 $field = module.get.field(field.identifier), 1515 type = rule.type, 1516 value = $field.val(), 1517 isValid = true, 1518 ancillary = module.get.ancillaryValue(rule), 1519 ruleName = module.get.ruleName(rule), 1520 ruleFunction = settings.rules[ruleName] 1521 ; 1522 if( !$.isFunction(ruleFunction) ) { 1523 module.error(error.noRule, ruleName); 1524 return; 1525 } 1526 // cast to string avoiding encoding special values 1527 value = (value === undefined || value === '' || value === null) 1528 ? '' 1529 : $.trim(value + '') 1530 ; 1531 return ruleFunction.call($field, value, ancillary); 1532 } 1533 }, 1534 1535 setting: function(name, value) { 1536 if( $.isPlainObject(name) ) { 1537 $.extend(true, settings, name); 1538 } 1539 else if(value !== undefined) { 1540 settings[name] = value; 1541 } 1542 else { 1543 return settings[name]; 1544 } 1545 }, 1546 internal: function(name, value) { 1547 if( $.isPlainObject(name) ) { 1548 $.extend(true, module, name); 1549 } 1550 else if(value !== undefined) { 1551 module[name] = value; 1552 } 1553 else { 1554 return module[name]; 1555 } 1556 }, 1557 debug: function() { 1558 if(!settings.silent && settings.debug) { 1559 if(settings.performance) { 1560 module.performance.log(arguments); 1561 } 1562 else { 1563 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 1564 module.debug.apply(console, arguments); 1565 } 1566 } 1567 },
vendor: 4,505 bytes, lines 1568-1651
1568 verbose: function() { 1569 if(!settings.silent && settings.verbose && settings.debug) { 1570 if(settings.performance) { 1571 module.performance.log(arguments); 1572 } 1573 else { 1574 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 1575 module.verbose.apply(console, arguments); 1576 } 1577 } 1578 }, 1579 error: function() { 1580 if(!settings.silent) { 1581 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 1582 module.error.apply(console, arguments); 1583 } 1584 }, 1585 performance: { 1586 log: function(message) { 1587 var 1588 currentTime, 1589 executionTime, 1590 previousTime 1591 ; 1592 if(settings.performance) { 1593 currentTime = new Date().getTime(); 1594 previousTime = time || currentTime; 1595 executionTime = currentTime - previousTime; 1596 time = currentTime; 1597 performance.push({ 1598 'Name' : message[0], 1599 'Arguments' : [].slice.call(message, 1) || '', 1600 'Element' : element, 1601 'Execution Time' : executionTime 1602 }); 1603 } 1604 clearTimeout(module.performance.timer); 1605 module.performance.timer = setTimeout(module.performance.display, 500); 1606 }, 1607 display: function() { 1608 var 1609 title = settings.name + ':', 1610 totalTime = 0 1611 ; 1612 time = false; 1613 clearTimeout(module.performance.timer); 1614 $.each(performance, function(index, data) { 1615 totalTime += data['Execution Time']; 1616 }); 1617 title += ' ' + totalTime + 'ms'; 1618 if(moduleSelector) { 1619 title += ' \'' + moduleSelector + '\''; 1620 } 1621 if($allModules.length > 1) { 1622 title += ' ' + '(' + $allModules.length + ')'; 1623 } 1624 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 1625 console.groupCollapsed(title); 1626 if(console.table) { 1627 console.table(performance); 1628 } 1629 else { 1630 $.each(performance, function(index, data) { 1631 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 1632 }); 1633 } 1634 console.groupEnd(); 1635 } 1636 performance = []; 1637 } 1638 }, 1639 invoke: function(query, passedArguments, context) { 1640 var 1641 object = instance, 1642 maxDepth, 1643 found, 1644 response 1645 ; 1646 passedArguments = passedArguments || queryArguments; 1647 context = element || context; 1648 if(typeof query == 'string' && object !== undefined) { 1649 query = query.split(/[\. ]/); 1650 maxDepth = query.length - 1; 1651 $.each(query, function(depth, value) {
vendor: 18,971 bytes, lines 1652-2131
1652 var camelCaseValue = (depth != maxDepth) 1653 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 1654 : query 1655 ; 1656 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 1657 object = object[camelCaseValue]; 1658 } 1659 else if( object[camelCaseValue] !== undefined ) { 1660 found = object[camelCaseValue]; 1661 return false; 1662 } 1663 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 1664 object = object[value]; 1665 } 1666 else if( object[value] !== undefined ) { 1667 found = object[value]; 1668 return false; 1669 } 1670 else { 1671 return false; 1672 } 1673 }); 1674 } 1675 if( $.isFunction( found ) ) { 1676 response = found.apply(context, passedArguments); 1677 } 1678 else if(found !== undefined) { 1679 response = found; 1680 } 1681 if($.isArray(returnedValue)) { 1682 returnedValue.push(response); 1683 } 1684 else if(returnedValue !== undefined) { 1685 returnedValue = [returnedValue, response]; 1686 } 1687 else if(response !== undefined) { 1688 returnedValue = response; 1689 } 1690 return found; 1691 } 1692 }; 1693 module.initialize(); 1694 }) 1695 ; 1696 1697 return (returnedValue !== undefined) 1698 ? returnedValue 1699 : this 1700 ; 1701 }; 1702 1703 $.fn.form.settings = { 1704 1705 name : 'Form', 1706 namespace : 'form', 1707 1708 debug : false, 1709 verbose : false, 1710 performance : true, 1711 1712 fields : false, 1713 1714 keyboardShortcuts : true, 1715 on : 'submit', 1716 inline : false, 1717 1718 delay : 200, 1719 revalidate : true, 1720 1721 transition : 'scale', 1722 duration : 200, 1723 1724 onValid : function() {}, 1725 onInvalid : function() {}, 1726 onSuccess : function() { return true; }, 1727 onFailure : function() { return false; }, 1728 1729 metadata : { 1730 defaultValue : 'default', 1731 validate : 'validate' 1732 }, 1733 1734 regExp: { 1735 htmlID : /^[a-zA-Z][\w:.-]*$/g, 1736 bracket : /\[(.*)\]/i, 1737 decimal : /^\d+\.?\d*$/, 1738 email : /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i, 1739 escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, 1740 flags : /^\/(.*)\/(.*)?/, 1741 integer : /^\-?\d+$/, 1742 number : /^\-?\d*(\.\d+)?$/, 1743 url : /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/i 1744 }, 1745 1746 text: { 1747 unspecifiedRule : 'Please enter a valid value', 1748 unspecifiedField : 'This field' 1749 }, 1750 1751 prompt: { 1752 empty : '{name} must have a value', 1753 checked : '{name} must be checked', 1754 email : '{name} must be a valid e-mail', 1755 url : '{name} must be a valid url', 1756 regExp : '{name} is not formatted correctly', 1757 integer : '{name} must be an integer', 1758 decimal : '{name} must be a decimal number', 1759 number : '{name} must be set to a number', 1760 is : '{name} must be "{ruleValue}"', 1761 isExactly : '{name} must be exactly "{ruleValue}"', 1762 not : '{name} cannot be set to "{ruleValue}"', 1763 notExactly : '{name} cannot be set to exactly "{ruleValue}"', 1764 contain : '{name} cannot contain "{ruleValue}"', 1765 containExactly : '{name} cannot contain exactly "{ruleValue}"', 1766 doesntContain : '{name} must contain "{ruleValue}"', 1767 doesntContainExactly : '{name} must contain exactly "{ruleValue}"', 1768 minLength : '{name} must be at least {ruleValue} characters', 1769 length : '{name} must be at least {ruleValue} characters', 1770 exactLength : '{name} must be exactly {ruleValue} characters', 1771 maxLength : '{name} cannot be longer than {ruleValue} characters', 1772 match : '{name} must match {ruleValue} field', 1773 different : '{name} must have a different value than {ruleValue} field', 1774 creditCard : '{name} must be a valid credit card number', 1775 minCount : '{name} must have at least {ruleValue} choices', 1776 exactCount : '{name} must have exactly {ruleValue} choices', 1777 maxCount : '{name} must have {ruleValue} or less choices' 1778 }, 1779 1780 selector : { 1781 checkbox : 'input[type="checkbox"], input[type="radio"]', 1782 clear : '.clear', 1783 field : 'input, textarea, select', 1784 group : '.field', 1785 input : 'input', 1786 message : '.error.message', 1787 prompt : '.prompt.label', 1788 radio : 'input[type="radio"]', 1789 reset : '.reset:not([type="reset"])', 1790 submit : '.submit:not([type="submit"])', 1791 uiCheckbox : '.ui.checkbox', 1792 uiDropdown : '.ui.dropdown' 1793 }, 1794 1795 className : { 1796 error : 'error', 1797 label : 'ui prompt label', 1798 pressed : 'down', 1799 success : 'success' 1800 }, 1801 1802 error: { 1803 identifier : 'You must specify a string identifier for each field', 1804 method : 'The method you called is not defined.', 1805 noRule : 'There is no rule matching the one you specified', 1806 oldSyntax : 'Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.' 1807 }, 1808 1809 templates: { 1810 1811 // template that produces error message 1812 error: function(errors) { 1813 var 1814 html = '<ul class="list">' 1815 ; 1816 $.each(errors, function(index, value) { 1817 html += '<li>' + value + '</li>'; 1818 }); 1819 html += '</ul>'; 1820 return $(html); 1821 }, 1822 1823 // template that produces label 1824 prompt: function(errors) { 1825 return $('<div/>') 1826 .addClass('ui basic red pointing prompt label') 1827 .html(errors[0]) 1828 ; 1829 } 1830 }, 1831 1832 rules: { 1833 1834 // is not empty or blank string 1835 empty: function(value) { 1836 return !(value === undefined || '' === value || $.isArray(value) && value.length === 0); 1837 }, 1838 1839 // checkbox checked 1840 checked: function() { 1841 return ($(this).filter(':checked').length > 0); 1842 }, 1843 1844 // is most likely an email 1845 email: function(value){ 1846 return $.fn.form.settings.regExp.email.test(value); 1847 }, 1848 1849 // value is most likely url 1850 url: function(value) { 1851 return $.fn.form.settings.regExp.url.test(value); 1852 }, 1853 1854 // matches specified regExp 1855 regExp: function(value, regExp) { 1856 if(regExp instanceof RegExp) { 1857 return value.match(regExp); 1858 } 1859 var 1860 regExpParts = regExp.match($.fn.form.settings.regExp.flags), 1861 flags 1862 ; 1863 // regular expression specified as /baz/gi (flags) 1864 if(regExpParts) { 1865 regExp = (regExpParts.length >= 2) 1866 ? regExpParts[1] 1867 : regExp 1868 ; 1869 flags = (regExpParts.length >= 3) 1870 ? regExpParts[2] 1871 : '' 1872 ; 1873 } 1874 return value.match( new RegExp(regExp, flags) ); 1875 }, 1876 1877 // is valid integer or matches range 1878 integer: function(value, range) { 1879 var 1880 intRegExp = $.fn.form.settings.regExp.integer, 1881 min, 1882 max, 1883 parts 1884 ; 1885 if( !range || ['', '..'].indexOf(range) !== -1) { 1886 // do nothing 1887 } 1888 else if(range.indexOf('..') == -1) { 1889 if(intRegExp.test(range)) { 1890 min = max = range - 0; 1891 } 1892 } 1893 else { 1894 parts = range.split('..', 2); 1895 if(intRegExp.test(parts[0])) { 1896 min = parts[0] - 0; 1897 } 1898 if(intRegExp.test(parts[1])) { 1899 max = parts[1] - 0; 1900 } 1901 } 1902 return ( 1903 intRegExp.test(value) && 1904 (min === undefined || value >= min) && 1905 (max === undefined || value <= max) 1906 ); 1907 }, 1908 1909 // is valid number (with decimal) 1910 decimal: function(value) { 1911 return $.fn.form.settings.regExp.decimal.test(value); 1912 }, 1913 1914 // is valid number 1915 number: function(value) { 1916 return $.fn.form.settings.regExp.number.test(value); 1917 }, 1918 1919 // is value (case insensitive) 1920 is: function(value, text) { 1921 text = (typeof text == 'string') 1922 ? text.toLowerCase() 1923 : text 1924 ; 1925 value = (typeof value == 'string') 1926 ? value.toLowerCase() 1927 : value 1928 ; 1929 return (value == text); 1930 }, 1931 1932 // is value 1933 isExactly: function(value, text) { 1934 return (value == text); 1935 }, 1936 1937 // value is not another value (case insensitive) 1938 not: function(value, notValue) { 1939 value = (typeof value == 'string') 1940 ? value.toLowerCase() 1941 : value 1942 ; 1943 notValue = (typeof notValue == 'string') 1944 ? notValue.toLowerCase() 1945 : notValue 1946 ; 1947 return (value != notValue); 1948 }, 1949 1950 // value is not another value (case sensitive) 1951 notExactly: function(value, notValue) { 1952 return (value != notValue); 1953 }, 1954 1955 // value contains text (insensitive) 1956 contains: function(value, text) { 1957 // escape regex characters 1958 text = text.replace($.fn.form.settings.regExp.escape, "\\$&"); 1959 return (value.search( new RegExp(text, 'i') ) !== -1); 1960 }, 1961 1962 // value contains text (case sensitive) 1963 containsExactly: function(value, text) { 1964 // escape regex characters 1965 text = text.replace($.fn.form.settings.regExp.escape, "\\$&"); 1966 return (value.search( new RegExp(text) ) !== -1); 1967 }, 1968 1969 // value contains text (insensitive) 1970 doesntContain: function(value, text) { 1971 // escape regex characters 1972 text = text.replace($.fn.form.settings.regExp.escape, "\\$&"); 1973 return (value.search( new RegExp(text, 'i') ) === -1); 1974 }, 1975 1976 // value contains text (case sensitive) 1977 doesntContainExactly: function(value, text) { 1978 // escape regex characters 1979 text = text.replace($.fn.form.settings.regExp.escape, "\\$&"); 1980 return (value.search( new RegExp(text) ) === -1); 1981 }, 1982 1983 // is at least string length 1984 minLength: function(value, requiredLength) { 1985 return (value !== undefined) 1986 ? (value.length >= requiredLength) 1987 : false 1988 ; 1989 }, 1990 1991 // see rls notes for 2.0.6 (this is a duplicate of minLength) 1992 length: function(value, requiredLength) { 1993 return (value !== undefined) 1994 ? (value.length >= requiredLength) 1995 : false 1996 ; 1997 }, 1998 1999 // is exactly length 2000 exactLength: function(value, requiredLength) { 2001 return (value !== undefined) 2002 ? (value.length == requiredLength) 2003 : false 2004 ; 2005 }, 2006 2007 // is less than length 2008 maxLength: function(value, maxLength) { 2009 return (value !== undefined) 2010 ? (value.length <= maxLength) 2011 : false 2012 ; 2013 }, 2014 2015 // matches another field 2016 match: function(value, identifier) { 2017 var 2018 $form = $(this), 2019 matchingValue 2020 ; 2021 if( $('[data-validate="'+ identifier +'"]').length > 0 ) { 2022 matchingValue = $('[data-validate="'+ identifier +'"]').val(); 2023 } 2024 else if($('#' + identifier).length > 0) { 2025 matchingValue = $('#' + identifier).val(); 2026 } 2027 else if($('[name="' + identifier +'"]').length > 0) { 2028 matchingValue = $('[name="' + identifier + '"]').val(); 2029 } 2030 else if( $('[name="' + identifier +'[]"]').length > 0 ) { 2031 matchingValue = $('[name="' + identifier +'[]"]'); 2032 } 2033 return (matchingValue !== undefined) 2034 ? ( value.toString() == matchingValue.toString() ) 2035 : false 2036 ; 2037 }, 2038 2039 // different than another field 2040 different: function(value, identifier) { 2041 // use either id or name of field 2042 var 2043 $form = $(this), 2044 matchingValue 2045 ; 2046 if( $('[data-validate="'+ identifier +'"]').length > 0 ) { 2047 matchingValue = $('[data-validate="'+ identifier +'"]').val(); 2048 } 2049 else if($('#' + identifier).length > 0) { 2050 matchingValue = $('#' + identifier).val(); 2051 } 2052 else if($('[name="' + identifier +'"]').length > 0) { 2053 matchingValue = $('[name="' + identifier + '"]').val(); 2054 } 2055 else if( $('[name="' + identifier +'[]"]').length > 0 ) { 2056 matchingValue = $('[name="' + identifier +'[]"]'); 2057 } 2058 return (matchingValue !== undefined) 2059 ? ( value.toString() !== matchingValue.toString() ) 2060 : false 2061 ; 2062 }, 2063 2064 creditCard: function(cardNumber, cardTypes) { 2065 var 2066 cards = { 2067 visa: { 2068 pattern : /^4/, 2069 length : [16] 2070 }, 2071 amex: { 2072 pattern : /^3[47]/, 2073 length : [15] 2074 }, 2075 mastercard: { 2076 pattern : /^5[1-5]/, 2077 length : [16] 2078 }, 2079 discover: { 2080 pattern : /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/, 2081 length : [16] 2082 }, 2083 unionPay: { 2084 pattern : /^(62|88)/, 2085 length : [16, 17, 18, 19] 2086 }, 2087 jcb: { 2088 pattern : /^35(2[89]|[3-8][0-9])/, 2089 length : [16] 2090 }, 2091 maestro: { 2092 pattern : /^(5018|5020|5038|6304|6759|676[1-3])/, 2093 length : [12, 13, 14, 15, 16, 17, 18, 19] 2094 }, 2095 dinersClub: { 2096 pattern : /^(30[0-5]|^36)/, 2097 length : [14] 2098 }, 2099 laser: { 2100 pattern : /^(6304|670[69]|6771)/, 2101 length : [16, 17, 18, 19] 2102 }, 2103 visaElectron: { 2104 pattern : /^(4026|417500|4508|4844|491(3|7))/, 2105 length : [16] 2106 } 2107 }, 2108 valid = {}, 2109 validCard = false, 2110 requiredTypes = (typeof cardTypes == 'string') 2111 ? cardTypes.split(',') 2112 : false, 2113 unionPay, 2114 validation 2115 ; 2116 2117 if(typeof cardNumber !== 'string' || cardNumber.length === 0) { 2118 return; 2119 } 2120 2121 // allow dashes in card 2122 cardNumber = cardNumber.replace(/[\-]/g, ''); 2123 2124 // verify card types 2125 if(requiredTypes) { 2126 $.each(requiredTypes, function(index, type){ 2127 // verify each card type 2128 validation = cards[type]; 2129 if(validation) { 2130 valid = { 2131 length : ($.inArray(cardNumber.length, val
vendor: 16,384 bytes, lines 2131-2503
2131idation.length) !== -1), 2132 pattern : (cardNumber.search(validation.pattern) !== -1) 2133 }; 2134 if(valid.length && valid.pattern) { 2135 validCard = true; 2136 } 2137 } 2138 }); 2139 2140 if(!validCard) { 2141 return false; 2142 } 2143 } 2144 2145 // skip luhn for UnionPay 2146 unionPay = { 2147 number : ($.inArray(cardNumber.length, cards.unionPay.length) !== -1), 2148 pattern : (cardNumber.search(cards.unionPay.pattern) !== -1) 2149 }; 2150 if(unionPay.number && unionPay.pattern) { 2151 return true; 2152 } 2153 2154 // verify luhn, adapted from <https://gist.github.com/2134376> 2155 var 2156 length = cardNumber.length, 2157 multiple = 0, 2158 producedValue = [ 2159 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2160 [0, 2, 4, 6, 8, 1, 3, 5, 7, 9] 2161 ], 2162 sum = 0 2163 ; 2164 while (length--) { 2165 sum += producedValue[multiple][parseInt(cardNumber.charAt(length), 10)]; 2166 multiple ^= 1; 2167 } 2168 return (sum % 10 === 0 && sum > 0); 2169 }, 2170 2171 minCount: function(value, minCount) { 2172 if(minCount == 0) { 2173 return true; 2174 } 2175 if(minCount == 1) { 2176 return (value !== ''); 2177 } 2178 return (value.split(',').length >= minCount); 2179 }, 2180 2181 exactCount: function(value, exactCount) { 2182 if(exactCount == 0) { 2183 return (value === ''); 2184 } 2185 if(exactCount == 1) { 2186 return (value !== '' && value.search(',') === -1); 2187 } 2188 return (value.split(',').length == exactCount); 2189 }, 2190 2191 maxCount: function(value, maxCount) { 2192 if(maxCount == 0) { 2193 return false; 2194 } 2195 if(maxCount == 1) { 2196 return (value.search(',') === -1); 2197 } 2198 return (value.split(',').length <= maxCount); 2199 } 2200 } 2201 2202 }; 2203 2204})( jQuery, window, document ); 2205 2206/*! 2207 * # Semantic UI 2.2.12 - Accordion 2208 * http://github.com/semantic-org/semantic-ui/ 2209 * 2210 * 2211 * Released under the MIT license 2212 * http://opensource.org/licenses/MIT 2213 * 2214 */ 2215 2216;(function ($, window, document, undefined) { 2217 2218 "use strict"; 2219 2220 window = (typeof window != 'undefined' && window.Math == Math) 2221 ? window 2222 : (typeof self != 'undefined' && self.Math == Math) 2223 ? self 2224 : Function('return this')() 2225 ; 2226 2227 $.fn.accordion = function(parameters) { 2228 var 2229 $allModules = $(this), 2230 2231 time = new Date().getTime(), 2232 performance = [], 2233 2234 query = arguments[0], 2235 methodInvoked = (typeof query == 'string'), 2236 queryArguments = [].slice.call(arguments, 1), 2237 2238 requestAnimationFrame = window.requestAnimationFrame 2239 || window.mozRequestAnimationFrame 2240 || window.webkitRequestAnimationFrame 2241 || window.msRequestAnimationFrame 2242 || function(callback) { setTimeout(callback, 0); }, 2243 2244 returnedValue 2245 ; 2246 $allModules 2247 .each(function() { 2248 var 2249 settings = ( $.isPlainObject(parameters) ) 2250 ? $.extend(true, {}, $.fn.accordion.settings, parameters) 2251 : $.extend({}, $.fn.accordion.settings), 2252 2253 className = settings.className, 2254 namespace = settings.namespace, 2255 selector = settings.selector, 2256 error = settings.error, 2257 2258 eventNamespace = '.' + namespace, 2259 moduleNamespace = 'module-' + namespace, 2260 moduleSelector = $allModules.selector || '', 2261 2262 $module = $(this), 2263 $title = $module.find(selector.title), 2264 $content = $module.find(selector.content), 2265 2266 element = this, 2267 instance = $module.data(moduleNamespace), 2268 observer, 2269 module 2270 ; 2271 2272 module = { 2273 2274 initialize: function() { 2275 module.debug('Initializing', $module); 2276 module.bind.events(); 2277 if(settings.observeChanges) { 2278 module.observeChanges(); 2279 } 2280 module.instantiate(); 2281 }, 2282 2283 instantiate: function() { 2284 instance = module; 2285 $module 2286 .data(moduleNamespace, module) 2287 ; 2288 }, 2289 2290 destroy: function() { 2291 module.debug('Destroying previous instance', $module); 2292 $module 2293 .off(eventNamespace) 2294 .removeData(moduleNamespace) 2295 ; 2296 }, 2297 2298 refresh: function() { 2299 $title = $module.find(selector.title); 2300 $content = $module.find(selector.content); 2301 }, 2302 2303 observeChanges: function() { 2304 if('MutationObserver' in window) { 2305 observer = new MutationObserver(function(mutations) { 2306 module.debug('DOM tree modified, updating selector cache'); 2307 module.refresh(); 2308 }); 2309 observer.observe(element, { 2310 childList : true, 2311 subtree : true 2312 }); 2313 module.debug('Setting up mutation observer', observer); 2314 } 2315 }, 2316 2317 bind: { 2318 events: function() { 2319 module.debug('Binding delegated events'); 2320 $module 2321 .on(settings.on + eventNamespace, selector.trigger, module.event.click) 2322 ; 2323 } 2324 }, 2325 2326 event: { 2327 click: function() { 2328 module.toggle.call(this); 2329 } 2330 }, 2331 2332 toggle: function(query) { 2333 var 2334 $activeTitle = (query !== undefined) 2335 ? (typeof query === 'number') 2336 ? $title.eq(query) 2337 : $(query).closest(selector.title) 2338 : $(this).closest(selector.title), 2339 $activeContent = $activeTitle.next($content), 2340 isAnimating = $activeContent.hasClass(className.animating), 2341 isActive = $activeContent.hasClass(className.active), 2342 isOpen = (isActive && !isAnimating), 2343 isOpening = (!isActive && isAnimating) 2344 ; 2345 module.debug('Toggling visibility of content', $activeTitle); 2346 if(isOpen || isOpening) { 2347 if(settings.collapsible) { 2348 module.close.call($activeTitle); 2349 } 2350 else { 2351 module.debug('Cannot close accordion content collapsing is disabled'); 2352 } 2353 } 2354 else { 2355 module.open.call($activeTitle); 2356 } 2357 }, 2358 2359 open: function(query) { 2360 var 2361 $activeTitle = (query !== undefined) 2362 ? (typeof query === 'number') 2363 ? $title.eq(query) 2364 : $(query).closest(selector.title) 2365 : $(this).closest(selector.title), 2366 $activeContent = $activeTitle.next($content), 2367 isAnimating = $activeContent.hasClass(className.animating), 2368 isActive = $activeContent.hasClass(className.active), 2369 isOpen = (isActive || isAnimating) 2370 ; 2371 if(isOpen) { 2372 module.debug('Accordion already open, skipping', $activeContent); 2373 return; 2374 } 2375 module.debug('Opening accordion content', $activeTitle); 2376 settings.onOpening.call($activeContent); 2377 if(settings.exclusive) { 2378 module.closeOthers.call($activeTitle); 2379 } 2380 $activeTitle 2381 .addClass(className.active) 2382 ; 2383 $activeContent 2384 .stop(true, true) 2385 .addClass(className.animating) 2386 ; 2387 if(settings.animateChildren) { 2388 if($.fn.transition !== undefined && $module.transition('is supported')) { 2389 $activeContent 2390 .children() 2391 .transition({ 2392 animation : 'fade in', 2393 queue : false, 2394 useFailSafe : true, 2395 debug : settings.debug, 2396 verbose : settings.verbose, 2397 duration : settings.duration 2398 }) 2399 ; 2400 } 2401 else { 2402 $activeContent 2403 .children() 2404 .stop(true, true) 2405 .animate({ 2406 opacity: 1 2407 }, settings.duration, module.resetOpacity) 2408 ; 2409 } 2410 } 2411 $activeContent 2412 .slideDown(settings.duration, settings.easing, function() { 2413 $activeContent 2414 .removeClass(className.animating) 2415 .addClass(className.active) 2416 ; 2417 module.reset.display.call(this); 2418 settings.onOpen.call(this); 2419 settings.onChange.call(this); 2420 }) 2421 ; 2422 }, 2423 2424 close: function(query) { 2425 var 2426 $activeTitle = (query !== undefined) 2427 ? (typeof query === 'number') 2428 ? $title.eq(query) 2429 : $(query).closest(selector.title) 2430 : $(this).closest(selector.title), 2431 $activeContent = $activeTitle.next($content), 2432 isAnimating = $activeContent.hasClass(className.animating), 2433 isActive = $activeContent.hasClass(className.active), 2434 isOpening = (!isActive && isAnimating), 2435 isClosing = (isActive && isAnimating) 2436 ; 2437 if((isActive || isOpening) && !isClosing) { 2438 module.debug('Closing accordion content', $activeContent); 2439 settings.onClosing.call($activeContent); 2440 $activeTitle 2441 .removeClass(className.active) 2442 ; 2443 $activeContent 2444 .stop(true, true) 2445 .addClass(className.animating) 2446 ; 2447 if(settings.animateChildren) { 2448 if($.fn.transition !== undefined && $module.transition('is supported')) { 2449 $activeContent 2450 .children() 2451 .transition({ 2452 animation : 'fade out', 2453 queue : false, 2454 useFailSafe : true, 2455 debug : settings.debug, 2456 verbose : settings.verbose, 2457 duration : settings.duration 2458 }) 2459 ; 2460 } 2461 else { 2462 $activeContent 2463 .children() 2464 .stop(true, true) 2465 .animate({ 2466 opacity: 0 2467 }, settings.duration, module.resetOpacity) 2468 ; 2469 } 2470 } 2471 $activeContent 2472 .slideUp(settings.duration, settings.easing, function() { 2473 $activeContent 2474 .removeClass(className.animating) 2475 .removeClass(className.active) 2476 ; 2477 module.reset.display.call(this); 2478 settings.onClose.call(this); 2479 settings.onChange.call(this); 2480 }) 2481 ; 2482 } 2483 }, 2484 2485 closeOthers: function(index) { 2486 var 2487 $activeTitle = (index !== undefined) 2488 ? $title.eq(index) 2489 : $(this).closest(selector.title), 2490 $parentTitles = $activeTitle.parents(selector.content).prev(selector.title), 2491 $activeAccordion = $activeTitle.closest(selector.accordion), 2492 activeSelector = selector.title + '.' + className.active + ':visible', 2493 activeContent = selector.content + '.' + className.active + ':visible', 2494 $openTitles, 2495 $nestedTitles, 2496 $openContents 2497 ; 2498 if(settings.closeNested) { 2499 $openTitles = $activeAccordion.find(activeSelector).not($parentTitles); 2500 $openContents = $openTitles.next($content); 2501 } 2502 else { 2503 $openTitles =
vendor: 9,831 bytes, lines 2503-2697
2503 $activeAccordion.find(activeSelector).not($parentTitles); 2504 $nestedTitles = $activeAccordion.find(activeContent).find(activeSelector).not($parentTitles); 2505 $openTitles = $openTitles.not($nestedTitles); 2506 $openContents = $openTitles.next($content); 2507 } 2508 if( ($openTitles.length > 0) ) { 2509 module.debug('Exclusive enabled, closing other content', $openTitles); 2510 $openTitles 2511 .removeClass(className.active) 2512 ; 2513 $openContents 2514 .removeClass(className.animating) 2515 .stop(true, true) 2516 ; 2517 if(settings.animateChildren) { 2518 if($.fn.transition !== undefined && $module.transition('is supported')) { 2519 $openContents 2520 .children() 2521 .transition({ 2522 animation : 'fade out', 2523 useFailSafe : true, 2524 debug : settings.debug, 2525 verbose : settings.verbose, 2526 duration : settings.duration 2527 }) 2528 ; 2529 } 2530 else { 2531 $openContents 2532 .children() 2533 .stop(true, true) 2534 .animate({ 2535 opacity: 0 2536 }, settings.duration, module.resetOpacity) 2537 ; 2538 } 2539 } 2540 $openContents 2541 .slideUp(settings.duration , settings.easing, function() { 2542 $(this).removeClass(className.active); 2543 module.reset.display.call(this); 2544 }) 2545 ; 2546 } 2547 }, 2548 2549 reset: { 2550 2551 display: function() { 2552 module.verbose('Removing inline display from element', this); 2553 $(this).css('display', ''); 2554 if( $(this).attr('style') === '') { 2555 $(this) 2556 .attr('style', '') 2557 .removeAttr('style') 2558 ; 2559 } 2560 }, 2561 2562 opacity: function() { 2563 module.verbose('Removing inline opacity from element', this); 2564 $(this).css('opacity', ''); 2565 if( $(this).attr('style') === '') { 2566 $(this) 2567 .attr('style', '') 2568 .removeAttr('style') 2569 ; 2570 } 2571 }, 2572 2573 }, 2574 2575 setting: function(name, value) { 2576 module.debug('Changing setting', name, value); 2577 if( $.isPlainObject(name) ) { 2578 $.extend(true, settings, name); 2579 } 2580 else if(value !== undefined) { 2581 if($.isPlainObject(settings[name])) { 2582 $.extend(true, settings[name], value); 2583 } 2584 else { 2585 settings[name] = value; 2586 } 2587 } 2588 else { 2589 return settings[name]; 2590 } 2591 }, 2592 internal: function(name, value) { 2593 module.debug('Changing internal', name, value); 2594 if(value !== undefined) { 2595 if( $.isPlainObject(name) ) { 2596 $.extend(true, module, name); 2597 } 2598 else { 2599 module[name] = value; 2600 } 2601 } 2602 else { 2603 return module[name]; 2604 } 2605 }, 2606 debug: function() { 2607 if(!settings.silent && settings.debug) { 2608 if(settings.performance) { 2609 module.performance.log(arguments); 2610 } 2611 else { 2612 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 2613 module.debug.apply(console, arguments); 2614 } 2615 } 2616 }, 2617 verbose: function() { 2618 if(!settings.silent && settings.verbose && settings.debug) { 2619 if(settings.performance) { 2620 module.performance.log(arguments); 2621 } 2622 else { 2623 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 2624 module.verbose.apply(console, arguments); 2625 } 2626 } 2627 }, 2628 error: function() { 2629 if(!settings.silent) { 2630 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 2631 module.error.apply(console, arguments); 2632 } 2633 }, 2634 performance: { 2635 log: function(message) { 2636 var 2637 currentTime, 2638 executionTime, 2639 previousTime 2640 ; 2641 if(settings.performance) { 2642 currentTime = new Date().getTime(); 2643 previousTime = time || currentTime; 2644 executionTime = currentTime - previousTime; 2645 time = currentTime; 2646 performance.push({ 2647 'Name' : message[0], 2648 'Arguments' : [].slice.call(message, 1) || '', 2649 'Element' : element, 2650 'Execution Time' : executionTime 2651 }); 2652 } 2653 clearTimeout(module.performance.timer); 2654 module.performance.timer = setTimeout(module.performance.display, 500); 2655 }, 2656 display: function() { 2657 var 2658 title = settings.name + ':', 2659 totalTime = 0 2660 ; 2661 time = false; 2662 clearTimeout(module.performance.timer); 2663 $.each(performance, function(index, data) { 2664 totalTime += data['Execution Time']; 2665 }); 2666 title += ' ' + totalTime + 'ms'; 2667 if(moduleSelector) { 2668 title += ' \'' + moduleSelector + '\''; 2669 } 2670 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 2671 console.groupCollapsed(title); 2672 if(console.table) { 2673 console.table(performance); 2674 } 2675 else { 2676 $.each(performance, function(index, data) { 2677 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 2678 }); 2679 } 2680 console.groupEnd(); 2681 } 2682 performance = []; 2683 } 2684 }, 2685 invoke: function(query, passedArguments, context) { 2686 var 2687 object = instance, 2688 maxDepth, 2689 found, 2690 response 2691 ; 2692 passedArguments = passedArguments || queryArguments; 2693 context = element || context; 2694 if(typeof query == 'string' && object !== undefined) { 2695 query = query.split(/[\. ]/); 2696 maxDepth = query.length - 1; 2697 $.each(query, function(depth, value) {
vendor: 10,796 bytes, lines 2698-2980
2698 var camelCaseValue = (depth != maxDepth) 2699 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 2700 : query 2701 ; 2702 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 2703 object = object[camelCaseValue]; 2704 } 2705 else if( object[camelCaseValue] !== undefined ) { 2706 found = object[camelCaseValue]; 2707 return false; 2708 } 2709 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 2710 object = object[value]; 2711 } 2712 else if( object[value] !== undefined ) { 2713 found = object[value]; 2714 return false; 2715 } 2716 else { 2717 module.error(error.method, query); 2718 return false; 2719 } 2720 }); 2721 } 2722 if ( $.isFunction( found ) ) { 2723 response = found.apply(context, passedArguments); 2724 } 2725 else if(found !== undefined) { 2726 response = found; 2727 } 2728 if($.isArray(returnedValue)) { 2729 returnedValue.push(response); 2730 } 2731 else if(returnedValue !== undefined) { 2732 returnedValue = [returnedValue, response]; 2733 } 2734 else if(response !== undefined) { 2735 returnedValue = response; 2736 } 2737 return found; 2738 } 2739 }; 2740 if(methodInvoked) { 2741 if(instance === undefined) { 2742 module.initialize(); 2743 } 2744 module.invoke(query); 2745 } 2746 else { 2747 if(instance !== undefined) { 2748 instance.invoke('destroy'); 2749 } 2750 module.initialize(); 2751 } 2752 }) 2753 ; 2754 return (returnedValue !== undefined) 2755 ? returnedValue 2756 : this 2757 ; 2758 }; 2759 2760 $.fn.accordion.settings = { 2761 2762 name : 'Accordion', 2763 namespace : 'accordion', 2764 2765 silent : false, 2766 debug : false, 2767 verbose : false, 2768 performance : true, 2769 2770 on : 'click', // event on title that opens accordion 2771 2772 observeChanges : true, // whether accordion should automatically refresh on DOM insertion 2773 2774 exclusive : true, // whether a single accordion content panel should be open at once 2775 collapsible : true, // whether accordion content can be closed 2776 closeNested : false, // whether nested content should be closed when a panel is closed 2777 animateChildren : true, // whether children opacity should be animated 2778 2779 duration : 350, // duration of animation 2780 easing : 'easeOutQuad', // easing equation for animation 2781 2782 2783 onOpening : function(){}, // callback before open animation 2784 onOpen : function(){}, // callback after open animation 2785 onClosing : function(){}, // callback before closing animation 2786 onClose : function(){}, // callback after closing animation 2787 onChange : function(){}, // callback after closing or opening animation 2788 2789 error: { 2790 method : 'The method you called is not defined' 2791 }, 2792 2793 className : { 2794 active : 'active', 2795 animating : 'animating' 2796 }, 2797 2798 selector : { 2799 accordion : '.accordion', 2800 title : '.title', 2801 trigger : '.title', 2802 content : '.content' 2803 } 2804 2805 }; 2806 2807// Adds easing 2808 $.extend( $.easing, { 2809 easeOutQuad: function (x, t, b, c, d) { 2810 return -c *(t/=d)*(t-2) + b; 2811 } 2812 }); 2813 2814})( jQuery, window, document ); 2815 2816 2817/*! 2818 * # Semantic UI 2.2.12 - Checkbox 2819 * http://github.com/semantic-org/semantic-ui/ 2820 * 2821 * 2822 * Released under the MIT license 2823 * http://opensource.org/licenses/MIT 2824 * 2825 */ 2826 2827;(function ($, window, document, undefined) { 2828 2829 "use strict"; 2830 2831 window = (typeof window != 'undefined' && window.Math == Math) 2832 ? window 2833 : (typeof self != 'undefined' && self.Math == Math) 2834 ? self 2835 : Function('return this')() 2836 ; 2837 2838 $.fn.checkbox = function(parameters) { 2839 var 2840 $allModules = $(this), 2841 moduleSelector = $allModules.selector || '', 2842 2843 time = new Date().getTime(), 2844 performance = [], 2845 2846 query = arguments[0], 2847 methodInvoked = (typeof query == 'string'), 2848 queryArguments = [].slice.call(arguments, 1), 2849 returnedValue 2850 ; 2851 2852 $allModules 2853 .each(function() { 2854 var 2855 settings = $.extend(true, {}, $.fn.checkbox.settings, parameters), 2856 2857 className = settings.className, 2858 namespace = settings.namespace, 2859 selector = settings.selector, 2860 error = settings.error, 2861 2862 eventNamespace = '.' + namespace, 2863 moduleNamespace = 'module-' + namespace, 2864 2865 $module = $(this), 2866 $label = $(this).children(selector.label), 2867 $input = $(this).children(selector.input), 2868 input = $input[0], 2869 2870 initialLoad = false, 2871 shortcutPressed = false, 2872 instance = $module.data(moduleNamespace), 2873 2874 observer, 2875 element = this, 2876 module 2877 ; 2878 2879 module = { 2880 2881 initialize: function() { 2882 module.verbose('Initializing checkbox', settings); 2883 2884 module.create.label(); 2885 module.bind.events(); 2886 2887 module.set.tabbable(); 2888 module.hide.input(); 2889 2890 module.observeChanges(); 2891 module.instantiate(); 2892 module.setup(); 2893 }, 2894 2895 instantiate: function() { 2896 module.verbose('Storing instance of module', module); 2897 instance = module; 2898 $module 2899 .data(moduleNamespace, module) 2900 ; 2901 }, 2902 2903 destroy: function() { 2904 module.verbose('Destroying module'); 2905 module.unbind.events(); 2906 module.show.input(); 2907 $module.removeData(moduleNamespace); 2908 }, 2909 2910 fix: { 2911 reference: function() { 2912 if( $module.is(selector.input) ) { 2913 module.debug('Behavior called on <input> adjusting invoked element'); 2914 $module = $module.closest(selector.checkbox); 2915 module.refresh(); 2916 } 2917 } 2918 }, 2919 2920 setup: function() { 2921 module.set.initialLoad(); 2922 if( module.is.indeterminate() ) { 2923 module.debug('Initial value is indeterminate'); 2924 module.indeterminate(); 2925 } 2926 else if( module.is.checked() ) { 2927 module.debug('Initial value is checked'); 2928 module.check(); 2929 } 2930 else { 2931 module.debug('Initial value is unchecked'); 2932 module.uncheck(); 2933 } 2934 module.remove.initialLoad(); 2935 }, 2936 2937 refresh: function() { 2938 $label = $module.children(selector.label); 2939 $input = $module.children(selector.input); 2940 input = $input[0]; 2941 }, 2942 2943 hide: { 2944 input: function() { 2945 module.verbose('Modifying <input> z-index to be unselectable'); 2946 $input.addClass(className.hidden); 2947 } 2948 }, 2949 show: { 2950 input: function() { 2951 module.verbose('Modifying <input> z-index to be selectable'); 2952 $input.removeClass(className.hidden); 2953 } 2954 }, 2955 2956 observeChanges: function() { 2957 if('MutationObserver' in window) { 2958 observer = new MutationObserver(function(mutations) { 2959 module.debug('DOM tree modified, updating selector cache'); 2960 module.refresh(); 2961 }); 2962 observer.observe(element, { 2963 childList : true, 2964 subtree : true 2965 }); 2966 module.debug('Setting up mutation observer', observer); 2967 } 2968 }, 2969 2970 attachEvents: function(selector, event) { 2971 var 2972 $element = $(selector) 2973 ; 2974 event = $.isFunction(module[event]) 2975 ? module[event] 2976 : module.toggle 2977 ; 2978 if($element.length > 0) { 2979 module.debug('Attaching checkbox events to element', selector, event); 2980 $element
vendor: 22,107 bytes, lines 2981-3445
2981 .on('click' + eventNamespace, event) 2982 ; 2983 } 2984 else { 2985 module.error(error.notFound); 2986 } 2987 }, 2988 2989 event: { 2990 click: function(event) { 2991 var 2992 $target = $(event.target) 2993 ; 2994 if( $target.is(selector.input) ) { 2995 module.verbose('Using default check action on initialized checkbox'); 2996 return; 2997 } 2998 if( $target.is(selector.link) ) { 2999 module.debug('Clicking link inside checkbox, skipping toggle'); 3000 return; 3001 } 3002 module.toggle(); 3003 $input.focus(); 3004 event.preventDefault(); 3005 }, 3006 keydown: function(event) { 3007 var 3008 key = event.which, 3009 keyCode = { 3010 enter : 13, 3011 space : 32, 3012 escape : 27 3013 } 3014 ; 3015 if(key == keyCode.escape) { 3016 module.verbose('Escape key pressed blurring field'); 3017 $input.blur(); 3018 shortcutPressed = true; 3019 } 3020 else if(!event.ctrlKey && ( key == keyCode.space || key == keyCode.enter) ) { 3021 module.verbose('Enter/space key pressed, toggling checkbox'); 3022 module.toggle(); 3023 shortcutPressed = true; 3024 } 3025 else { 3026 shortcutPressed = false; 3027 } 3028 }, 3029 keyup: function(event) { 3030 if(shortcutPressed) { 3031 event.preventDefault(); 3032 } 3033 } 3034 }, 3035 3036 check: function() { 3037 if( !module.should.allowCheck() ) { 3038 return; 3039 } 3040 module.debug('Checking checkbox', $input); 3041 module.set.checked(); 3042 if( !module.should.ignoreCallbacks() ) { 3043 settings.onChecked.call(input); 3044 settings.onChange.call(input); 3045 } 3046 }, 3047 3048 uncheck: function() { 3049 if( !module.should.allowUncheck() ) { 3050 return; 3051 } 3052 module.debug('Unchecking checkbox'); 3053 module.set.unchecked(); 3054 if( !module.should.ignoreCallbacks() ) { 3055 settings.onUnchecked.call(input); 3056 settings.onChange.call(input); 3057 } 3058 }, 3059 3060 indeterminate: function() { 3061 if( module.should.allowIndeterminate() ) { 3062 module.debug('Checkbox is already indeterminate'); 3063 return; 3064 } 3065 module.debug('Making checkbox indeterminate'); 3066 module.set.indeterminate(); 3067 if( !module.should.ignoreCallbacks() ) { 3068 settings.onIndeterminate.call(input); 3069 settings.onChange.call(input); 3070 } 3071 }, 3072 3073 determinate: function() { 3074 if( module.should.allowDeterminate() ) { 3075 module.debug('Checkbox is already determinate'); 3076 return; 3077 } 3078 module.debug('Making checkbox determinate'); 3079 module.set.determinate(); 3080 if( !module.should.ignoreCallbacks() ) { 3081 settings.onDeterminate.call(input); 3082 settings.onChange.call(input); 3083 } 3084 }, 3085 3086 enable: function() { 3087 if( module.is.enabled() ) { 3088 module.debug('Checkbox is already enabled'); 3089 return; 3090 } 3091 module.debug('Enabling checkbox'); 3092 module.set.enabled(); 3093 settings.onEnable.call(input); 3094 // preserve legacy callbacks 3095 settings.onEnabled.call(input); 3096 }, 3097 3098 disable: function() { 3099 if( module.is.disabled() ) { 3100 module.debug('Checkbox is already disabled'); 3101 return; 3102 } 3103 module.debug('Disabling checkbox'); 3104 module.set.disabled(); 3105 settings.onDisable.call(input); 3106 // preserve legacy callbacks 3107 settings.onDisabled.call(input); 3108 }, 3109 3110 get: { 3111 radios: function() { 3112 var 3113 name = module.get.name() 3114 ; 3115 return $('input[name="' + name + '"]').closest(selector.checkbox); 3116 }, 3117 otherRadios: function() { 3118 return module.get.radios().not($module); 3119 }, 3120 name: function() { 3121 return $input.attr('name'); 3122 } 3123 }, 3124 3125 is: { 3126 initialLoad: function() { 3127 return initialLoad; 3128 }, 3129 radio: function() { 3130 return ($input.hasClass(className.radio) || $input.attr('type') == 'radio'); 3131 }, 3132 indeterminate: function() { 3133 return $input.prop('indeterminate') !== undefined && $input.prop('indeterminate'); 3134 }, 3135 checked: function() { 3136 return $input.prop('checked') !== undefined && $input.prop('checked'); 3137 }, 3138 disabled: function() { 3139 return $input.prop('disabled') !== undefined && $input.prop('disabled'); 3140 }, 3141 enabled: function() { 3142 return !module.is.disabled(); 3143 }, 3144 determinate: function() { 3145 return !module.is.indeterminate(); 3146 }, 3147 unchecked: function() { 3148 return !module.is.checked(); 3149 } 3150 }, 3151 3152 should: { 3153 allowCheck: function() { 3154 if(module.is.determinate() && module.is.checked() && !module.should.forceCallbacks() ) { 3155 module.debug('Should not allow check, checkbox is already checked'); 3156 return false; 3157 } 3158 if(settings.beforeChecked.apply(input) === false) { 3159 module.debug('Should not allow check, beforeChecked cancelled'); 3160 return false; 3161 } 3162 return true; 3163 }, 3164 allowUncheck: function() { 3165 if(module.is.determinate() && module.is.unchecked() && !module.should.forceCallbacks() ) { 3166 module.debug('Should not allow uncheck, checkbox is already unchecked'); 3167 return false; 3168 } 3169 if(settings.beforeUnchecked.apply(input) === false) { 3170 module.debug('Should not allow uncheck, beforeUnchecked cancelled'); 3171 return false; 3172 } 3173 return true; 3174 }, 3175 allowIndeterminate: function() { 3176 if(module.is.indeterminate() && !module.should.forceCallbacks() ) { 3177 module.debug('Should not allow indeterminate, checkbox is already indeterminate'); 3178 return false; 3179 } 3180 if(settings.beforeIndeterminate.apply(input) === false) { 3181 module.debug('Should not allow indeterminate, beforeIndeterminate cancelled'); 3182 return false; 3183 } 3184 return true; 3185 }, 3186 allowDeterminate: function() { 3187 if(module.is.determinate() && !module.should.forceCallbacks() ) { 3188 module.debug('Should not allow determinate, checkbox is already determinate'); 3189 return false; 3190 } 3191 if(settings.beforeDeterminate.apply(input) === false) { 3192 module.debug('Should not allow determinate, beforeDeterminate cancelled'); 3193 return false; 3194 } 3195 return true; 3196 }, 3197 forceCallbacks: function() { 3198 return (module.is.initialLoad() && settings.fireOnInit); 3199 }, 3200 ignoreCallbacks: function() { 3201 return (initialLoad && !settings.fireOnInit); 3202 } 3203 }, 3204 3205 can: { 3206 change: function() { 3207 return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly') ); 3208 }, 3209 uncheck: function() { 3210 return (typeof settings.uncheckable === 'boolean') 3211 ? settings.uncheckable 3212 : !module.is.radio() 3213 ; 3214 } 3215 }, 3216 3217 set: { 3218 initialLoad: function() { 3219 initialLoad = true; 3220 }, 3221 checked: function() { 3222 module.verbose('Setting class to checked'); 3223 $module 3224 .removeClass(className.indeterminate) 3225 .addClass(className.checked) 3226 ; 3227 if( module.is.radio() ) { 3228 module.uncheckOthers(); 3229 } 3230 if(!module.is.indeterminate() && module.is.checked()) { 3231 module.debug('Input is already checked, skipping input property change'); 3232 return; 3233 } 3234 module.verbose('Setting state to checked', input); 3235 $input 3236 .prop('indeterminate', false) 3237 .prop('checked', true) 3238 ; 3239 module.trigger.change(); 3240 }, 3241 unchecked: function() { 3242 module.verbose('Removing checked class'); 3243 $module 3244 .removeClass(className.indeterminate) 3245 .removeClass(className.checked) 3246 ; 3247 if(!module.is.indeterminate() && module.is.unchecked() ) { 3248 module.debug('Input is already unchecked'); 3249 return; 3250 } 3251 module.debug('Setting state to unchecked'); 3252 $input 3253 .prop('indeterminate', false) 3254 .prop('checked', false) 3255 ; 3256 module.trigger.change(); 3257 }, 3258 indeterminate: function() { 3259 module.verbose('Setting class to indeterminate'); 3260 $module 3261 .addClass(className.indeterminate) 3262 ; 3263 if( module.is.indeterminate() ) { 3264 module.debug('Input is already indeterminate, skipping input property change'); 3265 return; 3266 } 3267 module.debug('Setting state to indeterminate'); 3268 $input 3269 .prop('indeterminate', true) 3270 ; 3271 module.trigger.change(); 3272 }, 3273 determinate: function() { 3274 module.verbose('Removing indeterminate class'); 3275 $module 3276 .removeClass(className.indeterminate) 3277 ; 3278 if( module.is.determinate() ) { 3279 module.debug('Input is already determinate, skipping input property change'); 3280 return; 3281 } 3282 module.debug('Setting state to determinate'); 3283 $input 3284 .prop('indeterminate', false) 3285 ; 3286 }, 3287 disabled: function() { 3288 module.verbose('Setting class to disabled'); 3289 $module 3290 .addClass(className.disabled) 3291 ; 3292 if( module.is.disabled() ) { 3293 module.debug('Input is already disabled, skipping input property change'); 3294 return; 3295 } 3296 module.debug('Setting state to disabled'); 3297 $input 3298 .prop('disabled', 'disabled') 3299 ; 3300 module.trigger.change(); 3301 }, 3302 enabled: function() { 3303 module.verbose('Removing disabled class'); 3304 $module.removeClass(className.disabled); 3305 if( module.is.enabled() ) { 3306 module.debug('Input is already enabled, skipping input property change'); 3307 return; 3308 } 3309 module.debug('Setting state to enabled'); 3310 $input 3311 .prop('disabled', false) 3312 ; 3313 module.trigger.change(); 3314 }, 3315 tabbable: function() { 3316 module.verbose('Adding tabindex to checkbox'); 3317 if( $input.attr('tabindex') === undefined) { 3318 $input.attr('tabindex', 0); 3319 } 3320 } 3321 }, 3322 3323 remove: { 3324 initialLoad: function() { 3325 initialLoad = false; 3326 } 3327 }, 3328 3329 trigger: { 3330 change: function() { 3331 var 3332 events = document.createEvent('HTMLEvents'), 3333 inputElement = $input[0] 3334 ; 3335 if(inputElement) { 3336 module.verbose('Triggering native change event'); 3337 events.initEvent('change', true, false); 3338 inputElement.dispatchEvent(events); 3339 } 3340 } 3341 }, 3342 3343 3344 create: { 3345 label: function() { 3346 if($input.prevAll(selector.label).length > 0) { 3347 $input.prev(selector.label).detach().insertAfter($input); 3348 module.debug('Moving existing label', $label); 3349 } 3350 else if( !module.has.label() ) { 3351 $label = $('<label>').insertAfter($input); 3352 module.debug('Creating label', $label); 3353 } 3354 } 3355 }, 3356 3357 has: { 3358 label: function() { 3359 return ($label.length > 0); 3360 } 3361 }, 3362 3363 bind: { 3364 events: function() { 3365 module.verbose('Attaching checkbox events'); 3366 $module 3367 .on('click' + eventNamespace, module.event.click) 3368 .on('keydown' + eventNamespace, selector.input, module.event.keydown) 3369 .on('keyup' + eventNamespace, selector.input, module.event.keyup) 3370 ; 3371 } 3372 }, 3373 3374 unbind: { 3375 events: function() { 3376 module.debug('Removing events'); 3377 $module 3378 .off(eventNamespace) 3379 ; 3380 } 3381 }, 3382 3383 uncheckOthers: function() { 3384 var 3385 $radios = module.get.otherRadios() 3386 ; 3387 module.debug('Unchecking other radios', $radios); 3388 $radios.removeClass(className.checked); 3389 }, 3390 3391 toggle: function() { 3392 if( !module.can.change() ) { 3393 if(!module.is.radio()) { 3394 module.debug('Checkbox is read-only or disabled, ignoring toggle'); 3395 } 3396 return; 3397 } 3398 if( module.is.indeterminate() || module.is.unchecked() ) { 3399 module.debug('Currently unchecked'); 3400 module.check(); 3401 } 3402 else if( module.is.checked() && module.can.uncheck() ) { 3403 module.debug('Currently checked'); 3404 module.uncheck(); 3405 } 3406 }, 3407 setting: function(name, value) { 3408 module.debug('Changing setting', name, value); 3409 if( $.isPlainObject(name) ) { 3410 $.extend(true, settings, name); 3411 } 3412 else if(value !== undefined) { 3413 if($.isPlainObject(settings[name])) { 3414 $.extend(true, settings[name], value); 3415 } 3416 else { 3417 settings[name] = value; 3418 } 3419 } 3420 else { 3421 return settings[name]; 3422 } 3423 }, 3424 internal: function(name, value) { 3425 if( $.isPlainObject(name) ) { 3426 $.extend(true, module, name); 3427 } 3428 else if(value !== undefined) { 3429 module[name] = value; 3430 } 3431 else { 3432 return module[name]; 3433 } 3434 }, 3435 debug: function() { 3436 if(!settings.silent && settings.debug) { 3437 if(settings.performance) { 3438 module.performance.log(arguments); 3439 } 3440 else { 3441 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 3442 module.debug.apply(console, arguments); 3443 } 3444 } 3445 },
vendor: 4,339 bytes, lines 3446-3526
3446 verbose: function() { 3447 if(!settings.silent && settings.verbose && settings.debug) { 3448 if(settings.performance) { 3449 module.performance.log(arguments); 3450 } 3451 else { 3452 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 3453 module.verbose.apply(console, arguments); 3454 } 3455 } 3456 }, 3457 error: function() { 3458 if(!settings.silent) { 3459 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 3460 module.error.apply(console, arguments); 3461 } 3462 }, 3463 performance: { 3464 log: function(message) { 3465 var 3466 currentTime, 3467 executionTime, 3468 previousTime 3469 ; 3470 if(settings.performance) { 3471 currentTime = new Date().getTime(); 3472 previousTime = time || currentTime; 3473 executionTime = currentTime - previousTime; 3474 time = currentTime; 3475 performance.push({ 3476 'Name' : message[0], 3477 'Arguments' : [].slice.call(message, 1) || '', 3478 'Element' : element, 3479 'Execution Time' : executionTime 3480 }); 3481 } 3482 clearTimeout(module.performance.timer); 3483 module.performance.timer = setTimeout(module.performance.display, 500); 3484 }, 3485 display: function() { 3486 var 3487 title = settings.name + ':', 3488 totalTime = 0 3489 ; 3490 time = false; 3491 clearTimeout(module.performance.timer); 3492 $.each(performance, function(index, data) { 3493 totalTime += data['Execution Time']; 3494 }); 3495 title += ' ' + totalTime + 'ms'; 3496 if(moduleSelector) { 3497 title += ' \'' + moduleSelector + '\''; 3498 } 3499 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 3500 console.groupCollapsed(title); 3501 if(console.table) { 3502 console.table(performance); 3503 } 3504 else { 3505 $.each(performance, function(index, data) { 3506 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 3507 }); 3508 } 3509 console.groupEnd(); 3510 } 3511 performance = []; 3512 } 3513 }, 3514 invoke: function(query, passedArguments, context) { 3515 var 3516 object = instance, 3517 maxDepth, 3518 found, 3519 response 3520 ; 3521 passedArguments = passedArguments || queryArguments; 3522 context = element || context; 3523 if(typeof query == 'string' && object !== undefined) { 3524 query = query.split(/[\. ]/); 3525 maxDepth = query.length - 1; 3526 $.each(query, function(depth, value) {
vendor: 16,384 bytes, lines 3527-3935
3527 var camelCaseValue = (depth != maxDepth) 3528 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 3529 : query 3530 ; 3531 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 3532 object = object[camelCaseValue]; 3533 } 3534 else if( object[camelCaseValue] !== undefined ) { 3535 found = object[camelCaseValue]; 3536 return false; 3537 } 3538 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 3539 object = object[value]; 3540 } 3541 else if( object[value] !== undefined ) { 3542 found = object[value]; 3543 return false; 3544 } 3545 else { 3546 module.error(error.method, query); 3547 return false; 3548 } 3549 }); 3550 } 3551 if ( $.isFunction( found ) ) { 3552 response = found.apply(context, passedArguments); 3553 } 3554 else if(found !== undefined) { 3555 response = found; 3556 } 3557 if($.isArray(returnedValue)) { 3558 returnedValue.push(response); 3559 } 3560 else if(returnedValue !== undefined) { 3561 returnedValue = [returnedValue, response]; 3562 } 3563 else if(response !== undefined) { 3564 returnedValue = response; 3565 } 3566 return found; 3567 } 3568 }; 3569 3570 if(methodInvoked) { 3571 if(instance === undefined) { 3572 module.initialize(); 3573 } 3574 module.invoke(query); 3575 } 3576 else { 3577 if(instance !== undefined) { 3578 instance.invoke('destroy'); 3579 } 3580 module.initialize(); 3581 } 3582 }) 3583 ; 3584 3585 return (returnedValue !== undefined) 3586 ? returnedValue 3587 : this 3588 ; 3589 }; 3590 3591 $.fn.checkbox.settings = { 3592 3593 name : 'Checkbox', 3594 namespace : 'checkbox', 3595 3596 silent : false, 3597 debug : false, 3598 verbose : true, 3599 performance : true, 3600 3601 // delegated event context 3602 uncheckable : 'auto', 3603 fireOnInit : false, 3604 3605 onChange : function(){}, 3606 3607 beforeChecked : function(){}, 3608 beforeUnchecked : function(){}, 3609 beforeDeterminate : function(){}, 3610 beforeIndeterminate : function(){}, 3611 3612 onChecked : function(){}, 3613 onUnchecked : function(){}, 3614 3615 onDeterminate : function() {}, 3616 onIndeterminate : function() {}, 3617 3618 onEnable : function(){}, 3619 onDisable : function(){}, 3620 3621 // preserve misspelled callbacks (will be removed in 3.0) 3622 onEnabled : function(){}, 3623 onDisabled : function(){}, 3624 3625 className : { 3626 checked : 'checked', 3627 indeterminate : 'indeterminate', 3628 disabled : 'disabled', 3629 hidden : 'hidden', 3630 radio : 'radio', 3631 readOnly : 'read-only' 3632 }, 3633 3634 error : { 3635 method : 'The method you called is not defined' 3636 }, 3637 3638 selector : { 3639 checkbox : '.ui.checkbox', 3640 label : 'label, .box', 3641 input : 'input[type="checkbox"], input[type="radio"]', 3642 link : 'a[href]' 3643 } 3644 3645 }; 3646 3647})( jQuery, window, document ); 3648 3649/*! 3650 * # Semantic UI 2.2.12 - Dimmer 3651 * http://github.com/semantic-org/semantic-ui/ 3652 * 3653 * 3654 * Released under the MIT license 3655 * http://opensource.org/licenses/MIT 3656 * 3657 */ 3658 3659;(function ($, window, document, undefined) { 3660 3661 "use strict"; 3662 3663 window = (typeof window != 'undefined' && window.Math == Math) 3664 ? window 3665 : (typeof self != 'undefined' && self.Math == Math) 3666 ? self 3667 : Function('return this')() 3668 ; 3669 3670 $.fn.dimmer = function(parameters) { 3671 var 3672 $allModules = $(this), 3673 3674 time = new Date().getTime(), 3675 performance = [], 3676 3677 query = arguments[0], 3678 methodInvoked = (typeof query == 'string'), 3679 queryArguments = [].slice.call(arguments, 1), 3680 3681 returnedValue 3682 ; 3683 3684 $allModules 3685 .each(function() { 3686 var 3687 settings = ( $.isPlainObject(parameters) ) 3688 ? $.extend(true, {}, $.fn.dimmer.settings, parameters) 3689 : $.extend({}, $.fn.dimmer.settings), 3690 3691 selector = settings.selector, 3692 namespace = settings.namespace, 3693 className = settings.className, 3694 error = settings.error, 3695 3696 eventNamespace = '.' + namespace, 3697 moduleNamespace = 'module-' + namespace, 3698 moduleSelector = $allModules.selector || '', 3699 3700 clickEvent = ('ontouchstart' in document.documentElement) 3701 ? 'touchstart' 3702 : 'click', 3703 3704 $module = $(this), 3705 $dimmer, 3706 $dimmable, 3707 3708 element = this, 3709 instance = $module.data(moduleNamespace), 3710 module 3711 ; 3712 3713 module = { 3714 3715 preinitialize: function() { 3716 if( module.is.dimmer() ) { 3717 3718 $dimmable = $module.parent(); 3719 $dimmer = $module; 3720 } 3721 else { 3722 $dimmable = $module; 3723 if( module.has.dimmer() ) { 3724 if(settings.dimmerName) { 3725 $dimmer = $dimmable.find(selector.dimmer).filter('.' + settings.dimmerName); 3726 } 3727 else { 3728 $dimmer = $dimmable.find(selector.dimmer); 3729 } 3730 } 3731 else { 3732 $dimmer = module.create(); 3733 } 3734 module.set.variation(); 3735 } 3736 }, 3737 3738 initialize: function() { 3739 module.debug('Initializing dimmer', settings); 3740 3741 module.bind.events(); 3742 module.set.dimmable(); 3743 module.instantiate(); 3744 }, 3745 3746 instantiate: function() { 3747 module.verbose('Storing instance of module', module); 3748 instance = module; 3749 $module 3750 .data(moduleNamespace, instance) 3751 ; 3752 }, 3753 3754 destroy: function() { 3755 module.verbose('Destroying previous module', $dimmer); 3756 module.unbind.events(); 3757 module.remove.variation(); 3758 $dimmable 3759 .off(eventNamespace) 3760 ; 3761 }, 3762 3763 bind: { 3764 events: function() { 3765 if(settings.on == 'hover') { 3766 $dimmable 3767 .on('mouseenter' + eventNamespace, module.show) 3768 .on('mouseleave' + eventNamespace, module.hide) 3769 ; 3770 } 3771 else if(settings.on == 'click') { 3772 $dimmable 3773 .on(clickEvent + eventNamespace, module.toggle) 3774 ; 3775 } 3776 if( module.is.page() ) { 3777 module.debug('Setting as a page dimmer', $dimmable); 3778 module.set.pageDimmer(); 3779 } 3780 3781 if( module.is.closable() ) { 3782 module.verbose('Adding dimmer close event', $dimmer); 3783 $dimmable 3784 .on(clickEvent + eventNamespace, selector.dimmer, module.event.click) 3785 ; 3786 } 3787 } 3788 }, 3789 3790 unbind: { 3791 events: function() { 3792 $module 3793 .removeData(moduleNamespace) 3794 ; 3795 $dimmable 3796 .off(eventNamespace) 3797 ; 3798 } 3799 }, 3800 3801 event: { 3802 click: function(event) { 3803 module.verbose('Determining if event occured on dimmer', event); 3804 if( $dimmer.find(event.target).length === 0 || $(event.target).is(selector.content) ) { 3805 module.hide(); 3806 event.stopImmediatePropagation(); 3807 } 3808 } 3809 }, 3810 3811 addContent: function(element) { 3812 var 3813 $content = $(element) 3814 ; 3815 module.debug('Add content to dimmer', $content); 3816 if($content.parent()[0] !== $dimmer[0]) { 3817 $content.detach().appendTo($dimmer); 3818 } 3819 }, 3820 3821 create: function() { 3822 var 3823 $element = $( settings.template.dimmer() ) 3824 ; 3825 if(settings.dimmerName) { 3826 module.debug('Creating named dimmer', settings.dimmerName); 3827 $element.addClass(settings.dimmerName); 3828 } 3829 $element 3830 .appendTo($dimmable) 3831 ; 3832 return $element; 3833 }, 3834 3835 show: function(callback) { 3836 callback = $.isFunction(callback) 3837 ? callback 3838 : function(){} 3839 ; 3840 module.debug('Showing dimmer', $dimmer, settings); 3841 if( (!module.is.dimmed() || module.is.animating()) && module.is.enabled() ) { 3842 module.animate.show(callback); 3843 settings.onShow.call(element); 3844 settings.onChange.call(element); 3845 } 3846 else { 3847 module.debug('Dimmer is already shown or disabled'); 3848 } 3849 }, 3850 3851 hide: function(callback) { 3852 callback = $.isFunction(callback) 3853 ? callback 3854 : function(){} 3855 ; 3856 if( module.is.dimmed() || module.is.animating() ) { 3857 module.debug('Hiding dimmer', $dimmer); 3858 module.animate.hide(callback); 3859 settings.onHide.call(element); 3860 settings.onChange.call(element); 3861 } 3862 else { 3863 module.debug('Dimmer is not visible'); 3864 } 3865 }, 3866 3867 toggle: function() { 3868 module.verbose('Toggling dimmer visibility', $dimmer); 3869 if( !module.is.dimmed() ) { 3870 module.show(); 3871 } 3872 else { 3873 module.hide(); 3874 } 3875 }, 3876 3877 animate: { 3878 show: function(callback) { 3879 callback = $.isFunction(callback) 3880 ? callback 3881 : function(){} 3882 ; 3883 if(settings.useCSS && $.fn.transition !== undefined && $dimmer.transition('is supported')) { 3884 if(settings.opacity !== 'auto') { 3885 module.set.opacity(); 3886 } 3887 $dimmer 3888 .transition({ 3889 animation : settings.transition + ' in', 3890 queue : false, 3891 duration : module.get.duration(), 3892 useFailSafe : true, 3893 onStart : function() { 3894 module.set.dimmed(); 3895 }, 3896 onComplete : function() { 3897 module.set.active(); 3898 callback(); 3899 } 3900 }) 3901 ; 3902 } 3903 else { 3904 module.verbose('Showing dimmer animation with javascript'); 3905 module.set.dimmed(); 3906 if(settings.opacity == 'auto') { 3907 settings.opacity = 0.8; 3908 } 3909 $dimmer 3910 .stop() 3911 .css({ 3912 opacity : 0, 3913 width : '100%', 3914 height : '100%' 3915 }) 3916 .fadeTo(module.get.duration(), settings.opacity, function() { 3917 $dimmer.removeAttr('style'); 3918 module.set.active(); 3919 callback(); 3920 }) 3921 ; 3922 } 3923 }, 3924 hide: function(callback) { 3925 callback = $.isFunction(callback) 3926 ? callback 3927 : function(){} 3928 ; 3929 if(settings.useCSS && $.fn.transition !== undefined && $dimmer.transition('is supported')) { 3930 module.verbose('Hiding dimmer with css'); 3931 $dimmer 3932 .transition({ 3933 animation : settings.transition + ' out', 3934 queue : false, 3935
vendor: 13,666 bytes, lines 3935-4219
3935 duration : module.get.duration(), 3936 useFailSafe : true, 3937 onStart : function() { 3938 module.remove.dimmed(); 3939 }, 3940 onComplete : function() { 3941 module.remove.active(); 3942 callback(); 3943 } 3944 }) 3945 ; 3946 } 3947 else { 3948 module.verbose('Hiding dimmer with javascript'); 3949 module.remove.dimmed(); 3950 $dimmer 3951 .stop() 3952 .fadeOut(module.get.duration(), function() { 3953 module.remove.active(); 3954 $dimmer.removeAttr('style'); 3955 callback(); 3956 }) 3957 ; 3958 } 3959 } 3960 }, 3961 3962 get: { 3963 dimmer: function() { 3964 return $dimmer; 3965 }, 3966 duration: function() { 3967 if(typeof settings.duration == 'object') { 3968 if( module.is.active() ) { 3969 return settings.duration.hide; 3970 } 3971 else { 3972 return settings.duration.show; 3973 } 3974 } 3975 return settings.duration; 3976 } 3977 }, 3978 3979 has: { 3980 dimmer: function() { 3981 if(settings.dimmerName) { 3982 return ($module.find(selector.dimmer).filter('.' + settings.dimmerName).length > 0); 3983 } 3984 else { 3985 return ( $module.find(selector.dimmer).length > 0 ); 3986 } 3987 } 3988 }, 3989 3990 is: { 3991 active: function() { 3992 return $dimmer.hasClass(className.active); 3993 }, 3994 animating: function() { 3995 return ( $dimmer.is(':animated') || $dimmer.hasClass(className.animating) ); 3996 }, 3997 closable: function() { 3998 if(settings.closable == 'auto') { 3999 if(settings.on == 'hover') { 4000 return false; 4001 } 4002 return true; 4003 } 4004 return settings.closable; 4005 }, 4006 dimmer: function() { 4007 return $module.hasClass(className.dimmer); 4008 }, 4009 dimmable: function() { 4010 return $module.hasClass(className.dimmable); 4011 }, 4012 dimmed: function() { 4013 return $dimmable.hasClass(className.dimmed); 4014 }, 4015 disabled: function() { 4016 return $dimmable.hasClass(className.disabled); 4017 }, 4018 enabled: function() { 4019 return !module.is.disabled(); 4020 }, 4021 page: function () { 4022 return $dimmable.is('body'); 4023 }, 4024 pageDimmer: function() { 4025 return $dimmer.hasClass(className.pageDimmer); 4026 } 4027 }, 4028 4029 can: { 4030 show: function() { 4031 return !$dimmer.hasClass(className.disabled); 4032 } 4033 }, 4034 4035 set: { 4036 opacity: function(opacity) { 4037 var 4038 color = $dimmer.css('background-color'), 4039 colorArray = color.split(','), 4040 isRGB = (colorArray && colorArray.length == 3), 4041 isRGBA = (colorArray && colorArray.length == 4) 4042 ; 4043 opacity = settings.opacity === 0 ? 0 : settings.opacity || opacity; 4044 if(isRGB || isRGBA) { 4045 colorArray[3] = opacity + ')'; 4046 color = colorArray.join(','); 4047 } 4048 else { 4049 color = 'rgba(0, 0, 0, ' + opacity + ')'; 4050 } 4051 module.debug('Setting opacity to', opacity); 4052 $dimmer.css('background-color', color); 4053 }, 4054 active: function() { 4055 $dimmer.addClass(className.active); 4056 }, 4057 dimmable: function() { 4058 $dimmable.addClass(className.dimmable); 4059 }, 4060 dimmed: function() { 4061 $dimmable.addClass(className.dimmed); 4062 }, 4063 pageDimmer: function() { 4064 $dimmer.addClass(className.pageDimmer); 4065 }, 4066 disabled: function() { 4067 $dimmer.addClass(className.disabled); 4068 }, 4069 variation: function(variation) { 4070 variation = variation || settings.variation; 4071 if(variation) { 4072 $dimmer.addClass(variation); 4073 } 4074 } 4075 }, 4076 4077 remove: { 4078 active: function() { 4079 $dimmer 4080 .removeClass(className.active) 4081 ; 4082 }, 4083 dimmed: function() { 4084 $dimmable.removeClass(className.dimmed); 4085 }, 4086 disabled: function() { 4087 $dimmer.removeClass(className.disabled); 4088 }, 4089 variation: function(variation) { 4090 variation = variation || settings.variation; 4091 if(variation) { 4092 $dimmer.removeClass(variation); 4093 } 4094 } 4095 }, 4096 4097 setting: function(name, value) { 4098 module.debug('Changing setting', name, value); 4099 if( $.isPlainObject(name) ) { 4100 $.extend(true, settings, name); 4101 } 4102 else if(value !== undefined) { 4103 if($.isPlainObject(settings[name])) { 4104 $.extend(true, settings[name], value); 4105 } 4106 else { 4107 settings[name] = value; 4108 } 4109 } 4110 else { 4111 return settings[name]; 4112 } 4113 }, 4114 internal: function(name, value) { 4115 if( $.isPlainObject(name) ) { 4116 $.extend(true, module, name); 4117 } 4118 else if(value !== undefined) { 4119 module[name] = value; 4120 } 4121 else { 4122 return module[name]; 4123 } 4124 }, 4125 debug: function() { 4126 if(!settings.silent && settings.debug) { 4127 if(settings.performance) { 4128 module.performance.log(arguments); 4129 } 4130 else { 4131 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 4132 module.debug.apply(console, arguments); 4133 } 4134 } 4135 }, 4136 verbose: function() { 4137 if(!settings.silent && settings.verbose && settings.debug) { 4138 if(settings.performance) { 4139 module.performance.log(arguments); 4140 } 4141 else { 4142 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 4143 module.verbose.apply(console, arguments); 4144 } 4145 } 4146 }, 4147 error: function() { 4148 if(!settings.silent) { 4149 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 4150 module.error.apply(console, arguments); 4151 } 4152 }, 4153 performance: { 4154 log: function(message) { 4155 var 4156 currentTime, 4157 executionTime, 4158 previousTime 4159 ; 4160 if(settings.performance) { 4161 currentTime = new Date().getTime(); 4162 previousTime = time || currentTime; 4163 executionTime = currentTime - previousTime; 4164 time = currentTime; 4165 performance.push({ 4166 'Name' : message[0], 4167 'Arguments' : [].slice.call(message, 1) || '', 4168 'Element' : element, 4169 'Execution Time' : executionTime 4170 }); 4171 } 4172 clearTimeout(module.performance.timer); 4173 module.performance.timer = setTimeout(module.performance.display, 500); 4174 }, 4175 display: function() { 4176 var 4177 title = settings.name + ':', 4178 totalTime = 0 4179 ; 4180 time = false; 4181 clearTimeout(module.performance.timer); 4182 $.each(performance, function(index, data) { 4183 totalTime += data['Execution Time']; 4184 }); 4185 title += ' ' + totalTime + 'ms'; 4186 if(moduleSelector) { 4187 title += ' \'' + moduleSelector + '\''; 4188 } 4189 if($allModules.length > 1) { 4190 title += ' ' + '(' + $allModules.length + ')'; 4191 } 4192 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 4193 console.groupCollapsed(title); 4194 if(console.table) { 4195 console.table(performance); 4196 } 4197 else { 4198 $.each(performance, function(index, data) { 4199 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 4200 }); 4201 } 4202 console.groupEnd(); 4203 } 4204 performance = []; 4205 } 4206 }, 4207 invoke: function(query, passedArguments, context) { 4208 var 4209 object = instance, 4210 maxDepth, 4211 found, 4212 response 4213 ; 4214 passedArguments = passedArguments || queryArguments; 4215 context = element || context; 4216 if(typeof query == 'string' && object !== undefined) { 4217 query = query.split(/[\. ]/); 4218 maxDepth = query.length - 1; 4219 $.each(query, function(depth, value) {
vendor: 12,296 bytes, lines 4220-4559
4220 var camelCaseValue = (depth != maxDepth) 4221 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 4222 : query 4223 ; 4224 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 4225 object = object[camelCaseValue]; 4226 } 4227 else if( object[camelCaseValue] !== undefined ) { 4228 found = object[camelCaseValue]; 4229 return false; 4230 } 4231 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 4232 object = object[value]; 4233 } 4234 else if( object[value] !== undefined ) { 4235 found = object[value]; 4236 return false; 4237 } 4238 else { 4239 module.error(error.method, query); 4240 return false; 4241 } 4242 }); 4243 } 4244 if ( $.isFunction( found ) ) { 4245 response = found.apply(context, passedArguments); 4246 } 4247 else if(found !== undefined) { 4248 response = found; 4249 } 4250 if($.isArray(returnedValue)) { 4251 returnedValue.push(response); 4252 } 4253 else if(returnedValue !== undefined) { 4254 returnedValue = [returnedValue, response]; 4255 } 4256 else if(response !== undefined) { 4257 returnedValue = response; 4258 } 4259 return found; 4260 } 4261 }; 4262 4263 module.preinitialize(); 4264 4265 if(methodInvoked) { 4266 if(instance === undefined) { 4267 module.initialize(); 4268 } 4269 module.invoke(query); 4270 } 4271 else { 4272 if(instance !== undefined) { 4273 instance.invoke('destroy'); 4274 } 4275 module.initialize(); 4276 } 4277 }) 4278 ; 4279 4280 return (returnedValue !== undefined) 4281 ? returnedValue 4282 : this 4283 ; 4284 }; 4285 4286 $.fn.dimmer.settings = { 4287 4288 name : 'Dimmer', 4289 namespace : 'dimmer', 4290 4291 silent : false, 4292 debug : false, 4293 verbose : false, 4294 performance : true, 4295 4296 // name to distinguish between multiple dimmers in context 4297 dimmerName : false, 4298 4299 // whether to add a variation type 4300 variation : false, 4301 4302 // whether to bind close events 4303 closable : 'auto', 4304 4305 // whether to use css animations 4306 useCSS : true, 4307 4308 // css animation to use 4309 transition : 'fade', 4310 4311 // event to bind to 4312 on : false, 4313 4314 // overriding opacity value 4315 opacity : 'auto', 4316 4317 // transition durations 4318 duration : { 4319 show : 500, 4320 hide : 500 4321 }, 4322 4323 onChange : function(){}, 4324 onShow : function(){}, 4325 onHide : function(){}, 4326 4327 error : { 4328 method : 'The method you called is not defined.' 4329 }, 4330 4331 className : { 4332 active : 'active', 4333 animating : 'animating', 4334 dimmable : 'dimmable', 4335 dimmed : 'dimmed', 4336 dimmer : 'dimmer', 4337 disabled : 'disabled', 4338 hide : 'hide', 4339 pageDimmer : 'page', 4340 show : 'show' 4341 }, 4342 4343 selector: { 4344 dimmer : '> .ui.dimmer', 4345 content : '.ui.dimmer > .content, .ui.dimmer > .content > .center' 4346 }, 4347 4348 template: { 4349 dimmer: function() { 4350 return $('<div />').attr('class', 'ui dimmer'); 4351 } 4352 } 4353 4354 }; 4355 4356})( jQuery, window, document ); 4357 4358/*! 4359 * # Semantic UI 2.2.12 - Dropdown 4360 * http://github.com/semantic-org/semantic-ui/ 4361 * 4362 * 4363 * Released under the MIT license 4364 * http://opensource.org/licenses/MIT 4365 * 4366 */ 4367 4368;(function ($, window, document, undefined) { 4369 4370 "use strict"; 4371 4372 window = (typeof window != 'undefined' && window.Math == Math) 4373 ? window 4374 : (typeof self != 'undefined' && self.Math == Math) 4375 ? self 4376 : Function('return this')() 4377 ; 4378 4379 $.fn.dropdown = function(parameters) { 4380 var 4381 $allModules = $(this), 4382 $document = $(document), 4383 4384 moduleSelector = $allModules.selector || '', 4385 4386 hasTouch = ('ontouchstart' in document.documentElement), 4387 time = new Date().getTime(), 4388 performance = [], 4389 4390 query = arguments[0], 4391 methodInvoked = (typeof query == 'string'), 4392 queryArguments = [].slice.call(arguments, 1), 4393 returnedValue 4394 ; 4395 4396 $allModules 4397 .each(function(elementIndex) { 4398 var 4399 settings = ( $.isPlainObject(parameters) ) 4400 ? $.extend(true, {}, $.fn.dropdown.settings, parameters) 4401 : $.extend({}, $.fn.dropdown.settings), 4402 4403 className = settings.className, 4404 message = settings.message, 4405 fields = settings.fields, 4406 keys = settings.keys, 4407 metadata = settings.metadata, 4408 namespace = settings.namespace, 4409 regExp = settings.regExp, 4410 selector = settings.selector, 4411 error = settings.error, 4412 templates = settings.templates, 4413 4414 eventNamespace = '.' + namespace, 4415 moduleNamespace = 'module-' + namespace, 4416 4417 $module = $(this), 4418 $context = $(settings.context), 4419 $text = $module.find(selector.text), 4420 $search = $module.find(selector.search), 4421 $sizer = $module.find(selector.sizer), 4422 $input = $module.find(selector.input), 4423 $icon = $module.find(selector.icon), 4424 4425 $combo = ($module.prev().find(selector.text).length > 0) 4426 ? $module.prev().find(selector.text) 4427 : $module.prev(), 4428 4429 $menu = $module.children(selector.menu), 4430 $item = $menu.find(selector.item), 4431 4432 activated = false, 4433 itemActivated = false, 4434 internalChange = false, 4435 element = this, 4436 instance = $module.data(moduleNamespace), 4437 4438 initialLoad, 4439 pageLostFocus, 4440 willRefocus, 4441 elementNamespace, 4442 id, 4443 selectObserver, 4444 menuObserver, 4445 module 4446 ; 4447 4448 module = { 4449 4450 initialize: function() { 4451 module.debug('Initializing dropdown', settings); 4452 4453 if( module.is.alreadySetup() ) { 4454 module.setup.reference(); 4455 } 4456 else { 4457 4458 module.setup.layout(); 4459 4460 if(settings.values) { 4461 module.change.values(settings.values); 4462 } 4463 4464 module.refreshData(); 4465 4466 module.save.defaults(); 4467 module.restore.selected(); 4468 4469 module.create.id(); 4470 module.bind.events(); 4471 4472 module.observeChanges(); 4473 module.instantiate(); 4474 } 4475 4476 }, 4477 4478 instantiate: function() { 4479 module.verbose('Storing instance of dropdown', module); 4480 instance = module; 4481 $module 4482 .data(moduleNamespace, module) 4483 ; 4484 }, 4485 4486 destroy: function() { 4487 module.verbose('Destroying previous dropdown', $module); 4488 module.remove.tabbable(); 4489 $module 4490 .off(eventNamespace) 4491 .removeData(moduleNamespace) 4492 ; 4493 $menu 4494 .off(eventNamespace) 4495 ; 4496 $document 4497 .off(elementNamespace) 4498 ; 4499 module.disconnect.menuObserver(); 4500 module.disconnect.selectObserver(); 4501 }, 4502 4503 observeChanges: function() { 4504 if('MutationObserver' in window) { 4505 selectObserver = new MutationObserver(module.event.select.mutation); 4506 menuObserver = new MutationObserver(module.event.menu.mutation); 4507 module.debug('Setting up mutation observer', selectObserver, menuObserver); 4508 module.observe.select(); 4509 module.observe.menu(); 4510 } 4511 }, 4512 4513 disconnect: { 4514 menuObserver: function() { 4515 if(menuObserver) { 4516 menuObserver.disconnect(); 4517 } 4518 }, 4519 selectObserver: function() { 4520 if(selectObserver) { 4521 selectObserver.disconnect(); 4522 } 4523 } 4524 }, 4525 observe: { 4526 select: function() { 4527 if(module.has.input()) { 4528 selectObserver.observe($module[0], { 4529 childList : true, 4530 subtree : true 4531 }); 4532 } 4533 }, 4534 menu: function() { 4535 if(module.has.menu()) { 4536 menuObserver.observe($menu[0], { 4537 childList : true, 4538 subtree : true 4539 }); 4540 } 4541 } 4542 }, 4543 4544 create: { 4545 id: function() { 4546 id = (Math.random().toString(16) + '000000000').substr(2, 8); 4547 elementNamespace = '.' + id; 4548 module.verbose('Creating unique id for element', id); 4549 }, 4550 userChoice: function(values) { 4551 var 4552 $userChoices, 4553 $userChoice, 4554 isUserValue, 4555 html 4556 ; 4557 values = values || module.get.userValues(); 4558 if(!values) { 4559 return false;
vendor: 20,027 bytes, lines 4560-4952
4560 } 4561 values = $.isArray(values) 4562 ? values 4563 : [values] 4564 ; 4565 $.each(values, function(index, value) { 4566 if(module.get.item(value) === false) { 4567 html = settings.templates.addition( module.add.variables(message.addResult, value) ); 4568 $userChoice = $('<div />') 4569 .html(html) 4570 .attr('data-' + metadata.value, value) 4571 .attr('data-' + metadata.text, value) 4572 .addClass(className.addition) 4573 .addClass(className.item) 4574 ; 4575 if(settings.hideAdditions) { 4576 $userChoice.addClass(className.hidden); 4577 } 4578 $userChoices = ($userChoices === undefined) 4579 ? $userChoice 4580 : $userChoices.add($userChoice) 4581 ; 4582 module.verbose('Creating user choices for value', value, $userChoice); 4583 } 4584 }); 4585 return $userChoices; 4586 }, 4587 userLabels: function(value) { 4588 var 4589 userValues = module.get.userValues() 4590 ; 4591 if(userValues) { 4592 module.debug('Adding user labels', userValues); 4593 $.each(userValues, function(index, value) { 4594 module.verbose('Adding custom user value'); 4595 module.add.label(value, value); 4596 }); 4597 } 4598 }, 4599 menu: function() { 4600 $menu = $('<div />') 4601 .addClass(className.menu) 4602 .appendTo($module) 4603 ; 4604 }, 4605 sizer: function() { 4606 $sizer = $('<span />') 4607 .addClass(className.sizer) 4608 .insertAfter($search) 4609 ; 4610 } 4611 }, 4612 4613 search: function(query) { 4614 query = (query !== undefined) 4615 ? query 4616 : module.get.query() 4617 ; 4618 module.verbose('Searching for query', query); 4619 if(module.has.minCharacters(query)) { 4620 module.filter(query); 4621 } 4622 else { 4623 module.hide(); 4624 } 4625 }, 4626 4627 select: { 4628 firstUnfiltered: function() { 4629 module.verbose('Selecting first non-filtered element'); 4630 module.remove.selectedItem(); 4631 $item 4632 .not(selector.unselectable) 4633 .not(selector.addition + selector.hidden) 4634 .eq(0) 4635 .addClass(className.selected) 4636 ; 4637 }, 4638 nextAvailable: function($selected) { 4639 $selected = $selected.eq(0); 4640 var 4641 $nextAvailable = $selected.nextAll(selector.item).not(selector.unselectable).eq(0), 4642 $prevAvailable = $selected.prevAll(selector.item).not(selector.unselectable).eq(0), 4643 hasNext = ($nextAvailable.length > 0) 4644 ; 4645 if(hasNext) { 4646 module.verbose('Moving selection to', $nextAvailable); 4647 $nextAvailable.addClass(className.selected); 4648 } 4649 else { 4650 module.verbose('Moving selection to', $prevAvailable); 4651 $prevAvailable.addClass(className.selected); 4652 } 4653 } 4654 }, 4655 4656 setup: { 4657 api: function() { 4658 var 4659 apiSettings = { 4660 debug : settings.debug, 4661 urlData : { 4662 value : module.get.value(), 4663 query : module.get.query() 4664 }, 4665 on : false 4666 } 4667 ; 4668 module.verbose('First request, initializing API'); 4669 $module 4670 .api(apiSettings) 4671 ; 4672 }, 4673 layout: function() { 4674 if( $module.is('select') ) { 4675 module.setup.select(); 4676 module.setup.returnedObject(); 4677 } 4678 if( !module.has.menu() ) { 4679 module.create.menu(); 4680 } 4681 if( module.is.search() && !module.has.search() ) { 4682 module.verbose('Adding search input'); 4683 $search = $('<input />') 4684 .addClass(className.search) 4685 .prop('autocomplete', 'off') 4686 .insertBefore($text) 4687 ; 4688 } 4689 if( module.is.multiple() && module.is.searchSelection() && !module.has.sizer()) { 4690 module.create.sizer(); 4691 } 4692 if(settings.allowTab) { 4693 module.set.tabbable(); 4694 } 4695 }, 4696 select: function() { 4697 var 4698 selectValues = module.get.selectValues() 4699 ; 4700 module.debug('Dropdown initialized on a select', selectValues); 4701 if( $module.is('select') ) { 4702 $input = $module; 4703 } 4704 // see if select is placed correctly already 4705 if($input.parent(selector.dropdown).length > 0) { 4706 module.debug('UI dropdown already exists. Creating dropdown menu only'); 4707 $module = $input.closest(selector.dropdown); 4708 if( !module.has.menu() ) { 4709 module.create.menu(); 4710 } 4711 $menu = $module.children(selector.menu); 4712 module.setup.menu(selectValues); 4713 } 4714 else { 4715 module.debug('Creating entire dropdown from select'); 4716 $module = $('<div />') 4717 .attr('class', $input.attr('class') ) 4718 .addClass(className.selection) 4719 .addClass(className.dropdown) 4720 .html( templates.dropdown(selectValues) ) 4721 .insertBefore($input) 4722 ; 4723 if($input.hasClass(className.multiple) && $input.prop('multiple') === false) { 4724 module.error(error.missingMultiple); 4725 $input.prop('multiple', true); 4726 } 4727 if($input.is('[multiple]')) { 4728 module.set.multiple(); 4729 } 4730 if ($input.prop('disabled')) { 4731 module.debug('Disabling dropdown'); 4732 $module.addClass(className.disabled); 4733 } 4734 $input 4735 .removeAttr('class') 4736 .detach() 4737 .prependTo($module) 4738 ; 4739 } 4740 module.refresh(); 4741 }, 4742 menu: function(values) { 4743 $menu.html( templates.menu(values, fields)); 4744 $item = $menu.find(selector.item); 4745 }, 4746 reference: function() { 4747 module.debug('Dropdown behavior was called on select, replacing with closest dropdown'); 4748 // replace module reference 4749 $module = $module.parent(selector.dropdown); 4750 instance = $module.data(moduleNamespace); 4751 element = $module.get(0); 4752 module.refresh(); 4753 module.setup.returnedObject(); 4754 }, 4755 returnedObject: function() { 4756 var 4757 $firstModules = $allModules.slice(0, elementIndex), 4758 $lastModules = $allModules.slice(elementIndex + 1) 4759 ; 4760 // adjust all modules to use correct reference 4761 $allModules = $firstModules.add($module).add($lastModules); 4762 } 4763 }, 4764 4765 refresh: function() { 4766 module.refreshSelectors(); 4767 module.refreshData(); 4768 }, 4769 4770 refreshItems: function() { 4771 $item = $menu.find(selector.item); 4772 }, 4773 4774 refreshSelectors: function() { 4775 module.verbose('Refreshing selector cache'); 4776 $text = $module.find(selector.text); 4777 $search = $module.find(selector.search); 4778 $input = $module.find(selector.input); 4779 $icon = $module.find(selector.icon); 4780 $combo = ($module.prev().find(selector.text).length > 0) 4781 ? $module.prev().find(selector.text) 4782 : $module.prev() 4783 ; 4784 $menu = $module.children(selector.menu); 4785 $item = $menu.find(selector.item); 4786 }, 4787 4788 refreshData: function() { 4789 module.verbose('Refreshing cached metadata'); 4790 $item 4791 .removeData(metadata.text) 4792 .removeData(metadata.value) 4793 ; 4794 }, 4795 4796 clearData: function() { 4797 module.verbose('Clearing metadata'); 4798 $item 4799 .removeData(metadata.text) 4800 .removeData(metadata.value) 4801 ; 4802 $module 4803 .removeData(metadata.defaultText) 4804 .removeData(metadata.defaultValue) 4805 .removeData(metadata.placeholderText) 4806 ; 4807 }, 4808 4809 toggle: function() { 4810 module.verbose('Toggling menu visibility'); 4811 if( !module.is.active() ) { 4812 module.show(); 4813 } 4814 else { 4815 module.hide(); 4816 } 4817 }, 4818 4819 show: function(callback) { 4820 callback = $.isFunction(callback) 4821 ? callback 4822 : function(){} 4823 ; 4824 if(!module.can.show() && module.is.remote()) { 4825 module.debug('No API results retrieved, searching before show'); 4826 module.queryRemote(module.get.query(), module.show); 4827 } 4828 if( module.can.show() && !module.is.active() ) { 4829 module.debug('Showing dropdown'); 4830 if(module.has.message() && !(module.has.maxSelections() || module.has.allResultsFiltered()) ) { 4831 module.remove.message(); 4832 } 4833 if(module.is.allFiltered()) { 4834 return true; 4835 } 4836 if(settings.onShow.call(element) !== false) { 4837 module.animate.show(function() { 4838 if( module.can.click() ) { 4839 module.bind.intent(); 4840 } 4841 if(module.has.menuSearch()) { 4842 module.focusSearch(); 4843 } 4844 module.set.visible(); 4845 callback.call(element); 4846 }); 4847 } 4848 } 4849 }, 4850 4851 hide: function(callback) { 4852 callback = $.isFunction(callback) 4853 ? callback 4854 : function(){} 4855 ; 4856 if( module.is.active() ) { 4857 module.debug('Hiding dropdown'); 4858 if(settings.onHide.call(element) !== false) { 4859 module.animate.hide(function() { 4860 module.remove.visible(); 4861 callback.call(element); 4862 }); 4863 } 4864 } 4865 }, 4866 4867 hideOthers: function() { 4868 module.verbose('Finding other dropdowns to hide'); 4869 $allModules 4870 .not($module) 4871 .has(selector.menu + '.' + className.visible) 4872 .dropdown('hide') 4873 ; 4874 }, 4875 4876 hideMenu: function() { 4877 module.verbose('Hiding menu instantaneously'); 4878 module.remove.active(); 4879 module.remove.visible(); 4880 $menu.transition('hide'); 4881 }, 4882 4883 hideSubMenus: function() { 4884 var 4885 $subMenus = $menu.children(selector.item).find(selector.menu) 4886 ; 4887 module.verbose('Hiding sub menus', $subMenus); 4888 $subMenus.transition('hide'); 4889 }, 4890 4891 bind: { 4892 events: function() { 4893 if(hasTouch) { 4894 module.bind.touchEvents(); 4895 } 4896 module.bind.keyboardEvents(); 4897 module.bind.inputEvents(); 4898 module.bind.mouseEvents(); 4899 }, 4900 touchEvents: function() { 4901 module.debug('Touch device detected binding additional touch events'); 4902 if( module.is.searchSelection() ) { 4903 // do nothing special yet 4904 } 4905 else if( module.is.single() ) { 4906 $module 4907 .on('touchstart' + eventNamespace, module.event.test.toggle) 4908 ; 4909 } 4910 $menu 4911 .on('touchstart' + eventNamespace, selector.item, module.event.item.mouseenter) 4912 ; 4913 }, 4914 keyboardEvents: function() { 4915 module.verbose('Binding keyboard events'); 4916 $module 4917 .on('keydown' + eventNamespace, module.event.keydown) 4918 ; 4919 if( module.has.search() ) { 4920 $module 4921 .on(module.get.inputEvent() + eventNamespace, selector.search, module.event.input) 4922 ; 4923 } 4924 if( module.is.multiple() ) { 4925 $document 4926 .on('keydown' + elementNamespace, module.event.document.keydown) 4927 ; 4928 } 4929 }, 4930 inputEvents: function() { 4931 module.verbose('Binding input change events'); 4932 $module 4933 .on('change' + eventNamespace, selector.input, module.event.change) 4934 ; 4935 }, 4936 mouseEvents: function() { 4937 module.verbose('Binding mouse events'); 4938 if(module.is.multiple()) { 4939 $module 4940 .on('click' + eventNamespace, selector.label, module.event.label.click) 4941 .on('click' + eventNamespace, selector.remove, module.event.remove.click) 4942 ; 4943 } 4944 if( module.is.searchSelection() ) { 4945 $module 4946 .on('mousedown' + eventNamespace, module.event.mousedown) 4947 .on('mouseup' + eventNamespace, module.event.mouseup) 4948 .on('mousedown' + eventNamespace, selector.menu, module.event.menu.mousedown) 4949 .on('mouseup' + eventNamespace, selector.menu, module.event.menu.mouseup) 4950 .on('click' + eventNamespace, selector.icon, module.event.icon.click) 4951 .on('focus' + eventNamespace, selector.search, module.event.search.focus) 4952 .on('click' + eventNamespace, selector.search, module.event.search.focus)
vendor: 4,100 bytes, lines 4953-5025
4953 .on('blur' + eventNamespace, selector.search, module.event.search.blur) 4954 .on('click' + eventNamespace, selector.text, module.event.text.focus) 4955 ; 4956 if(module.is.multiple()) { 4957 $module 4958 .on('click' + eventNamespace, module.event.click) 4959 ; 4960 } 4961 } 4962 else { 4963 if(settings.on == 'click') { 4964 $module 4965 .on('click' + eventNamespace, selector.icon, module.event.icon.click) 4966 .on('click' + eventNamespace, module.event.test.toggle) 4967 ; 4968 } 4969 else if(settings.on == 'hover') { 4970 $module 4971 .on('mouseenter' + eventNamespace, module.delay.show) 4972 .on('mouseleave' + eventNamespace, module.delay.hide) 4973 ; 4974 } 4975 else { 4976 $module 4977 .on(settings.on + eventNamespace, module.toggle) 4978 ; 4979 } 4980 $module 4981 .on('mousedown' + eventNamespace, module.event.mousedown) 4982 .on('mouseup' + eventNamespace, module.event.mouseup) 4983 .on('focus' + eventNamespace, module.event.focus) 4984 ; 4985 if(module.has.menuSearch() ) { 4986 $module 4987 .on('blur' + eventNamespace, selector.search, module.event.search.blur) 4988 ; 4989 } 4990 else { 4991 $module 4992 .on('blur' + eventNamespace, module.event.blur) 4993 ; 4994 } 4995 } 4996 $menu 4997 .on('mouseenter' + eventNamespace, selector.item, module.event.item.mouseenter) 4998 .on('mouseleave' + eventNamespace, selector.item, module.event.item.mouseleave) 4999 .on('click' + eventNamespace, selector.item, module.event.item.click) 5000 ; 5001 }, 5002 intent: function() { 5003 module.verbose('Binding hide intent event to document'); 5004 if(hasTouch) { 5005 $document 5006 .on('touchstart' + elementNamespace, module.event.test.touch) 5007 .on('touchmove' + elementNamespace, module.event.test.touch) 5008 ; 5009 } 5010 $document 5011 .on('click' + elementNamespace, module.event.test.hide) 5012 ; 5013 } 5014 }, 5015 5016 unbind: { 5017 intent: function() { 5018 module.verbose('Removing hide intent event from document'); 5019 if(hasTouch) { 5020 $document 5021 .off('touchstart' + elementNamespace) 5022 .off('touchmove' + elementNamespace) 5023 ; 5024 } 5025 $document
vendor: 15,346 bytes, lines 5026-5325
5026 .off('click' + elementNamespace) 5027 ; 5028 } 5029 }, 5030 5031 filter: function(query) { 5032 var 5033 searchTerm = (query !== undefined) 5034 ? query 5035 : module.get.query(), 5036 afterFiltered = function() { 5037 if(module.is.multiple()) { 5038 module.filterActive(); 5039 } 5040 if(query || (!query && module.get.activeItem().length == 0)) { 5041 module.select.firstUnfiltered(); 5042 } 5043 if( module.has.allResultsFiltered() ) { 5044 if( settings.onNoResults.call(element, searchTerm) ) { 5045 if(settings.allowAdditions) { 5046 if(settings.hideAdditions) { 5047 module.verbose('User addition with no menu, setting empty style'); 5048 module.set.empty(); 5049 module.hideMenu(); 5050 } 5051 } 5052 else { 5053 module.verbose('All items filtered, showing message', searchTerm); 5054 module.add.message(message.noResults); 5055 } 5056 } 5057 else { 5058 module.verbose('All items filtered, hiding dropdown', searchTerm); 5059 module.hideMenu(); 5060 } 5061 } 5062 else { 5063 module.remove.empty(); 5064 module.remove.message(); 5065 } 5066 if(settings.allowAdditions) { 5067 module.add.userSuggestion(query); 5068 } 5069 if(module.is.searchSelection() && module.can.show() && module.is.focusedOnSearch() ) { 5070 module.show(); 5071 } 5072 } 5073 ; 5074 if(settings.useLabels && module.has.maxSelections()) { 5075 return; 5076 } 5077 if(settings.apiSettings) { 5078 if( module.can.useAPI() ) { 5079 module.queryRemote(searchTerm, function() { 5080 if(settings.filterRemoteData) { 5081 module.filterItems(searchTerm); 5082 } 5083 afterFiltered(); 5084 }); 5085 } 5086 else { 5087 module.error(error.noAPI); 5088 } 5089 } 5090 else { 5091 module.filterItems(searchTerm); 5092 afterFiltered(); 5093 } 5094 }, 5095 5096 queryRemote: function(query, callback) { 5097 var 5098 apiSettings = { 5099 errorDuration : false, 5100 cache : 'local', 5101 throttle : settings.throttle, 5102 urlData : { 5103 query: query 5104 }, 5105 onError: function() { 5106 module.add.message(message.serverError); 5107 callback(); 5108 }, 5109 onFailure: function() { 5110 module.add.message(message.serverError); 5111 callback(); 5112 }, 5113 onSuccess : function(response) { 5114 module.remove.message(); 5115 module.setup.menu({ 5116 values: response[fields.remoteValues] 5117 }); 5118 callback(); 5119 } 5120 } 5121 ; 5122 if( !$module.api('get request') ) { 5123 module.setup.api(); 5124 } 5125 apiSettings = $.extend(true, {}, apiSettings, settings.apiSettings); 5126 $module 5127 .api('setting', apiSettings) 5128 .api('query') 5129 ; 5130 }, 5131 5132 filterItems: function(query) { 5133 var 5134 searchTerm = (query !== undefined) 5135 ? query 5136 : module.get.query(), 5137 results = null, 5138 escapedTerm = module.escape.string(searchTerm), 5139 beginsWithRegExp = new RegExp('^' + escapedTerm, 'igm') 5140 ; 5141 // avoid loop if we're matching nothing 5142 if( module.has.query() ) { 5143 results = []; 5144 5145 module.verbose('Searching for matching values', searchTerm); 5146 $item 5147 .each(function(){ 5148 var 5149 $choice = $(this), 5150 text, 5151 value 5152 ; 5153 if(settings.match == 'both' || settings.match == 'text') { 5154 text = String(module.get.choiceText($choice, false)); 5155 if(text.search(beginsWithRegExp) !== -1) { 5156 results.push(this); 5157 return true; 5158 } 5159 else if (settings.fullTextSearch === 'exact' && module.exactSearch(searchTerm, text)) { 5160 results.push(this); 5161 return true; 5162 } 5163 else if (settings.fullTextSearch === true && module.fuzzySearch(searchTerm, text)) { 5164 results.push(this); 5165 return true; 5166 } 5167 } 5168 if(settings.match == 'both' || settings.match == 'value') { 5169 value = String(module.get.choiceValue($choice, text)); 5170 if(value.search(beginsWithRegExp) !== -1) { 5171 results.push(this); 5172 return true; 5173 } 5174 else if (settings.fullTextSearch === 'exact' && module.exactSearch(searchTerm, value)) { 5175 results.push(this); 5176 return true; 5177 } 5178 else if (settings.fullTextSearch === true && module.fuzzySearch(searchTerm, value)) { 5179 results.push(this); 5180 return true; 5181 } 5182 } 5183 }) 5184 ; 5185 } 5186 module.debug('Showing only matched items', searchTerm); 5187 module.remove.filteredItem(); 5188 if(results) { 5189 $item 5190 .not(results) 5191 .addClass(className.filtered) 5192 ; 5193 } 5194 }, 5195 5196 fuzzySearch: function(query, term) { 5197 var 5198 termLength = term.length, 5199 queryLength = query.length 5200 ; 5201 query = query.toLowerCase(); 5202 term = term.toLowerCase(); 5203 if(queryLength > termLength) { 5204 return false; 5205 } 5206 if(queryLength === termLength) { 5207 return (query === term); 5208 } 5209 search: for (var characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) { 5210 var 5211 queryCharacter = query.charCodeAt(characterIndex) 5212 ; 5213 while(nextCharacterIndex < termLength) { 5214 if(term.charCodeAt(nextCharacterIndex++) === queryCharacter) { 5215 continue search; 5216 } 5217 } 5218 return false; 5219 } 5220 return true; 5221 }, 5222 exactSearch: function (query, term) { 5223 query = query.toLowerCase(); 5224 term = term.toLowerCase(); 5225 if(term.indexOf(query) > -1) { 5226 return true; 5227 } 5228 return false; 5229 }, 5230 filterActive: function() { 5231 if(settings.useLabels) { 5232 $item.filter('.' + className.active) 5233 .addClass(className.filtered) 5234 ; 5235 } 5236 }, 5237 5238 focusSearch: function(skipHandler) { 5239 if( module.has.search() && !module.is.focusedOnSearch() ) { 5240 if(skipHandler) { 5241 $module.off('focus' + eventNamespace, selector.search); 5242 $search.focus(); 5243 $module.on('focus' + eventNamespace, selector.search, module.event.search.focus); 5244 } 5245 else { 5246 $search.focus(); 5247 } 5248 } 5249 }, 5250 5251 forceSelection: function() { 5252 var 5253 $currentlySelected = $item.not(className.filtered).filter('.' + className.selected).eq(0), 5254 $activeItem = $item.not(className.filtered).filter('.' + className.active).eq(0), 5255 $selectedItem = ($currentlySelected.length > 0) 5256 ? $currentlySelected 5257 : $activeItem, 5258 hasSelected = ($selectedItem.length > 0) 5259 ; 5260 if(hasSelected && !module.is.multiple()) { 5261 module.debug('Forcing partial selection to selected item', $selectedItem); 5262 module.event.item.click.call($selectedItem, {}, true); 5263 return; 5264 } 5265 else { 5266 if(settings.allowAdditions) { 5267 module.set.selected(module.get.query()); 5268 module.remove.searchTerm(); 5269 } 5270 else { 5271 module.remove.searchTerm(); 5272 } 5273 } 5274 }, 5275 5276 change: { 5277 values: function(values) { 5278 if(!settings.allowAdditions) { 5279 module.clear(); 5280 } 5281 module.debug('Creating dropdown with specified values', values); 5282 module.setup.menu({values: values}); 5283 $.each(values, function(index, item) { 5284 if(item.selected == true) { 5285 module.debug('Setting initial selection to', item.value); 5286 module.set.selected(item.value); 5287 return true; 5288 } 5289 }); 5290 } 5291 }, 5292 5293 event: { 5294 change: function() { 5295 if(!internalChange) { 5296 module.debug('Input changed, updating selection'); 5297 module.set.selected(); 5298 } 5299 }, 5300 focus: function() { 5301 if(settings.showOnFocus && !activated && module.is.hidden() && !pageLostFocus) { 5302 module.show(); 5303 } 5304 }, 5305 blur: function(event) { 5306 pageLostFocus = (document.activeElement === this); 5307 if(!activated && !pageLostFocus) { 5308 module.remove.activeLabel(); 5309 module.hide(); 5310 } 5311 }, 5312 mousedown: function() { 5313 if(module.is.searchSelection()) { 5314 // prevent menu hiding on immediate re-focus 5315 willRefocus = true; 5316 } 5317 else { 5318 // prevents focus callback from occurring on mousedown 5319 activated = true; 5320 } 5321 }, 5322 mouseup: function() { 5323 if(module.is.searchSelection()) { 5324 // prevent menu hiding on immediate re-focus 5325 willRefocus = false;
vendor: 5,593 bytes, lines 5326-5434
5326 } 5327 else { 5328 activated = false; 5329 } 5330 }, 5331 click: function(event) { 5332 var 5333 $target = $(event.target) 5334 ; 5335 // focus search 5336 if($target.is($module)) { 5337 if(!module.is.focusedOnSearch()) { 5338 module.focusSearch(); 5339 } 5340 else { 5341 module.show(); 5342 } 5343 } 5344 }, 5345 search: { 5346 focus: function() { 5347 activated = true; 5348 if(module.is.multiple()) { 5349 module.remove.activeLabel(); 5350 } 5351 if(settings.showOnFocus) { 5352 module.search(); 5353 } 5354 }, 5355 blur: function(event) { 5356 pageLostFocus = (document.activeElement === this); 5357 if(module.is.searchSelection() && !willRefocus) { 5358 if(!itemActivated && !pageLostFocus) { 5359 if(settings.forceSelection) { 5360 module.forceSelection(); 5361 } 5362 module.hide(); 5363 } 5364 } 5365 willRefocus = false; 5366 } 5367 }, 5368 icon: { 5369 click: function(event) { 5370 module.toggle(); 5371 } 5372 }, 5373 text: { 5374 focus: function(event) { 5375 activated = true; 5376 module.focusSearch(); 5377 } 5378 }, 5379 input: function(event) { 5380 if(module.is.multiple() || module.is.searchSelection()) { 5381 module.set.filtered(); 5382 } 5383 clearTimeout(module.timer); 5384 module.timer = setTimeout(module.search, settings.delay.search); 5385 }, 5386 label: { 5387 click: function(event) { 5388 var 5389 $label = $(this), 5390 $labels = $module.find(selector.label), 5391 $activeLabels = $labels.filter('.' + className.active), 5392 $nextActive = $label.nextAll('.' + className.active), 5393 $prevActive = $label.prevAll('.' + className.active), 5394 $range = ($nextActive.length > 0) 5395 ? $label.nextUntil($nextActive).add($activeLabels).add($label) 5396 : $label.prevUntil($prevActive).add($activeLabels).add($label) 5397 ; 5398 if(event.shiftKey) { 5399 $activeLabels.removeClass(className.active); 5400 $range.addClass(className.active); 5401 } 5402 else if(event.ctrlKey) { 5403 $label.toggleClass(className.active); 5404 } 5405 else { 5406 $activeLabels.removeClass(className.active); 5407 $label.addClass(className.active); 5408 } 5409 settings.onLabelSelect.apply(this, $labels.filter('.' + className.active)); 5410 } 5411 }, 5412 remove: { 5413 click: function() { 5414 var 5415 $label = $(this).parent() 5416 ; 5417 if( $label.hasClass(className.active) ) { 5418 // remove all selected labels 5419 module.remove.activeLabels(); 5420 } 5421 else { 5422 // remove this label only 5423 module.remove.activeLabels( $label ); 5424 } 5425 } 5426 }, 5427 test: { 5428 toggle: function(event) { 5429 var 5430 toggleBehavior = (module.is.multiple()) 5431 ? module.show 5432 : module.toggle 5433 ; 5434 if(module.is.bubbledLabelClick(event) || module.is.bubbledIconCl
vendor: 81,940 bytes, lines 5434-6911
5434ick(event)) { 5435 return; 5436 } 5437 if( module.determine.eventOnElement(event, toggleBehavior) ) { 5438 event.preventDefault(); 5439 } 5440 }, 5441 touch: function(event) { 5442 module.determine.eventOnElement(event, function() { 5443 if(event.type == 'touchstart') { 5444 module.timer = setTimeout(function() { 5445 module.hide(); 5446 }, settings.delay.touch); 5447 } 5448 else if(event.type == 'touchmove') { 5449 clearTimeout(module.timer); 5450 } 5451 }); 5452 event.stopPropagation(); 5453 }, 5454 hide: function(event) { 5455 module.determine.eventInModule(event, module.hide); 5456 } 5457 }, 5458 select: { 5459 mutation: function(mutations) { 5460 module.debug('<select> modified, recreating menu'); 5461 var 5462 isSelectMutation = false 5463 ; 5464 $.each(mutations, function(index, mutation) { 5465 if($(mutation.target).is('select') || $(mutation.addedNodes).is('select')) { 5466 isSelectMutation = true; 5467 return true; 5468 } 5469 }); 5470 if(isSelectMutation) { 5471 module.disconnect.selectObserver(); 5472 module.refresh(); 5473 module.setup.select(); 5474 module.set.selected(); 5475 module.observe.select(); 5476 } 5477 } 5478 }, 5479 menu: { 5480 mutation: function(mutations) { 5481 var 5482 mutation = mutations[0], 5483 $addedNode = mutation.addedNodes 5484 ? $(mutation.addedNodes[0]) 5485 : $(false), 5486 $removedNode = mutation.removedNodes 5487 ? $(mutation.removedNodes[0]) 5488 : $(false), 5489 $changedNodes = $addedNode.add($removedNode), 5490 isUserAddition = $changedNodes.is(selector.addition) || $changedNodes.closest(selector.addition).length > 0, 5491 isMessage = $changedNodes.is(selector.message) || $changedNodes.closest(selector.message).length > 0 5492 ; 5493 if(isUserAddition || isMessage) { 5494 module.debug('Updating item selector cache'); 5495 module.refreshItems(); 5496 } 5497 else { 5498 module.debug('Menu modified, updating selector cache'); 5499 module.refresh(); 5500 } 5501 }, 5502 mousedown: function() { 5503 itemActivated = true; 5504 }, 5505 mouseup: function() { 5506 itemActivated = false; 5507 } 5508 }, 5509 item: { 5510 mouseenter: function(event) { 5511 var 5512 $target = $(event.target), 5513 $item = $(this), 5514 $subMenu = $item.children(selector.menu), 5515 $otherMenus = $item.siblings(selector.item).children(selector.menu), 5516 hasSubMenu = ($subMenu.length > 0), 5517 isBubbledEvent = ($subMenu.find($target).length > 0) 5518 ; 5519 if( !isBubbledEvent && hasSubMenu ) { 5520 clearTimeout(module.itemTimer); 5521 module.itemTimer = setTimeout(function() { 5522 module.verbose('Showing sub-menu', $subMenu); 5523 $.each($otherMenus, function() { 5524 module.animate.hide(false, $(this)); 5525 }); 5526 module.animate.show(false, $subMenu); 5527 }, settings.delay.show); 5528 event.preventDefault(); 5529 } 5530 }, 5531 mouseleave: function(event) { 5532 var 5533 $subMenu = $(this).children(selector.menu) 5534 ; 5535 if($subMenu.length > 0) { 5536 clearTimeout(module.itemTimer); 5537 module.itemTimer = setTimeout(function() { 5538 module.verbose('Hiding sub-menu', $subMenu); 5539 module.animate.hide(false, $subMenu); 5540 }, settings.delay.hide); 5541 } 5542 }, 5543 click: function (event, skipRefocus) { 5544 var 5545 $choice = $(this), 5546 $target = (event) 5547 ? $(event.target) 5548 : $(''), 5549 $subMenu = $choice.find(selector.menu), 5550 text = module.get.choiceText($choice), 5551 value = module.get.choiceValue($choice, text), 5552 hasSubMenu = ($subMenu.length > 0), 5553 isBubbledEvent = ($subMenu.find($target).length > 0) 5554 ; 5555 // prevents IE11 bug where menu receives focus even though `tabindex=-1` 5556 if(module.has.menuSearch()) { 5557 $(document.activeElement).blur(); 5558 } 5559 if(!isBubbledEvent && (!hasSubMenu || settings.allowCategorySelection)) { 5560 if(module.is.searchSelection()) { 5561 if(settings.allowAdditions) { 5562 module.remove.userAddition(); 5563 } 5564 module.remove.searchTerm(); 5565 if(!module.is.focusedOnSearch() && !(skipRefocus == true)) { 5566 module.focusSearch(true); 5567 } 5568 } 5569 if(!settings.useLabels) { 5570 module.remove.filteredItem(); 5571 module.set.scrollPosition($choice); 5572 } 5573 module.determine.selectAction.call(this, text, value); 5574 } 5575 } 5576 }, 5577 5578 document: { 5579 // label selection should occur even when element has no focus 5580 keydown: function(event) { 5581 var 5582 pressedKey = event.which, 5583 isShortcutKey = module.is.inObject(pressedKey, keys) 5584 ; 5585 if(isShortcutKey) { 5586 var 5587 $label = $module.find(selector.label), 5588 $activeLabel = $label.filter('.' + className.active), 5589 activeValue = $activeLabel.data(metadata.value), 5590 labelIndex = $label.index($activeLabel), 5591 labelCount = $label.length, 5592 hasActiveLabel = ($activeLabel.length > 0), 5593 hasMultipleActive = ($activeLabel.length > 1), 5594 isFirstLabel = (labelIndex === 0), 5595 isLastLabel = (labelIndex + 1 == labelCount), 5596 isSearch = module.is.searchSelection(), 5597 isFocusedOnSearch = module.is.focusedOnSearch(), 5598 isFocused = module.is.focused(), 5599 caretAtStart = (isFocusedOnSearch && module.get.caretPosition() === 0), 5600 $nextLabel 5601 ; 5602 if(isSearch && !hasActiveLabel && !isFocusedOnSearch) { 5603 return; 5604 } 5605 5606 if(pressedKey == keys.leftArrow) { 5607 // activate previous label 5608 if((isFocused || caretAtStart) && !hasActiveLabel) { 5609 module.verbose('Selecting previous label'); 5610 $label.last().addClass(className.active); 5611 } 5612 else if(hasActiveLabel) { 5613 if(!event.shiftKey) { 5614 module.verbose('Selecting previous label'); 5615 $label.removeClass(className.active); 5616 } 5617 else { 5618 module.verbose('Adding previous label to selection'); 5619 } 5620 if(isFirstLabel && !hasMultipleActive) { 5621 $activeLabel.addClass(className.active); 5622 } 5623 else { 5624 $activeLabel.prev(selector.siblingLabel) 5625 .addClass(className.active) 5626 .end() 5627 ; 5628 } 5629 event.preventDefault(); 5630 } 5631 } 5632 else if(pressedKey == keys.rightArrow) { 5633 // activate first label 5634 if(isFocused && !hasActiveLabel) { 5635 $label.first().addClass(className.active); 5636 } 5637 // activate next label 5638 if(hasActiveLabel) { 5639 if(!event.shiftKey) { 5640 module.verbose('Selecting next label'); 5641 $label.removeClass(className.active); 5642 } 5643 else { 5644 module.verbose('Adding next label to selection'); 5645 } 5646 if(isLastLabel) { 5647 if(isSearch) { 5648 if(!isFocusedOnSearch) { 5649 module.focusSearch(); 5650 } 5651 else { 5652 $label.removeClass(className.active); 5653 } 5654 } 5655 else if(hasMultipleActive) { 5656 $activeLabel.next(selector.siblingLabel).addClass(className.active); 5657 } 5658 else { 5659 $activeLabel.addClass(className.active); 5660 } 5661 } 5662 else { 5663 $activeLabel.next(selector.siblingLabel).addClass(className.active); 5664 } 5665 event.preventDefault(); 5666 } 5667 } 5668 else if(pressedKey == keys.deleteKey || pressedKey == keys.backspace) { 5669 if(hasActiveLabel) { 5670 module.verbose('Removing active labels'); 5671 if(isLastLabel) { 5672 if(isSearch && !isFocusedOnSearch) { 5673 module.focusSearch(); 5674 } 5675 } 5676 $activeLabel.last().next(selector.siblingLabel).addClass(className.active); 5677 module.remove.activeLabels($activeLabel); 5678 event.preventDefault(); 5679 } 5680 else if(caretAtStart && !hasActiveLabel && pressedKey == keys.backspace) { 5681 module.verbose('Removing last label on input backspace'); 5682 $activeLabel = $label.last().addClass(className.active); 5683 module.remove.activeLabels($activeLabel); 5684 } 5685 } 5686 else { 5687 $activeLabel.removeClass(className.active); 5688 } 5689 } 5690 } 5691 }, 5692 5693 keydown: function(event) { 5694 var 5695 pressedKey = event.which, 5696 isShortcutKey = module.is.inObject(pressedKey, keys) 5697 ; 5698 if(isShortcutKey) { 5699 var 5700 $currentlySelected = $item.not(selector.unselectable).filter('.' + className.selected).eq(0), 5701 $activeItem = $menu.children('.' + className.active).eq(0), 5702 $selectedItem = ($currentlySelected.length > 0) 5703 ? $currentlySelected 5704 : $activeItem, 5705 $visibleItems = ($selectedItem.length > 0) 5706 ? $selectedItem.siblings(':not(.' + className.filtered +')').addBack() 5707 : $menu.children(':not(.' + className.filtered +')'), 5708 $subMenu = $selectedItem.children(selector.menu), 5709 $parentMenu = $selectedItem.closest(selector.menu), 5710 inVisibleMenu = ($parentMenu.hasClass(className.visible) || $parentMenu.hasClass(className.animating) || $parentMenu.parent(selector.menu).length > 0), 5711 hasSubMenu = ($subMenu.length> 0), 5712 hasSelectedItem = ($selectedItem.length > 0), 5713 selectedIsSelectable = ($selectedItem.not(selector.unselectable).length > 0), 5714 delimiterPressed = (pressedKey == keys.delimiter && settings.allowAdditions && module.is.multiple()), 5715 isAdditionWithoutMenu = (settings.allowAdditions && settings.hideAdditions && (pressedKey == keys.enter || delimiterPressed) && selectedIsSelectable), 5716 $nextItem, 5717 isSubMenuItem, 5718 newIndex 5719 ; 5720 // allow selection with menu closed 5721 if(isAdditionWithoutMenu) { 5722 module.verbose('Selecting item from keyboard shortcut', $selectedItem); 5723 module.event.item.click.call($selectedItem, event); 5724 if(module.is.searchSelection()) { 5725 module.remove.searchTerm(); 5726 } 5727 } 5728 5729 // visible menu keyboard shortcuts 5730 if( module.is.visible() ) { 5731 5732 // enter (select or open sub-menu) 5733 if(pressedKey == keys.enter || delimiterPressed) { 5734 if(pressedKey == keys.enter && hasSelectedItem && hasSubMenu && !settings.allowCategorySelection) { 5735 module.verbose('Pressed enter on unselectable category, opening sub menu'); 5736 pressedKey = keys.rightArrow; 5737 } 5738 else if(selectedIsSelectable) { 5739 module.verbose('Selecting item from keyboard shortcut', $selectedItem); 5740 module.event.item.click.call($selectedItem, event); 5741 if(module.is.searchSelection()) { 5742 module.remove.searchTerm(); 5743 } 5744 } 5745 event.preventDefault(); 5746 } 5747 5748 // sub-menu actions 5749 if(hasSelectedItem) { 5750 5751 if(pressedKey == keys.leftArrow) { 5752 5753 isSubMenuItem = ($parentMenu[0] !== $menu[0]); 5754 5755 if(isSubMenuItem) { 5756 module.verbose('Left key pressed, closing sub-menu'); 5757 module.animate.hide(false, $parentMenu); 5758 $selectedItem 5759 .removeClass(className.selected) 5760 ; 5761 $parentMenu 5762 .closest(selector.item) 5763 .addClass(className.selected) 5764 ; 5765 event.preventDefault(); 5766 } 5767 } 5768 5769 // right arrow (show sub-menu) 5770 if(pressedKey == keys.rightArrow) { 5771 if(hasSubMenu) { 5772 module.verbose('Right key pressed, opening sub-menu'); 5773 module.animate.show(false, $subMenu); 5774 $selectedItem 5775 .removeClass(className.selected) 5776 ; 5777 $subMenu 5778 .find(selector.item).eq(0) 5779 .addClass(className.selected) 5780 ; 5781 event.preventDefault(); 5782 } 5783 } 5784 } 5785 5786 // up arrow (traverse menu up) 5787 if(pressedKey == keys.upArrow) { 5788 $nextItem = (hasSelectedItem && inVisibleMenu) 5789 ? $selectedItem.prevAll(selector.item + ':not(' + selector.unselectable + ')').eq(0) 5790 : $item.eq(0) 5791 ; 5792 if($visibleItems.index( $nextItem ) < 0) { 5793 module.verbose('Up key pressed but reached top of current menu'); 5794 event.preventDefault(); 5795 return; 5796 } 5797 else { 5798 module.verbose('Up key pressed, changing active item'); 5799 $selectedItem 5800 .removeClass(className.selected) 5801 ; 5802 $nextItem 5803 .addClass(className.selected) 5804 ; 5805 module.set.scrollPosition($nextItem); 5806 if(settings.selectOnKeydown && module.is.single()) { 5807 module.set.selectedItem($nextItem); 5808 } 5809 } 5810 event.preventDefault(); 5811 } 5812 5813 // down arrow (traverse menu down) 5814 if(pressedKey == keys.downArrow) { 5815 $nextItem = (hasSelectedItem && inVisibleMenu) 5816 ? $nextItem = $selectedItem.nextAll(selector.item + ':not(' + selector.unselectable + ')').eq(0) 5817 : $item.eq(0) 5818 ; 5819 if($nextItem.length === 0) { 5820 module.verbose('Down key pressed but reached bottom of current menu'); 5821 event.preventDefault(); 5822 return; 5823 } 5824 else { 5825 module.verbose('Down key pressed, changing active item'); 5826 $item 5827 .removeClass(className.selected) 5828 ; 5829 $nextItem 5830 .addClass(className.selected) 5831 ; 5832 module.set.scrollPosition($nextItem); 5833 if(settings.selectOnKeydown && module.is.single()) { 5834 module.set.selectedItem($nextItem); 5835 } 5836 } 5837 event.preventDefault(); 5838 } 5839 5840 // page down (show next page) 5841 if(pressedKey == keys.pageUp) { 5842 module.scrollPage('up'); 5843 event.preventDefault(); 5844 } 5845 if(pressedKey == keys.pageDown) { 5846 module.scrollPage('down'); 5847 event.preventDefault(); 5848 } 5849 5850 // escape (close menu) 5851 if(pressedKey == keys.escape) { 5852 module.verbose('Escape key pressed, closing dropdown'); 5853 module.hide(); 5854 } 5855 5856 } 5857 else { 5858 // delimiter key 5859 if(delimiterPressed) { 5860 event.preventDefault(); 5861 } 5862 // down arrow (open menu) 5863 if(pressedKey == keys.downArrow && !module.is.visible()) { 5864 module.verbose('Down key pressed, showing dropdown'); 5865 module.show(); 5866 event.preventDefault(); 5867 } 5868 } 5869 } 5870 else { 5871 if( !module.has.search() ) { 5872 module.set.selectedLetter( String.fromCharCode(pressedKey) ); 5873 } 5874 } 5875 } 5876 }, 5877 5878 trigger: { 5879 change: function() { 5880 var 5881 events = document.createEvent('HTMLEvents'), 5882 inputElement = $input[0] 5883 ; 5884 if(inputElement) { 5885 module.verbose('Triggering native change event'); 5886 events.initEvent('change', true, false); 5887 inputElement.dispatchEvent(events); 5888 } 5889 } 5890 }, 5891 5892 determine: { 5893 selectAction: function(text, value) { 5894 module.verbose('Determining action', settings.action); 5895 if( $.isFunction( module.action[settings.action] ) ) { 5896 module.verbose('Triggering preset action', settings.action, text, value); 5897 module.action[ settings.action ].call(element, text, value, this); 5898 } 5899 else if( $.isFunction(settings.action) ) { 5900 module.verbose('Triggering user action', settings.action, text, value); 5901 settings.action.call(element, text, value, this); 5902 } 5903 else { 5904 module.error(error.action, settings.action); 5905 } 5906 }, 5907 eventInModule: function(event, callback) { 5908 var 5909 $target = $(event.target), 5910 inDocument = ($target.closest(document.documentElement).length > 0), 5911 inModule = ($target.closest($module).length > 0) 5912 ; 5913 callback = $.isFunction(callback) 5914 ? callback 5915 : function(){} 5916 ; 5917 if(inDocument && !inModule) { 5918 module.verbose('Triggering event', callback); 5919 callback(); 5920 return true; 5921 } 5922 else { 5923 module.verbose('Event occurred in dropdown, canceling callback'); 5924 return false; 5925 } 5926 }, 5927 eventOnElement: function(event, callback) { 5928 var 5929 $target = $(event.target), 5930 $label = $target.closest(selector.siblingLabel), 5931 inVisibleDOM = document.body.contains(event.target), 5932 notOnLabel = ($module.find($label).length === 0), 5933 notInMenu = ($target.closest($menu).length === 0) 5934 ; 5935 callback = $.isFunction(callback) 5936 ? callback 5937 : function(){} 5938 ; 5939 if(inVisibleDOM && notOnLabel && notInMenu) { 5940 module.verbose('Triggering event', callback); 5941 callback(); 5942 return true; 5943 } 5944 else { 5945 module.verbose('Event occurred in dropdown menu, canceling callback'); 5946 return false; 5947 } 5948 } 5949 }, 5950 5951 action: { 5952 5953 nothing: function() {}, 5954 5955 activate: function(text, value, element) { 5956 value = (value !== undefined) 5957 ? value 5958 : text 5959 ; 5960 if( module.can.activate( $(element) ) ) { 5961 module.set.selected(value, $(element)); 5962 if(module.is.multiple() && !module.is.allFiltered()) { 5963 return; 5964 } 5965 else { 5966 module.hideAndClear(); 5967 } 5968 } 5969 }, 5970 5971 select: function(text, value, element) { 5972 value = (value !== undefined) 5973 ? value 5974 : text 5975 ; 5976 if( module.can.activate( $(element) ) ) { 5977 module.set.value(value, $(element)); 5978 if(module.is.multiple() && !module.is.allFiltered()) { 5979 return; 5980 } 5981 else { 5982 module.hideAndClear(); 5983 } 5984 } 5985 }, 5986 5987 combo: function(text, value, element) { 5988 value = (value !== undefined) 5989 ? value 5990 : text 5991 ; 5992 module.set.selected(value, $(element)); 5993 module.hideAndClear(); 5994 }, 5995 5996 hide: function(text, value, element) { 5997 module.set.value(value, text); 5998 module.hideAndClear(); 5999 } 6000 6001 }, 6002 6003 get: { 6004 id: function() { 6005 return id; 6006 }, 6007 defaultText: function() { 6008 return $module.data(metadata.defaultText); 6009 }, 6010 defaultValue: function() { 6011 return $module.data(metadata.defaultValue); 6012 }, 6013 placeholderText: function() { 6014 if(settings.placeholder != 'auto' && typeof settings.placeholder == 'string') { 6015 return settings.placeholder; 6016 } 6017 return $module.data(metadata.placeholderText) || ''; 6018 }, 6019 text: function() { 6020 return $text.text(); 6021 }, 6022 query: function() { 6023 return $.trim($search.val()); 6024 }, 6025 searchWidth: function(value) { 6026 value = (value !== undefined) 6027 ? value 6028 : $search.val() 6029 ; 6030 $sizer.text(value); 6031 // prevent rounding issues 6032 return Math.ceil( $sizer.width() + 1); 6033 }, 6034 selectionCount: function() { 6035 var 6036 values = module.get.values(), 6037 count 6038 ; 6039 count = ( module.is.multiple() ) 6040 ? $.isArray(values) 6041 ? values.length 6042 : 0 6043 : (module.get.value() !== '') 6044 ? 1 6045 : 0 6046 ; 6047 return count; 6048 }, 6049 transition: function($subMenu) { 6050 return (settings.transition == 'auto') 6051 ? module.is.upward($subMenu) 6052 ? 'slide up' 6053 : 'slide down' 6054 : settings.transition 6055 ; 6056 }, 6057 userValues: function() { 6058 var 6059 values = module.get.values() 6060 ; 6061 if(!values) { 6062 return false; 6063 } 6064 values = $.isArray(values) 6065 ? values 6066 : [values] 6067 ; 6068 return $.grep(values, function(value) { 6069 return (module.get.item(value) === false); 6070 }); 6071 }, 6072 uniqueArray: function(array) { 6073 return $.grep(array, function (value, index) { 6074 return $.inArray(value, array) === index; 6075 }); 6076 }, 6077 caretPosition: function() { 6078 var 6079 input = $search.get(0), 6080 range, 6081 rangeLength 6082 ; 6083 if('selectionStart' in input) { 6084 return input.selectionStart; 6085 } 6086 else if (document.selection) { 6087 input.focus(); 6088 range = document.selection.createRange(); 6089 rangeLength = range.text.length; 6090 range.moveStart('character', -input.value.length); 6091 return range.text.length - rangeLength; 6092 } 6093 }, 6094 value: function() { 6095 var 6096 value = ($input.length > 0) 6097 ? $input.val() 6098 : $module.data(metadata.value), 6099 isEmptyMultiselect = ($.isArray(value) && value.length === 1 && value[0] === '') 6100 ; 6101 // prevents placeholder element from being selected when multiple 6102 return (value === undefined || isEmptyMultiselect) 6103 ? '' 6104 : value 6105 ; 6106 }, 6107 values: function() { 6108 var 6109 value = module.get.value() 6110 ; 6111 if(value === '') { 6112 return ''; 6113 } 6114 return ( !module.has.selectInput() && module.is.multiple() ) 6115 ? (typeof value == 'string') // delimited string 6116 ? value.split(settings.delimiter) 6117 : '' 6118 : value 6119 ; 6120 }, 6121 remoteValues: function() { 6122 var 6123 values = module.get.values(), 6124 remoteValues = false 6125 ; 6126 if(values) { 6127 if(typeof values == 'string') { 6128 values = [values]; 6129 } 6130 $.each(values, function(index, value) { 6131 var 6132 name = module.read.remoteData(value) 6133 ; 6134 module.verbose('Restoring value from session data', name, value); 6135 if(name) { 6136 if(!remoteValues) { 6137 remoteValues = {}; 6138 } 6139 remoteValues[value] = name; 6140 } 6141 }); 6142 } 6143 return remoteValues; 6144 }, 6145 choiceText: function($choice, preserveHTML) { 6146 preserveHTML = (preserveHTML !== undefined) 6147 ? preserveHTML 6148 : settings.preserveHTML 6149 ; 6150 if($choice) { 6151 if($choice.find(selector.menu).length > 0) { 6152 module.verbose('Retrieving text of element with sub-menu'); 6153 $choice = $choice.clone(); 6154 $choice.find(selector.menu).remove(); 6155 $choice.find(selector.menuIcon).remove(); 6156 } 6157 return ($choice.data(metadata.text) !== undefined) 6158 ? $choice.data(metadata.text) 6159 : (preserveHTML) 6160 ? $.trim($choice.html()) 6161 : $.trim($choice.text()) 6162 ; 6163 } 6164 }, 6165 choiceValue: function($choice, choiceText) { 6166 choiceText = choiceText || module.get.choiceText($choice); 6167 if(!$choice) { 6168 return false; 6169 } 6170 return ($choice.data(metadata.value) !== undefined) 6171 ? String( $choice.data(metadata.value) ) 6172 : (typeof choiceText === 'string') 6173 ? $.trim(choiceText.toLowerCase()) 6174 : String(choiceText) 6175 ; 6176 }, 6177 inputEvent: function() { 6178 var 6179 input = $search[0] 6180 ; 6181 if(input) { 6182 return (input.oninput !== undefined) 6183 ? 'input' 6184 : (input.onpropertychange !== undefined) 6185 ? 'propertychange' 6186 : 'keyup' 6187 ; 6188 } 6189 return false; 6190 }, 6191 selectValues: function() { 6192 var 6193 select = {} 6194 ; 6195 select.values = []; 6196 $module 6197 .find('option') 6198 .each(function() { 6199 var 6200 $option = $(this), 6201 name = $option.html(), 6202 disabled = $option.attr('disabled'), 6203 value = ( $option.attr('value') !== undefined ) 6204 ? $option.attr('value') 6205 : name 6206 ; 6207 if(settings.placeholder === 'auto' && value === '') { 6208 select.placeholder = name; 6209 } 6210 else { 6211 select.values.push({ 6212 name : name, 6213 value : value, 6214 disabled : disabled 6215 }); 6216 } 6217 }) 6218 ; 6219 if(settings.placeholder && settings.placeholder !== 'auto') { 6220 module.debug('Setting placeholder value to', settings.placeholder); 6221 select.placeholder = settings.placeholder; 6222 } 6223 if(settings.sortSelect) { 6224 select.values.sort(function(a, b) { 6225 return (a.name > b.name) 6226 ? 1 6227 : -1 6228 ; 6229 }); 6230 module.debug('Retrieved and sorted values from select', select); 6231 } 6232 else { 6233 module.debug('Retrieved values from select', select); 6234 } 6235 return select; 6236 }, 6237 activeItem: function() { 6238 return $item.filter('.' + className.active); 6239 }, 6240 selectedItem: function() { 6241 var 6242 $selectedItem = $item.not(selector.unselectable).filter('.' + className.selected) 6243 ; 6244 return ($selectedItem.length > 0) 6245 ? $selectedItem 6246 : $item.eq(0) 6247 ; 6248 }, 6249 itemWithAdditions: function(value) { 6250 var 6251 $items = module.get.item(value), 6252 $userItems = module.create.userChoice(value), 6253 hasUserItems = ($userItems && $userItems.length > 0) 6254 ; 6255 if(hasUserItems) { 6256 $items = ($items.length > 0) 6257 ? $items.add($userItems) 6258 : $userItems 6259 ; 6260 } 6261 return $items; 6262 }, 6263 item: function(value, strict) { 6264 var 6265 $selectedItem = false, 6266 shouldSearch, 6267 isMultiple 6268 ; 6269 value = (value !== undefined) 6270 ? value 6271 : ( module.get.values() !== undefined) 6272 ? module.get.values() 6273 : module.get.text() 6274 ; 6275 shouldSearch = (isMultiple) 6276 ? (value.length > 0) 6277 : (value !== undefined && value !== null) 6278 ; 6279 isMultiple = (module.is.multiple() && $.isArray(value)); 6280 strict = (value === '' || value === 0) 6281 ? true 6282 : strict || false 6283 ; 6284 if(shouldSearch) { 6285 $item 6286 .each(function() { 6287 var 6288 $choice = $(this), 6289 optionText = module.get.choiceText($choice), 6290 optionValue = module.get.choiceValue($choice, optionText) 6291 ; 6292 // safe early exit 6293 if(optionValue === null || optionValue === undefined) { 6294 return; 6295 } 6296 if(isMultiple) { 6297 if($.inArray( String(optionValue), value) !== -1 || $.inArray(optionText, value) !== -1) { 6298 $selectedItem = ($selectedItem) 6299 ? $selectedItem.add($choice) 6300 : $choice 6301 ; 6302 } 6303 } 6304 else if(strict) { 6305 module.verbose('Ambiguous dropdown value using strict type check', $choice, value); 6306 if( optionValue === value || optionText === value) { 6307 $selectedItem = $choice; 6308 return true; 6309 } 6310 } 6311 else { 6312 if( String(optionValue) == String(value) || optionText == value) { 6313 module.verbose('Found select item by value', optionValue, value); 6314 $selectedItem = $choice; 6315 return true; 6316 } 6317 } 6318 }) 6319 ; 6320 } 6321 return $selectedItem; 6322 } 6323 }, 6324 6325 check: { 6326 maxSelections: function(selectionCount) { 6327 if(settings.maxSelections) { 6328 selectionCount = (selectionCount !== undefined) 6329 ? selectionCount 6330 : module.get.selectionCount() 6331 ; 6332 if(selectionCount >= settings.maxSelections) { 6333 module.debug('Maximum selection count reached'); 6334 if(settings.useLabels) { 6335 $item.addClass(className.filtered); 6336 module.add.message(message.maxSelections); 6337 } 6338 return true; 6339 } 6340 else { 6341 module.verbose('No longer at maximum selection count'); 6342 module.remove.message(); 6343 module.remove.filteredItem(); 6344 if(module.is.searchSelection()) { 6345 module.filterItems(); 6346 } 6347 return false; 6348 } 6349 } 6350 return true; 6351 } 6352 }, 6353 6354 restore: { 6355 defaults: function() { 6356 module.clear(); 6357 module.restore.defaultText(); 6358 module.restore.defaultValue(); 6359 }, 6360 defaultText: function() { 6361 var 6362 defaultText = module.get.defaultText(), 6363 placeholderText = module.get.placeholderText 6364 ; 6365 if(defaultText === placeholderText) { 6366 module.debug('Restoring default placeholder text', defaultText); 6367 module.set.placeholderText(defaultText); 6368 } 6369 else { 6370 module.debug('Restoring default text', defaultText); 6371 module.set.text(defaultText); 6372 } 6373 }, 6374 placeholderText: function() { 6375 module.set.placeholderText(); 6376 }, 6377 defaultValue: function() { 6378 var 6379 defaultValue = module.get.defaultValue() 6380 ; 6381 if(defaultValue !== undefined) { 6382 module.debug('Restoring default value', defaultValue); 6383 if(defaultValue !== '') { 6384 module.set.value(defaultValue); 6385 module.set.selected(); 6386 } 6387 else { 6388 module.remove.activeItem(); 6389 module.remove.selectedItem(); 6390 } 6391 } 6392 }, 6393 labels: function() { 6394 if(settings.allowAdditions) { 6395 if(!settings.useLabels) { 6396 module.error(error.labels); 6397 settings.useLabels = true; 6398 } 6399 module.debug('Restoring selected values'); 6400 module.create.userLabels(); 6401 } 6402 module.check.maxSelections(); 6403 }, 6404 selected: function() { 6405 module.restore.values(); 6406 if(module.is.multiple()) { 6407 module.debug('Restoring previously selected values and labels'); 6408 module.restore.labels(); 6409 } 6410 else { 6411 module.debug('Restoring previously selected values'); 6412 } 6413 }, 6414 values: function() { 6415 // prevents callbacks from occurring on initial load 6416 module.set.initialLoad(); 6417 if(settings.apiSettings && settings.saveRemoteData && module.get.remoteValues()) { 6418 module.restore.remoteValues(); 6419 } 6420 else { 6421 module.set.selected(); 6422 } 6423 module.remove.initialLoad(); 6424 }, 6425 remoteValues: function() { 6426 var 6427 values = module.get.remoteValues() 6428 ; 6429 module.debug('Recreating selected from session data', values); 6430 if(values) { 6431 if( module.is.single() ) { 6432 $.each(values, function(value, name) { 6433 module.set.text(name); 6434 }); 6435 } 6436 else { 6437 $.each(values, function(value, name) { 6438 module.add.label(value, name); 6439 }); 6440 } 6441 } 6442 } 6443 }, 6444 6445 read: { 6446 remoteData: function(value) { 6447 var 6448 name 6449 ; 6450 if(window.Storage === undefined) { 6451 module.error(error.noStorage); 6452 return; 6453 } 6454 name = sessionStorage.getItem(value); 6455 return (name !== undefined) 6456 ? name 6457 : false 6458 ; 6459 } 6460 }, 6461 6462 save: { 6463 defaults: function() { 6464 module.save.defaultText(); 6465 module.save.placeholderText(); 6466 module.save.defaultValue(); 6467 }, 6468 defaultValue: function() { 6469 var 6470 value = module.get.value() 6471 ; 6472 module.verbose('Saving default value as', value); 6473 $module.data(metadata.defaultValue, value); 6474 }, 6475 defaultText: function() { 6476 var 6477 text = module.get.text() 6478 ; 6479 module.verbose('Saving default text as', text); 6480 $module.data(metadata.defaultText, text); 6481 }, 6482 placeholderText: function() { 6483 var 6484 text 6485 ; 6486 if(settings.placeholder !== false && $text.hasClass(className.placeholder)) { 6487 text = module.get.text(); 6488 module.verbose('Saving placeholder text as', text); 6489 $module.data(metadata.placeholderText, text); 6490 } 6491 }, 6492 remoteData: function(name, value) { 6493 if(window.Storage === undefined) { 6494 module.error(error.noStorage); 6495 return; 6496 } 6497 module.verbose('Saving remote data to session storage', value, name); 6498 sessionStorage.setItem(value, name); 6499 } 6500 }, 6501 6502 clear: function() { 6503 if(module.is.multiple() && settings.useLabels) { 6504 module.remove.labels(); 6505 } 6506 else { 6507 module.remove.activeItem(); 6508 module.remove.selectedItem(); 6509 } 6510 module.set.placeholderText(); 6511 module.clearValue(); 6512 }, 6513 6514 clearValue: function() { 6515 module.set.value(''); 6516 }, 6517 6518 scrollPage: function(direction, $selectedItem) { 6519 var 6520 $currentItem = $selectedItem || module.get.selectedItem(), 6521 $menu = $currentItem.closest(selector.menu), 6522 menuHeight = $menu.outerHeight(), 6523 currentScroll = $menu.scrollTop(), 6524 itemHeight = $item.eq(0).outerHeight(), 6525 itemsPerPage = Math.floor(menuHeight / itemHeight), 6526 maxScroll = $menu.prop('scrollHeight'), 6527 newScroll = (direction == 'up') 6528 ? currentScroll - (itemHeight * itemsPerPage) 6529 : currentScroll + (itemHeight * itemsPerPage), 6530 $selectableItem = $item.not(selector.unselectable), 6531 isWithinRange, 6532 $nextSelectedItem, 6533 elementIndex 6534 ; 6535 elementIndex = (direction == 'up') 6536 ? $selectableItem.index($currentItem) - itemsPerPage 6537 : $selectableItem.index($currentItem) + itemsPerPage 6538 ; 6539 isWithinRange = (direction == 'up') 6540 ? (elementIndex >= 0) 6541 : (elementIndex < $selectableItem.length) 6542 ; 6543 $nextSelectedItem = (isWithinRange) 6544 ? $selectableItem.eq(elementIndex) 6545 : (direction == 'up') 6546 ? $selectableItem.first() 6547 : $selectableItem.last() 6548 ; 6549 if($nextSelectedItem.length > 0) { 6550 module.debug('Scrolling page', direction, $nextSelectedItem); 6551 $currentItem 6552 .removeClass(className.selected) 6553 ; 6554 $nextSelectedItem 6555 .addClass(className.selected) 6556 ; 6557 if(settings.selectOnKeydown && module.is.single()) { 6558 module.set.selectedItem($nextSelectedItem); 6559 } 6560 $menu 6561 .scrollTop(newScroll) 6562 ; 6563 } 6564 }, 6565 6566 set: { 6567 filtered: function() { 6568 var 6569 isMultiple = module.is.multiple(), 6570 isSearch = module.is.searchSelection(), 6571 isSearchMultiple = (isMultiple && isSearch), 6572 searchValue = (isSearch) 6573 ? module.get.query() 6574 : '', 6575 hasSearchValue = (typeof searchValue === 'string' && searchValue.length > 0), 6576 searchWidth = module.get.searchWidth(), 6577 valueIsSet = searchValue !== '' 6578 ; 6579 if(isMultiple && hasSearchValue) { 6580 module.verbose('Adjusting input width', searchWidth, settings.glyphWidth); 6581 $search.css('width', searchWidth); 6582 } 6583 if(hasSearchValue || (isSearchMultiple && valueIsSet)) { 6584 module.verbose('Hiding placeholder text'); 6585 $text.addClass(className.filtered); 6586 } 6587 else if(!isMultiple || (isSearchMultiple && !valueIsSet)) { 6588 module.verbose('Showing placeholder text'); 6589 $text.removeClass(className.filtered); 6590 } 6591 }, 6592 empty: function() { 6593 $module.addClass(className.empty); 6594 }, 6595 loading: function() { 6596 $module.addClass(className.loading); 6597 }, 6598 placeholderText: function(text) { 6599 text = text || module.get.placeholderText(); 6600 module.debug('Setting placeholder text', text); 6601 module.set.text(text); 6602 $text.addClass(className.placeholder); 6603 }, 6604 tabbable: function() { 6605 if( module.is.searchSelection() ) { 6606 module.debug('Added tabindex to searchable dropdown'); 6607 $search 6608 .val('') 6609 .attr('tabindex', 0) 6610 ; 6611 $menu 6612 .attr('tabindex', -1) 6613 ; 6614 } 6615 else { 6616 module.debug('Added tabindex to dropdown'); 6617 if( $module.attr('tabindex') === undefined) { 6618 $module 6619 .attr('tabindex', 0) 6620 ; 6621 $menu 6622 .attr('tabindex', -1) 6623 ; 6624 } 6625 } 6626 }, 6627 initialLoad: function() { 6628 module.verbose('Setting initial load'); 6629 initialLoad = true; 6630 }, 6631 activeItem: function($item) { 6632 if( settings.allowAdditions && $item.filter(selector.addition).length > 0 ) { 6633 $item.addClass(className.filtered); 6634 } 6635 else { 6636 $item.addClass(className.active); 6637 } 6638 }, 6639 partialSearch: function(text) { 6640 var 6641 length = module.get.query().length 6642 ; 6643 $search.val( text.substr(0 , length)); 6644 }, 6645 scrollPosition: function($item, forceScroll) { 6646 var 6647 edgeTolerance = 5, 6648 $menu, 6649 hasActive, 6650 offset, 6651 itemHeight, 6652 itemOffset, 6653 menuOffset, 6654 menuScroll, 6655 menuHeight, 6656 abovePage, 6657 belowPage 6658 ; 6659 6660 $item = $item || module.get.selectedItem(); 6661 $menu = $item.closest(selector.menu); 6662 hasActive = ($item && $item.length > 0); 6663 forceScroll = (forceScroll !== undefined) 6664 ? forceScroll 6665 : false 6666 ; 6667 if($item && $menu.length > 0 && hasActive) { 6668 itemOffset = $item.position().top; 6669 6670 $menu.addClass(className.loading); 6671 menuScroll = $menu.scrollTop(); 6672 menuOffset = $menu.offset().top; 6673 itemOffset = $item.offset().top; 6674 offset = menuScroll - menuOffset + itemOffset; 6675 if(!forceScroll) { 6676 menuHeight = $menu.height(); 6677 belowPage = menuScroll + menuHeight < (offset + edgeTolerance); 6678 abovePage = ((offset - edgeTolerance) < menuScroll); 6679 } 6680 module.debug('Scrolling to active item', offset); 6681 if(forceScroll || abovePage || belowPage) { 6682 $menu.scrollTop(offset); 6683 } 6684 $menu.removeClass(className.loading); 6685 } 6686 }, 6687 text: function(text) { 6688 if(settings.action !== 'select') { 6689 if(settings.action == 'combo') { 6690 module.debug('Changing combo button text', text, $combo); 6691 if(settings.preserveHTML) { 6692 $combo.html(text); 6693 } 6694 else { 6695 $combo.text(text); 6696 } 6697 } 6698 else { 6699 if(text !== module.get.placeholderText()) { 6700 $text.removeClass(className.placeholder); 6701 } 6702 module.debug('Changing text', text, $text); 6703 $text 6704 .removeClass(className.filtered) 6705 ; 6706 if(settings.preserveHTML) { 6707 $text.html(text); 6708 } 6709 else { 6710 $text.text(text); 6711 } 6712 } 6713 } 6714 }, 6715 selectedItem: function($item) { 6716 var 6717 value = module.get.choiceValue($item), 6718 searchText = module.get.choiceText($item, false), 6719 text = module.get.choiceText($item, true) 6720 ; 6721 module.debug('Setting user selection to item', $item); 6722 module.remove.activeItem(); 6723 module.set.partialSearch(searchText); 6724 module.set.activeItem($item); 6725 module.set.selected(value, $item); 6726 module.set.text(text); 6727 }, 6728 selectedLetter: function(letter) { 6729 var 6730 $selectedItem = $item.filter('.' + className.selected), 6731 alreadySelectedLetter = $selectedItem.length > 0 && module.has.firstLetter($selectedItem, letter), 6732 $nextValue = false, 6733 $nextItem 6734 ; 6735 // check next of same letter 6736 if(alreadySelectedLetter) { 6737 $nextItem = $selectedItem.nextAll($item).eq(0); 6738 if( module.has.firstLetter($nextItem, letter) ) { 6739 $nextValue = $nextItem; 6740 } 6741 } 6742 // check all values 6743 if(!$nextValue) { 6744 $item 6745 .each(function(){ 6746 if(module.has.firstLetter($(this), letter)) { 6747 $nextValue = $(this); 6748 return false; 6749 } 6750 }) 6751 ; 6752 } 6753 // set next value 6754 if($nextValue) { 6755 module.verbose('Scrolling to next value with letter', letter); 6756 module.set.scrollPosition($nextValue); 6757 $selectedItem.removeClass(className.selected); 6758 $nextValue.addClass(className.selected); 6759 if(settings.selectOnKeydown && module.is.single()) { 6760 module.set.selectedItem($nextValue); 6761 } 6762 } 6763 }, 6764 direction: function($menu) { 6765 if(settings.direction == 'auto') { 6766 // reset position 6767 module.remove.upward(); 6768 6769 if(module.can.openDownward($menu)) { 6770 module.remove.upward($menu); 6771 } 6772 else { 6773 module.set.upward($menu); 6774 } 6775 if(!module.is.leftward($menu) && !module.can.openRightward($menu)) { 6776 module.set.leftward($menu); 6777 } 6778 } 6779 else if(settings.direction == 'upward') { 6780 module.set.upward($menu); 6781 } 6782 }, 6783 upward: function($currentMenu) { 6784 var $element = $currentMenu || $module; 6785 $element.addClass(className.upward); 6786 }, 6787 leftward: function($currentMenu) { 6788 var $element = $currentMenu || $menu; 6789 $element.addClass(className.leftward); 6790 }, 6791 value: function(value, text, $selected) { 6792 var 6793 escapedValue = module.escape.value(value), 6794 hasInput = ($input.length > 0), 6795 isAddition = !module.has.value(value), 6796 currentValue = module.get.values(), 6797 stringValue = (value !== undefined) 6798 ? String(value) 6799 : value, 6800 newValue 6801 ; 6802 if(hasInput) { 6803 if(!settings.allowReselection && stringValue == currentValue) { 6804 module.verbose('Skipping value update already same value', value, currentValue); 6805 if(!module.is.initialLoad()) { 6806 return; 6807 } 6808 } 6809 6810 if( module.is.single() && module.has.selectInput() && module.can.extendSelect() ) { 6811 module.debug('Adding user option', value); 6812 module.add.optionValue(value); 6813 } 6814 module.debug('Updating input value', escapedValue, currentValue); 6815 internalChange = true; 6816 $input 6817 .val(escapedValue) 6818 ; 6819 if(settings.fireOnInit === false && module.is.initialLoad()) { 6820 module.debug('Input native change event ignored on initial load'); 6821 } 6822 else { 6823 module.trigger.change(); 6824 } 6825 internalChange = false; 6826 } 6827 else { 6828 module.verbose('Storing value in metadata', escapedValue, $input); 6829 if(escapedValue !== currentValue) { 6830 $module.data(metadata.value, stringValue); 6831 } 6832 } 6833 if(settings.fireOnInit === false && module.is.initialLoad()) { 6834 module.verbose('No callback on initial load', settings.onChange); 6835 } 6836 else { 6837 settings.onChange.call(element, value, text, $selected); 6838 } 6839 }, 6840 active: function() { 6841 $module 6842 .addClass(className.active) 6843 ; 6844 }, 6845 multiple: function() { 6846 $module.addClass(className.multiple); 6847 }, 6848 visible: function() { 6849 $module.addClass(className.visible); 6850 }, 6851 exactly: function(value, $selectedItem) { 6852 module.debug('Setting selected to exact values'); 6853 module.clear(); 6854 module.set.selected(value, $selectedItem); 6855 }, 6856 selected: function(value, $selectedItem) { 6857 var 6858 isMultiple = module.is.multiple(), 6859 $userSelectedItem 6860 ; 6861 $selectedItem = (settings.allowAdditions) 6862 ? $selectedItem || module.get.itemWithAdditions(value) 6863 : $selectedItem || module.get.item(value) 6864 ; 6865 if(!$selectedItem) { 6866 return; 6867 } 6868 module.debug('Setting selected menu item to', $selectedItem); 6869 if(module.is.multiple()) { 6870 module.remove.searchWidth(); 6871 } 6872 if(module.is.single()) { 6873 module.remove.activeItem(); 6874 module.remove.selectedItem(); 6875 } 6876 else if(settings.useLabels) { 6877 module.remove.selectedItem(); 6878 } 6879 // select each item 6880 $selectedItem 6881 .each(function() { 6882 var 6883 $selected = $(this), 6884 selectedText = module.get.choiceText($selected), 6885 selectedValue = module.get.choiceValue($selected, selectedText), 6886 6887 isFiltered = $selected.hasClass(className.filtered), 6888 isActive = $selected.hasClass(className.active), 6889 isUserValue = $selected.hasClass(className.addition), 6890 shouldAnimate = (isMultiple && $selectedItem.length == 1) 6891 ; 6892 if(isMultiple) { 6893 if(!isActive || isUserValue) { 6894 if(settings.apiSettings && settings.saveRemoteData) { 6895 module.save.remoteData(selectedText, selectedValue); 6896 } 6897 if(settings.useLabels) { 6898 module.add.value(selectedValue, selectedText, $selected); 6899 module.add.label(selectedValue, selectedText, shouldAnimate); 6900 module.set.activeItem($selected); 6901 module.filterActive(); 6902 module.select.nextAvailable($selectedItem); 6903 } 6904 else { 6905 module.add.value(selectedValue, selectedText, $selected); 6906 module.set.text(module.add.variables(message.count)); 6907 module.set.activeItem($selected); 6908 } 6909 } 6910 else if(!isFiltered) { 6911 module.debug('Selected active value, remov
vendor: 12,008 bytes, lines 6911-7136
6911ing label'); 6912 module.remove.selected(selectedValue); 6913 } 6914 } 6915 else { 6916 if(settings.apiSettings && settings.saveRemoteData) { 6917 module.save.remoteData(selectedText, selectedValue); 6918 } 6919 module.set.text(selectedText); 6920 module.set.value(selectedValue, selectedText, $selected); 6921 $selected 6922 .addClass(className.active) 6923 .addClass(className.selected) 6924 ; 6925 } 6926 }) 6927 ; 6928 } 6929 }, 6930 6931 add: { 6932 label: function(value, text, shouldAnimate) { 6933 var 6934 $next = module.is.searchSelection() 6935 ? $search 6936 : $text, 6937 escapedValue = module.escape.value(value), 6938 $label 6939 ; 6940 $label = $('<a />') 6941 .addClass(className.label) 6942 .attr('data-' + metadata.value, escapedValue) 6943 .html(templates.label(escapedValue, text)) 6944 ; 6945 $label = settings.onLabelCreate.call($label, escapedValue, text); 6946 6947 if(module.has.label(value)) { 6948 module.debug('Label already exists, skipping', escapedValue); 6949 return; 6950 } 6951 if(settings.label.variation) { 6952 $label.addClass(settings.label.variation); 6953 } 6954 if(shouldAnimate === true) { 6955 module.debug('Animating in label', $label); 6956 $label 6957 .addClass(className.hidden) 6958 .insertBefore($next) 6959 .transition(settings.label.transition, settings.label.duration) 6960 ; 6961 } 6962 else { 6963 module.debug('Adding selection label', $label); 6964 $label 6965 .insertBefore($next) 6966 ; 6967 } 6968 }, 6969 message: function(message) { 6970 var 6971 $message = $menu.children(selector.message), 6972 html = settings.templates.message(module.add.variables(message)) 6973 ; 6974 if($message.length > 0) { 6975 $message 6976 .html(html) 6977 ; 6978 } 6979 else { 6980 $message = $('<div/>') 6981 .html(html) 6982 .addClass(className.message) 6983 .appendTo($menu) 6984 ; 6985 } 6986 }, 6987 optionValue: function(value) { 6988 var 6989 escapedValue = module.escape.value(value), 6990 $option = $input.find('option[value="' + module.escape.string(escapedValue) + '"]'), 6991 hasOption = ($option.length > 0) 6992 ; 6993 if(hasOption) { 6994 return; 6995 } 6996 // temporarily disconnect observer 6997 module.disconnect.selectObserver(); 6998 if( module.is.single() ) { 6999 module.verbose('Removing previous user addition'); 7000 $input.find('option.' + className.addition).remove(); 7001 } 7002 $('<option/>') 7003 .prop('value', escapedValue) 7004 .addClass(className.addition) 7005 .html(value) 7006 .appendTo($input) 7007 ; 7008 module.verbose('Adding user addition as an <option>', value); 7009 module.observe.select(); 7010 }, 7011 userSuggestion: function(value) { 7012 var 7013 $addition = $menu.children(selector.addition), 7014 $existingItem = module.get.item(value), 7015 alreadyHasValue = $existingItem && $existingItem.not(selector.addition).length, 7016 hasUserSuggestion = $addition.length > 0, 7017 html 7018 ; 7019 if(settings.useLabels && module.has.maxSelections()) { 7020 return; 7021 } 7022 if(value === '' || alreadyHasValue) { 7023 $addition.remove(); 7024 return; 7025 } 7026 if(hasUserSuggestion) { 7027 $addition 7028 .data(metadata.value, value) 7029 .data(metadata.text, value) 7030 .attr('data-' + metadata.value, value) 7031 .attr('data-' + metadata.text, value) 7032 .removeClass(className.filtered) 7033 ; 7034 if(!settings.hideAdditions) { 7035 html = settings.templates.addition( module.add.variables(message.addResult, value) ); 7036 $addition 7037 .html(html) 7038 ; 7039 } 7040 module.verbose('Replacing user suggestion with new value', $addition); 7041 } 7042 else { 7043 $addition = module.create.userChoice(value); 7044 $addition 7045 .prependTo($menu) 7046 ; 7047 module.verbose('Adding item choice to menu corresponding with user choice addition', $addition); 7048 } 7049 if(!settings.hideAdditions || module.is.allFiltered()) { 7050 $addition 7051 .addClass(className.selected) 7052 .siblings() 7053 .removeClass(className.selected) 7054 ; 7055 } 7056 module.refreshItems(); 7057 }, 7058 variables: function(message, term) { 7059 var 7060 hasCount = (message.search('{count}') !== -1), 7061 hasMaxCount = (message.search('{maxCount}') !== -1), 7062 hasTerm = (message.search('{term}') !== -1), 7063 values, 7064 count, 7065 query 7066 ; 7067 module.verbose('Adding templated variables to message', message); 7068 if(hasCount) { 7069 count = module.get.selectionCount(); 7070 message = message.replace('{count}', count); 7071 } 7072 if(hasMaxCount) { 7073 count = module.get.selectionCount(); 7074 message = message.replace('{maxCount}', settings.maxSelections); 7075 } 7076 if(hasTerm) { 7077 query = term || module.get.query(); 7078 message = message.replace('{term}', query); 7079 } 7080 return message; 7081 }, 7082 value: function(addedValue, addedText, $selectedItem) { 7083 var 7084 currentValue = module.get.values(), 7085 newValue 7086 ; 7087 if(addedValue === '') { 7088 module.debug('Cannot select blank values from multiselect'); 7089 return; 7090 } 7091 // extend current array 7092 if($.isArray(currentValue)) { 7093 newValue = currentValue.concat([addedValue]); 7094 newValue = module.get.uniqueArray(newValue); 7095 } 7096 else { 7097 newValue = [addedValue]; 7098 } 7099 // add values 7100 if( module.has.selectInput() ) { 7101 if(module.can.extendSelect()) { 7102 module.debug('Adding value to select', addedValue, newValue, $input); 7103 module.add.optionValue(addedValue); 7104 } 7105 } 7106 else { 7107 newValue = newValue.join(settings.delimiter); 7108 module.debug('Setting hidden input to delimited value', newValue, $input); 7109 } 7110 7111 if(settings.fireOnInit === false && module.is.initialLoad()) { 7112 module.verbose('Skipping onadd callback on initial load', settings.onAdd); 7113 } 7114 else { 7115 settings.onAdd.call(element, addedValue, addedText, $selectedItem); 7116 } 7117 module.set.value(newValue, addedValue, addedText, $selectedItem); 7118 module.check.maxSelections(); 7119 } 7120 }, 7121 7122 remove: { 7123 active: function() { 7124 $module.removeClass(className.active); 7125 }, 7126 activeLabel: function() { 7127 $module.find(selector.label).removeClass(className.active); 7128 }, 7129 empty: function() { 7130 $module.removeClass(className.empty); 7131 }, 7132 loading: function() { 7133 $module.removeClass(className.loading); 7134 }, 7135 initialLoad: function() { 7136 initialLoad = false;
vendor: 9,429 bytes, lines 7137-7303
7137 }, 7138 upward: function($currentMenu) { 7139 var $element = $currentMenu || $module; 7140 $element.removeClass(className.upward); 7141 }, 7142 leftward: function($currentMenu) { 7143 var $element = $currentMenu || $menu; 7144 $element.removeClass(className.leftward); 7145 }, 7146 visible: function() { 7147 $module.removeClass(className.visible); 7148 }, 7149 activeItem: function() { 7150 $item.removeClass(className.active); 7151 }, 7152 filteredItem: function() { 7153 if(settings.useLabels && module.has.maxSelections() ) { 7154 return; 7155 } 7156 if(settings.useLabels && module.is.multiple()) { 7157 $item.not('.' + className.active).removeClass(className.filtered); 7158 } 7159 else { 7160 $item.removeClass(className.filtered); 7161 } 7162 module.remove.empty(); 7163 }, 7164 optionValue: function(value) { 7165 var 7166 escapedValue = module.escape.value(value), 7167 $option = $input.find('option[value="' + module.escape.string(escapedValue) + '"]'), 7168 hasOption = ($option.length > 0) 7169 ; 7170 if(!hasOption || !$option.hasClass(className.addition)) { 7171 return; 7172 } 7173 // temporarily disconnect observer 7174 if(selectObserver) { 7175 selectObserver.disconnect(); 7176 module.verbose('Temporarily disconnecting mutation observer'); 7177 } 7178 $option.remove(); 7179 module.verbose('Removing user addition as an <option>', escapedValue); 7180 if(selectObserver) { 7181 selectObserver.observe($input[0], { 7182 childList : true, 7183 subtree : true 7184 }); 7185 } 7186 }, 7187 message: function() { 7188 $menu.children(selector.message).remove(); 7189 }, 7190 searchWidth: function() { 7191 $search.css('width', ''); 7192 }, 7193 searchTerm: function() { 7194 module.verbose('Cleared search term'); 7195 $search.val(''); 7196 module.set.filtered(); 7197 }, 7198 userAddition: function() { 7199 $item.filter(selector.addition).remove(); 7200 }, 7201 selected: function(value, $selectedItem) { 7202 $selectedItem = (settings.allowAdditions) 7203 ? $selectedItem || module.get.itemWithAdditions(value) 7204 : $selectedItem || module.get.item(value) 7205 ; 7206 7207 if(!$selectedItem) { 7208 return false; 7209 } 7210 7211 $selectedItem 7212 .each(function() { 7213 var 7214 $selected = $(this), 7215 selectedText = module.get.choiceText($selected), 7216 selectedValue = module.get.choiceValue($selected, selectedText) 7217 ; 7218 if(module.is.multiple()) { 7219 if(settings.useLabels) { 7220 module.remove.value(selectedValue, selectedText, $selected); 7221 module.remove.label(selectedValue); 7222 } 7223 else { 7224 module.remove.value(selectedValue, selectedText, $selected); 7225 if(module.get.selectionCount() === 0) { 7226 module.set.placeholderText(); 7227 } 7228 else { 7229 module.set.text(module.add.variables(message.count)); 7230 } 7231 } 7232 } 7233 else { 7234 module.remove.value(selectedValue, selectedText, $selected); 7235 } 7236 $selected 7237 .removeClass(className.filtered) 7238 .removeClass(className.active) 7239 ; 7240 if(settings.useLabels) { 7241 $selected.removeClass(className.selected); 7242 } 7243 }) 7244 ; 7245 }, 7246 selectedItem: function() { 7247 $item.removeClass(className.selected); 7248 }, 7249 value: function(removedValue, removedText, $removedItem) { 7250 var 7251 values = module.get.values(), 7252 newValue 7253 ; 7254 if( module.has.selectInput() ) { 7255 module.verbose('Input is <select> removing selected option', removedValue); 7256 newValue = module.remove.arrayValue(removedValue, values); 7257 module.remove.optionValue(removedValue); 7258 } 7259 else { 7260 module.verbose('Removing from delimited values', removedValue); 7261 newValue = module.remove.arrayValue(removedValue, values); 7262 newValue = newValue.join(settings.delimiter); 7263 } 7264 if(settings.fireOnInit === false && module.is.initialLoad()) { 7265 module.verbose('No callback on initial load', settings.onRemove); 7266 } 7267 else { 7268 settings.onRemove.call(element, removedValue, removedText, $removedItem); 7269 } 7270 module.set.value(newValue, removedText, $removedItem); 7271 module.check.maxSelections(); 7272 }, 7273 arrayValue: function(removedValue, values) { 7274 if( !$.isArray(values) ) { 7275 values = [values]; 7276 } 7277 values = $.grep(values, function(value){ 7278 return (removedValue != value); 7279 }); 7280 module.verbose('Removed value from delimited string', removedValue, values); 7281 return values; 7282 }, 7283 label: function(value, shouldAnimate) { 7284 var 7285 $labels = $module.find(selector.label), 7286 $removedLabel = $labels.filter('[data-' + metadata.value + '="' + module.escape.string(value) +'"]') 7287 ; 7288 module.verbose('Removing label', $removedLabel); 7289 $removedLabel.remove(); 7290 }, 7291 activeLabels: function($activeLabels) { 7292 $activeLabels = $activeLabels || $module.find(selector.label).filter('.' + className.active); 7293 module.verbose('Removing active label selections', $activeLabels); 7294 module.remove.labels($activeLabels); 7295 }, 7296 labels: function($labels) { 7297 $labels = $labels || $module.find(selector.label); 7298 module.verbose('Removing labels', $labels); 7299 $labels 7300 .each(function(){ 7301 var 7302 $label = $(this), 7303 value = $label.data(metadata.value),
vendor: 6,733 bytes, lines 7304-7437
7304 stringValue = (value !== undefined) 7305 ? String(value) 7306 : value, 7307 isUserValue = module.is.userValue(stringValue) 7308 ; 7309 if(settings.onLabelRemove.call($label, value) === false) { 7310 module.debug('Label remove callback cancelled removal'); 7311 return; 7312 } 7313 module.remove.message(); 7314 if(isUserValue) { 7315 module.remove.value(stringValue); 7316 module.remove.label(stringValue); 7317 } 7318 else { 7319 // selected will also remove label 7320 module.remove.selected(stringValue); 7321 } 7322 }) 7323 ; 7324 }, 7325 tabbable: function() { 7326 if( module.is.searchSelection() ) { 7327 module.debug('Searchable dropdown initialized'); 7328 $search 7329 .removeAttr('tabindex') 7330 ; 7331 $menu 7332 .removeAttr('tabindex') 7333 ; 7334 } 7335 else { 7336 module.debug('Simple selection dropdown initialized'); 7337 $module 7338 .removeAttr('tabindex') 7339 ; 7340 $menu 7341 .removeAttr('tabindex') 7342 ; 7343 } 7344 } 7345 }, 7346 7347 has: { 7348 menuSearch: function() { 7349 return (module.has.search() && $search.closest($menu).length > 0); 7350 }, 7351 search: function() { 7352 return ($search.length > 0); 7353 }, 7354 sizer: function() { 7355 return ($sizer.length > 0); 7356 }, 7357 selectInput: function() { 7358 return ( $input.is('select') ); 7359 }, 7360 minCharacters: function(searchTerm) { 7361 if(settings.minCharacters) { 7362 searchTerm = (searchTerm !== undefined) 7363 ? String(searchTerm) 7364 : String(module.get.query()) 7365 ; 7366 return (searchTerm.length >= settings.minCharacters); 7367 } 7368 return true; 7369 }, 7370 firstLetter: function($item, letter) { 7371 var 7372 text, 7373 firstLetter 7374 ; 7375 if(!$item || $item.length === 0 || typeof letter !== 'string') { 7376 return false; 7377 } 7378 text = module.get.choiceText($item, false); 7379 letter = letter.toLowerCase(); 7380 firstLetter = String(text).charAt(0).toLowerCase(); 7381 return (letter == firstLetter); 7382 }, 7383 input: function() { 7384 return ($input.length > 0); 7385 }, 7386 items: function() { 7387 return ($item.length > 0); 7388 }, 7389 menu: function() { 7390 return ($menu.length > 0); 7391 }, 7392 message: function() { 7393 return ($menu.children(selector.message).length !== 0); 7394 }, 7395 label: function(value) { 7396 var 7397 escapedValue = module.escape.value(value), 7398 $labels = $module.find(selector.label) 7399 ; 7400 return ($labels.filter('[data-' + metadata.value + '="' + module.escape.string(escapedValue) +'"]').length > 0); 7401 }, 7402 maxSelections: function() { 7403 return (settings.maxSelections && module.get.selectionCount() >= settings.maxSelections); 7404 }, 7405 allResultsFiltered: function() { 7406 var 7407 $normalResults = $item.not(selector.addition) 7408 ; 7409 return ($normalResults.filter(selector.unselectable).length === $normalResults.length); 7410 }, 7411 userSuggestion: function() { 7412 return ($menu.children(selector.addition).length > 0); 7413 }, 7414 query: function() { 7415 return (module.get.query() !== ''); 7416 }, 7417 value: function(value) { 7418 var 7419 values = module.get.values(), 7420 hasValue = $.isArray(values) 7421 ? values && ($.inArray(value, values) !== -1) 7422 : (values == value) 7423 ; 7424 return (hasValue) 7425 ? true 7426 : false 7427 ; 7428 } 7429 }, 7430 7431 is: { 7432 active: function() { 7433 return $module.hasClass(className.active); 7434 }, 7435 bubbledLabelClick: function(event) { 7436 return $(event.target).is('select, input') && $module.closest('label').length > 0; 7437 },
vendor: 38,211 bytes, lines 7438-8219
7438 bubbledIconClick: function(event) { 7439 return $(event.target).closest($icon).length > 0; 7440 }, 7441 alreadySetup: function() { 7442 return ($module.is('select') && $module.parent(selector.dropdown).data(moduleNamespace) !== undefined && $module.prev().length === 0); 7443 }, 7444 animating: function($subMenu) { 7445 return ($subMenu) 7446 ? $subMenu.transition && $subMenu.transition('is animating') 7447 : $menu.transition && $menu.transition('is animating') 7448 ; 7449 }, 7450 leftward: function($subMenu) { 7451 var $selectedMenu = $subMenu || $menu; 7452 return $selectedMenu.hasClass(className.leftward); 7453 }, 7454 disabled: function() { 7455 return $module.hasClass(className.disabled); 7456 }, 7457 focused: function() { 7458 return (document.activeElement === $module[0]); 7459 }, 7460 focusedOnSearch: function() { 7461 return (document.activeElement === $search[0]); 7462 }, 7463 allFiltered: function() { 7464 return( (module.is.multiple() || module.has.search()) && !(settings.hideAdditions == false && module.has.userSuggestion()) && !module.has.message() && module.has.allResultsFiltered() ); 7465 }, 7466 hidden: function($subMenu) { 7467 return !module.is.visible($subMenu); 7468 }, 7469 initialLoad: function() { 7470 return initialLoad; 7471 }, 7472 inObject: function(needle, object) { 7473 var 7474 found = false 7475 ; 7476 $.each(object, function(index, property) { 7477 if(property == needle) { 7478 found = true; 7479 return true; 7480 } 7481 }); 7482 return found; 7483 }, 7484 multiple: function() { 7485 return $module.hasClass(className.multiple); 7486 }, 7487 remote: function() { 7488 return settings.apiSettings && module.can.useAPI(); 7489 }, 7490 single: function() { 7491 return !module.is.multiple(); 7492 }, 7493 selectMutation: function(mutations) { 7494 var 7495 selectChanged = false 7496 ; 7497 $.each(mutations, function(index, mutation) { 7498 if(mutation.target && $(mutation.target).is('select')) { 7499 selectChanged = true; 7500 return true; 7501 } 7502 }); 7503 return selectChanged; 7504 }, 7505 search: function() { 7506 return $module.hasClass(className.search); 7507 }, 7508 searchSelection: function() { 7509 return ( module.has.search() && $search.parent(selector.dropdown).length === 1 ); 7510 }, 7511 selection: function() { 7512 return $module.hasClass(className.selection); 7513 }, 7514 userValue: function(value) { 7515 return ($.inArray(value, module.get.userValues()) !== -1); 7516 }, 7517 upward: function($menu) { 7518 var $element = $menu || $module; 7519 return $element.hasClass(className.upward); 7520 }, 7521 visible: function($subMenu) { 7522 return ($subMenu) 7523 ? $subMenu.hasClass(className.visible) 7524 : $menu.hasClass(className.visible) 7525 ; 7526 }, 7527 verticallyScrollableContext: function() { 7528 var 7529 overflowY = ($context.get(0) !== window) 7530 ? $context.css('overflow-y') 7531 : false 7532 ; 7533 return (overflowY == 'auto' || overflowY == 'scroll'); 7534 }, 7535 horizontallyScrollableContext: function() { 7536 var 7537 overflowX = ($context.get(0) !== window) 7538 ? $context.css('overflow-X') 7539 : false 7540 ; 7541 return (overflowX == 'auto' || overflowX == 'scroll'); 7542 } 7543 }, 7544 7545 can: { 7546 activate: function($item) { 7547 if(settings.useLabels) { 7548 return true; 7549 } 7550 if(!module.has.maxSelections()) { 7551 return true; 7552 } 7553 if(module.has.maxSelections() && $item.hasClass(className.active)) { 7554 return true; 7555 } 7556 return false; 7557 }, 7558 openDownward: function($subMenu) { 7559 var 7560 $currentMenu = $subMenu || $menu, 7561 canOpenDownward = true, 7562 onScreen = {}, 7563 calculations 7564 ; 7565 $currentMenu 7566 .addClass(className.loading) 7567 ; 7568 calculations = { 7569 context: { 7570 scrollTop : $context.scrollTop(), 7571 height : $context.outerHeight() 7572 }, 7573 menu : { 7574 offset: $currentMenu.offset(), 7575 height: $currentMenu.outerHeight() 7576 } 7577 }; 7578 if(module.is.verticallyScrollableContext()) { 7579 calculations.menu.offset.top += calculations.context.scrollTop; 7580 } 7581 onScreen = { 7582 above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.menu.height, 7583 below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top + calculations.menu.height 7584 }; 7585 if(onScreen.below) { 7586 module.verbose('Dropdown can fit in context downward', onScreen); 7587 canOpenDownward = true; 7588 } 7589 else if(!onScreen.below && !onScreen.above) { 7590 module.verbose('Dropdown cannot fit in either direction, favoring downward', onScreen); 7591 canOpenDownward = true; 7592 } 7593 else { 7594 module.verbose('Dropdown cannot fit below, opening upward', onScreen); 7595 canOpenDownward = false; 7596 } 7597 $currentMenu.removeClass(className.loading); 7598 return canOpenDownward; 7599 }, 7600 openRightward: function($subMenu) { 7601 var 7602 $currentMenu = $subMenu || $menu, 7603 canOpenRightward = true, 7604 isOffscreenRight = false, 7605 calculations 7606 ; 7607 $currentMenu 7608 .addClass(className.loading) 7609 ; 7610 calculations = { 7611 context: { 7612 scrollLeft : $context.scrollLeft(), 7613 width : $context.outerWidth() 7614 }, 7615 menu: { 7616 offset : $currentMenu.offset(), 7617 width : $currentMenu.outerWidth() 7618 } 7619 }; 7620 if(module.is.horizontallyScrollableContext()) { 7621 calculations.menu.offset.left += calculations.context.scrollLeft; 7622 } 7623 isOffscreenRight = (calculations.menu.offset.left + calculations.menu.width >= calculations.context.scrollLeft + calculations.context.width); 7624 if(isOffscreenRight) { 7625 module.verbose('Dropdown cannot fit in context rightward', isOffscreenRight); 7626 canOpenRightward = false; 7627 } 7628 $currentMenu.removeClass(className.loading); 7629 return canOpenRightward; 7630 }, 7631 click: function() { 7632 return (hasTouch || settings.on == 'click'); 7633 }, 7634 extendSelect: function() { 7635 return settings.allowAdditions || settings.apiSettings; 7636 }, 7637 show: function() { 7638 return !module.is.disabled() && (module.has.items() || module.has.message()); 7639 }, 7640 useAPI: function() { 7641 return $.fn.api !== undefined; 7642 } 7643 }, 7644 7645 animate: { 7646 show: function(callback, $subMenu) { 7647 var 7648 $currentMenu = $subMenu || $menu, 7649 start = ($subMenu) 7650 ? function() {} 7651 : function() { 7652 module.hideSubMenus(); 7653 module.hideOthers(); 7654 module.set.active(); 7655 }, 7656 transition 7657 ; 7658 callback = $.isFunction(callback) 7659 ? callback 7660 : function(){} 7661 ; 7662 module.verbose('Doing menu show animation', $currentMenu); 7663 module.set.direction($subMenu); 7664 transition = module.get.transition($subMenu); 7665 if( module.is.selection() ) { 7666 module.set.scrollPosition(module.get.selectedItem(), true); 7667 } 7668 if( module.is.hidden($currentMenu) || module.is.animating($currentMenu) ) { 7669 if(transition == 'none') { 7670 start(); 7671 $currentMenu.transition('show'); 7672 callback.call(element); 7673 } 7674 else if($.fn.transition !== undefined && $module.transition('is supported')) { 7675 $currentMenu 7676 .transition({ 7677 animation : transition + ' in', 7678 debug : settings.debug, 7679 verbose : settings.verbose, 7680 duration : settings.duration, 7681 queue : true, 7682 onStart : start, 7683 onComplete : function() { 7684 callback.call(element); 7685 } 7686 }) 7687 ; 7688 } 7689 else { 7690 module.error(error.noTransition, transition); 7691 } 7692 } 7693 }, 7694 hide: function(callback, $subMenu) { 7695 var 7696 $currentMenu = $subMenu || $menu, 7697 duration = ($subMenu) 7698 ? (settings.duration * 0.9) 7699 : settings.duration, 7700 start = ($subMenu) 7701 ? function() {} 7702 : function() { 7703 if( module.can.click() ) { 7704 module.unbind.intent(); 7705 } 7706 module.remove.active(); 7707 }, 7708 transition = module.get.transition($subMenu) 7709 ; 7710 callback = $.isFunction(callback) 7711 ? callback 7712 : function(){} 7713 ; 7714 if( module.is.visible($currentMenu) || module.is.animating($currentMenu) ) { 7715 module.verbose('Doing menu hide animation', $currentMenu); 7716 7717 if(transition == 'none') { 7718 start(); 7719 $currentMenu.transition('hide'); 7720 callback.call(element); 7721 } 7722 else if($.fn.transition !== undefined && $module.transition('is supported')) { 7723 $currentMenu 7724 .transition({ 7725 animation : transition + ' out', 7726 duration : settings.duration, 7727 debug : settings.debug, 7728 verbose : settings.verbose, 7729 queue : true, 7730 onStart : start, 7731 onComplete : function() { 7732 callback.call(element); 7733 } 7734 }) 7735 ; 7736 } 7737 else { 7738 module.error(error.transition); 7739 } 7740 } 7741 } 7742 }, 7743 7744 hideAndClear: function() { 7745 module.remove.searchTerm(); 7746 if( module.has.maxSelections() ) { 7747 return; 7748 } 7749 if(module.has.search()) { 7750 module.hide(function() { 7751 module.remove.filteredItem(); 7752 }); 7753 } 7754 else { 7755 module.hide(); 7756 } 7757 }, 7758 7759 delay: { 7760 show: function() { 7761 module.verbose('Delaying show event to ensure user intent'); 7762 clearTimeout(module.timer); 7763 module.timer = setTimeout(module.show, settings.delay.show); 7764 }, 7765 hide: function() { 7766 module.verbose('Delaying hide event to ensure user intent'); 7767 clearTimeout(module.timer); 7768 module.timer = setTimeout(module.hide, settings.delay.hide); 7769 } 7770 }, 7771 7772 escape: { 7773 value: function(value) { 7774 var 7775 multipleValues = $.isArray(value), 7776 stringValue = (typeof value === 'string'), 7777 isUnparsable = (!stringValue && !multipleValues), 7778 hasQuotes = (stringValue && value.search(regExp.quote) !== -1), 7779 values = [] 7780 ; 7781 if(isUnparsable || !hasQuotes) { 7782 return value; 7783 } 7784 module.debug('Encoding quote values for use in select', value); 7785 if(multipleValues) { 7786 $.each(value, function(index, value){ 7787 values.push(value.replace(regExp.quote, '"')); 7788 }); 7789 return values; 7790 } 7791 return value.replace(regExp.quote, '"'); 7792 }, 7793 string: function(text) { 7794 text = String(text); 7795 return text.replace(regExp.escape, '\\$&'); 7796 } 7797 }, 7798 7799 setting: function(name, value) { 7800 module.debug('Changing setting', name, value); 7801 if( $.isPlainObject(name) ) { 7802 $.extend(true, settings, name); 7803 } 7804 else if(value !== undefined) { 7805 if($.isPlainObject(settings[name])) { 7806 $.extend(true, settings[name], value); 7807 } 7808 else { 7809 settings[name] = value; 7810 } 7811 } 7812 else { 7813 return settings[name]; 7814 } 7815 }, 7816 internal: function(name, value) { 7817 if( $.isPlainObject(name) ) { 7818 $.extend(true, module, name); 7819 } 7820 else if(value !== undefined) { 7821 module[name] = value; 7822 } 7823 else { 7824 return module[name]; 7825 } 7826 }, 7827 debug: function() { 7828 if(!settings.silent && settings.debug) { 7829 if(settings.performance) { 7830 module.performance.log(arguments); 7831 } 7832 else { 7833 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 7834 module.debug.apply(console, arguments); 7835 } 7836 } 7837 }, 7838 verbose: function() { 7839 if(!settings.silent && settings.verbose && settings.debug) { 7840 if(settings.performance) { 7841 module.performance.log(arguments); 7842 } 7843 else { 7844 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 7845 module.verbose.apply(console, arguments); 7846 } 7847 } 7848 }, 7849 error: function() { 7850 if(!settings.silent) { 7851 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 7852 module.error.apply(console, arguments); 7853 } 7854 }, 7855 performance: { 7856 log: function(message) { 7857 var 7858 currentTime, 7859 executionTime, 7860 previousTime 7861 ; 7862 if(settings.performance) { 7863 currentTime = new Date().getTime(); 7864 previousTime = time || currentTime; 7865 executionTime = currentTime - previousTime; 7866 time = currentTime; 7867 performance.push({ 7868 'Name' : message[0], 7869 'Arguments' : [].slice.call(message, 1) || '', 7870 'Element' : element, 7871 'Execution Time' : executionTime 7872 }); 7873 } 7874 clearTimeout(module.performance.timer); 7875 module.performance.timer = setTimeout(module.performance.display, 500); 7876 }, 7877 display: function() { 7878 var 7879 title = settings.name + ':', 7880 totalTime = 0 7881 ; 7882 time = false; 7883 clearTimeout(module.performance.timer); 7884 $.each(performance, function(index, data) { 7885 totalTime += data['Execution Time']; 7886 }); 7887 title += ' ' + totalTime + 'ms'; 7888 if(moduleSelector) { 7889 title += ' \'' + moduleSelector + '\''; 7890 } 7891 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 7892 console.groupCollapsed(title); 7893 if(console.table) { 7894 console.table(performance); 7895 } 7896 else { 7897 $.each(performance, function(index, data) { 7898 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 7899 }); 7900 } 7901 console.groupEnd(); 7902 } 7903 performance = []; 7904 } 7905 }, 7906 invoke: function(query, passedArguments, context) { 7907 var 7908 object = instance, 7909 maxDepth, 7910 found, 7911 response 7912 ; 7913 passedArguments = passedArguments || queryArguments; 7914 context = element || context; 7915 if(typeof query == 'string' && object !== undefined) { 7916 query = query.split(/[\. ]/); 7917 maxDepth = query.length - 1; 7918 $.each(query, function(depth, value) { 7919 var camelCaseValue = (depth != maxDepth) 7920 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 7921 : query 7922 ; 7923 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 7924 object = object[camelCaseValue]; 7925 } 7926 else if( object[camelCaseValue] !== undefined ) { 7927 found = object[camelCaseValue]; 7928 return false; 7929 } 7930 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 7931 object = object[value]; 7932 } 7933 else if( object[value] !== undefined ) { 7934 found = object[value]; 7935 return false; 7936 } 7937 else { 7938 module.error(error.method, query); 7939 return false; 7940 } 7941 }); 7942 } 7943 if ( $.isFunction( found ) ) { 7944 response = found.apply(context, passedArguments); 7945 } 7946 else if(found !== undefined) { 7947 response = found; 7948 } 7949 if($.isArray(returnedValue)) { 7950 returnedValue.push(response); 7951 } 7952 else if(returnedValue !== undefined) { 7953 returnedValue = [returnedValue, response]; 7954 } 7955 else if(response !== undefined) { 7956 returnedValue = response; 7957 } 7958 return found; 7959 } 7960 }; 7961 7962 if(methodInvoked) { 7963 if(instance === undefined) { 7964 module.initialize(); 7965 } 7966 module.invoke(query); 7967 } 7968 else { 7969 if(instance !== undefined) { 7970 instance.invoke('destroy'); 7971 } 7972 module.initialize(); 7973 } 7974 }) 7975 ; 7976 return (returnedValue !== undefined) 7977 ? returnedValue 7978 : $allModules 7979 ; 7980 }; 7981 7982 $.fn.dropdown.settings = { 7983 7984 silent : false, 7985 debug : false, 7986 verbose : false, 7987 performance : true, 7988 7989 on : 'click', // what event should show menu action on item selection 7990 action : 'activate', // action on item selection (nothing, activate, select, combo, hide, function(){}) 7991 7992 values : false, // specify values to use for dropdown 7993 7994 apiSettings : false, 7995 selectOnKeydown : true, // Whether selection should occur automatically when keyboard shortcuts used 7996 minCharacters : 0, // Minimum characters required to trigger API call 7997 7998 filterRemoteData : false, // Whether API results should be filtered after being returned for query term 7999 saveRemoteData : true, // Whether remote name/value pairs should be stored in sessionStorage to allow remote data to be restored on page refresh 8000 8001 throttle : 200, // How long to wait after last user input to search remotely 8002 8003 context : window, // Context to use when determining if on screen 8004 direction : 'auto', // Whether dropdown should always open in one direction 8005 keepOnScreen : true, // Whether dropdown should check whether it is on screen before showing 8006 8007 match : 'both', // what to match against with search selection (both, text, or label) 8008 fullTextSearch : false, // search anywhere in value (set to 'exact' to require exact matches) 8009 8010 placeholder : 'auto', // whether to convert blank <select> values to placeholder text 8011 preserveHTML : true, // preserve html when selecting value 8012 sortSelect : false, // sort selection on init 8013 8014 forceSelection : true, // force a choice on blur with search selection 8015 8016 allowAdditions : false, // whether multiple select should allow user added values 8017 hideAdditions : true, // whether or not to hide special message prompting a user they can enter a value 8018 8019 maxSelections : false, // When set to a number limits the number of selections to this count 8020 useLabels : true, // whether multiple select should filter currently active selections from choices 8021 delimiter : ',', // when multiselect uses normal <input> the values will be delimited with this character 8022 8023 showOnFocus : true, // show menu on focus 8024 allowReselection : false, // whether current value should trigger callbacks when reselected 8025 allowTab : true, // add tabindex to element 8026 allowCategorySelection : false, // allow elements with sub-menus to be selected 8027 8028 fireOnInit : false, // Whether callbacks should fire when initializing dropdown values 8029 8030 transition : 'auto', // auto transition will slide down or up based on direction 8031 duration : 200, // duration of transition 8032 8033 glyphWidth : 1.037, // widest glyph width in em (W is 1.037 em) used to calculate multiselect input width 8034 8035 // label settings on multi-select 8036 label: { 8037 transition : 'scale', 8038 duration : 200, 8039 variation : false 8040 }, 8041 8042 // delay before event 8043 delay : { 8044 hide : 300, 8045 show : 200, 8046 search : 20, 8047 touch : 50 8048 }, 8049 8050 /* Callbacks */ 8051 onChange : function(value, text, $selected){}, 8052 onAdd : function(value, text, $selected){}, 8053 onRemove : function(value, text, $selected){}, 8054 8055 onLabelSelect : function($selectedLabels){}, 8056 onLabelCreate : function(value, text) { return $(this); }, 8057 onLabelRemove : function(value) { return true; }, 8058 onNoResults : function(searchTerm) { return true; }, 8059 onShow : function(){}, 8060 onHide : function(){}, 8061 8062 /* Component */ 8063 name : 'Dropdown', 8064 namespace : 'dropdown', 8065 8066 message: { 8067 addResult : 'Add <b>{term}</b>', 8068 count : '{count} selected', 8069 maxSelections : 'Max {maxCount} selections', 8070 noResults : 'No results found.', 8071 serverError : 'There was an error contacting the server' 8072 }, 8073 8074 error : { 8075 action : 'You called a dropdown action that was not defined', 8076 alreadySetup : 'Once a select has been initialized behaviors must be called on the created ui dropdown', 8077 labels : 'Allowing user additions currently requires the use of labels.', 8078 missingMultiple : '<select> requires multiple property to be set to correctly preserve multiple values', 8079 method : 'The method you called is not defined.', 8080 noAPI : 'The API module is required to load resources remotely', 8081 noStorage : 'Saving remote data requires session storage', 8082 noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>' 8083 }, 8084 8085 regExp : { 8086 escape : /[-[\]{}()*+?.,\\^$|#\s]/g, 8087 quote : /"/g 8088 }, 8089 8090 metadata : { 8091 defaultText : 'defaultText', 8092 defaultValue : 'defaultValue', 8093 placeholderText : 'placeholder', 8094 text : 'text', 8095 value : 'value' 8096 }, 8097 8098 // property names for remote query 8099 fields: { 8100 remoteValues : 'results', // grouping for api results 8101 values : 'values', // grouping for all dropdown values 8102 disabled : 'disabled', // whether value should be disabled 8103 name : 'name', // displayed dropdown text 8104 value : 'value', // actual dropdown value 8105 text : 'text' // displayed text when selected 8106 }, 8107 8108 keys : { 8109 backspace : 8, 8110 delimiter : 188, // comma 8111 deleteKey : 46, 8112 enter : 13, 8113 escape : 27, 8114 pageUp : 33, 8115 pageDown : 34, 8116 leftArrow : 37, 8117 upArrow : 38, 8118 rightArrow : 39, 8119 downArrow : 40 8120 }, 8121 8122 selector : { 8123 addition : '.addition', 8124 dropdown : '.ui.dropdown', 8125 hidden : '.hidden', 8126 icon : '> .dropdown.icon', 8127 input : '> input[type="hidden"], > select', 8128 item : '.item', 8129 label : '> .label', 8130 remove : '> .label > .delete.icon', 8131 siblingLabel : '.label', 8132 menu : '.menu', 8133 message : '.message', 8134 menuIcon : '.dropdown.icon', 8135 search : 'input.search, .menu > .search > input, .menu input.search', 8136 sizer : '> input.sizer', 8137 text : '> .text:not(.icon)', 8138 unselectable : '.disabled, .filtered' 8139 }, 8140 8141 className : { 8142 active : 'active', 8143 addition : 'addition', 8144 animating : 'animating', 8145 disabled : 'disabled', 8146 empty : 'empty', 8147 dropdown : 'ui dropdown', 8148 filtered : 'filtered', 8149 hidden : 'hidden transition', 8150 item : 'item', 8151 label : 'ui label', 8152 loading : 'loading', 8153 menu : 'menu', 8154 message : 'message', 8155 multiple : 'multiple', 8156 placeholder : 'default', 8157 sizer : 'sizer', 8158 search : 'search', 8159 selected : 'selected', 8160 selection : 'selection', 8161 upward : 'upward', 8162 leftward : 'left', 8163 visible : 'visible' 8164 } 8165 8166 }; 8167 8168 /* Templates */ 8169 $.fn.dropdown.settings.templates = { 8170 8171 // generates dropdown from select values 8172 dropdown: function(select) { 8173 var 8174 placeholder = select.placeholder || false, 8175 values = select.values || {}, 8176 html = '' 8177 ; 8178 html += '<i class="dropdown icon"></i>'; 8179 if(select.placeholder) { 8180 html += '<div class="default text">' + placeholder + '</div>'; 8181 } 8182 else { 8183 html += '<div class="text"></div>'; 8184 } 8185 html += '<div class="menu">'; 8186 $.each(select.values, function(index, option) { 8187 html += (option.disabled) 8188 ? '<div class="disabled item" data-value="' + option.value + '">' + option.name + '</div>' 8189 : '<div class="item" data-value="' + option.value + '">' + option.name + '</div>' 8190 ; 8191 }); 8192 html += '</div>'; 8193 return html; 8194 }, 8195 8196 // generates just menu from select 8197 menu: function(response, fields) { 8198 var 8199 values = response[fields.values] || {}, 8200 html = '' 8201 ; 8202 $.each(values, function(index, option) { 8203 var 8204 maybeText = (option[fields.text]) 8205 ? 'data-text="' + option[fields.text] + '"' 8206 : '', 8207 maybeDisabled = (option[fields.disabled]) 8208 ? 'disabled ' 8209 : '' 8210 ; 8211 html += '<div class="'+ maybeDisabled +'item" data-value="' + option[fields.value] + '"' + maybeText + '>' 8212 html += option[fields.name]; 8213 html += '</div>'; 8214 }); 8215 return html; 8216 }, 8217 8218 // generates label for multiselect 8219 label: function(value, text) {
vendor: 4,107 bytes, lines 8220-8343
8220 return text + '<i class="delete icon"></i>'; 8221 }, 8222 8223 8224 // generates messages like "No results" 8225 message: function(message) { 8226 return message; 8227 }, 8228 8229 // generates user addition to selection menu 8230 addition: function(choice) { 8231 return choice; 8232 } 8233 8234 }; 8235 8236})( jQuery, window, document ); 8237 8238/*! 8239 * # Semantic UI 2.2.12 - Embed 8240 * http://github.com/semantic-org/semantic-ui/ 8241 * 8242 * 8243 * Released under the MIT license 8244 * http://opensource.org/licenses/MIT 8245 * 8246 */ 8247 8248;(function ($, window, document, undefined) { 8249 8250 "use strict"; 8251 8252 window = (typeof window != 'undefined' && window.Math == Math) 8253 ? window 8254 : (typeof self != 'undefined' && self.Math == Math) 8255 ? self 8256 : Function('return this')() 8257 ; 8258 8259 $.fn.embed = function(parameters) { 8260 8261 var 8262 $allModules = $(this), 8263 8264 moduleSelector = $allModules.selector || '', 8265 8266 time = new Date().getTime(), 8267 performance = [], 8268 8269 query = arguments[0], 8270 methodInvoked = (typeof query == 'string'), 8271 queryArguments = [].slice.call(arguments, 1), 8272 8273 returnedValue 8274 ; 8275 8276 $allModules 8277 .each(function() { 8278 var 8279 settings = ( $.isPlainObject(parameters) ) 8280 ? $.extend(true, {}, $.fn.embed.settings, parameters) 8281 : $.extend({}, $.fn.embed.settings), 8282 8283 selector = settings.selector, 8284 className = settings.className, 8285 sources = settings.sources, 8286 error = settings.error, 8287 metadata = settings.metadata, 8288 namespace = settings.namespace, 8289 templates = settings.templates, 8290 8291 eventNamespace = '.' + namespace, 8292 moduleNamespace = 'module-' + namespace, 8293 8294 $window = $(window), 8295 $module = $(this), 8296 $placeholder = $module.find(selector.placeholder), 8297 $icon = $module.find(selector.icon), 8298 $embed = $module.find(selector.embed), 8299 8300 element = this, 8301 instance = $module.data(moduleNamespace), 8302 module 8303 ; 8304 8305 module = { 8306 8307 initialize: function() { 8308 module.debug('Initializing embed'); 8309 module.determine.autoplay(); 8310 module.create(); 8311 module.bind.events(); 8312 module.instantiate(); 8313 }, 8314 8315 instantiate: function() { 8316 module.verbose('Storing instance of module', module); 8317 instance = module; 8318 $module 8319 .data(moduleNamespace, module) 8320 ; 8321 }, 8322 8323 destroy: function() { 8324 module.verbose('Destroying previous instance of embed'); 8325 module.reset(); 8326 $module 8327 .removeData(moduleNamespace) 8328 .off(eventNamespace) 8329 ; 8330 }, 8331 8332 refresh: function() { 8333 module.verbose('Refreshing selector cache'); 8334 $placeholder = $module.find(selector.placeholder); 8335 $icon = $module.find(selector.icon); 8336 $embed = $module.find(selector.embed); 8337 }, 8338 8339 bind: { 8340 events: function() { 8341 if( module.has.placeholder() ) { 8342 module.debug('Adding placeholder events'); 8343 $module
vendor: 24,431 bytes, lines 8344-8917
8344 .on('click' + eventNamespace, selector.placeholder, module.createAndShow) 8345 .on('click' + eventNamespace, selector.icon, module.createAndShow) 8346 ; 8347 } 8348 } 8349 }, 8350 8351 create: function() { 8352 var 8353 placeholder = module.get.placeholder() 8354 ; 8355 if(placeholder) { 8356 module.createPlaceholder(); 8357 } 8358 else { 8359 module.createAndShow(); 8360 } 8361 }, 8362 8363 createPlaceholder: function(placeholder) { 8364 var 8365 icon = module.get.icon(), 8366 url = module.get.url(), 8367 embed = module.generate.embed(url) 8368 ; 8369 placeholder = placeholder || module.get.placeholder(); 8370 $module.html( templates.placeholder(placeholder, icon) ); 8371 module.debug('Creating placeholder for embed', placeholder, icon); 8372 }, 8373 8374 createEmbed: function(url) { 8375 module.refresh(); 8376 url = url || module.get.url(); 8377 $embed = $('<div/>') 8378 .addClass(className.embed) 8379 .html( module.generate.embed(url) ) 8380 .appendTo($module) 8381 ; 8382 settings.onCreate.call(element, url); 8383 module.debug('Creating embed object', $embed); 8384 }, 8385 8386 changeEmbed: function(url) { 8387 $embed 8388 .html( module.generate.embed(url) ) 8389 ; 8390 }, 8391 8392 createAndShow: function() { 8393 module.createEmbed(); 8394 module.show(); 8395 }, 8396 8397 // sets new embed 8398 change: function(source, id, url) { 8399 module.debug('Changing video to ', source, id, url); 8400 $module 8401 .data(metadata.source, source) 8402 .data(metadata.id, id) 8403 ; 8404 if(url) { 8405 $module.data(metadata.url, url); 8406 } 8407 else { 8408 $module.removeData(metadata.url); 8409 } 8410 if(module.has.embed()) { 8411 module.changeEmbed(); 8412 } 8413 else { 8414 module.create(); 8415 } 8416 }, 8417 8418 // clears embed 8419 reset: function() { 8420 module.debug('Clearing embed and showing placeholder'); 8421 module.remove.active(); 8422 module.remove.embed(); 8423 module.showPlaceholder(); 8424 settings.onReset.call(element); 8425 }, 8426 8427 // shows current embed 8428 show: function() { 8429 module.debug('Showing embed'); 8430 module.set.active(); 8431 settings.onDisplay.call(element); 8432 }, 8433 8434 hide: function() { 8435 module.debug('Hiding embed'); 8436 module.showPlaceholder(); 8437 }, 8438 8439 showPlaceholder: function() { 8440 module.debug('Showing placeholder image'); 8441 module.remove.active(); 8442 settings.onPlaceholderDisplay.call(element); 8443 }, 8444 8445 get: { 8446 id: function() { 8447 return settings.id || $module.data(metadata.id); 8448 }, 8449 placeholder: function() { 8450 return settings.placeholder || $module.data(metadata.placeholder); 8451 }, 8452 icon: function() { 8453 return (settings.icon) 8454 ? settings.icon 8455 : ($module.data(metadata.icon) !== undefined) 8456 ? $module.data(metadata.icon) 8457 : module.determine.icon() 8458 ; 8459 }, 8460 source: function(url) { 8461 return (settings.source) 8462 ? settings.source 8463 : ($module.data(metadata.source) !== undefined) 8464 ? $module.data(metadata.source) 8465 : module.determine.source() 8466 ; 8467 }, 8468 type: function() { 8469 var source = module.get.source(); 8470 return (sources[source] !== undefined) 8471 ? sources[source].type 8472 : false 8473 ; 8474 }, 8475 url: function() { 8476 return (settings.url) 8477 ? settings.url 8478 : ($module.data(metadata.url) !== undefined) 8479 ? $module.data(metadata.url) 8480 : module.determine.url() 8481 ; 8482 } 8483 }, 8484 8485 determine: { 8486 autoplay: function() { 8487 if(module.should.autoplay()) { 8488 settings.autoplay = true; 8489 } 8490 }, 8491 source: function(url) { 8492 var 8493 matchedSource = false 8494 ; 8495 url = url || module.get.url(); 8496 if(url) { 8497 $.each(sources, function(name, source) { 8498 if(url.search(source.domain) !== -1) { 8499 matchedSource = name; 8500 return false; 8501 } 8502 }); 8503 } 8504 return matchedSource; 8505 }, 8506 icon: function() { 8507 var 8508 source = module.get.source() 8509 ; 8510 return (sources[source] !== undefined) 8511 ? sources[source].icon 8512 : false 8513 ; 8514 }, 8515 url: function() { 8516 var 8517 id = settings.id || $module.data(metadata.id), 8518 source = settings.source || $module.data(metadata.source), 8519 url 8520 ; 8521 url = (sources[source] !== undefined) 8522 ? sources[source].url.replace('{id}', id) 8523 : false 8524 ; 8525 if(url) { 8526 $module.data(metadata.url, url); 8527 } 8528 return url; 8529 } 8530 }, 8531 8532 8533 set: { 8534 active: function() { 8535 $module.addClass(className.active); 8536 } 8537 }, 8538 8539 remove: { 8540 active: function() { 8541 $module.removeClass(className.active); 8542 }, 8543 embed: function() { 8544 $embed.empty(); 8545 } 8546 }, 8547 8548 encode: { 8549 parameters: function(parameters) { 8550 var 8551 urlString = [], 8552 index 8553 ; 8554 for (index in parameters) { 8555 urlString.push( encodeURIComponent(index) + '=' + encodeURIComponent( parameters[index] ) ); 8556 } 8557 return urlString.join('&'); 8558 } 8559 }, 8560 8561 generate: { 8562 embed: function(url) { 8563 module.debug('Generating embed html'); 8564 var 8565 source = module.get.source(), 8566 html, 8567 parameters 8568 ; 8569 url = module.get.url(url); 8570 if(url) { 8571 parameters = module.generate.parameters(source); 8572 html = templates.iframe(url, parameters); 8573 } 8574 else { 8575 module.error(error.noURL, $module); 8576 } 8577 return html; 8578 }, 8579 parameters: function(source, extraParameters) { 8580 var 8581 parameters = (sources[source] && sources[source].parameters !== undefined) 8582 ? sources[source].parameters(settings) 8583 : {} 8584 ; 8585 extraParameters = extraParameters || settings.parameters; 8586 if(extraParameters) { 8587 parameters = $.extend({}, parameters, extraParameters); 8588 } 8589 parameters = settings.onEmbed(parameters); 8590 return module.encode.parameters(parameters); 8591 } 8592 }, 8593 8594 has: { 8595 embed: function() { 8596 return ($embed.length > 0); 8597 }, 8598 placeholder: function() { 8599 return settings.placeholder || $module.data(metadata.placeholder); 8600 } 8601 }, 8602 8603 should: { 8604 autoplay: function() { 8605 return (settings.autoplay === 'auto') 8606 ? (settings.placeholder || $module.data(metadata.placeholder) !== undefined) 8607 : settings.autoplay 8608 ; 8609 } 8610 }, 8611 8612 is: { 8613 video: function() { 8614 return module.get.type() == 'video'; 8615 } 8616 }, 8617 8618 setting: function(name, value) { 8619 module.debug('Changing setting', name, value); 8620 if( $.isPlainObject(name) ) { 8621 $.extend(true, settings, name); 8622 } 8623 else if(value !== undefined) { 8624 if($.isPlainObject(settings[name])) { 8625 $.extend(true, settings[name], value); 8626 } 8627 else { 8628 settings[name] = value; 8629 } 8630 } 8631 else { 8632 return settings[name]; 8633 } 8634 }, 8635 internal: function(name, value) { 8636 if( $.isPlainObject(name) ) { 8637 $.extend(true, module, name); 8638 } 8639 else if(value !== undefined) { 8640 module[name] = value; 8641 } 8642 else { 8643 return module[name]; 8644 } 8645 }, 8646 debug: function() { 8647 if(!settings.silent && settings.debug) { 8648 if(settings.performance) { 8649 module.performance.log(arguments); 8650 } 8651 else { 8652 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 8653 module.debug.apply(console, arguments); 8654 } 8655 } 8656 }, 8657 verbose: function() { 8658 if(!settings.silent && settings.verbose && settings.debug) { 8659 if(settings.performance) { 8660 module.performance.log(arguments); 8661 } 8662 else { 8663 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 8664 module.verbose.apply(console, arguments); 8665 } 8666 } 8667 }, 8668 error: function() { 8669 if(!settings.silent) { 8670 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 8671 module.error.apply(console, arguments); 8672 } 8673 }, 8674 performance: { 8675 log: function(message) { 8676 var 8677 currentTime, 8678 executionTime, 8679 previousTime 8680 ; 8681 if(settings.performance) { 8682 currentTime = new Date().getTime(); 8683 previousTime = time || currentTime; 8684 executionTime = currentTime - previousTime; 8685 time = currentTime; 8686 performance.push({ 8687 'Name' : message[0], 8688 'Arguments' : [].slice.call(message, 1) || '', 8689 'Element' : element, 8690 'Execution Time' : executionTime 8691 }); 8692 } 8693 clearTimeout(module.performance.timer); 8694 module.performance.timer = setTimeout(module.performance.display, 500); 8695 }, 8696 display: function() { 8697 var 8698 title = settings.name + ':', 8699 totalTime = 0 8700 ; 8701 time = false; 8702 clearTimeout(module.performance.timer); 8703 $.each(performance, function(index, data) { 8704 totalTime += data['Execution Time']; 8705 }); 8706 title += ' ' + totalTime + 'ms'; 8707 if(moduleSelector) { 8708 title += ' \'' + moduleSelector + '\''; 8709 } 8710 if($allModules.length > 1) { 8711 title += ' ' + '(' + $allModules.length + ')'; 8712 } 8713 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 8714 console.groupCollapsed(title); 8715 if(console.table) { 8716 console.table(performance); 8717 } 8718 else { 8719 $.each(performance, function(index, data) { 8720 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 8721 }); 8722 } 8723 console.groupEnd(); 8724 } 8725 performance = []; 8726 } 8727 }, 8728 invoke: function(query, passedArguments, context) { 8729 var 8730 object = instance, 8731 maxDepth, 8732 found, 8733 response 8734 ; 8735 passedArguments = passedArguments || queryArguments; 8736 context = element || context; 8737 if(typeof query == 'string' && object !== undefined) { 8738 query = query.split(/[\. ]/); 8739 maxDepth = query.length - 1; 8740 $.each(query, function(depth, value) { 8741 var camelCaseValue = (depth != maxDepth) 8742 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 8743 : query 8744 ; 8745 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 8746 object = object[camelCaseValue]; 8747 } 8748 else if( object[camelCaseValue] !== undefined ) { 8749 found = object[camelCaseValue]; 8750 return false; 8751 } 8752 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 8753 object = object[value]; 8754 } 8755 else if( object[value] !== undefined ) { 8756 found = object[value]; 8757 return false; 8758 } 8759 else { 8760 module.error(error.method, query); 8761 return false; 8762 } 8763 }); 8764 } 8765 if ( $.isFunction( found ) ) { 8766 response = found.apply(context, passedArguments); 8767 } 8768 else if(found !== undefined) { 8769 response = found; 8770 } 8771 if($.isArray(returnedValue)) { 8772 returnedValue.push(response); 8773 } 8774 else if(returnedValue !== undefined) { 8775 returnedValue = [returnedValue, response]; 8776 } 8777 else if(response !== undefined) { 8778 returnedValue = response; 8779 } 8780 return found; 8781 } 8782 }; 8783 8784 if(methodInvoked) { 8785 if(instance === undefined) { 8786 module.initialize(); 8787 } 8788 module.invoke(query); 8789 } 8790 else { 8791 if(instance !== undefined) { 8792 instance.invoke('destroy'); 8793 } 8794 module.initialize(); 8795 } 8796 }) 8797 ; 8798 return (returnedValue !== undefined) 8799 ? returnedValue 8800 : this 8801 ; 8802 }; 8803 8804 $.fn.embed.settings = { 8805 8806 name : 'Embed', 8807 namespace : 'embed', 8808 8809 silent : false, 8810 debug : false, 8811 verbose : false, 8812 performance : true, 8813 8814 icon : false, 8815 source : false, 8816 url : false, 8817 id : false, 8818 8819 // standard video settings 8820 autoplay : 'auto', 8821 color : '#444444', 8822 hd : true, 8823 brandedUI : false, 8824 8825 // additional parameters to include with the embed 8826 parameters: false, 8827 8828 onDisplay : function() {}, 8829 onPlaceholderDisplay : function() {}, 8830 onReset : function() {}, 8831 onCreate : function(url) {}, 8832 onEmbed : function(parameters) { 8833 return parameters; 8834 }, 8835 8836 metadata : { 8837 id : 'id', 8838 icon : 'icon', 8839 placeholder : 'placeholder', 8840 source : 'source', 8841 url : 'url' 8842 }, 8843 8844 error : { 8845 noURL : 'No URL specified', 8846 method : 'The method you called is not defined' 8847 }, 8848 8849 className : { 8850 active : 'active', 8851 embed : 'embed' 8852 }, 8853 8854 selector : { 8855 embed : '.embed', 8856 placeholder : '.placeholder', 8857 icon : '.icon' 8858 }, 8859 8860 sources: { 8861 youtube: { 8862 name : 'youtube', 8863 type : 'video', 8864 icon : 'video play', 8865 domain : 'youtube.com', 8866 url : '//www.youtube.com/embed/{id}', 8867 parameters: function(settings) { 8868 return { 8869 autohide : !settings.brandedUI, 8870 autoplay : settings.autoplay, 8871 color : settings.color || undefined, 8872 hq : settings.hd, 8873 jsapi : settings.api, 8874 modestbranding : !settings.brandedUI 8875 }; 8876 } 8877 }, 8878 vimeo: { 8879 name : 'vimeo', 8880 type : 'video', 8881 icon : 'video play', 8882 domain : 'vimeo.com', 8883 url : '//player.vimeo.com/video/{id}', 8884 parameters: function(settings) { 8885 return { 8886 api : settings.api, 8887 autoplay : settings.autoplay, 8888 byline : settings.brandedUI, 8889 color : settings.color || undefined, 8890 portrait : settings.brandedUI, 8891 title : settings.brandedUI 8892 }; 8893 } 8894 } 8895 }, 8896 8897 templates: { 8898 iframe : function(url, parameters) { 8899 var src = url; 8900 if (parameters) { 8901 src += '?' + parameters; 8902 } 8903 return '' 8904 + '<iframe src="' + src + '"' 8905 + ' width="100%" height="100%"' 8906 + ' frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>' 8907 ; 8908 }, 8909 placeholder : function(image, icon) { 8910 var 8911 html = '' 8912 ; 8913 if(icon) { 8914 html += '<i class="' + icon + ' icon"></i>'; 8915 } 8916 if(image) { 8917 html += '<img class="placeholder" src="' + image
vendor: 15,320 bytes, lines 8917-9281
8917+ '">'; 8918 } 8919 return html; 8920 } 8921 }, 8922 8923 // NOT YET IMPLEMENTED 8924 api : false, 8925 onPause : function() {}, 8926 onPlay : function() {}, 8927 onStop : function() {} 8928 8929 }; 8930 8931 8932 8933})( jQuery, window, document ); 8934 8935/*! 8936 * # Semantic UI 2.2.12 - Modal 8937 * http://github.com/semantic-org/semantic-ui/ 8938 * 8939 * 8940 * Released under the MIT license 8941 * http://opensource.org/licenses/MIT 8942 * 8943 */ 8944 8945;(function ($, window, document, undefined) { 8946 8947 "use strict"; 8948 8949 window = (typeof window != 'undefined' && window.Math == Math) 8950 ? window 8951 : (typeof self != 'undefined' && self.Math == Math) 8952 ? self 8953 : Function('return this')() 8954 ; 8955 8956 $.fn.modal = function(parameters) { 8957 var 8958 $allModules = $(this), 8959 $window = $(window), 8960 $document = $(document), 8961 $body = $('body'), 8962 8963 moduleSelector = $allModules.selector || '', 8964 8965 time = new Date().getTime(), 8966 performance = [], 8967 8968 query = arguments[0], 8969 methodInvoked = (typeof query == 'string'), 8970 queryArguments = [].slice.call(arguments, 1), 8971 8972 requestAnimationFrame = window.requestAnimationFrame 8973 || window.mozRequestAnimationFrame 8974 || window.webkitRequestAnimationFrame 8975 || window.msRequestAnimationFrame 8976 || function(callback) { setTimeout(callback, 0); }, 8977 8978 returnedValue 8979 ; 8980 8981 $allModules 8982 .each(function() { 8983 var 8984 settings = ( $.isPlainObject(parameters) ) 8985 ? $.extend(true, {}, $.fn.modal.settings, parameters) 8986 : $.extend({}, $.fn.modal.settings), 8987 8988 selector = settings.selector, 8989 className = settings.className, 8990 namespace = settings.namespace, 8991 error = settings.error, 8992 8993 eventNamespace = '.' + namespace, 8994 moduleNamespace = 'module-' + namespace, 8995 8996 $module = $(this), 8997 $context = $(settings.context), 8998 $close = $module.find(selector.close), 8999 9000 $allModals, 9001 $otherModals, 9002 $focusedElement, 9003 $dimmable, 9004 $dimmer, 9005 9006 element = this, 9007 instance = $module.data(moduleNamespace), 9008 9009 ignoreRepeatedEvents = false, 9010 9011 elementEventNamespace, 9012 id, 9013 observer, 9014 module 9015 ; 9016 module = { 9017 9018 initialize: function() { 9019 module.verbose('Initializing dimmer', $context); 9020 9021 module.create.id(); 9022 module.create.dimmer(); 9023 module.refreshModals(); 9024 9025 module.bind.events(); 9026 if(settings.observeChanges) { 9027 module.observeChanges(); 9028 } 9029 module.instantiate(); 9030 }, 9031 9032 instantiate: function() { 9033 module.verbose('Storing instance of modal'); 9034 instance = module; 9035 $module 9036 .data(moduleNamespace, instance) 9037 ; 9038 }, 9039 9040 create: { 9041 dimmer: function() { 9042 var 9043 defaultSettings = { 9044 debug : settings.debug, 9045 dimmerName : 'modals' 9046 }, 9047 dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings) 9048 ; 9049 if($.fn.dimmer === undefined) { 9050 module.error(error.dimmer); 9051 return; 9052 } 9053 module.debug('Creating dimmer'); 9054 $dimmable = $context.dimmer(dimmerSettings); 9055 if(settings.detachable) { 9056 module.verbose('Modal is detachable, moving content into dimmer'); 9057 $dimmable.dimmer('add content', $module); 9058 } 9059 else { 9060 module.set.undetached(); 9061 } 9062 $dimmer = $dimmable.dimmer('get dimmer'); 9063 }, 9064 id: function() { 9065 id = (Math.random().toString(16) + '000000000').substr(2,8); 9066 elementEventNamespace = '.' + id; 9067 module.verbose('Creating unique id for element', id); 9068 } 9069 }, 9070 9071 destroy: function() { 9072 module.verbose('Destroying previous modal'); 9073 $module 9074 .removeData(moduleNamespace) 9075 .off(eventNamespace) 9076 ; 9077 $window.off(elementEventNamespace); 9078 $dimmer.off(elementEventNamespace); 9079 $close.off(eventNamespace); 9080 $context.dimmer('destroy'); 9081 }, 9082 9083 observeChanges: function() { 9084 if('MutationObserver' in window) { 9085 observer = new MutationObserver(function(mutations) { 9086 module.debug('DOM tree modified, refreshing'); 9087 module.refresh(); 9088 }); 9089 observer.observe(element, { 9090 childList : true, 9091 subtree : true 9092 }); 9093 module.debug('Setting up mutation observer', observer); 9094 } 9095 }, 9096 9097 refresh: function() { 9098 module.remove.scrolling(); 9099 module.cacheSizes(); 9100 module.set.screenHeight(); 9101 module.set.type(); 9102 module.set.position(); 9103 }, 9104 9105 refreshModals: function() { 9106 $otherModals = $module.siblings(selector.modal); 9107 $allModals = $otherModals.add($module); 9108 }, 9109 9110 attachEvents: function(selector, event) { 9111 var 9112 $toggle = $(selector) 9113 ; 9114 event = $.isFunction(module[event]) 9115 ? module[event] 9116 : module.toggle 9117 ; 9118 if($toggle.length > 0) { 9119 module.debug('Attaching modal events to element', selector, event); 9120 $toggle 9121 .off(eventNamespace) 9122 .on('click' + eventNamespace, event) 9123 ; 9124 } 9125 else { 9126 module.error(error.notFound, selector); 9127 } 9128 }, 9129 9130 bind: { 9131 events: function() { 9132 module.verbose('Attaching events'); 9133 $module 9134 .on('click' + eventNamespace, selector.close, module.event.close) 9135 .on('click' + eventNamespace, selector.approve, module.event.approve) 9136 .on('click' + eventNamespace, selector.deny, module.event.deny) 9137 ; 9138 $window 9139 .on('resize' + elementEventNamespace, module.event.resize) 9140 ; 9141 } 9142 }, 9143 9144 get: { 9145 id: function() { 9146 return (Math.random().toString(16) + '000000000').substr(2,8); 9147 } 9148 }, 9149 9150 event: { 9151 approve: function() { 9152 if(ignoreRepeatedEvents || settings.onApprove.call(element, $(this)) === false) { 9153 module.verbose('Approve callback returned false cancelling hide'); 9154 return; 9155 } 9156 ignoreRepeatedEvents = true; 9157 module.hide(function() { 9158 ignoreRepeatedEvents = false; 9159 }); 9160 }, 9161 deny: function() { 9162 if(ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) { 9163 module.verbose('Deny callback returned false cancelling hide'); 9164 return; 9165 } 9166 ignoreRepeatedEvents = true; 9167 module.hide(function() { 9168 ignoreRepeatedEvents = false; 9169 }); 9170 }, 9171 close: function() { 9172 module.hide(); 9173 }, 9174 click: function(event) { 9175 var 9176 $target = $(event.target), 9177 isInModal = ($target.closest(selector.modal).length > 0), 9178 isInDOM = $.contains(document.documentElement, event.target) 9179 ; 9180 if(!isInModal && isInDOM) { 9181 module.debug('Dimmer clicked, hiding all modals'); 9182 if( module.is.active() ) { 9183 module.remove.clickaway(); 9184 if(settings.allowMultiple) { 9185 module.hide(); 9186 } 9187 else { 9188 module.hideAll(); 9189 } 9190 } 9191 } 9192 }, 9193 debounce: function(method, delay) { 9194 clearTimeout(module.timer); 9195 module.timer = setTimeout(method, delay); 9196 }, 9197 keyboard: function(event) { 9198 var 9199 keyCode = event.which, 9200 escapeKey = 27 9201 ; 9202 if(keyCode == escapeKey) { 9203 if(settings.closable) { 9204 module.debug('Escape key pressed hiding modal'); 9205 module.hide(); 9206 } 9207 else { 9208 module.debug('Escape key pressed, but closable is set to false'); 9209 } 9210 event.preventDefault(); 9211 } 9212 }, 9213 resize: function() { 9214 if( $dimmable.dimmer('is active') && ( module.is.animating() || module.is.active() ) ) { 9215 requestAnimationFrame(module.refresh); 9216 } 9217 } 9218 }, 9219 9220 toggle: function() { 9221 if( module.is.active() || module.is.animating() ) { 9222 module.hide(); 9223 } 9224 else { 9225 module.show(); 9226 } 9227 }, 9228 9229 show: function(callback) { 9230 callback = $.isFunction(callback) 9231 ? callback 9232 : function(){} 9233 ; 9234 module.refreshModals(); 9235 module.set.dimmerSettings(); 9236 module.showModal(callback); 9237 }, 9238 9239 hide: function(callback) { 9240 callback = $.isFunction(callback) 9241 ? callback 9242 : function(){} 9243 ; 9244 module.refreshModals(); 9245 module.hideModal(callback); 9246 }, 9247 9248 showModal: function(callback) { 9249 callback = $.isFunction(callback) 9250 ? callback 9251 : function(){} 9252 ; 9253 if( module.is.animating() || !module.is.active() ) { 9254 9255 module.showDimmer(); 9256 module.cacheSizes(); 9257 module.set.position(); 9258 module.set.screenHeight(); 9259 module.set.type(); 9260 module.set.clickaway(); 9261 9262 if( !settings.allowMultiple && module.others.active() ) { 9263 module.hideOthers(module.showModal); 9264 } 9265 else { 9266 if(settings.allowMultiple && settings.detachable) { 9267 $module.detach().appendTo($dimmer); 9268 } 9269 settings.onShow.call(element); 9270 if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { 9271 module.debug('Showing modal with css animations'); 9272 $module 9273 .transition({ 9274 debug : settings.debug, 9275 animation : settings.transition + ' in', 9276 queue : settings.queue, 9277 duration : settings.duration, 9278 useFailSafe : true, 9279 onComplete : function() { 9280 settings.onVisible.apply(element); 9281 if(settings.keyboardShortcuts) {
vendor: 4,473 bytes, lines 9282-9371
9282 module.add.keyboardShortcuts(); 9283 } 9284 module.save.focus(); 9285 module.set.active(); 9286 if(settings.autofocus) { 9287 module.set.autofocus(); 9288 } 9289 callback(); 9290 } 9291 }) 9292 ; 9293 } 9294 else { 9295 module.error(error.noTransition); 9296 } 9297 } 9298 } 9299 else { 9300 module.debug('Modal is already visible'); 9301 } 9302 }, 9303 9304 hideModal: function(callback, keepDimmed) { 9305 callback = $.isFunction(callback) 9306 ? callback 9307 : function(){} 9308 ; 9309 module.debug('Hiding modal'); 9310 if(settings.onHide.call(element, $(this)) === false) { 9311 module.verbose('Hide callback returned false cancelling hide'); 9312 return; 9313 } 9314 9315 if( module.is.animating() || module.is.active() ) { 9316 if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { 9317 module.remove.active(); 9318 $module 9319 .transition({ 9320 debug : settings.debug, 9321 animation : settings.transition + ' out', 9322 queue : settings.queue, 9323 duration : settings.duration, 9324 useFailSafe : true, 9325 onStart : function() { 9326 if(!module.others.active() && !keepDimmed) { 9327 module.hideDimmer(); 9328 } 9329 if(settings.keyboardShortcuts) { 9330 module.remove.keyboardShortcuts(); 9331 } 9332 }, 9333 onComplete : function() { 9334 settings.onHidden.call(element); 9335 module.restore.focus(); 9336 callback(); 9337 } 9338 }) 9339 ; 9340 } 9341 else { 9342 module.error(error.noTransition); 9343 } 9344 } 9345 }, 9346 9347 showDimmer: function() { 9348 if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) { 9349 module.debug('Showing dimmer'); 9350 $dimmable.dimmer('show'); 9351 } 9352 else { 9353 module.debug('Dimmer already visible'); 9354 } 9355 }, 9356 9357 hideDimmer: function() { 9358 if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) { 9359 $dimmable.dimmer('hide', function() { 9360 module.remove.clickaway(); 9361 module.remove.screenHeight(); 9362 }); 9363 } 9364 else { 9365 module.debug('Dimmer is not visible cannot hide'); 9366 return; 9367 } 9368 }, 9369 9370 hideAll: function(callback) { 9371 var
vendor: 14,473 bytes, lines 9372-9677
9372 $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating) 9373 ; 9374 callback = $.isFunction(callback) 9375 ? callback 9376 : function(){} 9377 ; 9378 if( $visibleModals.length > 0 ) { 9379 module.debug('Hiding all visible modals'); 9380 module.hideDimmer(); 9381 $visibleModals 9382 .modal('hide modal', callback) 9383 ; 9384 } 9385 }, 9386 9387 hideOthers: function(callback) { 9388 var 9389 $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating) 9390 ; 9391 callback = $.isFunction(callback) 9392 ? callback 9393 : function(){} 9394 ; 9395 if( $visibleModals.length > 0 ) { 9396 module.debug('Hiding other modals', $otherModals); 9397 $visibleModals 9398 .modal('hide modal', callback, true) 9399 ; 9400 } 9401 }, 9402 9403 others: { 9404 active: function() { 9405 return ($otherModals.filter('.' + className.active).length > 0); 9406 }, 9407 animating: function() { 9408 return ($otherModals.filter('.' + className.animating).length > 0); 9409 } 9410 }, 9411 9412 9413 add: { 9414 keyboardShortcuts: function() { 9415 module.verbose('Adding keyboard shortcuts'); 9416 $document 9417 .on('keyup' + eventNamespace, module.event.keyboard) 9418 ; 9419 } 9420 }, 9421 9422 save: { 9423 focus: function() { 9424 $focusedElement = $(document.activeElement).blur(); 9425 } 9426 }, 9427 9428 restore: { 9429 focus: function() { 9430 if($focusedElement && $focusedElement.length > 0) { 9431 $focusedElement.focus(); 9432 } 9433 } 9434 }, 9435 9436 remove: { 9437 active: function() { 9438 $module.removeClass(className.active); 9439 }, 9440 clickaway: function() { 9441 if(settings.closable) { 9442 $dimmer 9443 .off('click' + elementEventNamespace) 9444 ; 9445 } 9446 }, 9447 bodyStyle: function() { 9448 if($body.attr('style') === '') { 9449 module.verbose('Removing style attribute'); 9450 $body.removeAttr('style'); 9451 } 9452 }, 9453 screenHeight: function() { 9454 module.debug('Removing page height'); 9455 $body 9456 .css('height', '') 9457 ; 9458 }, 9459 keyboardShortcuts: function() { 9460 module.verbose('Removing keyboard shortcuts'); 9461 $document 9462 .off('keyup' + eventNamespace) 9463 ; 9464 }, 9465 scrolling: function() { 9466 $dimmable.removeClass(className.scrolling); 9467 $module.removeClass(className.scrolling); 9468 } 9469 }, 9470 9471 cacheSizes: function() { 9472 $module.addClass(className.loading); 9473 var 9474 scrollHeight = $module.prop('scrollHeight'), 9475 modalHeight = $module.outerHeight() 9476 ; 9477 if(module.cache === undefined || modalHeight !== 0) { 9478 module.cache = { 9479 pageHeight : $(document).outerHeight(), 9480 height : modalHeight + settings.offset, 9481 scrollHeight : scrollHeight + settings.offset, 9482 contextHeight : (settings.context == 'body') 9483 ? $(window).height() 9484 : $dimmable.height(), 9485 }; 9486 module.cache.topOffset = -(module.cache.height / 2); 9487 } 9488 $module.removeClass(className.loading); 9489 module.debug('Caching modal and container sizes', module.cache); 9490 }, 9491 9492 can: { 9493 fit: function() { 9494 var 9495 contextHeight = module.cache.contextHeight, 9496 verticalCenter = module.cache.contextHeight / 2, 9497 topOffset = module.cache.topOffset, 9498 scrollHeight = module.cache.scrollHeight, 9499 height = module.cache.height, 9500 paddingHeight = settings.padding, 9501 startPosition = (verticalCenter + topOffset) 9502 ; 9503 return (scrollHeight > height) 9504 ? (startPosition + scrollHeight + paddingHeight < contextHeight) 9505 : (height + (paddingHeight * 2) < contextHeight) 9506 ; 9507 } 9508 }, 9509 9510 is: { 9511 active: function() { 9512 return $module.hasClass(className.active); 9513 }, 9514 animating: function() { 9515 return $module.transition('is supported') 9516 ? $module.transition('is animating') 9517 : $module.is(':visible') 9518 ; 9519 }, 9520 scrolling: function() { 9521 return $dimmable.hasClass(className.scrolling); 9522 }, 9523 modernBrowser: function() { 9524 // appName for IE11 reports 'Netscape' can no longer use 9525 return !(window.ActiveXObject || "ActiveXObject" in window); 9526 } 9527 }, 9528 9529 set: { 9530 autofocus: function() { 9531 var 9532 $inputs = $module.find('[tabindex], :input').filter(':visible'), 9533 $autofocus = $inputs.filter('[autofocus]'), 9534 $input = ($autofocus.length > 0) 9535 ? $autofocus.first() 9536 : $inputs.first() 9537 ; 9538 if($input.length > 0) { 9539 $input.focus(); 9540 } 9541 }, 9542 clickaway: function() { 9543 if(settings.closable) { 9544 $dimmer 9545 .on('click' + elementEventNamespace, module.event.click) 9546 ; 9547 } 9548 }, 9549 dimmerSettings: function() { 9550 if($.fn.dimmer === undefined) { 9551 module.error(error.dimmer); 9552 return; 9553 } 9554 var 9555 defaultSettings = { 9556 debug : settings.debug, 9557 dimmerName : 'modals', 9558 variation : false, 9559 closable : 'auto', 9560 duration : { 9561 show : settings.duration, 9562 hide : settings.duration 9563 } 9564 }, 9565 dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings) 9566 ; 9567 if(settings.inverted) { 9568 dimmerSettings.variation = (dimmerSettings.variation !== undefined) 9569 ? dimmerSettings.variation + ' inverted' 9570 : 'inverted' 9571 ; 9572 $dimmer.addClass(className.inverted); 9573 } 9574 else { 9575 $dimmer.removeClass(className.inverted); 9576 } 9577 if(settings.blurring) { 9578 $dimmable.addClass(className.blurring); 9579 } 9580 else { 9581 $dimmable.removeClass(className.blurring); 9582 } 9583 $context.dimmer('setting', dimmerSettings); 9584 }, 9585 screenHeight: function() { 9586 if( module.can.fit() ) { 9587 $body.css('height', ''); 9588 } 9589 else { 9590 module.debug('Modal is taller than page content, resizing page height'); 9591 $body 9592 .css('height', module.cache.height + (settings.padding * 2) ) 9593 ; 9594 } 9595 }, 9596 active: function() { 9597 $module.addClass(className.active); 9598 }, 9599 scrolling: function() { 9600 $dimmable.addClass(className.scrolling); 9601 $module.addClass(className.scrolling); 9602 }, 9603 type: function() { 9604 if(module.can.fit()) { 9605 module.verbose('Modal fits on screen'); 9606 if(!module.others.active() && !module.others.animating()) { 9607 module.remove.scrolling(); 9608 } 9609 } 9610 else { 9611 module.verbose('Modal cannot fit on screen setting to scrolling'); 9612 module.set.scrolling(); 9613 } 9614 }, 9615 position: function() { 9616 module.verbose('Centering modal on page', module.cache); 9617 if(module.can.fit()) { 9618 $module 9619 .css({ 9620 top: '', 9621 marginTop: module.cache.topOffset 9622 }) 9623 ; 9624 } 9625 else { 9626 $module 9627 .css({ 9628 marginTop : '', 9629 top : $document.scrollTop() 9630 }) 9631 ; 9632 } 9633 }, 9634 undetached: function() { 9635 $dimmable.addClass(className.undetached); 9636 } 9637 }, 9638 9639 setting: function(name, value) { 9640 module.debug('Changing setting', name, value); 9641 if( $.isPlainObject(name) ) { 9642 $.extend(true, settings, name); 9643 } 9644 else if(value !== undefined) { 9645 if($.isPlainObject(settings[name])) { 9646 $.extend(true, settings[name], value); 9647 } 9648 else { 9649 settings[name] = value; 9650 } 9651 } 9652 else { 9653 return settings[name]; 9654 } 9655 }, 9656 internal: function(name, value) { 9657 if( $.isPlainObject(name) ) { 9658 $.extend(true, module, name); 9659 } 9660 else if(value !== undefined) { 9661 module[name] = value; 9662 } 9663 else { 9664 return module[name]; 9665 } 9666 }, 9667 debug: function() { 9668 if(!settings.silent && settings.debug) { 9669 if(settings.performance) { 9670 module.performance.log(arguments); 9671 } 9672 else { 9673 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 9674 module.debug.apply(console, arguments); 9675 } 9676 } 9677 },
vendor: 4,339 bytes, lines 9678-9758
9678 verbose: function() { 9679 if(!settings.silent && settings.verbose && settings.debug) { 9680 if(settings.performance) { 9681 module.performance.log(arguments); 9682 } 9683 else { 9684 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 9685 module.verbose.apply(console, arguments); 9686 } 9687 } 9688 }, 9689 error: function() { 9690 if(!settings.silent) { 9691 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 9692 module.error.apply(console, arguments); 9693 } 9694 }, 9695 performance: { 9696 log: function(message) { 9697 var 9698 currentTime, 9699 executionTime, 9700 previousTime 9701 ; 9702 if(settings.performance) { 9703 currentTime = new Date().getTime(); 9704 previousTime = time || currentTime; 9705 executionTime = currentTime - previousTime; 9706 time = currentTime; 9707 performance.push({ 9708 'Name' : message[0], 9709 'Arguments' : [].slice.call(message, 1) || '', 9710 'Element' : element, 9711 'Execution Time' : executionTime 9712 }); 9713 } 9714 clearTimeout(module.performance.timer); 9715 module.performance.timer = setTimeout(module.performance.display, 500); 9716 }, 9717 display: function() { 9718 var 9719 title = settings.name + ':', 9720 totalTime = 0 9721 ; 9722 time = false; 9723 clearTimeout(module.performance.timer); 9724 $.each(performance, function(index, data) { 9725 totalTime += data['Execution Time']; 9726 }); 9727 title += ' ' + totalTime + 'ms'; 9728 if(moduleSelector) { 9729 title += ' \'' + moduleSelector + '\''; 9730 } 9731 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 9732 console.groupCollapsed(title); 9733 if(console.table) { 9734 console.table(performance); 9735 } 9736 else { 9737 $.each(performance, function(index, data) { 9738 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 9739 }); 9740 } 9741 console.groupEnd(); 9742 } 9743 performance = []; 9744 } 9745 }, 9746 invoke: function(query, passedArguments, context) { 9747 var 9748 object = instance, 9749 maxDepth, 9750 found, 9751 response 9752 ; 9753 passedArguments = passedArguments || queryArguments; 9754 context = element || context; 9755 if(typeof query == 'string' && object !== undefined) { 9756 query = query.split(/[\. ]/); 9757 maxDepth = query.length - 1; 9758 $.each(query, function(depth, value) {
vendor: 7,512 bytes, lines 9759-9986
9759 var camelCaseValue = (depth != maxDepth) 9760 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 9761 : query 9762 ; 9763 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 9764 object = object[camelCaseValue]; 9765 } 9766 else if( object[camelCaseValue] !== undefined ) { 9767 found = object[camelCaseValue]; 9768 return false; 9769 } 9770 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 9771 object = object[value]; 9772 } 9773 else if( object[value] !== undefined ) { 9774 found = object[value]; 9775 return false; 9776 } 9777 else { 9778 return false; 9779 } 9780 }); 9781 } 9782 if ( $.isFunction( found ) ) { 9783 response = found.apply(context, passedArguments); 9784 } 9785 else if(found !== undefined) { 9786 response = found; 9787 } 9788 if($.isArray(returnedValue)) { 9789 returnedValue.push(response); 9790 } 9791 else if(returnedValue !== undefined) { 9792 returnedValue = [returnedValue, response]; 9793 } 9794 else if(response !== undefined) { 9795 returnedValue = response; 9796 } 9797 return found; 9798 } 9799 }; 9800 9801 if(methodInvoked) { 9802 if(instance === undefined) { 9803 module.initialize(); 9804 } 9805 module.invoke(query); 9806 } 9807 else { 9808 if(instance !== undefined) { 9809 instance.invoke('destroy'); 9810 } 9811 module.initialize(); 9812 } 9813 }) 9814 ; 9815 9816 return (returnedValue !== undefined) 9817 ? returnedValue 9818 : this 9819 ; 9820 }; 9821 9822 $.fn.modal.settings = { 9823 9824 name : 'Modal', 9825 namespace : 'modal', 9826 9827 silent : false, 9828 debug : false, 9829 verbose : false, 9830 performance : true, 9831 9832 observeChanges : false, 9833 9834 allowMultiple : false, 9835 detachable : true, 9836 closable : true, 9837 autofocus : true, 9838 9839 inverted : false, 9840 blurring : false, 9841 9842 dimmerSettings : { 9843 closable : false, 9844 useCSS : true 9845 }, 9846 9847 // whether to use keyboard shortcuts 9848 keyboardShortcuts: true, 9849 9850 context : 'body', 9851 9852 queue : false, 9853 duration : 500, 9854 offset : 0, 9855 transition : 'scale', 9856 9857 // padding with edge of page 9858 padding : 50, 9859 9860 // called before show animation 9861 onShow : function(){}, 9862 9863 // called after show animation 9864 onVisible : function(){}, 9865 9866 // called before hide animation 9867 onHide : function(){ return true; }, 9868 9869 // called after hide animation 9870 onHidden : function(){}, 9871 9872 // called after approve selector match 9873 onApprove : function(){ return true; }, 9874 9875 // called after deny selector match 9876 onDeny : function(){ return true; }, 9877 9878 selector : { 9879 close : '> .close', 9880 approve : '.actions .positive, .actions .approve, .actions .ok', 9881 deny : '.actions .negative, .actions .deny, .actions .cancel', 9882 modal : '.ui.modal' 9883 }, 9884 error : { 9885 dimmer : 'UI Dimmer, a required component is not included in this page', 9886 method : 'The method you called is not defined.', 9887 notFound : 'The element you specified could not be found' 9888 }, 9889 className : { 9890 active : 'active', 9891 animating : 'animating', 9892 blurring : 'blurring', 9893 inverted : 'inverted', 9894 loading : 'loading', 9895 scrolling : 'scrolling', 9896 undetached : 'undetached' 9897 } 9898 }; 9899 9900 9901})( jQuery, window, document ); 9902 9903/*! 9904 * # Semantic UI 2.2.12 - Nag 9905 * http://github.com/semantic-org/semantic-ui/ 9906 * 9907 * 9908 * Released under the MIT license 9909 * http://opensource.org/licenses/MIT 9910 * 9911 */ 9912 9913;(function ($, window, document, undefined) { 9914 9915 "use strict"; 9916 9917 window = (typeof window != 'undefined' && window.Math == Math) 9918 ? window 9919 : (typeof self != 'undefined' && self.Math == Math) 9920 ? self 9921 : Function('return this')() 9922 ; 9923 9924 $.fn.nag = function(parameters) { 9925 var 9926 $allModules = $(this), 9927 moduleSelector = $allModules.selector || '', 9928 9929 time = new Date().getTime(), 9930 performance = [], 9931 9932 query = arguments[0], 9933 methodInvoked = (typeof query == 'string'), 9934 queryArguments = [].slice.call(arguments, 1), 9935 returnedValue 9936 ; 9937 $allModules 9938 .each(function() { 9939 var 9940 settings = ( $.isPlainObject(parameters) ) 9941 ? $.extend(true, {}, $.fn.nag.settings, parameters) 9942 : $.extend({}, $.fn.nag.settings), 9943 9944 className = settings.className, 9945 selector = settings.selector, 9946 error = settings.error, 9947 namespace = settings.namespace, 9948 9949 eventNamespace = '.' + namespace, 9950 moduleNamespace = namespace + '-module', 9951 9952 $module = $(this), 9953 9954 $close = $module.find(selector.close), 9955 $context = (settings.context) 9956 ? $(settings.context) 9957 : $('body'), 9958 9959 element = this, 9960 instance = $module.data(moduleNamespace), 9961 9962 moduleOffset, 9963 moduleHeight, 9964 9965 contextWidth, 9966 contextHeight, 9967 contextOffset, 9968 9969 yOffset, 9970 yPosition, 9971 9972 timer, 9973 module, 9974 9975 requestAnimationFrame = window.requestAnimationFrame 9976 || window.mozRequestAnimationFrame 9977 || window.webkitRequestAnimationFrame 9978 || window.msRequestAnimationFrame 9979 || function(callback) { setTimeout(callback, 0); } 9980 ; 9981 module = { 9982 9983 initialize: function() { 9984 module.verbose('Initializing element'); 9985 9986 $module
vendor: 9,885 bytes, lines 9987-10198
9987 .on('click' + eventNamespace, selector.close, module.dismiss) 9988 .data(moduleNamespace, module) 9989 ; 9990 9991 if(settings.detachable && $module.parent()[0] !== $context[0]) { 9992 $module 9993 .detach() 9994 .prependTo($context) 9995 ; 9996 } 9997 9998 if(settings.displayTime > 0) { 9999 setTimeout(module.hide, settings.displayTime); 10000 } 10001 module.show(); 10002 }, 10003 10004 destroy: function() { 10005 module.verbose('Destroying instance'); 10006 $module 10007 .removeData(moduleNamespace) 10008 .off(eventNamespace) 10009 ; 10010 }, 10011 10012 show: function() { 10013 if( module.should.show() && !$module.is(':visible') ) { 10014 module.debug('Showing nag', settings.animation.show); 10015 if(settings.animation.show == 'fade') { 10016 $module 10017 .fadeIn(settings.duration, settings.easing) 10018 ; 10019 } 10020 else { 10021 $module 10022 .slideDown(settings.duration, settings.easing) 10023 ; 10024 } 10025 } 10026 }, 10027 10028 hide: function() { 10029 module.debug('Showing nag', settings.animation.hide); 10030 if(settings.animation.show == 'fade') { 10031 $module 10032 .fadeIn(settings.duration, settings.easing) 10033 ; 10034 } 10035 else { 10036 $module 10037 .slideUp(settings.duration, settings.easing) 10038 ; 10039 } 10040 }, 10041 10042 onHide: function() { 10043 module.debug('Removing nag', settings.animation.hide); 10044 $module.remove(); 10045 if (settings.onHide) { 10046 settings.onHide(); 10047 } 10048 }, 10049 10050 dismiss: function(event) { 10051 if(settings.storageMethod) { 10052 module.storage.set(settings.key, settings.value); 10053 } 10054 module.hide(); 10055 event.stopImmediatePropagation(); 10056 event.preventDefault(); 10057 }, 10058 10059 should: { 10060 show: function() { 10061 if(settings.persist) { 10062 module.debug('Persistent nag is set, can show nag'); 10063 return true; 10064 } 10065 if( module.storage.get(settings.key) != settings.value.toString() ) { 10066 module.debug('Stored value is not set, can show nag', module.storage.get(settings.key)); 10067 return true; 10068 } 10069 module.debug('Stored value is set, cannot show nag', module.storage.get(settings.key)); 10070 return false; 10071 } 10072 }, 10073 10074 get: { 10075 storageOptions: function() { 10076 var 10077 options = {} 10078 ; 10079 if(settings.expires) { 10080 options.expires = settings.expires; 10081 } 10082 if(settings.domain) { 10083 options.domain = settings.domain; 10084 } 10085 if(settings.path) { 10086 options.path = settings.path; 10087 } 10088 return options; 10089 } 10090 }, 10091 10092 clear: function() { 10093 module.storage.remove(settings.key); 10094 }, 10095 10096 storage: { 10097 set: function(key, value) { 10098 var 10099 options = module.get.storageOptions() 10100 ; 10101 if(settings.storageMethod == 'localstorage' && window.localStorage !== undefined) { 10102 window.localStorage.setItem(key, value); 10103 module.debug('Value stored using local storage', key, value); 10104 } 10105 else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) { 10106 window.sessionStorage.setItem(key, value); 10107 module.debug('Value stored using session storage', key, value); 10108 } 10109 else if($.cookie !== undefined) { 10110 $.cookie(key, value, options); 10111 module.debug('Value stored using cookie', key, value, options); 10112 } 10113 else { 10114 module.error(error.noCookieStorage); 10115 return; 10116 } 10117 }, 10118 get: function(key, value) { 10119 var 10120 storedValue 10121 ; 10122 if(settings.storageMethod == 'localstorage' && window.localStorage !== undefined) { 10123 storedValue = window.localStorage.getItem(key); 10124 } 10125 else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) { 10126 storedValue = window.sessionStorage.getItem(key); 10127 } 10128 // get by cookie 10129 else if($.cookie !== undefined) { 10130 storedValue = $.cookie(key); 10131 } 10132 else { 10133 module.error(error.noCookieStorage); 10134 } 10135 if(storedValue == 'undefined' || storedValue == 'null' || storedValue === undefined || storedValue === null) { 10136 storedValue = undefined; 10137 } 10138 return storedValue; 10139 }, 10140 remove: function(key) { 10141 var 10142 options = module.get.storageOptions() 10143 ; 10144 if(settings.storageMethod == 'localstorage' && window.localStorage !== undefined) { 10145 window.localStorage.removeItem(key); 10146 } 10147 else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) { 10148 window.sessionStorage.removeItem(key); 10149 } 10150 // store by cookie 10151 else if($.cookie !== undefined) { 10152 $.removeCookie(key, options); 10153 } 10154 else { 10155 module.error(error.noStorage); 10156 } 10157 } 10158 }, 10159 10160 setting: function(name, value) { 10161 module.debug('Changing setting', name, value); 10162 if( $.isPlainObject(name) ) { 10163 $.extend(true, settings, name); 10164 } 10165 else if(value !== undefined) { 10166 if($.isPlainObject(settings[name])) { 10167 $.extend(true, settings[name], value); 10168 } 10169 else { 10170 settings[name] = value; 10171 } 10172 } 10173 else { 10174 return settings[name]; 10175 } 10176 }, 10177 internal: function(name, value) { 10178 if( $.isPlainObject(name) ) { 10179 $.extend(true, module, name); 10180 } 10181 else if(value !== undefined) { 10182 module[name] = value; 10183 } 10184 else { 10185 return module[name]; 10186 } 10187 }, 10188 debug: function() { 10189 if(!settings.silent && settings.debug) { 10190 if(settings.performance) { 10191 module.performance.log(arguments); 10192 } 10193 else { 10194 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 10195 module.debug.apply(console, arguments); 10196 } 10197 } 10198 },
vendor: 4,339 bytes, lines 10199-10279
10199 verbose: function() { 10200 if(!settings.silent && settings.verbose && settings.debug) { 10201 if(settings.performance) { 10202 module.performance.log(arguments); 10203 } 10204 else { 10205 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 10206 module.verbose.apply(console, arguments); 10207 } 10208 } 10209 }, 10210 error: function() { 10211 if(!settings.silent) { 10212 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 10213 module.error.apply(console, arguments); 10214 } 10215 }, 10216 performance: { 10217 log: function(message) { 10218 var 10219 currentTime, 10220 executionTime, 10221 previousTime 10222 ; 10223 if(settings.performance) { 10224 currentTime = new Date().getTime(); 10225 previousTime = time || currentTime; 10226 executionTime = currentTime - previousTime; 10227 time = currentTime; 10228 performance.push({ 10229 'Name' : message[0], 10230 'Arguments' : [].slice.call(message, 1) || '', 10231 'Element' : element, 10232 'Execution Time' : executionTime 10233 }); 10234 } 10235 clearTimeout(module.performance.timer); 10236 module.performance.timer = setTimeout(module.performance.display, 500); 10237 }, 10238 display: function() { 10239 var 10240 title = settings.name + ':', 10241 totalTime = 0 10242 ; 10243 time = false; 10244 clearTimeout(module.performance.timer); 10245 $.each(performance, function(index, data) { 10246 totalTime += data['Execution Time']; 10247 }); 10248 title += ' ' + totalTime + 'ms'; 10249 if(moduleSelector) { 10250 title += ' \'' + moduleSelector + '\''; 10251 } 10252 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 10253 console.groupCollapsed(title); 10254 if(console.table) { 10255 console.table(performance); 10256 } 10257 else { 10258 $.each(performance, function(index, data) { 10259 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 10260 }); 10261 } 10262 console.groupEnd(); 10263 } 10264 performance = []; 10265 } 10266 }, 10267 invoke: function(query, passedArguments, context) { 10268 var 10269 object = instance, 10270 maxDepth, 10271 found, 10272 response 10273 ; 10274 passedArguments = passedArguments || queryArguments; 10275 context = element || context; 10276 if(typeof query == 'string' && object !== undefined) { 10277 query = query.split(/[\. ]/); 10278 maxDepth = query.length - 1; 10279 $.each(query, function(depth, value) {
vendor: 6,179 bytes, lines 10280-10468
10280 var camelCaseValue = (depth != maxDepth) 10281 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 10282 : query 10283 ; 10284 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 10285 object = object[camelCaseValue]; 10286 } 10287 else if( object[camelCaseValue] !== undefined ) { 10288 found = object[camelCaseValue]; 10289 return false; 10290 } 10291 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 10292 object = object[value]; 10293 } 10294 else if( object[value] !== undefined ) { 10295 found = object[value]; 10296 return false; 10297 } 10298 else { 10299 module.error(error.method, query); 10300 return false; 10301 } 10302 }); 10303 } 10304 if ( $.isFunction( found ) ) { 10305 response = found.apply(context, passedArguments); 10306 } 10307 else if(found !== undefined) { 10308 response = found; 10309 } 10310 if($.isArray(returnedValue)) { 10311 returnedValue.push(response); 10312 } 10313 else if(returnedValue !== undefined) { 10314 returnedValue = [returnedValue, response]; 10315 } 10316 else if(response !== undefined) { 10317 returnedValue = response; 10318 } 10319 return found; 10320 } 10321 }; 10322 10323 if(methodInvoked) { 10324 if(instance === undefined) { 10325 module.initialize(); 10326 } 10327 module.invoke(query); 10328 } 10329 else { 10330 if(instance !== undefined) { 10331 instance.invoke('destroy'); 10332 } 10333 module.initialize(); 10334 } 10335 }) 10336 ; 10337 10338 return (returnedValue !== undefined) 10339 ? returnedValue 10340 : this 10341 ; 10342 }; 10343 10344 $.fn.nag.settings = { 10345 10346 name : 'Nag', 10347 10348 silent : false, 10349 debug : false, 10350 verbose : false, 10351 performance : true, 10352 10353 namespace : 'Nag', 10354 10355 // allows cookie to be overridden 10356 persist : false, 10357 10358 // set to zero to require manually dismissal, otherwise hides on its own 10359 displayTime : 0, 10360 10361 animation : { 10362 show : 'slide', 10363 hide : 'slide' 10364 }, 10365 10366 context : false, 10367 detachable : false, 10368 10369 expires : 30, 10370 domain : false, 10371 path : '/', 10372 10373 // type of storage to use 10374 storageMethod : 'cookie', 10375 10376 // value to store in dismissed localstorage/cookie 10377 key : 'nag', 10378 value : 'dismiss', 10379 10380 error: { 10381 noCookieStorage : '$.cookie is not included. A storage solution is required.', 10382 noStorage : 'Neither $.cookie or store is defined. A storage solution is required for storing state', 10383 method : 'The method you called is not defined.' 10384 }, 10385 10386 className : { 10387 bottom : 'bottom', 10388 fixed : 'fixed' 10389 }, 10390 10391 selector : { 10392 close : '.close.icon' 10393 }, 10394 10395 speed : 500, 10396 easing : 'easeOutQuad', 10397 10398 onHide: function() {} 10399 10400 }; 10401 10402// Adds easing 10403 $.extend( $.easing, { 10404 easeOutQuad: function (x, t, b, c, d) { 10405 return -c *(t/=d)*(t-2) + b; 10406 } 10407 }); 10408 10409})( jQuery, window, document ); 10410 10411/*! 10412 * # Semantic UI 2.2.12 - Popup 10413 * http://github.com/semantic-org/semantic-ui/ 10414 * 10415 * 10416 * Released under the MIT license 10417 * http://opensource.org/licenses/MIT 10418 * 10419 */ 10420 10421;(function ($, window, document, undefined) { 10422 10423 "use strict"; 10424 10425 window = (typeof window != 'undefined' && window.Math == Math) 10426 ? window 10427 : (typeof self != 'undefined' && self.Math == Math) 10428 ? self 10429 : Function('return this')() 10430 ; 10431 10432 $.fn.popup = function(parameters) { 10433 var 10434 $allModules = $(this), 10435 $document = $(document), 10436 $window = $(window), 10437 $body = $('body'), 10438 10439 moduleSelector = $allModules.selector || '', 10440 10441 hasTouch = (true), 10442 time = new Date().getTime(), 10443 performance = [], 10444 10445 query = arguments[0], 10446 methodInvoked = (typeof query == 'string'), 10447 queryArguments = [].slice.call(arguments, 1), 10448 10449 returnedValue 10450 ; 10451 $allModules 10452 .each(function() { 10453 var 10454 settings = ( $.isPlainObject(parameters) ) 10455 ? $.extend(true, {}, $.fn.popup.settings, parameters) 10456 : $.extend({}, $.fn.popup.settings), 10457 10458 selector = settings.selector, 10459 className = settings.className, 10460 error = settings.error, 10461 metadata = settings.metadata, 10462 namespace = settings.namespace, 10463 10464 eventNamespace = '.' + settings.namespace, 10465 moduleNamespace = 'module-' + namespace, 10466 10467 $module = $(this), 10468 $context = $(settings.context),
vendor: 15,126 bytes, lines 10469-10797
10469 $scrollContext = $(settings.scrollContext), 10470 $boundary = $(settings.boundary), 10471 $target = (settings.target) 10472 ? $(settings.target) 10473 : $module, 10474 10475 $popup, 10476 $offsetParent, 10477 10478 searchDepth = 0, 10479 triedPositions = false, 10480 openedWithTouch = false, 10481 10482 element = this, 10483 instance = $module.data(moduleNamespace), 10484 10485 documentObserver, 10486 elementNamespace, 10487 id, 10488 module 10489 ; 10490 10491 module = { 10492 10493 // binds events 10494 initialize: function() { 10495 module.debug('Initializing', $module); 10496 module.createID(); 10497 module.bind.events(); 10498 if(!module.exists() && settings.preserve) { 10499 module.create(); 10500 } 10501 if(settings.observeChanges) { 10502 module.observeChanges(); 10503 } 10504 module.instantiate(); 10505 }, 10506 10507 instantiate: function() { 10508 module.verbose('Storing instance', module); 10509 instance = module; 10510 $module 10511 .data(moduleNamespace, instance) 10512 ; 10513 }, 10514 10515 observeChanges: function() { 10516 if('MutationObserver' in window) { 10517 documentObserver = new MutationObserver(module.event.documentChanged); 10518 documentObserver.observe(document, { 10519 childList : true, 10520 subtree : true 10521 }); 10522 module.debug('Setting up mutation observer', documentObserver); 10523 } 10524 }, 10525 10526 refresh: function() { 10527 if(settings.popup) { 10528 $popup = $(settings.popup).eq(0); 10529 } 10530 else { 10531 if(settings.inline) { 10532 $popup = $target.nextAll(selector.popup).eq(0); 10533 settings.popup = $popup; 10534 } 10535 } 10536 if(settings.popup) { 10537 $popup.addClass(className.loading); 10538 $offsetParent = module.get.offsetParent(); 10539 $popup.removeClass(className.loading); 10540 if(settings.movePopup && module.has.popup() && module.get.offsetParent($popup)[0] !== $offsetParent[0]) { 10541 module.debug('Moving popup to the same offset parent as target'); 10542 $popup 10543 .detach() 10544 .appendTo($offsetParent) 10545 ; 10546 } 10547 } 10548 else { 10549 $offsetParent = (settings.inline) 10550 ? module.get.offsetParent($target) 10551 : module.has.popup() 10552 ? module.get.offsetParent($popup) 10553 : $body 10554 ; 10555 } 10556 if( $offsetParent.is('html') && $offsetParent[0] !== $body[0] ) { 10557 module.debug('Setting page as offset parent'); 10558 $offsetParent = $body; 10559 } 10560 if( module.get.variation() ) { 10561 module.set.variation(); 10562 } 10563 }, 10564 10565 reposition: function() { 10566 module.refresh(); 10567 module.set.position(); 10568 }, 10569 10570 destroy: function() { 10571 module.debug('Destroying previous module'); 10572 if(documentObserver) { 10573 documentObserver.disconnect(); 10574 } 10575 // remove element only if was created dynamically 10576 if($popup && !settings.preserve) { 10577 module.removePopup(); 10578 } 10579 // clear all timeouts 10580 clearTimeout(module.hideTimer); 10581 clearTimeout(module.showTimer); 10582 // remove events 10583 module.unbind.close(); 10584 module.unbind.events(); 10585 $module 10586 .removeData(moduleNamespace) 10587 ; 10588 }, 10589 10590 event: { 10591 start: function(event) { 10592 var 10593 delay = ($.isPlainObject(settings.delay)) 10594 ? settings.delay.show 10595 : settings.delay 10596 ; 10597 clearTimeout(module.hideTimer); 10598 if(!openedWithTouch) { 10599 module.showTimer = setTimeout(module.show, delay); 10600 } 10601 }, 10602 end: function() { 10603 var 10604 delay = ($.isPlainObject(settings.delay)) 10605 ? settings.delay.hide 10606 : settings.delay 10607 ; 10608 clearTimeout(module.showTimer); 10609 module.hideTimer = setTimeout(module.hide, delay); 10610 }, 10611 touchstart: function(event) { 10612 openedWithTouch = true; 10613 module.show(); 10614 }, 10615 resize: function() { 10616 if( module.is.visible() ) { 10617 module.set.position(); 10618 } 10619 }, 10620 documentChanged: function(mutations) { 10621 [].forEach.call(mutations, function(mutation) { 10622 if(mutation.removedNodes) { 10623 [].forEach.call(mutation.removedNodes, function(node) { 10624 if(node == element || $(node).find(element).length > 0) { 10625 module.debug('Element removed from DOM, tearing down events'); 10626 module.destroy(); 10627 } 10628 }); 10629 } 10630 }); 10631 }, 10632 hideGracefully: function(event) { 10633 var 10634 $target = $(event.target), 10635 isInDOM = $.contains(document.documentElement, event.target), 10636 inPopup = ($target.closest(selector.popup).length > 0) 10637 ; 10638 // don't close on clicks inside popup 10639 if(event && !inPopup && isInDOM) { 10640 module.debug('Click occurred outside popup hiding popup'); 10641 module.hide(); 10642 } 10643 else { 10644 module.debug('Click was inside popup, keeping popup open'); 10645 } 10646 } 10647 }, 10648 10649 // generates popup html from metadata 10650 create: function() { 10651 var 10652 html = module.get.html(), 10653 title = module.get.title(), 10654 content = module.get.content() 10655 ; 10656 10657 if(html || content || title) { 10658 module.debug('Creating pop-up html'); 10659 if(!html) { 10660 html = settings.templates.popup({ 10661 title : title, 10662 content : content 10663 }); 10664 } 10665 $popup = $('<div/>') 10666 .addClass(className.popup) 10667 .data(metadata.activator, $module) 10668 .html(html) 10669 ; 10670 if(settings.inline) { 10671 module.verbose('Inserting popup element inline', $popup); 10672 $popup 10673 .insertAfter($module) 10674 ; 10675 } 10676 else { 10677 module.verbose('Appending popup element to body', $popup); 10678 $popup 10679 .appendTo( $context ) 10680 ; 10681 } 10682 module.refresh(); 10683 module.set.variation(); 10684 10685 if(settings.hoverable) { 10686 module.bind.popup(); 10687 } 10688 settings.onCreate.call($popup, element); 10689 } 10690 else if($target.next(selector.popup).length !== 0) { 10691 module.verbose('Pre-existing popup found'); 10692 settings.inline = true; 10693 settings.popup = $target.next(selector.popup).data(metadata.activator, $module); 10694 module.refresh(); 10695 if(settings.hoverable) { 10696 module.bind.popup(); 10697 } 10698 } 10699 else if(settings.popup) { 10700 $(settings.popup).data(metadata.activator, $module); 10701 module.verbose('Used popup specified in settings'); 10702 module.refresh(); 10703 if(settings.hoverable) { 10704 module.bind.popup(); 10705 } 10706 } 10707 else { 10708 module.debug('No content specified skipping display', element); 10709 } 10710 }, 10711 10712 createID: function() { 10713 id = (Math.random().toString(16) + '000000000').substr(2, 8); 10714 elementNamespace = '.' + id; 10715 module.verbose('Creating unique id for element', id); 10716 }, 10717 10718 // determines popup state 10719 toggle: function() { 10720 module.debug('Toggling pop-up'); 10721 if( module.is.hidden() ) { 10722 module.debug('Popup is hidden, showing pop-up'); 10723 module.unbind.close(); 10724 module.show(); 10725 } 10726 else { 10727 module.debug('Popup is visible, hiding pop-up'); 10728 module.hide(); 10729 } 10730 }, 10731 10732 show: function(callback) { 10733 callback = callback || function(){}; 10734 module.debug('Showing pop-up', settings.transition); 10735 if(module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) { 10736 if( !module.exists() ) { 10737 module.create(); 10738 } 10739 if(settings.onShow.call($popup, element) === false) { 10740 module.debug('onShow callback returned false, cancelling popup animation'); 10741 return; 10742 } 10743 else if(!settings.preserve && !settings.popup) { 10744 module.refresh(); 10745 } 10746 if( $popup && module.set.position() ) { 10747 module.save.conditions(); 10748 if(settings.exclusive) { 10749 module.hideAll(); 10750 } 10751 module.animate.show(callback); 10752 } 10753 } 10754 }, 10755 10756 10757 hide: function(callback) { 10758 callback = callback || function(){}; 10759 if( module.is.visible() || module.is.animating() ) { 10760 if(settings.onHide.call($popup, element) === false) { 10761 module.debug('onHide callback returned false, cancelling popup animation'); 10762 return; 10763 } 10764 module.remove.visible(); 10765 module.unbind.close(); 10766 module.restore.conditions(); 10767 module.animate.hide(callback); 10768 } 10769 }, 10770 10771 hideAll: function() { 10772 $(selector.popup) 10773 .filter('.' + className.popupVisible) 10774 .each(function() { 10775 $(this) 10776 .data(metadata.activator) 10777 .popup('hide') 10778 ; 10779 }) 10780 ; 10781 }, 10782 exists: function() { 10783 if(!$popup) { 10784 return false; 10785 } 10786 if(settings.inline || settings.popup) { 10787 return ( module.has.popup() ); 10788 } 10789 else { 10790 return ( $popup.closest($context).length >= 1 ) 10791 ? true 10792 : false 10793 ; 10794 } 10795 }, 10796 10797 removePopup: function() {
vendor: 10,856 bytes, lines 10798-11001
10798 if( module.has.popup() && !settings.popup) { 10799 module.debug('Removing popup', $popup); 10800 $popup.remove(); 10801 $popup = undefined; 10802 settings.onRemove.call($popup, element); 10803 } 10804 }, 10805 10806 save: { 10807 conditions: function() { 10808 module.cache = { 10809 title: $module.attr('title') 10810 }; 10811 if (module.cache.title) { 10812 $module.removeAttr('title'); 10813 } 10814 module.verbose('Saving original attributes', module.cache.title); 10815 } 10816 }, 10817 restore: { 10818 conditions: function() { 10819 if(module.cache && module.cache.title) { 10820 $module.attr('title', module.cache.title); 10821 module.verbose('Restoring original attributes', module.cache.title); 10822 } 10823 return true; 10824 } 10825 }, 10826 supports: { 10827 svg: function() { 10828 return (typeof SVGGraphicsElement === 'undefined'); 10829 } 10830 }, 10831 animate: { 10832 show: function(callback) { 10833 callback = $.isFunction(callback) ? callback : function(){}; 10834 if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { 10835 module.set.visible(); 10836 $popup 10837 .transition({ 10838 animation : settings.transition + ' in', 10839 queue : false, 10840 debug : settings.debug, 10841 verbose : settings.verbose, 10842 duration : settings.duration, 10843 onComplete : function() { 10844 module.bind.close(); 10845 callback.call($popup, element); 10846 settings.onVisible.call($popup, element); 10847 } 10848 }) 10849 ; 10850 } 10851 else { 10852 module.error(error.noTransition); 10853 } 10854 }, 10855 hide: function(callback) { 10856 callback = $.isFunction(callback) ? callback : function(){}; 10857 module.debug('Hiding pop-up'); 10858 if(settings.onHide.call($popup, element) === false) { 10859 module.debug('onHide callback returned false, cancelling popup animation'); 10860 return; 10861 } 10862 if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { 10863 $popup 10864 .transition({ 10865 animation : settings.transition + ' out', 10866 queue : false, 10867 duration : settings.duration, 10868 debug : settings.debug, 10869 verbose : settings.verbose, 10870 onComplete : function() { 10871 module.reset(); 10872 callback.call($popup, element); 10873 settings.onHidden.call($popup, element); 10874 } 10875 }) 10876 ; 10877 } 10878 else { 10879 module.error(error.noTransition); 10880 } 10881 } 10882 }, 10883 10884 change: { 10885 content: function(html) { 10886 $popup.html(html); 10887 } 10888 }, 10889 10890 get: { 10891 html: function() { 10892 $module.removeData(metadata.html); 10893 return $module.data(metadata.html) || settings.html; 10894 }, 10895 title: function() { 10896 $module.removeData(metadata.title); 10897 return $module.data(metadata.title) || settings.title; 10898 }, 10899 content: function() { 10900 $module.removeData(metadata.content); 10901 return $module.data(metadata.content) || $module.attr('title') || settings.content; 10902 }, 10903 variation: function() { 10904 $module.removeData(metadata.variation); 10905 return $module.data(metadata.variation) || settings.variation; 10906 }, 10907 popup: function() { 10908 return $popup; 10909 }, 10910 popupOffset: function() { 10911 return $popup.offset(); 10912 }, 10913 calculations: function() { 10914 var 10915 targetElement = $target[0], 10916 isWindow = ($boundary[0] == window), 10917 targetPosition = (settings.inline || (settings.popup && settings.movePopup)) 10918 ? $target.position() 10919 : $target.offset(), 10920 screenPosition = (isWindow) 10921 ? { top: 0, left: 0 } 10922 : $boundary.offset(), 10923 calculations = {}, 10924 scroll = (isWindow) 10925 ? { top: $window.scrollTop(), left: $window.scrollLeft() } 10926 : { top: 0, left: 0}, 10927 screen 10928 ; 10929 calculations = { 10930 // element which is launching popup 10931 target : { 10932 element : $target[0], 10933 width : $target.outerWidth(), 10934 height : $target.outerHeight(), 10935 top : targetPosition.top, 10936 left : targetPosition.left, 10937 margin : {} 10938 }, 10939 // popup itself 10940 popup : { 10941 width : $popup.outerWidth(), 10942 height : $popup.outerHeight() 10943 }, 10944 // offset container (or 3d context) 10945 parent : { 10946 width : $offsetParent.outerWidth(), 10947 height : $offsetParent.outerHeight() 10948 }, 10949 // screen boundaries 10950 screen : { 10951 top : screenPosition.top, 10952 left : screenPosition.left, 10953 scroll: { 10954 top : scroll.top, 10955 left : scroll.left 10956 }, 10957 width : $boundary.width(), 10958 height : $boundary.height() 10959 } 10960 }; 10961 10962 // add in container calcs if fluid 10963 if( settings.setFluidWidth && module.is.fluid() ) { 10964 calculations.container = { 10965 width: $popup.parent().outerWidth() 10966 }; 10967 calculations.popup.width = calculations.container.width; 10968 } 10969 10970 // add in margins if inline 10971 calculations.target.margin.top = (settings.inline) 10972 ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10) 10973 : 0 10974 ; 10975 calculations.target.margin.left = (settings.inline) 10976 ? module.is.rtl() 10977 ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-right'), 10) 10978 : parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10) 10979 : 0 10980 ; 10981 // calculate screen boundaries 10982 screen = calculations.screen; 10983 calculations.boundary = { 10984 top : screen.top + screen.scroll.top, 10985 bottom : screen.top + screen.scroll.top + screen.height, 10986 left : screen.left + screen.scroll.left, 10987 right : screen.left + screen.scroll.left + screen.width 10988 }; 10989 return calculations; 10990 }, 10991 id: function() { 10992 return id; 10993 }, 10994 startEvent: function() { 10995 if(settings.on == 'hover') { 10996 return 'mouseenter'; 10997 } 10998 else if(settings.on == 'focus') { 10999 return 'focus'; 11000 } 11001 return false;
vendor: 23,968 bytes, lines 11002-11446
11002 }, 11003 scrollEvent: function() { 11004 return 'scroll'; 11005 }, 11006 endEvent: function() { 11007 if(settings.on == 'hover') { 11008 return 'mouseleave'; 11009 } 11010 else if(settings.on == 'focus') { 11011 return 'blur'; 11012 } 11013 return false; 11014 }, 11015 distanceFromBoundary: function(offset, calculations) { 11016 var 11017 distanceFromBoundary = {}, 11018 popup, 11019 boundary 11020 ; 11021 calculations = calculations || module.get.calculations(); 11022 11023 // shorthand 11024 popup = calculations.popup; 11025 boundary = calculations.boundary; 11026 11027 if(offset) { 11028 distanceFromBoundary = { 11029 top : (offset.top - boundary.top), 11030 left : (offset.left - boundary.left), 11031 right : (boundary.right - (offset.left + popup.width) ), 11032 bottom : (boundary.bottom - (offset.top + popup.height) ) 11033 }; 11034 module.verbose('Distance from boundaries determined', offset, distanceFromBoundary); 11035 } 11036 return distanceFromBoundary; 11037 }, 11038 offsetParent: function($target) { 11039 var 11040 element = ($target !== undefined) 11041 ? $target[0] 11042 : $module[0], 11043 parentNode = element.parentNode, 11044 $node = $(parentNode) 11045 ; 11046 if(parentNode) { 11047 var 11048 is2D = ($node.css('transform') === 'none'), 11049 isStatic = ($node.css('position') === 'static'), 11050 isHTML = $node.is('html') 11051 ; 11052 while(parentNode && !isHTML && isStatic && is2D) { 11053 parentNode = parentNode.parentNode; 11054 $node = $(parentNode); 11055 is2D = ($node.css('transform') === 'none'); 11056 isStatic = ($node.css('position') === 'static'); 11057 isHTML = $node.is('html'); 11058 } 11059 } 11060 return ($node && $node.length > 0) 11061 ? $node 11062 : $() 11063 ; 11064 }, 11065 positions: function() { 11066 return { 11067 'top left' : false, 11068 'top center' : false, 11069 'top right' : false, 11070 'bottom left' : false, 11071 'bottom center' : false, 11072 'bottom right' : false, 11073 'left center' : false, 11074 'right center' : false 11075 }; 11076 }, 11077 nextPosition: function(position) { 11078 var 11079 positions = position.split(' '), 11080 verticalPosition = positions[0], 11081 horizontalPosition = positions[1], 11082 opposite = { 11083 top : 'bottom', 11084 bottom : 'top', 11085 left : 'right', 11086 right : 'left' 11087 }, 11088 adjacent = { 11089 left : 'center', 11090 center : 'right', 11091 right : 'left' 11092 }, 11093 backup = { 11094 'top left' : 'top center', 11095 'top center' : 'top right', 11096 'top right' : 'right center', 11097 'right center' : 'bottom right', 11098 'bottom right' : 'bottom center', 11099 'bottom center' : 'bottom left', 11100 'bottom left' : 'left center', 11101 'left center' : 'top left' 11102 }, 11103 adjacentsAvailable = (verticalPosition == 'top' || verticalPosition == 'bottom'), 11104 oppositeTried = false, 11105 adjacentTried = false, 11106 nextPosition = false 11107 ; 11108 if(!triedPositions) { 11109 module.verbose('All available positions available'); 11110 triedPositions = module.get.positions(); 11111 } 11112 11113 module.debug('Recording last position tried', position); 11114 triedPositions[position] = true; 11115 11116 if(settings.prefer === 'opposite') { 11117 nextPosition = [opposite[verticalPosition], horizontalPosition]; 11118 nextPosition = nextPosition.join(' '); 11119 oppositeTried = (triedPositions[nextPosition] === true); 11120 module.debug('Trying opposite strategy', nextPosition); 11121 } 11122 if((settings.prefer === 'adjacent') && adjacentsAvailable ) { 11123 nextPosition = [verticalPosition, adjacent[horizontalPosition]]; 11124 nextPosition = nextPosition.join(' '); 11125 adjacentTried = (triedPositions[nextPosition] === true); 11126 module.debug('Trying adjacent strategy', nextPosition); 11127 } 11128 if(adjacentTried || oppositeTried) { 11129 module.debug('Using backup position', nextPosition); 11130 nextPosition = backup[position]; 11131 } 11132 return nextPosition; 11133 } 11134 }, 11135 11136 set: { 11137 position: function(position, calculations) { 11138 11139 // exit conditions 11140 if($target.length === 0 || $popup.length === 0) { 11141 module.error(error.notFound); 11142 return; 11143 } 11144 var 11145 offset, 11146 distanceAway, 11147 target, 11148 popup, 11149 parent, 11150 positioning, 11151 popupOffset, 11152 distanceFromBoundary 11153 ; 11154 11155 calculations = calculations || module.get.calculations(); 11156 position = position || $module.data(metadata.position) || settings.position; 11157 11158 offset = $module.data(metadata.offset) || settings.offset; 11159 distanceAway = settings.distanceAway; 11160 11161 // shorthand 11162 target = calculations.target; 11163 popup = calculations.popup; 11164 parent = calculations.parent; 11165 11166 if(target.width === 0 && target.height === 0 && !module.is.svg(target.element)) { 11167 module.debug('Popup target is hidden, no action taken'); 11168 return false; 11169 } 11170 11171 if(settings.inline) { 11172 module.debug('Adding margin to calculation', target.margin); 11173 if(position == 'left center' || position == 'right center') { 11174 offset += target.margin.top; 11175 distanceAway += -target.margin.left; 11176 } 11177 else if (position == 'top left' || position == 'top center' || position == 'top right') { 11178 offset += target.margin.left; 11179 distanceAway -= target.margin.top; 11180 } 11181 else { 11182 offset += target.margin.left; 11183 distanceAway += target.margin.top; 11184 } 11185 } 11186 11187 module.debug('Determining popup position from calculations', position, calculations); 11188 11189 if (module.is.rtl()) { 11190 position = position.replace(/left|right/g, function (match) { 11191 return (match == 'left') 11192 ? 'right' 11193 : 'left' 11194 ; 11195 }); 11196 module.debug('RTL: Popup position updated', position); 11197 } 11198 11199 // if last attempt use specified last resort position 11200 if(searchDepth == settings.maxSearchDepth && typeof settings.lastResort === 'string') { 11201 position = settings.lastResort; 11202 } 11203 11204 switch (position) { 11205 case 'top left': 11206 positioning = { 11207 top : 'auto', 11208 bottom : parent.height - target.top + distanceAway, 11209 left : target.left + offset, 11210 right : 'auto' 11211 }; 11212 break; 11213 case 'top center': 11214 positioning = { 11215 bottom : parent.height - target.top + distanceAway, 11216 left : target.left + (target.width / 2) - (popup.width / 2) + offset, 11217 top : 'auto', 11218 right : 'auto' 11219 }; 11220 break; 11221 case 'top right': 11222 positioning = { 11223 bottom : parent.height - target.top + distanceAway, 11224 right : parent.width - target.left - target.width - offset, 11225 top : 'auto', 11226 left : 'auto' 11227 }; 11228 break; 11229 case 'left center': 11230 positioning = { 11231 top : target.top + (target.height / 2) - (popup.height / 2) + offset, 11232 right : parent.width - target.left + distanceAway, 11233 left : 'auto', 11234 bottom : 'auto' 11235 }; 11236 break; 11237 case 'right center': 11238 positioning = { 11239 top : target.top + (target.height / 2) - (popup.height / 2) + offset, 11240 left : target.left + target.width + distanceAway, 11241 bottom : 'auto', 11242 right : 'auto' 11243 }; 11244 break; 11245 case 'bottom left': 11246 positioning = { 11247 top : target.top + target.height + distanceAway, 11248 left : target.left + offset, 11249 bottom : 'auto', 11250 right : 'auto' 11251 }; 11252 break; 11253 case 'bottom center': 11254 positioning = { 11255 top : target.top + target.height + distanceAway, 11256 left : target.left + (target.width / 2) - (popup.width / 2) + offset, 11257 bottom : 'auto', 11258 right : 'auto' 11259 }; 11260 break; 11261 case 'bottom right': 11262 positioning = { 11263 top : target.top + target.height + distanceAway, 11264 right : parent.width - target.left - target.width - offset, 11265 left : 'auto', 11266 bottom : 'auto' 11267 }; 11268 break; 11269 } 11270 if(positioning === undefined) { 11271 module.error(error.invalidPosition, position); 11272 } 11273 11274 module.debug('Calculated popup positioning values', positioning); 11275 11276 // tentatively place on stage 11277 $popup 11278 .css(positioning) 11279 .removeClass(className.position) 11280 .addClass(position) 11281 .addClass(className.loading) 11282 ; 11283 11284 popupOffset = module.get.popupOffset(); 11285 11286 // see if any boundaries are surpassed with this tentative position 11287 distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations); 11288 11289 if( module.is.offstage(distanceFromBoundary, position) ) { 11290 module.debug('Position is outside viewport', position); 11291 if(searchDepth < settings.maxSearchDepth) { 11292 searchDepth++; 11293 position = module.get.nextPosition(position); 11294 module.debug('Trying new position', position); 11295 return ($popup) 11296 ? module.set.position(position, calculations) 11297 : false 11298 ; 11299 } 11300 else { 11301 if(settings.lastResort) { 11302 module.debug('No position found, showing with last position'); 11303 } 11304 else { 11305 module.debug('Popup could not find a position to display', $popup); 11306 module.error(error.cannotPlace, element); 11307 module.remove.attempts(); 11308 module.remove.loading(); 11309 module.reset(); 11310 settings.onUnplaceable.call($popup, element); 11311 return false; 11312 } 11313 } 11314 } 11315 module.debug('Position is on stage', position); 11316 module.remove.attempts(); 11317 module.remove.loading(); 11318 if( settings.setFluidWidth && module.is.fluid() ) { 11319 module.set.fluidWidth(calculations); 11320 } 11321 return true; 11322 }, 11323 11324 fluidWidth: function(calculations) { 11325 calculations = calculations || module.get.calculations(); 11326 module.debug('Automatically setting element width to parent width', calculations.parent.width); 11327 $popup.css('width', calculations.container.width); 11328 }, 11329 11330 variation: function(variation) { 11331 variation = variation || module.get.variation(); 11332 if(variation && module.has.popup() ) { 11333 module.verbose('Adding variation to popup', variation); 11334 $popup.addClass(variation); 11335 } 11336 }, 11337 11338 visible: function() { 11339 $module.addClass(className.visible); 11340 } 11341 }, 11342 11343 remove: { 11344 loading: function() { 11345 $popup.removeClass(className.loading); 11346 }, 11347 variation: function(variation) { 11348 variation = variation || module.get.variation(); 11349 if(variation) { 11350 module.verbose('Removing variation', variation); 11351 $popup.removeClass(variation); 11352 } 11353 }, 11354 visible: function() { 11355 $module.removeClass(className.visible); 11356 }, 11357 attempts: function() { 11358 module.verbose('Resetting all searched positions'); 11359 searchDepth = 0; 11360 triedPositions = false; 11361 } 11362 }, 11363 11364 bind: { 11365 events: function() { 11366 module.debug('Binding popup events to module'); 11367 if(settings.on == 'click') { 11368 $module 11369 .on('click' + eventNamespace, module.toggle) 11370 ; 11371 } 11372 if(settings.on == 'hover' && hasTouch) { 11373 $module 11374 .on('touchstart' + eventNamespace, module.event.touchstart) 11375 ; 11376 } 11377 if( module.get.startEvent() ) { 11378 $module 11379 .on(module.get.startEvent() + eventNamespace, module.event.start) 11380 .on(module.get.endEvent() + eventNamespace, module.event.end) 11381 ; 11382 } 11383 if(settings.target) { 11384 module.debug('Target set to element', $target); 11385 } 11386 $window.on('resize' + elementNamespace, module.event.resize); 11387 }, 11388 popup: function() { 11389 module.verbose('Allowing hover events on popup to prevent closing'); 11390 if( $popup && module.has.popup() ) { 11391 $popup 11392 .on('mouseenter' + eventNamespace, module.event.start) 11393 .on('mouseleave' + eventNamespace, module.event.end) 11394 ; 11395 } 11396 }, 11397 close: function() { 11398 if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) { 11399 module.bind.closeOnScroll(); 11400 } 11401 if(settings.on == 'hover' && openedWithTouch) { 11402 module.bind.touchClose(); 11403 } 11404 if(settings.on == 'click' && settings.closable) { 11405 module.bind.clickaway(); 11406 } 11407 }, 11408 closeOnScroll: function() { 11409 module.verbose('Binding scroll close event to document'); 11410 $scrollContext 11411 .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully) 11412 ; 11413 }, 11414 touchClose: function() { 11415 module.verbose('Binding popup touchclose event to document'); 11416 $document 11417 .on('touchstart' + elementNamespace, function(event) { 11418 module.verbose('Touched away from popup'); 11419 module.event.hideGracefully.call(element, event); 11420 }) 11421 ; 11422 }, 11423 clickaway: function() { 11424 module.verbose('Binding popup close event to document'); 11425 $document 11426 .on('click' + elementNamespace, function(event) { 11427 module.verbose('Clicked away from popup'); 11428 module.event.hideGracefully.call(element, event); 11429 }) 11430 ; 11431 } 11432 }, 11433 11434 unbind: { 11435 events: function() { 11436 $window 11437 .off(elementNamespace) 11438 ; 11439 $module 11440 .off(eventNamespace) 11441 ; 11442 }, 11443 close: function() { 11444 $document 11445 .off(elementNamespace) 11446 ;
vendor: 4,609 bytes, lines 11447-11550
11447 $scrollContext 11448 .off(elementNamespace) 11449 ; 11450 }, 11451 }, 11452 11453 has: { 11454 popup: function() { 11455 return ($popup && $popup.length > 0); 11456 } 11457 }, 11458 11459 is: { 11460 offstage: function(distanceFromBoundary, position) { 11461 var 11462 offstage = [] 11463 ; 11464 // return boundaries that have been surpassed 11465 $.each(distanceFromBoundary, function(direction, distance) { 11466 if(distance < -settings.jitter) { 11467 module.debug('Position exceeds allowable distance from edge', direction, distance, position); 11468 offstage.push(direction); 11469 } 11470 }); 11471 if(offstage.length > 0) { 11472 return true; 11473 } 11474 else { 11475 return false; 11476 } 11477 }, 11478 svg: function(element) { 11479 return module.supports.svg() && (element instanceof SVGGraphicsElement); 11480 }, 11481 active: function() { 11482 return $module.hasClass(className.active); 11483 }, 11484 animating: function() { 11485 return ($popup !== undefined && $popup.hasClass(className.animating) ); 11486 }, 11487 fluid: function() { 11488 return ($popup !== undefined && $popup.hasClass(className.fluid)); 11489 }, 11490 visible: function() { 11491 return ($popup !== undefined && $popup.hasClass(className.popupVisible)); 11492 }, 11493 dropdown: function() { 11494 return $module.hasClass(className.dropdown); 11495 }, 11496 hidden: function() { 11497 return !module.is.visible(); 11498 }, 11499 rtl: function () { 11500 return $module.css('direction') == 'rtl'; 11501 } 11502 }, 11503 11504 reset: function() { 11505 module.remove.visible(); 11506 if(settings.preserve) { 11507 if($.fn.transition !== undefined) { 11508 $popup 11509 .transition('remove transition') 11510 ; 11511 } 11512 } 11513 else { 11514 module.removePopup(); 11515 } 11516 }, 11517 11518 setting: function(name, value) { 11519 if( $.isPlainObject(name) ) { 11520 $.extend(true, settings, name); 11521 } 11522 else if(value !== undefined) { 11523 settings[name] = value; 11524 } 11525 else { 11526 return settings[name]; 11527 } 11528 }, 11529 internal: function(name, value) { 11530 if( $.isPlainObject(name) ) { 11531 $.extend(true, module, name); 11532 } 11533 else if(value !== undefined) { 11534 module[name] = value; 11535 } 11536 else { 11537 return module[name]; 11538 } 11539 }, 11540 debug: function() { 11541 if(!settings.silent && settings.debug) { 11542 if(settings.performance) { 11543 module.performance.log(arguments); 11544 } 11545 else { 11546 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 11547 module.debug.apply(console, arguments); 11548 } 11549 } 11550 },
vendor: 4,339 bytes, lines 11551-11631
11551 verbose: function() { 11552 if(!settings.silent && settings.verbose && settings.debug) { 11553 if(settings.performance) { 11554 module.performance.log(arguments); 11555 } 11556 else { 11557 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 11558 module.verbose.apply(console, arguments); 11559 } 11560 } 11561 }, 11562 error: function() { 11563 if(!settings.silent) { 11564 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 11565 module.error.apply(console, arguments); 11566 } 11567 }, 11568 performance: { 11569 log: function(message) { 11570 var 11571 currentTime, 11572 executionTime, 11573 previousTime 11574 ; 11575 if(settings.performance) { 11576 currentTime = new Date().getTime(); 11577 previousTime = time || currentTime; 11578 executionTime = currentTime - previousTime; 11579 time = currentTime; 11580 performance.push({ 11581 'Name' : message[0], 11582 'Arguments' : [].slice.call(message, 1) || '', 11583 'Element' : element, 11584 'Execution Time' : executionTime 11585 }); 11586 } 11587 clearTimeout(module.performance.timer); 11588 module.performance.timer = setTimeout(module.performance.display, 500); 11589 }, 11590 display: function() { 11591 var 11592 title = settings.name + ':', 11593 totalTime = 0 11594 ; 11595 time = false; 11596 clearTimeout(module.performance.timer); 11597 $.each(performance, function(index, data) { 11598 totalTime += data['Execution Time']; 11599 }); 11600 title += ' ' + totalTime + 'ms'; 11601 if(moduleSelector) { 11602 title += ' \'' + moduleSelector + '\''; 11603 } 11604 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 11605 console.groupCollapsed(title); 11606 if(console.table) { 11607 console.table(performance); 11608 } 11609 else { 11610 $.each(performance, function(index, data) { 11611 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 11612 }); 11613 } 11614 console.groupEnd(); 11615 } 11616 performance = []; 11617 } 11618 }, 11619 invoke: function(query, passedArguments, context) { 11620 var 11621 object = instance, 11622 maxDepth, 11623 found, 11624 response 11625 ; 11626 passedArguments = passedArguments || queryArguments; 11627 context = element || context; 11628 if(typeof query == 'string' && object !== undefined) { 11629 query = query.split(/[\. ]/); 11630 maxDepth = query.length - 1; 11631 $.each(query, function(depth, value) {
vendor: 8,541 bytes, lines 11632-11882
11632 var camelCaseValue = (depth != maxDepth) 11633 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 11634 : query 11635 ; 11636 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 11637 object = object[camelCaseValue]; 11638 } 11639 else if( object[camelCaseValue] !== undefined ) { 11640 found = object[camelCaseValue]; 11641 return false; 11642 } 11643 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 11644 object = object[value]; 11645 } 11646 else if( object[value] !== undefined ) { 11647 found = object[value]; 11648 return false; 11649 } 11650 else { 11651 return false; 11652 } 11653 }); 11654 } 11655 if ( $.isFunction( found ) ) { 11656 response = found.apply(context, passedArguments); 11657 } 11658 else if(found !== undefined) { 11659 response = found; 11660 } 11661 if($.isArray(returnedValue)) { 11662 returnedValue.push(response); 11663 } 11664 else if(returnedValue !== undefined) { 11665 returnedValue = [returnedValue, response]; 11666 } 11667 else if(response !== undefined) { 11668 returnedValue = response; 11669 } 11670 return found; 11671 } 11672 }; 11673 11674 if(methodInvoked) { 11675 if(instance === undefined) { 11676 module.initialize(); 11677 } 11678 module.invoke(query); 11679 } 11680 else { 11681 if(instance !== undefined) { 11682 instance.invoke('destroy'); 11683 } 11684 module.initialize(); 11685 } 11686 }) 11687 ; 11688 11689 return (returnedValue !== undefined) 11690 ? returnedValue 11691 : this 11692 ; 11693 }; 11694 11695 $.fn.popup.settings = { 11696 11697 name : 'Popup', 11698 11699 // module settings 11700 silent : false, 11701 debug : false, 11702 verbose : false, 11703 performance : true, 11704 namespace : 'popup', 11705 11706 // whether it should use dom mutation observers 11707 observeChanges : true, 11708 11709 // callback only when element added to dom 11710 onCreate : function(){}, 11711 11712 // callback before element removed from dom 11713 onRemove : function(){}, 11714 11715 // callback before show animation 11716 onShow : function(){}, 11717 11718 // callback after show animation 11719 onVisible : function(){}, 11720 11721 // callback before hide animation 11722 onHide : function(){}, 11723 11724 // callback when popup cannot be positioned in visible screen 11725 onUnplaceable : function(){}, 11726 11727 // callback after hide animation 11728 onHidden : function(){}, 11729 11730 // when to show popup 11731 on : 'hover', 11732 11733 // element to use to determine if popup is out of boundary 11734 boundary : window, 11735 11736 // whether to add touchstart events when using hover 11737 addTouchEvents : true, 11738 11739 // default position relative to element 11740 position : 'top left', 11741 11742 // name of variation to use 11743 variation : '', 11744 11745 // whether popup should be moved to context 11746 movePopup : true, 11747 11748 // element which popup should be relative to 11749 target : false, 11750 11751 // jq selector or element that should be used as popup 11752 popup : false, 11753 11754 // popup should remain inline next to activator 11755 inline : false, 11756 11757 // popup should be removed from page on hide 11758 preserve : false, 11759 11760 // popup should not close when being hovered on 11761 hoverable : false, 11762 11763 // explicitly set content 11764 content : false, 11765 11766 // explicitly set html 11767 html : false, 11768 11769 // explicitly set title 11770 title : false, 11771 11772 // whether automatically close on clickaway when on click 11773 closable : true, 11774 11775 // automatically hide on scroll 11776 hideOnScroll : 'auto', 11777 11778 // hide other popups on show 11779 exclusive : false, 11780 11781 // context to attach popups 11782 context : 'body', 11783 11784 // context for binding scroll events 11785 scrollContext : window, 11786 11787 // position to prefer when calculating new position 11788 prefer : 'opposite', 11789 11790 // specify position to appear even if it doesn't fit 11791 lastResort : false, 11792 11793 // delay used to prevent accidental refiring of animations due to user error 11794 delay : { 11795 show : 50, 11796 hide : 70 11797 }, 11798 11799 // whether fluid variation should assign width explicitly 11800 setFluidWidth : true, 11801 11802 // transition settings 11803 duration : 200, 11804 transition : 'scale', 11805 11806 // distance away from activating element in px 11807 distanceAway : 0, 11808 11809 // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding) 11810 jitter : 2, 11811 11812 // offset on aligning axis from calculated position 11813 offset : 0, 11814 11815 // maximum times to look for a position before failing (9 positions total) 11816 maxSearchDepth : 15, 11817 11818 error: { 11819 invalidPosition : 'The position you specified is not a valid position', 11820 cannotPlace : 'Popup does not fit within the boundaries of the viewport', 11821 method : 'The method you called is not defined.', 11822 noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>', 11823 notFound : 'The target or popup you specified does not exist on the page' 11824 }, 11825 11826 metadata: { 11827 activator : 'activator', 11828 content : 'content', 11829 html : 'html', 11830 offset : 'offset', 11831 position : 'position', 11832 title : 'title', 11833 variation : 'variation' 11834 }, 11835 11836 className : { 11837 active : 'active', 11838 animating : 'animating', 11839 dropdown : 'dropdown', 11840 fluid : 'fluid', 11841 loading : 'loading', 11842 popup : 'ui popup', 11843 position : 'top left center bottom right', 11844 visible : 'visible', 11845 popupVisible : 'visible' 11846 }, 11847 11848 selector : { 11849 popup : '.ui.popup' 11850 }, 11851 11852 templates: { 11853 escape: function(string) { 11854 var 11855 badChars = /[&<>"'`]/g, 11856 shouldEscape = /[&<>"'`]/, 11857 escape = { 11858 "&": "&", 11859 "<": "<", 11860 ">": ">", 11861 '"': """, 11862 "'": "'", 11863 "`": "`" 11864 }, 11865 escapedChar = function(chr) { 11866 return escape[chr]; 11867 } 11868 ; 11869 if(shouldEscape.test(string)) { 11870 return string.replace(badChars, escapedChar); 11871 } 11872 return string; 11873 }, 11874 popup: function(text) { 11875 var 11876 html = '', 11877 escape = $.fn.popup.settings.templates.escape 11878 ; 11879 if(typeof text !== undefined) { 11880 if(typeof text.title !== undefined && text.title) { 11881 text.title = escape(text.title); 11882 html += '<div class="header">
vendor: 11,184 bytes, lines 11882-12148
11882' + text.title + '</div>'; 11883 } 11884 if(typeof text.content !== undefined && text.content) { 11885 text.content = escape(text.content); 11886 html += '<div class="content">' + text.content + '</div>'; 11887 } 11888 } 11889 return html; 11890 } 11891 } 11892 11893 }; 11894 11895 11896})( jQuery, window, document ); 11897 11898/*! 11899 * # Semantic UI 2.2.12 - Progress 11900 * http://github.com/semantic-org/semantic-ui/ 11901 * 11902 * 11903 * Released under the MIT license 11904 * http://opensource.org/licenses/MIT 11905 * 11906 */ 11907 11908;(function ($, window, document, undefined) { 11909 11910 "use strict"; 11911 11912 window = (typeof window != 'undefined' && window.Math == Math) 11913 ? window 11914 : (typeof self != 'undefined' && self.Math == Math) 11915 ? self 11916 : Function('return this')() 11917 ; 11918 11919 var 11920 global = (typeof window != 'undefined' && window.Math == Math) 11921 ? window 11922 : (typeof self != 'undefined' && self.Math == Math) 11923 ? self 11924 : Function('return this')() 11925 ; 11926 11927 $.fn.progress = function(parameters) { 11928 var 11929 $allModules = $(this), 11930 11931 moduleSelector = $allModules.selector || '', 11932 11933 time = new Date().getTime(), 11934 performance = [], 11935 11936 query = arguments[0], 11937 methodInvoked = (typeof query == 'string'), 11938 queryArguments = [].slice.call(arguments, 1), 11939 11940 returnedValue 11941 ; 11942 11943 $allModules 11944 .each(function() { 11945 var 11946 settings = ( $.isPlainObject(parameters) ) 11947 ? $.extend(true, {}, $.fn.progress.settings, parameters) 11948 : $.extend({}, $.fn.progress.settings), 11949 11950 className = settings.className, 11951 metadata = settings.metadata, 11952 namespace = settings.namespace, 11953 selector = settings.selector, 11954 error = settings.error, 11955 11956 eventNamespace = '.' + namespace, 11957 moduleNamespace = 'module-' + namespace, 11958 11959 $module = $(this), 11960 $bar = $(this).find(selector.bar), 11961 $progress = $(this).find(selector.progress), 11962 $label = $(this).find(selector.label), 11963 11964 element = this, 11965 instance = $module.data(moduleNamespace), 11966 11967 animating = false, 11968 transitionEnd, 11969 module 11970 ; 11971 11972 module = { 11973 11974 initialize: function() { 11975 module.debug('Initializing progress bar', settings); 11976 11977 module.set.duration(); 11978 module.set.transitionEvent(); 11979 11980 module.read.metadata(); 11981 module.read.settings(); 11982 11983 module.instantiate(); 11984 }, 11985 11986 instantiate: function() { 11987 module.verbose('Storing instance of progress', module); 11988 instance = module; 11989 $module 11990 .data(moduleNamespace, module) 11991 ; 11992 }, 11993 destroy: function() { 11994 module.verbose('Destroying previous progress for', $module); 11995 clearInterval(instance.interval); 11996 module.remove.state(); 11997 $module.removeData(moduleNamespace); 11998 instance = undefined; 11999 }, 12000 12001 reset: function() { 12002 module.remove.nextValue(); 12003 module.update.progress(0); 12004 }, 12005 12006 complete: function() { 12007 if(module.percent === undefined || module.percent < 100) { 12008 module.remove.progressPoll(); 12009 module.set.percent(100); 12010 } 12011 }, 12012 12013 read: { 12014 metadata: function() { 12015 var 12016 data = { 12017 percent : $module.data(metadata.percent), 12018 total : $module.data(metadata.total), 12019 value : $module.data(metadata.value) 12020 } 12021 ; 12022 if(data.percent) { 12023 module.debug('Current percent value set from metadata', data.percent); 12024 module.set.percent(data.percent); 12025 } 12026 if(data.total) { 12027 module.debug('Total value set from metadata', data.total); 12028 module.set.total(data.total); 12029 } 12030 if(data.value) { 12031 module.debug('Current value set from metadata', data.value); 12032 module.set.value(data.value); 12033 module.set.progress(data.value); 12034 } 12035 }, 12036 settings: function() { 12037 if(settings.total !== false) { 12038 module.debug('Current total set in settings', settings.total); 12039 module.set.total(settings.total); 12040 } 12041 if(settings.value !== false) { 12042 module.debug('Current value set in settings', settings.value); 12043 module.set.value(settings.value); 12044 module.set.progress(module.value); 12045 } 12046 if(settings.percent !== false) { 12047 module.debug('Current percent set in settings', settings.percent); 12048 module.set.percent(settings.percent); 12049 } 12050 } 12051 }, 12052 12053 bind: { 12054 transitionEnd: function(callback) { 12055 var 12056 transitionEnd = module.get.transitionEnd() 12057 ; 12058 $bar 12059 .one(transitionEnd + eventNamespace, function(event) { 12060 clearTimeout(module.failSafeTimer); 12061 callback.call(this, event); 12062 }) 12063 ; 12064 module.failSafeTimer = setTimeout(function() { 12065 $bar.triggerHandler(transitionEnd); 12066 }, settings.duration + settings.failSafeDelay); 12067 module.verbose('Adding fail safe timer', module.timer); 12068 } 12069 }, 12070 12071 increment: function(incrementValue) { 12072 var 12073 maxValue, 12074 startValue, 12075 newValue 12076 ; 12077 if( module.has.total() ) { 12078 startValue = module.get.value(); 12079 incrementValue = incrementValue || 1; 12080 newValue = startValue + incrementValue; 12081 } 12082 else { 12083 startValue = module.get.percent(); 12084 incrementValue = incrementValue || module.get.randomValue(); 12085 12086 newValue = startValue + incrementValue; 12087 maxValue = 100; 12088 module.debug('Incrementing percentage by', startValue, newValue); 12089 } 12090 newValue = module.get.normalizedValue(newValue); 12091 module.set.progress(newValue); 12092 }, 12093 decrement: function(decrementValue) { 12094 var 12095 total = module.get.total(), 12096 startValue, 12097 newValue 12098 ; 12099 if(total) { 12100 startValue = module.get.value(); 12101 decrementValue = decrementValue || 1; 12102 newValue = startValue - decrementValue; 12103 module.debug('Decrementing value by', decrementValue, startValue); 12104 } 12105 else { 12106 startValue = module.get.percent(); 12107 decrementValue = decrementValue || module.get.randomValue(); 12108 newValue = startValue - decrementValue; 12109 module.debug('Decrementing percentage by', decrementValue, startValue); 12110 } 12111 newValue = module.get.normalizedValue(newValue); 12112 module.set.progress(newValue); 12113 }, 12114 12115 has: { 12116 progressPoll: function() { 12117 return module.progressPoll; 12118 }, 12119 total: function() { 12120 return (module.get.total() !== false); 12121 } 12122 }, 12123 12124 get: { 12125 text: function(templateText) { 12126 var 12127 value = module.value || 0, 12128 total = module.total || 0, 12129 percent = (animating) 12130 ? module.get.displayPercent() 12131 : module.percent || 0, 12132 left = (module.total > 0) 12133 ? (total - value) 12134 : (100 - percent) 12135 ; 12136 templateText = templateText || ''; 12137 templateText = templateText 12138 .replace('{value}', value) 12139 .replace('{total}', total) 12140 .replace('{left}', left) 12141 .replace('{percent}', percent) 12142 ; 12143 module.verbose('Adding variables to progress bar text', templateText); 12144 return templateText; 12145 }, 12146 12147 normalizedValue: function(value) { 12148 if(value < 0) {
vendor: 22,971 bytes, lines 12149-12597
12149 module.debug('Value cannot decrement below 0'); 12150 return 0; 12151 } 12152 if(module.has.total()) { 12153 if(value > module.total) { 12154 module.debug('Value cannot increment above total', module.total); 12155 return module.total; 12156 } 12157 } 12158 else if(value > 100 ) { 12159 module.debug('Value cannot increment above 100 percent'); 12160 return 100; 12161 } 12162 return value; 12163 }, 12164 12165 updateInterval: function() { 12166 if(settings.updateInterval == 'auto') { 12167 return settings.duration; 12168 } 12169 return settings.updateInterval; 12170 }, 12171 12172 randomValue: function() { 12173 module.debug('Generating random increment percentage'); 12174 return Math.floor((Math.random() * settings.random.max) + settings.random.min); 12175 }, 12176 12177 numericValue: function(value) { 12178 return (typeof value === 'string') 12179 ? (value.replace(/[^\d.]/g, '') !== '') 12180 ? +(value.replace(/[^\d.]/g, '')) 12181 : false 12182 : value 12183 ; 12184 }, 12185 12186 transitionEnd: function() { 12187 var 12188 element = document.createElement('element'), 12189 transitions = { 12190 'transition' :'transitionend', 12191 'OTransition' :'oTransitionEnd', 12192 'MozTransition' :'transitionend', 12193 'WebkitTransition' :'webkitTransitionEnd' 12194 }, 12195 transition 12196 ; 12197 for(transition in transitions){ 12198 if( element.style[transition] !== undefined ){ 12199 return transitions[transition]; 12200 } 12201 } 12202 }, 12203 12204 // gets current displayed percentage (if animating values this is the intermediary value) 12205 displayPercent: function() { 12206 var 12207 barWidth = $bar.width(), 12208 totalWidth = $module.width(), 12209 minDisplay = parseInt($bar.css('min-width'), 10), 12210 displayPercent = (barWidth > minDisplay) 12211 ? (barWidth / totalWidth * 100) 12212 : module.percent 12213 ; 12214 return (settings.precision > 0) 12215 ? Math.round(displayPercent * (10 * settings.precision)) / (10 * settings.precision) 12216 : Math.round(displayPercent) 12217 ; 12218 }, 12219 12220 percent: function() { 12221 return module.percent || 0; 12222 }, 12223 value: function() { 12224 return module.nextValue || module.value || 0; 12225 }, 12226 total: function() { 12227 return module.total || false; 12228 } 12229 }, 12230 12231 create: { 12232 progressPoll: function() { 12233 module.progressPoll = setTimeout(function() { 12234 module.update.toNextValue(); 12235 module.remove.progressPoll(); 12236 }, module.get.updateInterval()); 12237 }, 12238 }, 12239 12240 is: { 12241 complete: function() { 12242 return module.is.success() || module.is.warning() || module.is.error(); 12243 }, 12244 success: function() { 12245 return $module.hasClass(className.success); 12246 }, 12247 warning: function() { 12248 return $module.hasClass(className.warning); 12249 }, 12250 error: function() { 12251 return $module.hasClass(className.error); 12252 }, 12253 active: function() { 12254 return $module.hasClass(className.active); 12255 }, 12256 visible: function() { 12257 return $module.is(':visible'); 12258 } 12259 }, 12260 12261 remove: { 12262 progressPoll: function() { 12263 module.verbose('Removing progress poll timer'); 12264 if(module.progressPoll) { 12265 clearTimeout(module.progressPoll); 12266 delete module.progressPoll; 12267 } 12268 }, 12269 nextValue: function() { 12270 module.verbose('Removing progress value stored for next update'); 12271 delete module.nextValue; 12272 }, 12273 state: function() { 12274 module.verbose('Removing stored state'); 12275 delete module.total; 12276 delete module.percent; 12277 delete module.value; 12278 }, 12279 active: function() { 12280 module.verbose('Removing active state'); 12281 $module.removeClass(className.active); 12282 }, 12283 success: function() { 12284 module.verbose('Removing success state'); 12285 $module.removeClass(className.success); 12286 }, 12287 warning: function() { 12288 module.verbose('Removing warning state'); 12289 $module.removeClass(className.warning); 12290 }, 12291 error: function() { 12292 module.verbose('Removing error state'); 12293 $module.removeClass(className.error); 12294 } 12295 }, 12296 12297 set: { 12298 barWidth: function(value) { 12299 if(value > 100) { 12300 module.error(error.tooHigh, value); 12301 } 12302 else if (value < 0) { 12303 module.error(error.tooLow, value); 12304 } 12305 else { 12306 $bar 12307 .css('width', value + '%') 12308 ; 12309 $module 12310 .attr('data-percent', parseInt(value, 10)) 12311 ; 12312 } 12313 }, 12314 duration: function(duration) { 12315 duration = duration || settings.duration; 12316 duration = (typeof duration == 'number') 12317 ? duration + 'ms' 12318 : duration 12319 ; 12320 module.verbose('Setting progress bar transition duration', duration); 12321 $bar 12322 .css({ 12323 'transition-duration': duration 12324 }) 12325 ; 12326 }, 12327 percent: function(percent) { 12328 percent = (typeof percent == 'string') 12329 ? +(percent.replace('%', '')) 12330 : percent 12331 ; 12332 // round display percentage 12333 percent = (settings.precision > 0) 12334 ? Math.round(percent * (10 * settings.precision)) / (10 * settings.precision) 12335 : Math.round(percent) 12336 ; 12337 module.percent = percent; 12338 if( !module.has.total() ) { 12339 module.value = (settings.precision > 0) 12340 ? Math.round( (percent / 100) * module.total * (10 * settings.precision)) / (10 * settings.precision) 12341 : Math.round( (percent / 100) * module.total * 10) / 10 12342 ; 12343 if(settings.limitValues) { 12344 module.value = (module.value > 100) 12345 ? 100 12346 : (module.value < 0) 12347 ? 0 12348 : module.value 12349 ; 12350 } 12351 } 12352 module.set.barWidth(percent); 12353 module.set.labelInterval(); 12354 module.set.labels(); 12355 settings.onChange.call(element, percent, module.value, module.total); 12356 }, 12357 labelInterval: function() { 12358 var 12359 animationCallback = function() { 12360 module.verbose('Bar finished animating, removing continuous label updates'); 12361 clearInterval(module.interval); 12362 animating = false; 12363 module.set.labels(); 12364 } 12365 ; 12366 clearInterval(module.interval); 12367 module.bind.transitionEnd(animationCallback); 12368 animating = true; 12369 module.interval = setInterval(function() { 12370 var 12371 isInDOM = $.contains(document.documentElement, element) 12372 ; 12373 if(!isInDOM) { 12374 clearInterval(module.interval); 12375 animating = false; 12376 } 12377 module.set.labels(); 12378 }, settings.framerate); 12379 }, 12380 labels: function() { 12381 module.verbose('Setting both bar progress and outer label text'); 12382 module.set.barLabel(); 12383 module.set.state(); 12384 }, 12385 label: function(text) { 12386 text = text || ''; 12387 if(text) { 12388 text = module.get.text(text); 12389 module.verbose('Setting label to text', text); 12390 $label.text(text); 12391 } 12392 }, 12393 state: function(percent) { 12394 percent = (percent !== undefined) 12395 ? percent 12396 : module.percent 12397 ; 12398 if(percent === 100) { 12399 if(settings.autoSuccess && !(module.is.warning() || module.is.error() || module.is.success())) { 12400 module.set.success(); 12401 module.debug('Automatically triggering success at 100%'); 12402 } 12403 else { 12404 module.verbose('Reached 100% removing active state'); 12405 module.remove.active(); 12406 module.remove.progressPoll(); 12407 } 12408 } 12409 else if(percent > 0) { 12410 module.verbose('Adjusting active progress bar label', percent); 12411 module.set.active(); 12412 } 12413 else { 12414 module.remove.active(); 12415 module.set.label(settings.text.active); 12416 } 12417 }, 12418 barLabel: function(text) { 12419 if(text !== undefined) { 12420 $progress.text( module.get.text(text) ); 12421 } 12422 else if(settings.label == 'ratio' && module.total) { 12423 module.verbose('Adding ratio to bar label'); 12424 $progress.text( module.get.text(settings.text.ratio) ); 12425 } 12426 else if(settings.label == 'percent') { 12427 module.verbose('Adding percentage to bar label'); 12428 $progress.text( module.get.text(settings.text.percent) ); 12429 } 12430 }, 12431 active: function(text) { 12432 text = text || settings.text.active; 12433 module.debug('Setting active state'); 12434 if(settings.showActivity && !module.is.active() ) { 12435 $module.addClass(className.active); 12436 } 12437 module.remove.warning(); 12438 module.remove.error(); 12439 module.remove.success(); 12440 text = settings.onLabelUpdate('active', text, module.value, module.total); 12441 if(text) { 12442 module.set.label(text); 12443 } 12444 module.bind.transitionEnd(function() { 12445 settings.onActive.call(element, module.value, module.total); 12446 }); 12447 }, 12448 success : function(text) { 12449 text = text || settings.text.success || settings.text.active; 12450 module.debug('Setting success state'); 12451 $module.addClass(className.success); 12452 module.remove.active(); 12453 module.remove.warning(); 12454 module.remove.error(); 12455 module.complete(); 12456 if(settings.text.success) { 12457 text = settings.onLabelUpdate('success', text, module.value, module.total); 12458 module.set.label(text); 12459 } 12460 else { 12461 text = settings.onLabelUpdate('active', text, module.value, module.total); 12462 module.set.label(text); 12463 } 12464 module.bind.transitionEnd(function() { 12465 settings.onSuccess.call(element, module.total); 12466 }); 12467 }, 12468 warning : function(text) { 12469 text = text || settings.text.warning; 12470 module.debug('Setting warning state'); 12471 $module.addClass(className.warning); 12472 module.remove.active(); 12473 module.remove.success(); 12474 module.remove.error(); 12475 module.complete(); 12476 text = settings.onLabelUpdate('warning', text, module.value, module.total); 12477 if(text) { 12478 module.set.label(text); 12479 } 12480 module.bind.transitionEnd(function() { 12481 settings.onWarning.call(element, module.value, module.total); 12482 }); 12483 }, 12484 error : function(text) { 12485 text = text || settings.text.error; 12486 module.debug('Setting error state'); 12487 $module.addClass(className.error); 12488 module.remove.active(); 12489 module.remove.success(); 12490 module.remove.warning(); 12491 module.complete(); 12492 text = settings.onLabelUpdate('error', text, module.value, module.total); 12493 if(text) { 12494 module.set.label(text); 12495 } 12496 module.bind.transitionEnd(function() { 12497 settings.onError.call(element, module.value, module.total); 12498 }); 12499 }, 12500 transitionEvent: function() { 12501 transitionEnd = module.get.transitionEnd(); 12502 }, 12503 total: function(totalValue) { 12504 module.total = totalValue; 12505 }, 12506 value: function(value) { 12507 module.value = value; 12508 }, 12509 progress: function(value) { 12510 if(!module.has.progressPoll()) { 12511 module.debug('First update in progress update interval, immediately updating', value); 12512 module.update.progress(value); 12513 module.create.progressPoll(); 12514 } 12515 else { 12516 module.debug('Updated within interval, setting next update to use new value', value); 12517 module.set.nextValue(value); 12518 } 12519 }, 12520 nextValue: function(value) { 12521 module.nextValue = value; 12522 } 12523 }, 12524 12525 update: { 12526 toNextValue: function() { 12527 var 12528 nextValue = module.nextValue 12529 ; 12530 if(nextValue) { 12531 module.debug('Update interval complete using last updated value', nextValue); 12532 module.update.progress(nextValue); 12533 module.remove.nextValue(); 12534 } 12535 }, 12536 progress: function(value) { 12537 var 12538 percentComplete 12539 ; 12540 value = module.get.numericValue(value); 12541 if(value === false) { 12542 module.error(error.nonNumeric, value); 12543 } 12544 value = module.get.normalizedValue(value); 12545 if( module.has.total() ) { 12546 module.set.value(value); 12547 percentComplete = (value / module.total) * 100; 12548 module.debug('Calculating percent complete from total', percentComplete); 12549 module.set.percent( percentComplete ); 12550 } 12551 else { 12552 percentComplete = value; 12553 module.debug('Setting value to exact percentage value', percentComplete); 12554 module.set.percent( percentComplete ); 12555 } 12556 } 12557 }, 12558 12559 setting: function(name, value) { 12560 module.debug('Changing setting', name, value); 12561 if( $.isPlainObject(name) ) { 12562 $.extend(true, settings, name); 12563 } 12564 else if(value !== undefined) { 12565 if($.isPlainObject(settings[name])) { 12566 $.extend(true, settings[name], value); 12567 } 12568 else { 12569 settings[name] = value; 12570 } 12571 } 12572 else { 12573 return settings[name]; 12574 } 12575 }, 12576 internal: function(name, value) { 12577 if( $.isPlainObject(name) ) { 12578 $.extend(true, module, name); 12579 } 12580 else if(value !== undefined) { 12581 module[name] = value; 12582 } 12583 else { 12584 return module[name]; 12585 } 12586 }, 12587 debug: function() { 12588 if(!settings.silent && settings.debug) { 12589 if(settings.performance) { 12590 module.performance.log(arguments); 12591 } 12592 else { 12593 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 12594 module.debug.apply(console, arguments); 12595 } 12596 } 12597 },
vendor: 4,339 bytes, lines 12598-12678
12598 verbose: function() { 12599 if(!settings.silent && settings.verbose && settings.debug) { 12600 if(settings.performance) { 12601 module.performance.log(arguments); 12602 } 12603 else { 12604 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 12605 module.verbose.apply(console, arguments); 12606 } 12607 } 12608 }, 12609 error: function() { 12610 if(!settings.silent) { 12611 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 12612 module.error.apply(console, arguments); 12613 } 12614 }, 12615 performance: { 12616 log: function(message) { 12617 var 12618 currentTime, 12619 executionTime, 12620 previousTime 12621 ; 12622 if(settings.performance) { 12623 currentTime = new Date().getTime(); 12624 previousTime = time || currentTime; 12625 executionTime = currentTime - previousTime; 12626 time = currentTime; 12627 performance.push({ 12628 'Name' : message[0], 12629 'Arguments' : [].slice.call(message, 1) || '', 12630 'Element' : element, 12631 'Execution Time' : executionTime 12632 }); 12633 } 12634 clearTimeout(module.performance.timer); 12635 module.performance.timer = setTimeout(module.performance.display, 500); 12636 }, 12637 display: function() { 12638 var 12639 title = settings.name + ':', 12640 totalTime = 0 12641 ; 12642 time = false; 12643 clearTimeout(module.performance.timer); 12644 $.each(performance, function(index, data) { 12645 totalTime += data['Execution Time']; 12646 }); 12647 title += ' ' + totalTime + 'ms'; 12648 if(moduleSelector) { 12649 title += ' \'' + moduleSelector + '\''; 12650 } 12651 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 12652 console.groupCollapsed(title); 12653 if(console.table) { 12654 console.table(performance); 12655 } 12656 else { 12657 $.each(performance, function(index, data) { 12658 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 12659 }); 12660 } 12661 console.groupEnd(); 12662 } 12663 performance = []; 12664 } 12665 }, 12666 invoke: function(query, passedArguments, context) { 12667 var 12668 object = instance, 12669 maxDepth, 12670 found, 12671 response 12672 ; 12673 passedArguments = passedArguments || queryArguments; 12674 context = element || context; 12675 if(typeof query == 'string' && object !== undefined) { 12676 query = query.split(/[\. ]/); 12677 maxDepth = query.length - 1; 12678 $.each(query, function(depth, value) {
vendor: 10,124 bytes, lines 12679-12974
12679 var camelCaseValue = (depth != maxDepth) 12680 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 12681 : query 12682 ; 12683 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 12684 object = object[camelCaseValue]; 12685 } 12686 else if( object[camelCaseValue] !== undefined ) { 12687 found = object[camelCaseValue]; 12688 return false; 12689 } 12690 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 12691 object = object[value]; 12692 } 12693 else if( object[value] !== undefined ) { 12694 found = object[value]; 12695 return false; 12696 } 12697 else { 12698 module.error(error.method, query); 12699 return false; 12700 } 12701 }); 12702 } 12703 if ( $.isFunction( found ) ) { 12704 response = found.apply(context, passedArguments); 12705 } 12706 else if(found !== undefined) { 12707 response = found; 12708 } 12709 if($.isArray(returnedValue)) { 12710 returnedValue.push(response); 12711 } 12712 else if(returnedValue !== undefined) { 12713 returnedValue = [returnedValue, response]; 12714 } 12715 else if(response !== undefined) { 12716 returnedValue = response; 12717 } 12718 return found; 12719 } 12720 }; 12721 12722 if(methodInvoked) { 12723 if(instance === undefined) { 12724 module.initialize(); 12725 } 12726 module.invoke(query); 12727 } 12728 else { 12729 if(instance !== undefined) { 12730 instance.invoke('destroy'); 12731 } 12732 module.initialize(); 12733 } 12734 }) 12735 ; 12736 12737 return (returnedValue !== undefined) 12738 ? returnedValue 12739 : this 12740 ; 12741 }; 12742 12743 $.fn.progress.settings = { 12744 12745 name : 'Progress', 12746 namespace : 'progress', 12747 12748 silent : false, 12749 debug : false, 12750 verbose : false, 12751 performance : true, 12752 12753 random : { 12754 min : 2, 12755 max : 5 12756 }, 12757 12758 duration : 300, 12759 12760 updateInterval : 'auto', 12761 12762 autoSuccess : true, 12763 showActivity : true, 12764 limitValues : true, 12765 12766 label : 'percent', 12767 precision : 0, 12768 framerate : (1000 / 30), /// 30 fps 12769 12770 percent : false, 12771 total : false, 12772 value : false, 12773 12774 // delay in ms for fail safe animation callback 12775 failSafeDelay : 100, 12776 12777 onLabelUpdate : function(state, text, value, total){ 12778 return text; 12779 }, 12780 onChange : function(percent, value, total){}, 12781 onSuccess : function(total){}, 12782 onActive : function(value, total){}, 12783 onError : function(value, total){}, 12784 onWarning : function(value, total){}, 12785 12786 error : { 12787 method : 'The method you called is not defined.', 12788 nonNumeric : 'Progress value is non numeric', 12789 tooHigh : 'Value specified is above 100%', 12790 tooLow : 'Value specified is below 0%' 12791 }, 12792 12793 regExp: { 12794 variable: /\{\$*[A-z0-9]+\}/g 12795 }, 12796 12797 metadata: { 12798 percent : 'percent', 12799 total : 'total', 12800 value : 'value' 12801 }, 12802 12803 selector : { 12804 bar : '> .bar', 12805 label : '> .label', 12806 progress : '.bar > .progress' 12807 }, 12808 12809 text : { 12810 active : false, 12811 error : false, 12812 success : false, 12813 warning : false, 12814 percent : '{percent}%', 12815 ratio : '{value} of {total}' 12816 }, 12817 12818 className : { 12819 active : 'active', 12820 error : 'error', 12821 success : 'success', 12822 warning : 'warning' 12823 } 12824 12825 }; 12826 12827 12828})( jQuery, window, document ); 12829 12830/*! 12831 * # Semantic UI 2.2.12 - Rating 12832 * http://github.com/semantic-org/semantic-ui/ 12833 * 12834 * 12835 * Released under the MIT license 12836 * http://opensource.org/licenses/MIT 12837 * 12838 */ 12839 12840;(function ($, window, document, undefined) { 12841 12842 "use strict"; 12843 12844 window = (typeof window != 'undefined' && window.Math == Math) 12845 ? window 12846 : (typeof self != 'undefined' && self.Math == Math) 12847 ? self 12848 : Function('return this')() 12849 ; 12850 12851 $.fn.rating = function(parameters) { 12852 var 12853 $allModules = $(this), 12854 moduleSelector = $allModules.selector || '', 12855 12856 time = new Date().getTime(), 12857 performance = [], 12858 12859 query = arguments[0], 12860 methodInvoked = (typeof query == 'string'), 12861 queryArguments = [].slice.call(arguments, 1), 12862 returnedValue 12863 ; 12864 $allModules 12865 .each(function() { 12866 var 12867 settings = ( $.isPlainObject(parameters) ) 12868 ? $.extend(true, {}, $.fn.rating.settings, parameters) 12869 : $.extend({}, $.fn.rating.settings), 12870 12871 namespace = settings.namespace, 12872 className = settings.className, 12873 metadata = settings.metadata, 12874 selector = settings.selector, 12875 error = settings.error, 12876 12877 eventNamespace = '.' + namespace, 12878 moduleNamespace = 'module-' + namespace, 12879 12880 element = this, 12881 instance = $(this).data(moduleNamespace), 12882 12883 $module = $(this), 12884 $icon = $module.find(selector.icon), 12885 12886 initialLoad, 12887 module 12888 ; 12889 12890 module = { 12891 12892 initialize: function() { 12893 module.verbose('Initializing rating module', settings); 12894 12895 if($icon.length === 0) { 12896 module.setup.layout(); 12897 } 12898 12899 if(settings.interactive) { 12900 module.enable(); 12901 } 12902 else { 12903 module.disable(); 12904 } 12905 module.set.initialLoad(); 12906 module.set.rating( module.get.initialRating() ); 12907 module.remove.initialLoad(); 12908 module.instantiate(); 12909 }, 12910 12911 instantiate: function() { 12912 module.verbose('Instantiating module', settings); 12913 instance = module; 12914 $module 12915 .data(moduleNamespace, module) 12916 ; 12917 }, 12918 12919 destroy: function() { 12920 module.verbose('Destroying previous instance', instance); 12921 module.remove.events(); 12922 $module 12923 .removeData(moduleNamespace) 12924 ; 12925 }, 12926 12927 refresh: function() { 12928 $icon = $module.find(selector.icon); 12929 }, 12930 12931 setup: { 12932 layout: function() { 12933 var 12934 maxRating = module.get.maxRating(), 12935 html = $.fn.rating.settings.templates.icon(maxRating) 12936 ; 12937 module.debug('Generating icon html dynamically'); 12938 $module 12939 .html(html) 12940 ; 12941 module.refresh(); 12942 } 12943 }, 12944 12945 event: { 12946 mouseenter: function() { 12947 var 12948 $activeIcon = $(this) 12949 ; 12950 $activeIcon 12951 .nextAll() 12952 .removeClass(className.selected) 12953 ; 12954 $module 12955 .addClass(className.selected) 12956 ; 12957 $activeIcon 12958 .addClass(className.selected) 12959 .prevAll() 12960 .addClass(className.selected) 12961 ; 12962 }, 12963 mouseleave: function() { 12964 $module 12965 .removeClass(className.selected) 12966 ; 12967 $icon 12968 .removeClass(className.selected) 12969 ; 12970 }, 12971 click: function() { 12972 var 12973 $activeIcon = $(this), 12974 currentRating = module.get.rating(
vendor: 6,983 bytes, lines 12974-13133
12974), 12975 rating = $icon.index($activeIcon) + 1, 12976 canClear = (settings.clearable == 'auto') 12977 ? ($icon.length === 1) 12978 : settings.clearable 12979 ; 12980 if(canClear && currentRating == rating) { 12981 module.clearRating(); 12982 } 12983 else { 12984 module.set.rating( rating ); 12985 } 12986 } 12987 }, 12988 12989 clearRating: function() { 12990 module.debug('Clearing current rating'); 12991 module.set.rating(0); 12992 }, 12993 12994 bind: { 12995 events: function() { 12996 module.verbose('Binding events'); 12997 $module 12998 .on('mouseenter' + eventNamespace, selector.icon, module.event.mouseenter) 12999 .on('mouseleave' + eventNamespace, selector.icon, module.event.mouseleave) 13000 .on('click' + eventNamespace, selector.icon, module.event.click) 13001 ; 13002 } 13003 }, 13004 13005 remove: { 13006 events: function() { 13007 module.verbose('Removing events'); 13008 $module 13009 .off(eventNamespace) 13010 ; 13011 }, 13012 initialLoad: function() { 13013 initialLoad = false; 13014 } 13015 }, 13016 13017 enable: function() { 13018 module.debug('Setting rating to interactive mode'); 13019 module.bind.events(); 13020 $module 13021 .removeClass(className.disabled) 13022 ; 13023 }, 13024 13025 disable: function() { 13026 module.debug('Setting rating to read-only mode'); 13027 module.remove.events(); 13028 $module 13029 .addClass(className.disabled) 13030 ; 13031 }, 13032 13033 is: { 13034 initialLoad: function() { 13035 return initialLoad; 13036 } 13037 }, 13038 13039 get: { 13040 initialRating: function() { 13041 if($module.data(metadata.rating) !== undefined) { 13042 $module.removeData(metadata.rating); 13043 return $module.data(metadata.rating); 13044 } 13045 return settings.initialRating; 13046 }, 13047 maxRating: function() { 13048 if($module.data(metadata.maxRating) !== undefined) { 13049 $module.removeData(metadata.maxRating); 13050 return $module.data(metadata.maxRating); 13051 } 13052 return settings.maxRating; 13053 }, 13054 rating: function() { 13055 var 13056 currentRating = $icon.filter('.' + className.active).length 13057 ; 13058 module.verbose('Current rating retrieved', currentRating); 13059 return currentRating; 13060 } 13061 }, 13062 13063 set: { 13064 rating: function(rating) { 13065 var 13066 ratingIndex = (rating - 1 >= 0) 13067 ? (rating - 1) 13068 : 0, 13069 $activeIcon = $icon.eq(ratingIndex) 13070 ; 13071 $module 13072 .removeClass(className.selected) 13073 ; 13074 $icon 13075 .removeClass(className.selected) 13076 .removeClass(className.active) 13077 ; 13078 if(rating > 0) { 13079 module.verbose('Setting current rating to', rating); 13080 $activeIcon 13081 .prevAll() 13082 .addBack() 13083 .addClass(className.active) 13084 ; 13085 } 13086 if(!module.is.initialLoad()) { 13087 settings.onRate.call(element, rating); 13088 } 13089 }, 13090 initialLoad: function() { 13091 initialLoad = true; 13092 } 13093 }, 13094 13095 setting: function(name, value) { 13096 module.debug('Changing setting', name, value); 13097 if( $.isPlainObject(name) ) { 13098 $.extend(true, settings, name); 13099 } 13100 else if(value !== undefined) { 13101 if($.isPlainObject(settings[name])) { 13102 $.extend(true, settings[name], value); 13103 } 13104 else { 13105 settings[name] = value; 13106 } 13107 } 13108 else { 13109 return settings[name]; 13110 } 13111 }, 13112 internal: function(name, value) { 13113 if( $.isPlainObject(name) ) { 13114 $.extend(true, module, name); 13115 } 13116 else if(value !== undefined) { 13117 module[name] = value; 13118 } 13119 else { 13120 return module[name]; 13121 } 13122 }, 13123 debug: function() { 13124 if(!settings.silent && settings.debug) { 13125 if(settings.performance) { 13126 module.performance.log(arguments); 13127 } 13128 else { 13129 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 13130 module.debug.apply(console, arguments); 13131 } 13132 } 13133 },
vendor: 4,505 bytes, lines 13134-13217
13134 verbose: function() { 13135 if(!settings.silent && settings.verbose && settings.debug) { 13136 if(settings.performance) { 13137 module.performance.log(arguments); 13138 } 13139 else { 13140 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 13141 module.verbose.apply(console, arguments); 13142 } 13143 } 13144 }, 13145 error: function() { 13146 if(!settings.silent) { 13147 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 13148 module.error.apply(console, arguments); 13149 } 13150 }, 13151 performance: { 13152 log: function(message) { 13153 var 13154 currentTime, 13155 executionTime, 13156 previousTime 13157 ; 13158 if(settings.performance) { 13159 currentTime = new Date().getTime(); 13160 previousTime = time || currentTime; 13161 executionTime = currentTime - previousTime; 13162 time = currentTime; 13163 performance.push({ 13164 'Name' : message[0], 13165 'Arguments' : [].slice.call(message, 1) || '', 13166 'Element' : element, 13167 'Execution Time' : executionTime 13168 }); 13169 } 13170 clearTimeout(module.performance.timer); 13171 module.performance.timer = setTimeout(module.performance.display, 500); 13172 }, 13173 display: function() { 13174 var 13175 title = settings.name + ':', 13176 totalTime = 0 13177 ; 13178 time = false; 13179 clearTimeout(module.performance.timer); 13180 $.each(performance, function(index, data) { 13181 totalTime += data['Execution Time']; 13182 }); 13183 title += ' ' + totalTime + 'ms'; 13184 if(moduleSelector) { 13185 title += ' \'' + moduleSelector + '\''; 13186 } 13187 if($allModules.length > 1) { 13188 title += ' ' + '(' + $allModules.length + ')'; 13189 } 13190 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 13191 console.groupCollapsed(title); 13192 if(console.table) { 13193 console.table(performance); 13194 } 13195 else { 13196 $.each(performance, function(index, data) { 13197 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 13198 }); 13199 } 13200 console.groupEnd(); 13201 } 13202 performance = []; 13203 } 13204 }, 13205 invoke: function(query, passedArguments, context) { 13206 var 13207 object = instance, 13208 maxDepth, 13209 found, 13210 response 13211 ; 13212 passedArguments = passedArguments || queryArguments; 13213 context = element || context; 13214 if(typeof query == 'string' && object !== undefined) { 13215 query = query.split(/[\. ]/); 13216 maxDepth = query.length - 1; 13217 $.each(query, function(depth, value) {
vendor: 8,793 bytes, lines 13218-13459
13218 var camelCaseValue = (depth != maxDepth) 13219 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 13220 : query 13221 ; 13222 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 13223 object = object[camelCaseValue]; 13224 } 13225 else if( object[camelCaseValue] !== undefined ) { 13226 found = object[camelCaseValue]; 13227 return false; 13228 } 13229 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 13230 object = object[value]; 13231 } 13232 else if( object[value] !== undefined ) { 13233 found = object[value]; 13234 return false; 13235 } 13236 else { 13237 return false; 13238 } 13239 }); 13240 } 13241 if ( $.isFunction( found ) ) { 13242 response = found.apply(context, passedArguments); 13243 } 13244 else if(found !== undefined) { 13245 response = found; 13246 } 13247 if($.isArray(returnedValue)) { 13248 returnedValue.push(response); 13249 } 13250 else if(returnedValue !== undefined) { 13251 returnedValue = [returnedValue, response]; 13252 } 13253 else if(response !== undefined) { 13254 returnedValue = response; 13255 } 13256 return found; 13257 } 13258 }; 13259 if(methodInvoked) { 13260 if(instance === undefined) { 13261 module.initialize(); 13262 } 13263 module.invoke(query); 13264 } 13265 else { 13266 if(instance !== undefined) { 13267 instance.invoke('destroy'); 13268 } 13269 module.initialize(); 13270 } 13271 }) 13272 ; 13273 13274 return (returnedValue !== undefined) 13275 ? returnedValue 13276 : this 13277 ; 13278 }; 13279 13280 $.fn.rating.settings = { 13281 13282 name : 'Rating', 13283 namespace : 'rating', 13284 13285 slent : false, 13286 debug : false, 13287 verbose : false, 13288 performance : true, 13289 13290 initialRating : 0, 13291 interactive : true, 13292 maxRating : 4, 13293 clearable : 'auto', 13294 13295 fireOnInit : false, 13296 13297 onRate : function(rating){}, 13298 13299 error : { 13300 method : 'The method you called is not defined', 13301 noMaximum : 'No maximum rating specified. Cannot generate HTML automatically' 13302 }, 13303 13304 13305 metadata: { 13306 rating : 'rating', 13307 maxRating : 'maxRating' 13308 }, 13309 13310 className : { 13311 active : 'active', 13312 disabled : 'disabled', 13313 selected : 'selected', 13314 loading : 'loading' 13315 }, 13316 13317 selector : { 13318 icon : '.icon' 13319 }, 13320 13321 templates: { 13322 icon: function(maxRating) { 13323 var 13324 icon = 1, 13325 html = '' 13326 ; 13327 while(icon <= maxRating) { 13328 html += '<i class="icon"></i>'; 13329 icon++; 13330 } 13331 return html; 13332 } 13333 } 13334 13335 }; 13336 13337})( jQuery, window, document ); 13338 13339/*! 13340 * # Semantic UI 2.2.12 - Search 13341 * http://github.com/semantic-org/semantic-ui/ 13342 * 13343 * 13344 * Released under the MIT license 13345 * http://opensource.org/licenses/MIT 13346 * 13347 */ 13348 13349;(function ($, window, document, undefined) { 13350 13351 "use strict"; 13352 13353 window = (typeof window != 'undefined' && window.Math == Math) 13354 ? window 13355 : (typeof self != 'undefined' && self.Math == Math) 13356 ? self 13357 : Function('return this')() 13358 ; 13359 13360 $.fn.search = function(parameters) { 13361 var 13362 $allModules = $(this), 13363 moduleSelector = $allModules.selector || '', 13364 13365 time = new Date().getTime(), 13366 performance = [], 13367 13368 query = arguments[0], 13369 methodInvoked = (typeof query == 'string'), 13370 queryArguments = [].slice.call(arguments, 1), 13371 returnedValue 13372 ; 13373 $(this) 13374 .each(function() { 13375 var 13376 settings = ( $.isPlainObject(parameters) ) 13377 ? $.extend(true, {}, $.fn.search.settings, parameters) 13378 : $.extend({}, $.fn.search.settings), 13379 13380 className = settings.className, 13381 metadata = settings.metadata, 13382 regExp = settings.regExp, 13383 fields = settings.fields, 13384 selector = settings.selector, 13385 error = settings.error, 13386 namespace = settings.namespace, 13387 13388 eventNamespace = '.' + namespace, 13389 moduleNamespace = namespace + '-module', 13390 13391 $module = $(this), 13392 $prompt = $module.find(selector.prompt), 13393 $searchButton = $module.find(selector.searchButton), 13394 $results = $module.find(selector.results), 13395 $result = $module.find(selector.result), 13396 $category = $module.find(selector.category), 13397 13398 element = this, 13399 instance = $module.data(moduleNamespace), 13400 13401 disabledBubbled = false, 13402 resultsDismissed = false, 13403 13404 module 13405 ; 13406 13407 module = { 13408 13409 initialize: function() { 13410 module.verbose('Initializing module'); 13411 module.determine.searchFields(); 13412 module.bind.events(); 13413 module.set.type(); 13414 module.create.results(); 13415 module.instantiate(); 13416 }, 13417 instantiate: function() { 13418 module.verbose('Storing instance of module', module); 13419 instance = module; 13420 $module 13421 .data(moduleNamespace, module) 13422 ; 13423 }, 13424 destroy: function() { 13425 module.verbose('Destroying instance'); 13426 $module 13427 .off(eventNamespace) 13428 .removeData(moduleNamespace) 13429 ; 13430 }, 13431 13432 refresh: function() { 13433 module.debug('Refreshing selector cache'); 13434 $prompt = $module.find(selector.prompt); 13435 $searchButton = $module.find(selector.searchButton); 13436 $category = $module.find(selector.category); 13437 $results = $module.find(selector.results); 13438 $result = $module.find(selector.result); 13439 }, 13440 13441 refreshResults: function() { 13442 $results = $module.find(selector.results); 13443 $result = $module.find(selector.result); 13444 }, 13445 13446 bind: { 13447 events: function() { 13448 module.verbose('Binding events to search'); 13449 if(settings.automatic) { 13450 $module 13451 .on(module.get.inputEvent() + eventNamespace, selector.prompt, module.event.input) 13452 ; 13453 $prompt 13454 .attr('autocomplete', 'off') 13455 ; 13456 } 13457 $module 13458 // prompt 13459 .on('focus' + eventNamespace, selector.prompt, module.event.focus)
vendor: 44,733 bytes, lines 13460-14353
13460 .on('blur' + eventNamespace, selector.prompt, module.event.blur) 13461 .on('keydown' + eventNamespace, selector.prompt, module.handleKeyboard) 13462 // search button 13463 .on('click' + eventNamespace, selector.searchButton, module.query) 13464 // results 13465 .on('mousedown' + eventNamespace, selector.results, module.event.result.mousedown) 13466 .on('mouseup' + eventNamespace, selector.results, module.event.result.mouseup) 13467 .on('click' + eventNamespace, selector.result, module.event.result.click) 13468 ; 13469 } 13470 }, 13471 13472 determine: { 13473 searchFields: function() { 13474 // this makes sure $.extend does not add specified search fields to default fields 13475 // this is the only setting which should not extend defaults 13476 if(parameters && parameters.searchFields !== undefined) { 13477 settings.searchFields = parameters.searchFields; 13478 } 13479 } 13480 }, 13481 13482 event: { 13483 input: function() { 13484 if(settings.searchDelay) { 13485 clearTimeout(module.timer); 13486 module.timer = setTimeout(function() { 13487 if(module.is.focused()) { 13488 module.query(); 13489 } 13490 }, settings.searchDelay); 13491 } 13492 else { 13493 module.query(); 13494 } 13495 }, 13496 focus: function() { 13497 module.set.focus(); 13498 if(settings.searchOnFocus && module.has.minimumCharacters() ) { 13499 module.query(function() { 13500 if(module.can.show() ) { 13501 module.showResults(); 13502 } 13503 }); 13504 } 13505 }, 13506 blur: function(event) { 13507 var 13508 pageLostFocus = (document.activeElement === this), 13509 callback = function() { 13510 module.cancel.query(); 13511 module.remove.focus(); 13512 module.timer = setTimeout(module.hideResults, settings.hideDelay); 13513 } 13514 ; 13515 if(pageLostFocus) { 13516 return; 13517 } 13518 resultsDismissed = false; 13519 if(module.resultsClicked) { 13520 module.debug('Determining if user action caused search to close'); 13521 $module 13522 .one('click.close' + eventNamespace, selector.results, function(event) { 13523 if(module.is.inMessage(event) || disabledBubbled) { 13524 $prompt.focus(); 13525 return; 13526 } 13527 disabledBubbled = false; 13528 if( !module.is.animating() && !module.is.hidden()) { 13529 callback(); 13530 } 13531 }) 13532 ; 13533 } 13534 else { 13535 module.debug('Input blurred without user action, closing results'); 13536 callback(); 13537 } 13538 }, 13539 result: { 13540 mousedown: function() { 13541 module.resultsClicked = true; 13542 }, 13543 mouseup: function() { 13544 module.resultsClicked = false; 13545 }, 13546 click: function(event) { 13547 module.debug('Search result selected'); 13548 var 13549 $result = $(this), 13550 $title = $result.find(selector.title).eq(0), 13551 $link = $result.is('a[href]') 13552 ? $result 13553 : $result.find('a[href]').eq(0), 13554 href = $link.attr('href') || false, 13555 target = $link.attr('target') || false, 13556 title = $title.html(), 13557 // title is used for result lookup 13558 value = ($title.length > 0) 13559 ? $title.text() 13560 : false, 13561 results = module.get.results(), 13562 result = $result.data(metadata.result) || module.get.result(value, results), 13563 returnedValue 13564 ; 13565 if( $.isFunction(settings.onSelect) ) { 13566 if(settings.onSelect.call(element, result, results) === false) { 13567 module.debug('Custom onSelect callback cancelled default select action'); 13568 disabledBubbled = true; 13569 return; 13570 } 13571 } 13572 module.hideResults(); 13573 if(value) { 13574 module.set.value(value); 13575 } 13576 if(href) { 13577 module.verbose('Opening search link found in result', $link); 13578 if(target == '_blank' || event.ctrlKey) { 13579 window.open(href); 13580 } 13581 else { 13582 window.location.href = (href); 13583 } 13584 } 13585 } 13586 } 13587 }, 13588 handleKeyboard: function(event) { 13589 var 13590 // force selector refresh 13591 $result = $module.find(selector.result), 13592 $category = $module.find(selector.category), 13593 $activeResult = $result.filter('.' + className.active), 13594 currentIndex = $result.index( $activeResult ), 13595 resultSize = $result.length, 13596 hasActiveResult = $activeResult.length > 0, 13597 13598 keyCode = event.which, 13599 keys = { 13600 backspace : 8, 13601 enter : 13, 13602 escape : 27, 13603 upArrow : 38, 13604 downArrow : 40 13605 }, 13606 newIndex 13607 ; 13608 // search shortcuts 13609 if(keyCode == keys.escape) { 13610 module.verbose('Escape key pressed, blurring search field'); 13611 module.hideResults(); 13612 resultsDismissed = true; 13613 } 13614 if( module.is.visible() ) { 13615 if(keyCode == keys.enter) { 13616 module.verbose('Enter key pressed, selecting active result'); 13617 if( $result.filter('.' + className.active).length > 0 ) { 13618 module.event.result.click.call($result.filter('.' + className.active), event); 13619 event.preventDefault(); 13620 return false; 13621 } 13622 } 13623 else if(keyCode == keys.upArrow && hasActiveResult) { 13624 module.verbose('Up key pressed, changing active result'); 13625 newIndex = (currentIndex - 1 < 0) 13626 ? currentIndex 13627 : currentIndex - 1 13628 ; 13629 $category 13630 .removeClass(className.active) 13631 ; 13632 $result 13633 .removeClass(className.active) 13634 .eq(newIndex) 13635 .addClass(className.active) 13636 .closest($category) 13637 .addClass(className.active) 13638 ; 13639 event.preventDefault(); 13640 } 13641 else if(keyCode == keys.downArrow) { 13642 module.verbose('Down key pressed, changing active result'); 13643 newIndex = (currentIndex + 1 >= resultSize) 13644 ? currentIndex 13645 : currentIndex + 1 13646 ; 13647 $category 13648 .removeClass(className.active) 13649 ; 13650 $result 13651 .removeClass(className.active) 13652 .eq(newIndex) 13653 .addClass(className.active) 13654 .closest($category) 13655 .addClass(className.active) 13656 ; 13657 event.preventDefault(); 13658 } 13659 } 13660 else { 13661 // query shortcuts 13662 if(keyCode == keys.enter) { 13663 module.verbose('Enter key pressed, executing query'); 13664 module.query(); 13665 module.set.buttonPressed(); 13666 $prompt.one('keyup', module.remove.buttonFocus); 13667 } 13668 } 13669 }, 13670 13671 setup: { 13672 api: function(searchTerm, callback) { 13673 var 13674 apiSettings = { 13675 debug : settings.debug, 13676 on : false, 13677 cache : true, 13678 action : 'search', 13679 urlData : { 13680 query : searchTerm 13681 }, 13682 onSuccess : function(response) { 13683 module.parse.response.call(element, response, searchTerm); 13684 callback(); 13685 }, 13686 onFailure : function() { 13687 module.displayMessage(error.serverError); 13688 callback(); 13689 }, 13690 onAbort : function(response) { 13691 }, 13692 onError : module.error 13693 }, 13694 searchHTML 13695 ; 13696 $.extend(true, apiSettings, settings.apiSettings); 13697 module.verbose('Setting up API request', apiSettings); 13698 $module.api(apiSettings); 13699 } 13700 }, 13701 13702 can: { 13703 useAPI: function() { 13704 return $.fn.api !== undefined; 13705 }, 13706 show: function() { 13707 return module.is.focused() && !module.is.visible() && !module.is.empty(); 13708 }, 13709 transition: function() { 13710 return settings.transition && $.fn.transition !== undefined && $module.transition('is supported'); 13711 } 13712 }, 13713 13714 is: { 13715 animating: function() { 13716 return $results.hasClass(className.animating); 13717 }, 13718 hidden: function() { 13719 return $results.hasClass(className.hidden); 13720 }, 13721 inMessage: function(event) { 13722 if(!event.target) { 13723 return; 13724 } 13725 var 13726 $target = $(event.target), 13727 isInDOM = $.contains(document.documentElement, event.target) 13728 ; 13729 return (isInDOM && $target.closest(selector.message).length > 0); 13730 }, 13731 empty: function() { 13732 return ($results.html() === ''); 13733 }, 13734 visible: function() { 13735 return ($results.filter(':visible').length > 0); 13736 }, 13737 focused: function() { 13738 return ($prompt.filter(':focus').length > 0); 13739 } 13740 }, 13741 13742 get: { 13743 inputEvent: function() { 13744 var 13745 prompt = $prompt[0], 13746 inputEvent = (prompt !== undefined && prompt.oninput !== undefined) 13747 ? 'input' 13748 : (prompt !== undefined && prompt.onpropertychange !== undefined) 13749 ? 'propertychange' 13750 : 'keyup' 13751 ; 13752 return inputEvent; 13753 }, 13754 value: function() { 13755 return $prompt.val(); 13756 }, 13757 results: function() { 13758 var 13759 results = $module.data(metadata.results) 13760 ; 13761 return results; 13762 }, 13763 result: function(value, results) { 13764 var 13765 lookupFields = ['title', 'id'], 13766 result = false 13767 ; 13768 value = (value !== undefined) 13769 ? value 13770 : module.get.value() 13771 ; 13772 results = (results !== undefined) 13773 ? results 13774 : module.get.results() 13775 ; 13776 if(settings.type === 'category') { 13777 module.debug('Finding result that matches', value); 13778 $.each(results, function(index, category) { 13779 if($.isArray(category.results)) { 13780 result = module.search.object(value, category.results, lookupFields)[0]; 13781 // don't continue searching if a result is found 13782 if(result) { 13783 return false; 13784 } 13785 } 13786 }); 13787 } 13788 else { 13789 module.debug('Finding result in results object', value); 13790 result = module.search.object(value, results, lookupFields)[0]; 13791 } 13792 return result || false; 13793 }, 13794 }, 13795 13796 select: { 13797 firstResult: function() { 13798 module.verbose('Selecting first result'); 13799 $result.first().addClass(className.active); 13800 } 13801 }, 13802 13803 set: { 13804 focus: function() { 13805 $module.addClass(className.focus); 13806 }, 13807 loading: function() { 13808 $module.addClass(className.loading); 13809 }, 13810 value: function(value) { 13811 module.verbose('Setting search input value', value); 13812 $prompt 13813 .val(value) 13814 ; 13815 }, 13816 type: function(type) { 13817 type = type || settings.type; 13818 if(settings.type == 'category') { 13819 $module.addClass(settings.type); 13820 } 13821 }, 13822 buttonPressed: function() { 13823 $searchButton.addClass(className.pressed); 13824 } 13825 }, 13826 13827 remove: { 13828 loading: function() { 13829 $module.removeClass(className.loading); 13830 }, 13831 focus: function() { 13832 $module.removeClass(className.focus); 13833 }, 13834 buttonPressed: function() { 13835 $searchButton.removeClass(className.pressed); 13836 } 13837 }, 13838 13839 query: function(callback) { 13840 callback = $.isFunction(callback) 13841 ? callback 13842 : function(){} 13843 ; 13844 var 13845 searchTerm = module.get.value(), 13846 cache = module.read.cache(searchTerm) 13847 ; 13848 callback = callback || function() {}; 13849 if( module.has.minimumCharacters() ) { 13850 if(cache) { 13851 module.debug('Reading result from cache', searchTerm); 13852 module.save.results(cache.results); 13853 module.addResults(cache.html); 13854 module.inject.id(cache.results); 13855 callback(); 13856 } 13857 else { 13858 module.debug('Querying for', searchTerm); 13859 if($.isPlainObject(settings.source) || $.isArray(settings.source)) { 13860 module.search.local(searchTerm); 13861 callback(); 13862 } 13863 else if( module.can.useAPI() ) { 13864 module.search.remote(searchTerm, callback); 13865 } 13866 else { 13867 module.error(error.source); 13868 callback(); 13869 } 13870 } 13871 settings.onSearchQuery.call(element, searchTerm); 13872 } 13873 else { 13874 module.hideResults(); 13875 } 13876 }, 13877 13878 search: { 13879 local: function(searchTerm) { 13880 var 13881 results = module.search.object(searchTerm, settings.content), 13882 searchHTML 13883 ; 13884 module.set.loading(); 13885 module.save.results(results); 13886 module.debug('Returned local search results', results); 13887 13888 searchHTML = module.generateResults({ 13889 results: results 13890 }); 13891 module.remove.loading(); 13892 module.addResults(searchHTML); 13893 module.inject.id(results); 13894 module.write.cache(searchTerm, { 13895 html : searchHTML, 13896 results : results 13897 }); 13898 }, 13899 remote: function(searchTerm, callback) { 13900 callback = $.isFunction(callback) 13901 ? callback 13902 : function(){} 13903 ; 13904 if($module.api('is loading')) { 13905 $module.api('abort'); 13906 } 13907 module.setup.api(searchTerm, callback); 13908 $module 13909 .api('query') 13910 ; 13911 }, 13912 object: function(searchTerm, source, searchFields) { 13913 var 13914 results = [], 13915 fuzzyResults = [], 13916 searchExp = searchTerm.toString().replace(regExp.escape, '\\$&'), 13917 matchRegExp = new RegExp(regExp.beginsWith + searchExp, 'i'), 13918 13919 // avoid duplicates when pushing results 13920 addResult = function(array, result) { 13921 var 13922 notResult = ($.inArray(result, results) == -1), 13923 notFuzzyResult = ($.inArray(result, fuzzyResults) == -1) 13924 ; 13925 if(notResult && notFuzzyResult) { 13926 array.push(result); 13927 } 13928 } 13929 ; 13930 source = source || settings.source; 13931 searchFields = (searchFields !== undefined) 13932 ? searchFields 13933 : settings.searchFields 13934 ; 13935 13936 // search fields should be array to loop correctly 13937 if(!$.isArray(searchFields)) { 13938 searchFields = [searchFields]; 13939 } 13940 13941 // exit conditions if no source 13942 if(source === undefined || source === false) { 13943 module.error(error.source); 13944 return []; 13945 } 13946 13947 // iterate through search fields looking for matches 13948 $.each(searchFields, function(index, field) { 13949 $.each(source, function(label, content) { 13950 var 13951 fieldExists = (typeof content[field] == 'string') 13952 ; 13953 if(fieldExists) { 13954 if( content[field].search(matchRegExp) !== -1) { 13955 // content starts with value (first in results) 13956 addResult(results, content); 13957 } 13958 else if(settings.searchFullText && module.fuzzySearch(searchTerm, content[field]) ) { 13959 // content fuzzy matches (last in results) 13960 addResult(fuzzyResults, content); 13961 } 13962 } 13963 }); 13964 }); 13965 return $.merge(results, fuzzyResults); 13966 } 13967 }, 13968 13969 fuzzySearch: function(query, term) { 13970 var 13971 termLength = term.length, 13972 queryLength = query.length 13973 ; 13974 if(typeof query !== 'string') { 13975 return false; 13976 } 13977 query = query.toLowerCase(); 13978 term = term.toLowerCase(); 13979 if(queryLength > termLength) { 13980 return false; 13981 } 13982 if(queryLength === termLength) { 13983 return (query === term); 13984 } 13985 search: for (var characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) { 13986 var 13987 queryCharacter = query.charCodeAt(characterIndex) 13988 ; 13989 while(nextCharacterIndex < termLength) { 13990 if(term.charCodeAt(nextCharacterIndex++) === queryCharacter) { 13991 continue search; 13992 } 13993 } 13994 return false; 13995 } 13996 return true; 13997 }, 13998 13999 parse: { 14000 response: function(response, searchTerm) { 14001 var 14002 searchHTML = module.generateResults(response) 14003 ; 14004 module.verbose('Parsing server response', response); 14005 if(response !== undefined) { 14006 if(searchTerm !== undefined && response[fields.results] !== undefined) { 14007 module.addResults(searchHTML); 14008 module.inject.id(response[fields.results]); 14009 module.write.cache(searchTerm, { 14010 html : searchHTML, 14011 results : response[fields.results] 14012 }); 14013 module.save.results(response[fields.results]); 14014 } 14015 } 14016 } 14017 }, 14018 14019 cancel: { 14020 query: function() { 14021 if( module.can.useAPI() ) { 14022 $module.api('abort'); 14023 } 14024 } 14025 }, 14026 14027 has: { 14028 minimumCharacters: function() { 14029 var 14030 searchTerm = module.get.value(), 14031 numCharacters = searchTerm.length 14032 ; 14033 return (numCharacters >= settings.minCharacters); 14034 }, 14035 results: function() { 14036 if($results.length === 0) { 14037 return false; 14038 } 14039 var 14040 html = $results.html() 14041 ; 14042 return html != ''; 14043 } 14044 }, 14045 14046 clear: { 14047 cache: function(value) { 14048 var 14049 cache = $module.data(metadata.cache) 14050 ; 14051 if(!value) { 14052 module.debug('Clearing cache', value); 14053 $module.removeData(metadata.cache); 14054 } 14055 else if(value && cache && cache[value]) { 14056 module.debug('Removing value from cache', value); 14057 delete cache[value]; 14058 $module.data(metadata.cache, cache); 14059 } 14060 } 14061 }, 14062 14063 read: { 14064 cache: function(name) { 14065 var 14066 cache = $module.data(metadata.cache) 14067 ; 14068 if(settings.cache) { 14069 module.verbose('Checking cache for generated html for query', name); 14070 return (typeof cache == 'object') && (cache[name] !== undefined) 14071 ? cache[name] 14072 : false 14073 ; 14074 } 14075 return false; 14076 } 14077 }, 14078 14079 create: { 14080 id: function(resultIndex, categoryIndex) { 14081 var 14082 resultID = (resultIndex + 1), // not zero indexed 14083 categoryID = (categoryIndex + 1), 14084 firstCharCode, 14085 letterID, 14086 id 14087 ; 14088 if(categoryIndex !== undefined) { 14089 // start char code for "A" 14090 letterID = String.fromCharCode(97 + categoryIndex); 14091 id = letterID + resultID; 14092 module.verbose('Creating category result id', id); 14093 } 14094 else { 14095 id = resultID; 14096 module.verbose('Creating result id', id); 14097 } 14098 return id; 14099 }, 14100 results: function() { 14101 if($results.length === 0) { 14102 $results = $('<div />') 14103 .addClass(className.results) 14104 .appendTo($module) 14105 ; 14106 } 14107 } 14108 }, 14109 14110 inject: { 14111 result: function(result, resultIndex, categoryIndex) { 14112 module.verbose('Injecting result into results'); 14113 var 14114 $selectedResult = (categoryIndex !== undefined) 14115 ? $results 14116 .children().eq(categoryIndex) 14117 .children(selector.result).eq(resultIndex) 14118 : $results 14119 .children(selector.result).eq(resultIndex) 14120 ; 14121 module.verbose('Injecting results metadata', $selectedResult); 14122 $selectedResult 14123 .data(metadata.result, result) 14124 ; 14125 }, 14126 id: function(results) { 14127 module.debug('Injecting unique ids into results'); 14128 var 14129 // since results may be object, we must use counters 14130 categoryIndex = 0, 14131 resultIndex = 0 14132 ; 14133 if(settings.type === 'category') { 14134 // iterate through each category result 14135 $.each(results, function(index, category) { 14136 resultIndex = 0; 14137 $.each(category.results, function(index, value) { 14138 var 14139 result = category.results[index] 14140 ; 14141 if(result.id === undefined) { 14142 result.id = module.create.id(resultIndex, categoryIndex); 14143 } 14144 module.inject.result(result, resultIndex, categoryIndex); 14145 resultIndex++; 14146 }); 14147 categoryIndex++; 14148 }); 14149 } 14150 else { 14151 // top level 14152 $.each(results, function(index, value) { 14153 var 14154 result = results[index] 14155 ; 14156 if(result.id === undefined) { 14157 result.id = module.create.id(resultIndex); 14158 } 14159 module.inject.result(result, resultIndex); 14160 resultIndex++; 14161 }); 14162 } 14163 return results; 14164 } 14165 }, 14166 14167 save: { 14168 results: function(results) { 14169 module.verbose('Saving current search results to metadata', results); 14170 $module.data(metadata.results, results); 14171 } 14172 }, 14173 14174 write: { 14175 cache: function(name, value) { 14176 var 14177 cache = ($module.data(metadata.cache) !== undefined) 14178 ? $module.data(metadata.cache) 14179 : {} 14180 ; 14181 if(settings.cache) { 14182 module.verbose('Writing generated html to cache', name, value); 14183 cache[name] = value; 14184 $module 14185 .data(metadata.cache, cache) 14186 ; 14187 } 14188 } 14189 }, 14190 14191 addResults: function(html) { 14192 if( $.isFunction(settings.onResultsAdd) ) { 14193 if( settings.onResultsAdd.call($results, html) === false ) { 14194 module.debug('onResultsAdd callback cancelled default action'); 14195 return false; 14196 } 14197 } 14198 if(html) { 14199 $results 14200 .html(html) 14201 ; 14202 module.refreshResults(); 14203 if(settings.selectFirstResult) { 14204 module.select.firstResult(); 14205 } 14206 module.showResults(); 14207 } 14208 else { 14209 module.hideResults(function() { 14210 $results.empty(); 14211 }); 14212 } 14213 }, 14214 14215 showResults: function(callback) { 14216 callback = $.isFunction(callback) 14217 ? callback 14218 : function(){} 14219 ; 14220 if(resultsDismissed) { 14221 return; 14222 } 14223 if(!module.is.visible() && module.has.results()) { 14224 if( module.can.transition() ) { 14225 module.debug('Showing results with css animations'); 14226 $results 14227 .transition({ 14228 animation : settings.transition + ' in', 14229 debug : settings.debug, 14230 verbose : settings.verbose, 14231 duration : settings.duration, 14232 onComplete : function() { 14233 callback(); 14234 }, 14235 queue : true 14236 }) 14237 ; 14238 } 14239 else { 14240 module.debug('Showing results with javascript'); 14241 $results 14242 .stop() 14243 .fadeIn(settings.duration, settings.easing) 14244 ; 14245 } 14246 settings.onResultsOpen.call($results); 14247 } 14248 }, 14249 hideResults: function(callback) { 14250 callback = $.isFunction(callback) 14251 ? callback 14252 : function(){} 14253 ; 14254 if( module.is.visible() ) { 14255 if( module.can.transition() ) { 14256 module.debug('Hiding results with css animations'); 14257 $results 14258 .transition({ 14259 animation : settings.transition + ' out', 14260 debug : settings.debug, 14261 verbose : settings.verbose, 14262 duration : settings.duration, 14263 onComplete : function() { 14264 callback(); 14265 }, 14266 queue : true 14267 }) 14268 ; 14269 } 14270 else { 14271 module.debug('Hiding results with javascript'); 14272 $results 14273 .stop() 14274 .fadeOut(settings.duration, settings.easing) 14275 ; 14276 } 14277 settings.onResultsClose.call($results); 14278 } 14279 }, 14280 14281 generateResults: function(response) { 14282 module.debug('Generating html from response', response); 14283 var 14284 template = settings.templates[settings.type], 14285 isProperObject = ($.isPlainObject(response[fields.results]) && !$.isEmptyObject(response[fields.results])), 14286 isProperArray = ($.isArray(response[fields.results]) && response[fields.results].length > 0), 14287 html = '' 14288 ; 14289 if(isProperObject || isProperArray ) { 14290 if(settings.maxResults > 0) { 14291 if(isProperObject) { 14292 if(settings.type == 'standard') { 14293 module.error(error.maxResults); 14294 } 14295 } 14296 else { 14297 response[fields.results] = response[fields.results].slice(0, settings.maxResults); 14298 } 14299 } 14300 if($.isFunction(template)) { 14301 html = template(response, fields); 14302 } 14303 else { 14304 module.error(error.noTemplate, false); 14305 } 14306 } 14307 else if(settings.showNoResults) { 14308 html = module.displayMessage(error.noResults, 'empty'); 14309 } 14310 settings.onResults.call(element, response); 14311 return html; 14312 }, 14313 14314 displayMessage: function(text, type) { 14315 type = type || 'standard'; 14316 module.debug('Displaying message', text, type); 14317 module.addResults( settings.templates.message(text, type) ); 14318 return settings.templates.message(text, type); 14319 }, 14320 14321 setting: function(name, value) { 14322 if( $.isPlainObject(name) ) { 14323 $.extend(true, settings, name); 14324 } 14325 else if(value !== undefined) { 14326 settings[name] = value; 14327 } 14328 else { 14329 return settings[name]; 14330 } 14331 }, 14332 internal: function(name, value) { 14333 if( $.isPlainObject(name) ) { 14334 $.extend(true, module, name); 14335 } 14336 else if(value !== undefined) { 14337 module[name] = value; 14338 } 14339 else { 14340 return module[name]; 14341 } 14342 }, 14343 debug: function() { 14344 if(!settings.silent && settings.debug) { 14345 if(settings.performance) { 14346 module.performance.log(arguments); 14347 } 14348 else { 14349 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 14350 module.debug.apply(console, arguments); 14351 } 14352 } 14353 },
vendor: 4,505 bytes, lines 14354-14437
14354 verbose: function() { 14355 if(!settings.silent && settings.verbose && settings.debug) { 14356 if(settings.performance) { 14357 module.performance.log(arguments); 14358 } 14359 else { 14360 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 14361 module.verbose.apply(console, arguments); 14362 } 14363 } 14364 }, 14365 error: function() { 14366 if(!settings.silent) { 14367 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 14368 module.error.apply(console, arguments); 14369 } 14370 }, 14371 performance: { 14372 log: function(message) { 14373 var 14374 currentTime, 14375 executionTime, 14376 previousTime 14377 ; 14378 if(settings.performance) { 14379 currentTime = new Date().getTime(); 14380 previousTime = time || currentTime; 14381 executionTime = currentTime - previousTime; 14382 time = currentTime; 14383 performance.push({ 14384 'Name' : message[0], 14385 'Arguments' : [].slice.call(message, 1) || '', 14386 'Element' : element, 14387 'Execution Time' : executionTime 14388 }); 14389 } 14390 clearTimeout(module.performance.timer); 14391 module.performance.timer = setTimeout(module.performance.display, 500); 14392 }, 14393 display: function() { 14394 var 14395 title = settings.name + ':', 14396 totalTime = 0 14397 ; 14398 time = false; 14399 clearTimeout(module.performance.timer); 14400 $.each(performance, function(index, data) { 14401 totalTime += data['Execution Time']; 14402 }); 14403 title += ' ' + totalTime + 'ms'; 14404 if(moduleSelector) { 14405 title += ' \'' + moduleSelector + '\''; 14406 } 14407 if($allModules.length > 1) { 14408 title += ' ' + '(' + $allModules.length + ')'; 14409 } 14410 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 14411 console.groupCollapsed(title); 14412 if(console.table) { 14413 console.table(performance); 14414 } 14415 else { 14416 $.each(performance, function(index, data) { 14417 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 14418 }); 14419 } 14420 console.groupEnd(); 14421 } 14422 performance = []; 14423 } 14424 }, 14425 invoke: function(query, passedArguments, context) { 14426 var 14427 object = instance, 14428 maxDepth, 14429 found, 14430 response 14431 ; 14432 passedArguments = passedArguments || queryArguments; 14433 context = element || context; 14434 if(typeof query == 'string' && object !== undefined) { 14435 query = query.split(/[\. ]/); 14436 maxDepth = query.length - 1; 14437 $.each(query, function(depth, value) {
vendor: 11,890 bytes, lines 14438-14738
14438 var camelCaseValue = (depth != maxDepth) 14439 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 14440 : query 14441 ; 14442 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 14443 object = object[camelCaseValue]; 14444 } 14445 else if( object[camelCaseValue] !== undefined ) { 14446 found = object[camelCaseValue]; 14447 return false; 14448 } 14449 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 14450 object = object[value]; 14451 } 14452 else if( object[value] !== undefined ) { 14453 found = object[value]; 14454 return false; 14455 } 14456 else { 14457 return false; 14458 } 14459 }); 14460 } 14461 if( $.isFunction( found ) ) { 14462 response = found.apply(context, passedArguments); 14463 } 14464 else if(found !== undefined) { 14465 response = found; 14466 } 14467 if($.isArray(returnedValue)) { 14468 returnedValue.push(response); 14469 } 14470 else if(returnedValue !== undefined) { 14471 returnedValue = [returnedValue, response]; 14472 } 14473 else if(response !== undefined) { 14474 returnedValue = response; 14475 } 14476 return found; 14477 } 14478 }; 14479 if(methodInvoked) { 14480 if(instance === undefined) { 14481 module.initialize(); 14482 } 14483 module.invoke(query); 14484 } 14485 else { 14486 if(instance !== undefined) { 14487 instance.invoke('destroy'); 14488 } 14489 module.initialize(); 14490 } 14491 14492 }) 14493 ; 14494 14495 return (returnedValue !== undefined) 14496 ? returnedValue 14497 : this 14498 ; 14499 }; 14500 14501 $.fn.search.settings = { 14502 14503 name : 'Search', 14504 namespace : 'search', 14505 14506 silent : false, 14507 debug : false, 14508 verbose : false, 14509 performance : true, 14510 14511 // template to use (specified in settings.templates) 14512 type : 'standard', 14513 14514 // minimum characters required to search 14515 minCharacters : 1, 14516 14517 // whether to select first result after searching automatically 14518 selectFirstResult : false, 14519 14520 // API config 14521 apiSettings : false, 14522 14523 // object to search 14524 source : false, 14525 14526 // Whether search should query current term on focus 14527 searchOnFocus : true, 14528 14529 // fields to search 14530 searchFields : [ 14531 'title', 14532 'description' 14533 ], 14534 14535 // field to display in standard results template 14536 displayField : '', 14537 14538 // whether to include fuzzy results in local search 14539 searchFullText : true, 14540 14541 // whether to add events to prompt automatically 14542 automatic : true, 14543 14544 // delay before hiding menu after blur 14545 hideDelay : 0, 14546 14547 // delay before searching 14548 searchDelay : 200, 14549 14550 // maximum results returned from local 14551 maxResults : 7, 14552 14553 // whether to store lookups in local cache 14554 cache : true, 14555 14556 // whether no results errors should be shown 14557 showNoResults : true, 14558 14559 // transition settings 14560 transition : 'scale', 14561 duration : 200, 14562 easing : 'easeOutExpo', 14563 14564 // callbacks 14565 onSelect : false, 14566 onResultsAdd : false, 14567 14568 onSearchQuery : function(query){}, 14569 onResults : function(response){}, 14570 14571 onResultsOpen : function(){}, 14572 onResultsClose : function(){}, 14573 14574 className: { 14575 animating : 'animating', 14576 active : 'active', 14577 empty : 'empty', 14578 focus : 'focus', 14579 hidden : 'hidden', 14580 loading : 'loading', 14581 results : 'results', 14582 pressed : 'down' 14583 }, 14584 14585 error : { 14586 source : 'Cannot search. No source used, and Semantic API module was not included', 14587 noResults : 'Aucun résultat pour votre recherche', 14588 logging : 'Error in debug logging, exiting.', 14589 noEndpoint : 'No search endpoint was specified', 14590 noTemplate : 'A valid template name was not specified.', 14591 serverError : 'There was an issue querying the server.', 14592 maxResults : 'Results must be an array to use maxResults setting', 14593 method : 'The method you called is not defined.' 14594 }, 14595 14596 metadata: { 14597 cache : 'cache', 14598 results : 'results', 14599 result : 'result' 14600 }, 14601 14602 regExp: { 14603 escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, 14604 beginsWith : '(?:\s|^)' 14605 }, 14606 14607 // maps api response attributes to internal representation 14608 fields: { 14609 categories : 'results', // array of categories (category view) 14610 categoryName : 'name', // name of category (category view) 14611 categoryResults : 'results', // array of results (category view) 14612 description : 'description', // result description 14613 image : 'image', // result image 14614 price : 'price', // result price 14615 results : 'results', // array of results (standard) 14616 title : 'title', // result title 14617 url : 'url', // result url 14618 action : 'action', // "view more" object name 14619 actionText : 'text', // "view more" text 14620 actionURL : 'url' // "view more" url 14621 }, 14622 14623 selector : { 14624 prompt : '.prompt', 14625 searchButton : '.search.button', 14626 results : '.results', 14627 message : '.results > .message', 14628 category : '.category', 14629 result : '.result', 14630 title : '.title, .name' 14631 }, 14632 14633 templates: { 14634 escape: function(string) { 14635 var 14636 badChars = /[&<>"'`]/g, 14637 shouldEscape = /[&<>"'`]/, 14638 escape = { 14639 "&": "&", 14640 "<": "<", 14641 ">": ">", 14642 '"': """, 14643 "'": "'", 14644 "`": "`" 14645 }, 14646 escapedChar = function(chr) { 14647 return escape[chr]; 14648 } 14649 ; 14650 if(shouldEscape.test(string)) { 14651 return string.replace(badChars, escapedChar); 14652 } 14653 return string; 14654 }, 14655 message: function(message, type) { 14656 var 14657 html = '' 14658 ; 14659 if(message !== undefined && type !== undefined) { 14660 html += '' 14661 + '<div class="message ' + type + '">' 14662 ; 14663 // message type 14664 if(type == 'empty') { 14665 html += '' 14666 + '<div class="header">Aucun résultat trouvé</div class="header">' 14667 + '<div class="description">' + message + '</div class="description">' 14668 ; 14669 } 14670 else { 14671 html += ' <div class="description">' + message + '</div>'; 14672 } 14673 html += '</div>'; 14674 } 14675 return html; 14676 }, 14677 category: function(response, fields) { 14678 var 14679 html = '', 14680 escape = $.fn.search.settings.templates.escape 14681 ; 14682 if(response[fields.categoryResults] !== undefined) { 14683 14684 // each category 14685 $.each(response[fields.categoryResults], function(index, category) { 14686 if(category[fields.results] !== undefined && category.results.length > 0) { 14687 14688 html += '<div class="category">'; 14689 14690 if(category[fields.categoryName] !== undefined) { 14691 html += '<div class="name">' + category[fields.categoryName] + '</div>'; 14692 } 14693 14694 // each item inside category 14695 $.each(category.results, function(index, result) { 14696 if(result[fields.url]) { 14697 // html += '<a class="result" href="' + result[fields.url] + '">'; 14698 html += '<a class="result" onclick="loadAPI(\'' + result[fields.url] + '\')" >'; 14699 } 14700 else { 14701 html += '<a class="result">'; 14702 } 14703 if(result[fields.image] !== undefined) { 14704 html += '' 14705 + '<div class="image">' 14706 + ' <img src="' + result[fields.image] + '">' 14707 + '</div>' 14708 ; 14709 } 14710 html += '<div class="content">'; 14711 if(result[fields.price] !== undefined) { 14712 html += '<div class="price">' + result[fields.price] + '</div>'; 14713 } 14714 if(result[fields.title] !== undefined) { 14715 html += '<div class="title">' + result[fields.title] + '</div>'; 14716 } 14717 if(result[fields.description] !== undefined) { 14718 html += '<div class="description">' + result[fields.description] + '</div>'; 14719 } 14720 html += '' 14721 + '</div>' 14722 ; 14723 html += '</a>'; 14724 }); 14725 html += '' 14726 + '</div>' 14727 ; 14728 } 14729 }); 14730 if(response[fields.action]) { 14731 html += '' 14732 + '<a href="' + response[fields.action][fields.actionURL] + '" class="action">' 14733 + response[fields.action][fields.actionText] 14734 + '</a>'; 14735 } 14736 return html; 14737 } 14738 return false;
vendor: 10,417 bytes, lines 14739-14996
14739 }, 14740 standard: function(response, fields) { 14741 var 14742 html = '' 14743 ; 14744 if(response[fields.results] !== undefined) { 14745 14746 // each result 14747 $.each(response[fields.results], function(index, result) { 14748 if(result[fields.url]) { 14749 // html += '<a class="result" href="' + result[fields.url] + '">'; 14750 html += '<a class="result" onclick="loadAPI(\'' + result[fields.url] + '\')" >'; 14751 } 14752 else { 14753 html += '<a class="result">'; 14754 } 14755 if(result[fields.image] !== undefined) { 14756 html += '' 14757 + '<div class="image">' 14758 + ' <img src="' + result[fields.image] + '">' 14759 + '</div>' 14760 ; 14761 } 14762 html += '<div class="content">'; 14763 if(result[fields.price] !== undefined) { 14764 html += '<div class="price">' + result[fields.price] + '</div>'; 14765 } 14766 if(result[fields.title] !== undefined) { 14767 html += '<div class="title">' + result[fields.title] + '</div>'; 14768 } 14769 if(result[fields.description] !== undefined) { 14770 html += '<div class="description">' + result[fields.description] + '</div>'; 14771 } 14772 html += '' 14773 + '</div>' 14774 ; 14775 html += '</a>'; 14776 }); 14777 14778 if(response[fields.action]) { 14779 html += '' 14780 + '<a href="' + response[fields.action][fields.actionURL] + '" class="action">' 14781 + response[fields.action][fields.actionText] 14782 + '</a>'; 14783 } 14784 return html; 14785 } 14786 return false; 14787 } 14788 } 14789 }; 14790 14791})( jQuery, window, document ); 14792 14793/*! 14794 * # Semantic UI 2.2.12 - Shape 14795 * http://github.com/semantic-org/semantic-ui/ 14796 * 14797 * 14798 * Released under the MIT license 14799 * http://opensource.org/licenses/MIT 14800 * 14801 */ 14802 14803;(function ($, window, document, undefined) { 14804 14805 "use strict"; 14806 14807 window = (typeof window != 'undefined' && window.Math == Math) 14808 ? window 14809 : (typeof self != 'undefined' && self.Math == Math) 14810 ? self 14811 : Function('return this')() 14812 ; 14813 14814 $.fn.shape = function(parameters) { 14815 var 14816 $allModules = $(this), 14817 $body = $('body'), 14818 14819 time = new Date().getTime(), 14820 performance = [], 14821 14822 query = arguments[0], 14823 methodInvoked = (typeof query == 'string'), 14824 queryArguments = [].slice.call(arguments, 1), 14825 14826 requestAnimationFrame = window.requestAnimationFrame 14827 || window.mozRequestAnimationFrame 14828 || window.webkitRequestAnimationFrame 14829 || window.msRequestAnimationFrame 14830 || function(callback) { setTimeout(callback, 0); }, 14831 14832 returnedValue 14833 ; 14834 14835 $allModules 14836 .each(function() { 14837 var 14838 moduleSelector = $allModules.selector || '', 14839 settings = ( $.isPlainObject(parameters) ) 14840 ? $.extend(true, {}, $.fn.shape.settings, parameters) 14841 : $.extend({}, $.fn.shape.settings), 14842 14843 // internal aliases 14844 namespace = settings.namespace, 14845 selector = settings.selector, 14846 error = settings.error, 14847 className = settings.className, 14848 14849 // define namespaces for modules 14850 eventNamespace = '.' + namespace, 14851 moduleNamespace = 'module-' + namespace, 14852 14853 // selector cache 14854 $module = $(this), 14855 $sides = $module.find(selector.sides), 14856 $side = $module.find(selector.side), 14857 14858 // private variables 14859 nextIndex = false, 14860 $activeSide, 14861 $nextSide, 14862 14863 // standard module 14864 element = this, 14865 instance = $module.data(moduleNamespace), 14866 module 14867 ; 14868 14869 module = { 14870 14871 initialize: function() { 14872 module.verbose('Initializing module for', element); 14873 module.set.defaultSide(); 14874 module.instantiate(); 14875 }, 14876 14877 instantiate: function() { 14878 module.verbose('Storing instance of module', module); 14879 instance = module; 14880 $module 14881 .data(moduleNamespace, instance) 14882 ; 14883 }, 14884 14885 destroy: function() { 14886 module.verbose('Destroying previous module for', element); 14887 $module 14888 .removeData(moduleNamespace) 14889 .off(eventNamespace) 14890 ; 14891 }, 14892 14893 refresh: function() { 14894 module.verbose('Refreshing selector cache for', element); 14895 $module = $(element); 14896 $sides = $(this).find(selector.shape); 14897 $side = $(this).find(selector.side); 14898 }, 14899 14900 repaint: function() { 14901 module.verbose('Forcing repaint event'); 14902 var 14903 shape = $sides[0] || document.createElement('div'), 14904 fakeAssignment = shape.offsetWidth 14905 ; 14906 }, 14907 14908 animate: function(propertyObject, callback) { 14909 module.verbose('Animating box with properties', propertyObject); 14910 callback = callback || function(event) { 14911 module.verbose('Executing animation callback'); 14912 if(event !== undefined) { 14913 event.stopPropagation(); 14914 } 14915 module.reset(); 14916 module.set.active(); 14917 }; 14918 settings.beforeChange.call($nextSide[0]); 14919 if(module.get.transitionEvent()) { 14920 module.verbose('Starting CSS animation'); 14921 $module 14922 .addClass(className.animating) 14923 ; 14924 $sides 14925 .css(propertyObject) 14926 .one(module.get.transitionEvent(), callback) 14927 ; 14928 module.set.duration(settings.duration); 14929 requestAnimationFrame(function() { 14930 $module 14931 .addClass(className.animating) 14932 ; 14933 $activeSide 14934 .addClass(className.hidden) 14935 ; 14936 }); 14937 } 14938 else { 14939 callback(); 14940 } 14941 }, 14942 14943 queue: function(method) { 14944 module.debug('Queueing animation of', method); 14945 $sides 14946 .one(module.get.transitionEvent(), function() { 14947 module.debug('Executing queued animation'); 14948 setTimeout(function(){ 14949 $module.shape(method); 14950 }, 0); 14951 }) 14952 ; 14953 }, 14954 14955 reset: function() { 14956 module.verbose('Animating states reset'); 14957 $module 14958 .removeClass(className.animating) 14959 .attr('style', '') 14960 .removeAttr('style') 14961 ; 14962 // removeAttr style does not consistently work in safari 14963 $sides 14964 .attr('style', '') 14965 .removeAttr('style') 14966 ; 14967 $side 14968 .attr('style', '') 14969 .removeAttr('style') 14970 .removeClass(className.hidden) 14971 ; 14972 $nextSide 14973 .removeClass(className.animating) 14974 .attr('style', '') 14975 .removeAttr('style') 14976 ; 14977 }, 14978 14979 is: { 14980 complete: function() { 14981 return ($side.filter('.' + className.active)[0] == $nextSide[0]); 14982 }, 14983 animating: function() { 14984 return $module.hasClass(className.animating); 14985 } 14986 }, 14987 14988 set: { 14989 14990 defaultSide: function() { 14991 $activeSide = $module.find('.' + settings.className.active); 14992 $nextSide = ( $activeSide.next(selector.side).length > 0 ) 14993 ? $activeSide.next(selector.side) 14994 : $module.find(selector.side).first() 14995 ; 14996 nextIndex = false;
vendor: 25,200 bytes, lines 14997-15503
14997 module.verbose('Active side set to', $activeSide); 14998 module.verbose('Next side set to', $nextSide); 14999 }, 15000 15001 duration: function(duration) { 15002 duration = duration || settings.duration; 15003 duration = (typeof duration == 'number') 15004 ? duration + 'ms' 15005 : duration 15006 ; 15007 module.verbose('Setting animation duration', duration); 15008 if(settings.duration || settings.duration === 0) { 15009 $sides.add($side) 15010 .css({ 15011 '-webkit-transition-duration': duration, 15012 '-moz-transition-duration': duration, 15013 '-ms-transition-duration': duration, 15014 '-o-transition-duration': duration, 15015 'transition-duration': duration 15016 }) 15017 ; 15018 } 15019 }, 15020 15021 currentStageSize: function() { 15022 var 15023 $activeSide = $module.find('.' + settings.className.active), 15024 width = $activeSide.outerWidth(true), 15025 height = $activeSide.outerHeight(true) 15026 ; 15027 $module 15028 .css({ 15029 width: width, 15030 height: height 15031 }) 15032 ; 15033 }, 15034 15035 stageSize: function() { 15036 var 15037 $clone = $module.clone().addClass(className.loading), 15038 $activeSide = $clone.find('.' + settings.className.active), 15039 $nextSide = (nextIndex) 15040 ? $clone.find(selector.side).eq(nextIndex) 15041 : ( $activeSide.next(selector.side).length > 0 ) 15042 ? $activeSide.next(selector.side) 15043 : $clone.find(selector.side).first(), 15044 newWidth = (settings.width == 'next') 15045 ? $nextSide.outerWidth(true) 15046 : (settings.width == 'initial') 15047 ? $module.width() 15048 : settings.width, 15049 newHeight = (settings.height == 'next') 15050 ? $nextSide.outerHeight(true) 15051 : (settings.height == 'initial') 15052 ? $module.height() 15053 : settings.height 15054 ; 15055 $activeSide.removeClass(className.active); 15056 $nextSide.addClass(className.active); 15057 $clone.insertAfter($module); 15058 $clone.remove(); 15059 if(settings.width != 'auto') { 15060 $module.css('width', newWidth + settings.jitter); 15061 module.verbose('Specifying width during animation', newWidth); 15062 } 15063 if(settings.height != 'auto') { 15064 $module.css('height', newHeight + settings.jitter); 15065 module.verbose('Specifying height during animation', newHeight); 15066 } 15067 }, 15068 15069 nextSide: function(selector) { 15070 nextIndex = selector; 15071 $nextSide = $side.filter(selector); 15072 nextIndex = $side.index($nextSide); 15073 if($nextSide.length === 0) { 15074 module.set.defaultSide(); 15075 module.error(error.side); 15076 } 15077 module.verbose('Next side manually set to', $nextSide); 15078 }, 15079 15080 active: function() { 15081 module.verbose('Setting new side to active', $nextSide); 15082 $side 15083 .removeClass(className.active) 15084 ; 15085 $nextSide 15086 .addClass(className.active) 15087 ; 15088 settings.onChange.call($nextSide[0]); 15089 module.set.defaultSide(); 15090 } 15091 }, 15092 15093 flip: { 15094 15095 up: function() { 15096 if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { 15097 module.debug('Side already visible', $nextSide); 15098 return; 15099 } 15100 if( !module.is.animating()) { 15101 module.debug('Flipping up', $nextSide); 15102 var 15103 transform = module.get.transform.up() 15104 ; 15105 module.set.stageSize(); 15106 module.stage.above(); 15107 module.animate(transform); 15108 } 15109 else { 15110 module.queue('flip up'); 15111 } 15112 }, 15113 15114 down: function() { 15115 if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { 15116 module.debug('Side already visible', $nextSide); 15117 return; 15118 } 15119 if( !module.is.animating()) { 15120 module.debug('Flipping down', $nextSide); 15121 var 15122 transform = module.get.transform.down() 15123 ; 15124 module.set.stageSize(); 15125 module.stage.below(); 15126 module.animate(transform); 15127 } 15128 else { 15129 module.queue('flip down'); 15130 } 15131 }, 15132 15133 left: function() { 15134 if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { 15135 module.debug('Side already visible', $nextSide); 15136 return; 15137 } 15138 if( !module.is.animating()) { 15139 module.debug('Flipping left', $nextSide); 15140 var 15141 transform = module.get.transform.left() 15142 ; 15143 module.set.stageSize(); 15144 module.stage.left(); 15145 module.animate(transform); 15146 } 15147 else { 15148 module.queue('flip left'); 15149 } 15150 }, 15151 15152 right: function() { 15153 if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { 15154 module.debug('Side already visible', $nextSide); 15155 return; 15156 } 15157 if( !module.is.animating()) { 15158 module.debug('Flipping right', $nextSide); 15159 var 15160 transform = module.get.transform.right() 15161 ; 15162 module.set.stageSize(); 15163 module.stage.right(); 15164 module.animate(transform); 15165 } 15166 else { 15167 module.queue('flip right'); 15168 } 15169 }, 15170 15171 over: function() { 15172 if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { 15173 module.debug('Side already visible', $nextSide); 15174 return; 15175 } 15176 if( !module.is.animating()) { 15177 module.debug('Flipping over', $nextSide); 15178 module.set.stageSize(); 15179 module.stage.behind(); 15180 module.animate(module.get.transform.over() ); 15181 } 15182 else { 15183 module.queue('flip over'); 15184 } 15185 }, 15186 15187 back: function() { 15188 if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { 15189 module.debug('Side already visible', $nextSide); 15190 return; 15191 } 15192 if( !module.is.animating()) { 15193 module.debug('Flipping back', $nextSide); 15194 module.set.stageSize(); 15195 module.stage.behind(); 15196 module.animate(module.get.transform.back() ); 15197 } 15198 else { 15199 module.queue('flip back'); 15200 } 15201 } 15202 15203 }, 15204 15205 get: { 15206 15207 transform: { 15208 up: function() { 15209 var 15210 translate = { 15211 y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), 15212 z: -($activeSide.outerHeight(true) / 2) 15213 } 15214 ; 15215 return { 15216 transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(-90deg)' 15217 }; 15218 }, 15219 15220 down: function() { 15221 var 15222 translate = { 15223 y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), 15224 z: -($activeSide.outerHeight(true) / 2) 15225 } 15226 ; 15227 return { 15228 transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(90deg)' 15229 }; 15230 }, 15231 15232 left: function() { 15233 var 15234 translate = { 15235 x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2), 15236 z : -($activeSide.outerWidth(true) / 2) 15237 } 15238 ; 15239 return { 15240 transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(90deg)' 15241 }; 15242 }, 15243 15244 right: function() { 15245 var 15246 translate = { 15247 x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2), 15248 z : -($activeSide.outerWidth(true) / 2) 15249 } 15250 ; 15251 return { 15252 transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(-90deg)' 15253 }; 15254 }, 15255 15256 over: function() { 15257 var 15258 translate = { 15259 x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2) 15260 } 15261 ; 15262 return { 15263 transform: 'translateX(' + translate.x + 'px) rotateY(180deg)' 15264 }; 15265 }, 15266 15267 back: function() { 15268 var 15269 translate = { 15270 x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2) 15271 } 15272 ; 15273 return { 15274 transform: 'translateX(' + translate.x + 'px) rotateY(-180deg)' 15275 }; 15276 } 15277 }, 15278 15279 transitionEvent: function() { 15280 var 15281 element = document.createElement('element'), 15282 transitions = { 15283 'transition' :'transitionend', 15284 'OTransition' :'oTransitionEnd', 15285 'MozTransition' :'transitionend', 15286 'WebkitTransition' :'webkitTransitionEnd' 15287 }, 15288 transition 15289 ; 15290 for(transition in transitions){ 15291 if( element.style[transition] !== undefined ){ 15292 return transitions[transition]; 15293 } 15294 } 15295 }, 15296 15297 nextSide: function() { 15298 return ( $activeSide.next(selector.side).length > 0 ) 15299 ? $activeSide.next(selector.side) 15300 : $module.find(selector.side).first() 15301 ; 15302 } 15303 15304 }, 15305 15306 stage: { 15307 15308 above: function() { 15309 var 15310 box = { 15311 origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), 15312 depth : { 15313 active : ($nextSide.outerHeight(true) / 2), 15314 next : ($activeSide.outerHeight(true) / 2) 15315 } 15316 } 15317 ; 15318 module.verbose('Setting the initial animation position as above', $nextSide, box); 15319 $sides 15320 .css({ 15321 'transform' : 'translateZ(-' + box.depth.active + 'px)' 15322 }) 15323 ; 15324 $activeSide 15325 .css({ 15326 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' 15327 }) 15328 ; 15329 $nextSide 15330 .addClass(className.animating) 15331 .css({ 15332 'top' : box.origin + 'px', 15333 'transform' : 'rotateX(90deg) translateZ(' + box.depth.next + 'px)' 15334 }) 15335 ; 15336 }, 15337 15338 below: function() { 15339 var 15340 box = { 15341 origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), 15342 depth : { 15343 active : ($nextSide.outerHeight(true) / 2), 15344 next : ($activeSide.outerHeight(true) / 2) 15345 } 15346 } 15347 ; 15348 module.verbose('Setting the initial animation position as below', $nextSide, box); 15349 $sides 15350 .css({ 15351 'transform' : 'translateZ(-' + box.depth.active + 'px)' 15352 }) 15353 ; 15354 $activeSide 15355 .css({ 15356 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' 15357 }) 15358 ; 15359 $nextSide 15360 .addClass(className.animating) 15361 .css({ 15362 'top' : box.origin + 'px', 15363 'transform' : 'rotateX(-90deg) translateZ(' + box.depth.next + 'px)' 15364 }) 15365 ; 15366 }, 15367 15368 left: function() { 15369 var 15370 height = { 15371 active : $activeSide.outerWidth(true), 15372 next : $nextSide.outerWidth(true) 15373 }, 15374 box = { 15375 origin : ( ( height.active - height.next ) / 2), 15376 depth : { 15377 active : (height.next / 2), 15378 next : (height.active / 2) 15379 } 15380 } 15381 ; 15382 module.verbose('Setting the initial animation position as left', $nextSide, box); 15383 $sides 15384 .css({ 15385 'transform' : 'translateZ(-' + box.depth.active + 'px)' 15386 }) 15387 ; 15388 $activeSide 15389 .css({ 15390 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' 15391 }) 15392 ; 15393 $nextSide 15394 .addClass(className.animating) 15395 .css({ 15396 'left' : box.origin + 'px', 15397 'transform' : 'rotateY(-90deg) translateZ(' + box.depth.next + 'px)' 15398 }) 15399 ; 15400 }, 15401 15402 right: function() { 15403 var 15404 height = { 15405 active : $activeSide.outerWidth(true), 15406 next : $nextSide.outerWidth(true) 15407 }, 15408 box = { 15409 origin : ( ( height.active - height.next ) / 2), 15410 depth : { 15411 active : (height.next / 2), 15412 next : (height.active / 2) 15413 } 15414 } 15415 ; 15416 module.verbose('Setting the initial animation position as left', $nextSide, box); 15417 $sides 15418 .css({ 15419 'transform' : 'translateZ(-' + box.depth.active + 'px)' 15420 }) 15421 ; 15422 $activeSide 15423 .css({ 15424 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' 15425 }) 15426 ; 15427 $nextSide 15428 .addClass(className.animating) 15429 .css({ 15430 'left' : box.origin + 'px', 15431 'transform' : 'rotateY(90deg) translateZ(' + box.depth.next + 'px)' 15432 }) 15433 ; 15434 }, 15435 15436 behind: function() { 15437 var 15438 height = { 15439 active : $activeSide.outerWidth(true), 15440 next : $nextSide.outerWidth(true) 15441 }, 15442 box = { 15443 origin : ( ( height.active - height.next ) / 2), 15444 depth : { 15445 active : (height.next / 2), 15446 next : (height.active / 2) 15447 } 15448 } 15449 ; 15450 module.verbose('Setting the initial animation position as behind', $nextSide, box); 15451 $activeSide 15452 .css({ 15453 'transform' : 'rotateY(0deg)' 15454 }) 15455 ; 15456 $nextSide 15457 .addClass(className.animating) 15458 .css({ 15459 'left' : box.origin + 'px', 15460 'transform' : 'rotateY(-180deg)' 15461 }) 15462 ; 15463 } 15464 }, 15465 setting: function(name, value) { 15466 module.debug('Changing setting', name, value); 15467 if( $.isPlainObject(name) ) { 15468 $.extend(true, settings, name); 15469 } 15470 else if(value !== undefined) { 15471 if($.isPlainObject(settings[name])) { 15472 $.extend(true, settings[name], value); 15473 } 15474 else { 15475 settings[name] = value; 15476 } 15477 } 15478 else { 15479 return settings[name]; 15480 } 15481 }, 15482 internal: function(name, value) { 15483 if( $.isPlainObject(name) ) { 15484 $.extend(true, module, name); 15485 } 15486 else if(value !== undefined) { 15487 module[name] = value; 15488 } 15489 else { 15490 return module[name]; 15491 } 15492 }, 15493 debug: function() { 15494 if(!settings.silent && settings.debug) { 15495 if(settings.performance) { 15496 module.performance.log(arguments); 15497 } 15498 else { 15499 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 15500 module.debug.apply(console, arguments); 15501 } 15502 } 15503 },
vendor: 4,505 bytes, lines 15504-15587
15504 verbose: function() { 15505 if(!settings.silent && settings.verbose && settings.debug) { 15506 if(settings.performance) { 15507 module.performance.log(arguments); 15508 } 15509 else { 15510 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 15511 module.verbose.apply(console, arguments); 15512 } 15513 } 15514 }, 15515 error: function() { 15516 if(!settings.silent) { 15517 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 15518 module.error.apply(console, arguments); 15519 } 15520 }, 15521 performance: { 15522 log: function(message) { 15523 var 15524 currentTime, 15525 executionTime, 15526 previousTime 15527 ; 15528 if(settings.performance) { 15529 currentTime = new Date().getTime(); 15530 previousTime = time || currentTime; 15531 executionTime = currentTime - previousTime; 15532 time = currentTime; 15533 performance.push({ 15534 'Name' : message[0], 15535 'Arguments' : [].slice.call(message, 1) || '', 15536 'Element' : element, 15537 'Execution Time' : executionTime 15538 }); 15539 } 15540 clearTimeout(module.performance.timer); 15541 module.performance.timer = setTimeout(module.performance.display, 500); 15542 }, 15543 display: function() { 15544 var 15545 title = settings.name + ':', 15546 totalTime = 0 15547 ; 15548 time = false; 15549 clearTimeout(module.performance.timer); 15550 $.each(performance, function(index, data) { 15551 totalTime += data['Execution Time']; 15552 }); 15553 title += ' ' + totalTime + 'ms'; 15554 if(moduleSelector) { 15555 title += ' \'' + moduleSelector + '\''; 15556 } 15557 if($allModules.length > 1) { 15558 title += ' ' + '(' + $allModules.length + ')'; 15559 } 15560 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 15561 console.groupCollapsed(title); 15562 if(console.table) { 15563 console.table(performance); 15564 } 15565 else { 15566 $.each(performance, function(index, data) { 15567 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 15568 }); 15569 } 15570 console.groupEnd(); 15571 } 15572 performance = []; 15573 } 15574 }, 15575 invoke: function(query, passedArguments, context) { 15576 var 15577 object = instance, 15578 maxDepth, 15579 found, 15580 response 15581 ; 15582 passedArguments = passedArguments || queryArguments; 15583 context = element || context; 15584 if(typeof query == 'string' && object !== undefined) { 15585 query = query.split(/[\. ]/); 15586 maxDepth = query.length - 1; 15587 $.each(query, function(depth, value) {
vendor: 9,251 bytes, lines 15588-15855
15588 var camelCaseValue = (depth != maxDepth) 15589 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 15590 : query 15591 ; 15592 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 15593 object = object[camelCaseValue]; 15594 } 15595 else if( object[camelCaseValue] !== undefined ) { 15596 found = object[camelCaseValue]; 15597 return false; 15598 } 15599 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 15600 object = object[value]; 15601 } 15602 else if( object[value] !== undefined ) { 15603 found = object[value]; 15604 return false; 15605 } 15606 else { 15607 return false; 15608 } 15609 }); 15610 } 15611 if ( $.isFunction( found ) ) { 15612 response = found.apply(context, passedArguments); 15613 } 15614 else if(found !== undefined) { 15615 response = found; 15616 } 15617 if($.isArray(returnedValue)) { 15618 returnedValue.push(response); 15619 } 15620 else if(returnedValue !== undefined) { 15621 returnedValue = [returnedValue, response]; 15622 } 15623 else if(response !== undefined) { 15624 returnedValue = response; 15625 } 15626 return found; 15627 } 15628 }; 15629 15630 if(methodInvoked) { 15631 if(instance === undefined) { 15632 module.initialize(); 15633 } 15634 module.invoke(query); 15635 } 15636 else { 15637 if(instance !== undefined) { 15638 instance.invoke('destroy'); 15639 } 15640 module.initialize(); 15641 } 15642 }) 15643 ; 15644 15645 return (returnedValue !== undefined) 15646 ? returnedValue 15647 : this 15648 ; 15649 }; 15650 15651 $.fn.shape.settings = { 15652 15653 // module info 15654 name : 'Shape', 15655 15656 // hide all debug content 15657 silent : false, 15658 15659 // debug content outputted to console 15660 debug : false, 15661 15662 // verbose debug output 15663 verbose : false, 15664 15665 // fudge factor in pixels when swapping from 2d to 3d (can be useful to correct rounding errors) 15666 jitter : 0, 15667 15668 // performance data output 15669 performance: true, 15670 15671 // event namespace 15672 namespace : 'shape', 15673 15674 // width during animation, can be set to 'auto', initial', 'next' or pixel amount 15675 width: 'initial', 15676 15677 // height during animation, can be set to 'auto', 'initial', 'next' or pixel amount 15678 height: 'initial', 15679 15680 // callback occurs on side change 15681 beforeChange : function() {}, 15682 onChange : function() {}, 15683 15684 // allow animation to same side 15685 allowRepeats: false, 15686 15687 // animation duration 15688 duration : false, 15689 15690 // possible errors 15691 error: { 15692 side : 'You tried to switch to a side that does not exist.', 15693 method : 'The method you called is not defined' 15694 }, 15695 15696 // classnames used 15697 className : { 15698 animating : 'animating', 15699 hidden : 'hidden', 15700 loading : 'loading', 15701 active : 'active' 15702 }, 15703 15704 // selectors used 15705 selector : { 15706 sides : '.sides', 15707 side : '.side' 15708 } 15709 15710 }; 15711 15712 15713})( jQuery, window, document ); 15714 15715/*! 15716 * # Semantic UI 2.2.12 - Sidebar 15717 * http://github.com/semantic-org/semantic-ui/ 15718 * 15719 * 15720 * Released under the MIT license 15721 * http://opensource.org/licenses/MIT 15722 * 15723 */ 15724 15725;(function ($, window, document, undefined) { 15726 15727 "use strict"; 15728 15729 window = (typeof window != 'undefined' && window.Math == Math) 15730 ? window 15731 : (typeof self != 'undefined' && self.Math == Math) 15732 ? self 15733 : Function('return this')() 15734 ; 15735 15736 $.fn.sidebar = function(parameters) { 15737 var 15738 $allModules = $(this), 15739 $window = $(window), 15740 $document = $(document), 15741 $html = $('html'), 15742 $head = $('head'), 15743 15744 moduleSelector = $allModules.selector || '', 15745 15746 time = new Date().getTime(), 15747 performance = [], 15748 15749 query = arguments[0], 15750 methodInvoked = (typeof query == 'string'), 15751 queryArguments = [].slice.call(arguments, 1), 15752 15753 requestAnimationFrame = window.requestAnimationFrame 15754 || window.mozRequestAnimationFrame 15755 || window.webkitRequestAnimationFrame 15756 || window.msRequestAnimationFrame 15757 || function(callback) { setTimeout(callback, 0); }, 15758 15759 returnedValue 15760 ; 15761 15762 $allModules 15763 .each(function() { 15764 var 15765 settings = ( $.isPlainObject(parameters) ) 15766 ? $.extend(true, {}, $.fn.sidebar.settings, parameters) 15767 : $.extend({}, $.fn.sidebar.settings), 15768 15769 selector = settings.selector, 15770 className = settings.className, 15771 namespace = settings.namespace, 15772 regExp = settings.regExp, 15773 error = settings.error, 15774 15775 eventNamespace = '.' + namespace, 15776 moduleNamespace = 'module-' + namespace, 15777 15778 $module = $(this), 15779 $context = $(settings.context), 15780 15781 $sidebars = $module.children(selector.sidebar), 15782 $fixed = $context.children(selector.fixed), 15783 $pusher = $context.children(selector.pusher), 15784 $style, 15785 15786 element = this, 15787 instance = $module.data(moduleNamespace), 15788 15789 elementNamespace, 15790 id, 15791 currentScroll, 15792 transitionEvent, 15793 15794 module 15795 ; 15796 15797 module = { 15798 15799 initialize: function() { 15800 module.debug('Initializing sidebar', parameters); 15801 15802 module.create.id(); 15803 15804 transitionEvent = module.get.transitionEvent(); 15805 15806 // avoids locking rendering if initialized in onReady 15807 if(settings.delaySetup) { 15808 requestAnimationFrame(module.setup.layout); 15809 } 15810 else { 15811 module.setup.layout(); 15812 } 15813 15814 requestAnimationFrame(function() { 15815 module.setup.cache(); 15816 }); 15817 15818 module.instantiate(); 15819 }, 15820 15821 instantiate: function() { 15822 module.verbose('Storing instance of module', module); 15823 instance = module; 15824 $module 15825 .data(moduleNamespace, module) 15826 ; 15827 }, 15828 15829 create: { 15830 id: function() { 15831 id = (Math.random().toString(16) + '000000000').substr(2,8); 15832 elementNamespace = '.' + id; 15833 module.verbose('Creating unique id for element', id); 15834 } 15835 }, 15836 15837 destroy: function() { 15838 module.verbose('Destroying previous module for', $module); 15839 $module 15840 .off(eventNamespace) 15841 .removeData(moduleNamespace) 15842 ; 15843 if(module.is.ios()) { 15844 module.remove.ios(); 15845 } 15846 // bound by uuid 15847 $context.off(elementNamespace); 15848 $window.off(elementNamespace); 15849 $document.off(elementNamespace); 15850 }, 15851 15852 event: { 15853 clickaway: function(event) { 15854 var 15855 clickedInPusher = ($pusher.find(event.target).length > 0 || $pusher.is(event.target)),
vendor: 32,424 bytes, lines 15856-16518
15856 clickedContext = ($context.is(event.target)) 15857 ; 15858 if(clickedInPusher) { 15859 module.verbose('User clicked on dimmed page'); 15860 module.hide(); 15861 } 15862 if(clickedContext) { 15863 module.verbose('User clicked on dimmable context (scaled out page)'); 15864 module.hide(); 15865 } 15866 }, 15867 touch: function(event) { 15868 //event.stopPropagation(); 15869 }, 15870 containScroll: function(event) { 15871 if(element.scrollTop <= 0) { 15872 element.scrollTop = 1; 15873 } 15874 if((element.scrollTop + element.offsetHeight) >= element.scrollHeight) { 15875 element.scrollTop = element.scrollHeight - element.offsetHeight - 1; 15876 } 15877 }, 15878 scroll: function(event) { 15879 if( $(event.target).closest(selector.sidebar).length === 0 ) { 15880 event.preventDefault(); 15881 } 15882 } 15883 }, 15884 15885 bind: { 15886 clickaway: function() { 15887 module.verbose('Adding clickaway events to context', $context); 15888 if(settings.closable) { 15889 $context 15890 .on('click' + elementNamespace, module.event.clickaway) 15891 .on('touchend' + elementNamespace, module.event.clickaway) 15892 ; 15893 } 15894 }, 15895 scrollLock: function() { 15896 if(settings.scrollLock) { 15897 module.debug('Disabling page scroll'); 15898 $window 15899 .on('DOMMouseScroll' + elementNamespace, module.event.scroll) 15900 ; 15901 } 15902 module.verbose('Adding events to contain sidebar scroll'); 15903 $document 15904 .on('touchmove' + elementNamespace, module.event.touch) 15905 ; 15906 $module 15907 .on('scroll' + eventNamespace, module.event.containScroll) 15908 ; 15909 } 15910 }, 15911 unbind: { 15912 clickaway: function() { 15913 module.verbose('Removing clickaway events from context', $context); 15914 $context.off(elementNamespace); 15915 }, 15916 scrollLock: function() { 15917 module.verbose('Removing scroll lock from page'); 15918 $document.off(elementNamespace); 15919 $window.off(elementNamespace); 15920 $module.off('scroll' + eventNamespace); 15921 } 15922 }, 15923 15924 add: { 15925 inlineCSS: function() { 15926 var 15927 width = module.cache.width || $module.outerWidth(), 15928 height = module.cache.height || $module.outerHeight(), 15929 isRTL = module.is.rtl(), 15930 direction = module.get.direction(), 15931 distance = { 15932 left : width, 15933 right : -width, 15934 top : height, 15935 bottom : -height 15936 }, 15937 style 15938 ; 15939 15940 if(isRTL){ 15941 module.verbose('RTL detected, flipping widths'); 15942 distance.left = -width; 15943 distance.right = width; 15944 } 15945 15946 style = '<style>'; 15947 15948 if(direction === 'left' || direction === 'right') { 15949 module.debug('Adding CSS rules for animation distance', width); 15950 style += '' 15951 + ' .ui.visible.' + direction + '.sidebar ~ .fixed,' 15952 + ' .ui.visible.' + direction + '.sidebar ~ .pusher {' 15953 + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);' 15954 + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);' 15955 + ' }' 15956 ; 15957 } 15958 else if(direction === 'top' || direction == 'bottom') { 15959 style += '' 15960 + ' .ui.visible.' + direction + '.sidebar ~ .fixed,' 15961 + ' .ui.visible.' + direction + '.sidebar ~ .pusher {' 15962 + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);' 15963 + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);' 15964 + ' }' 15965 ; 15966 } 15967 15968 /* IE is only browser not to create context with transforms */ 15969 /* https://www.w3.org/Bugs/Public/show_bug.cgi?id=16328 */ 15970 if( module.is.ie() ) { 15971 if(direction === 'left' || direction === 'right') { 15972 module.debug('Adding CSS rules for animation distance', width); 15973 style += '' 15974 + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher:after {' 15975 + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);' 15976 + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);' 15977 + ' }' 15978 ; 15979 } 15980 else if(direction === 'top' || direction == 'bottom') { 15981 style += '' 15982 + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher:after {' 15983 + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);' 15984 + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);' 15985 + ' }' 15986 ; 15987 } 15988 /* opposite sides visible forces content overlay */ 15989 style += '' 15990 + ' body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after,' 15991 + ' body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after {' 15992 + ' -webkit-transform: translate3d(0px, 0, 0);' 15993 + ' transform: translate3d(0px, 0, 0);' 15994 + ' }' 15995 ; 15996 } 15997 style += '</style>'; 15998 $style = $(style) 15999 .appendTo($head) 16000 ; 16001 module.debug('Adding sizing css to head', $style); 16002 } 16003 }, 16004 16005 refresh: function() { 16006 module.verbose('Refreshing selector cache'); 16007 $context = $(settings.context); 16008 $sidebars = $context.children(selector.sidebar); 16009 $pusher = $context.children(selector.pusher); 16010 $fixed = $context.children(selector.fixed); 16011 module.clear.cache(); 16012 }, 16013 16014 refreshSidebars: function() { 16015 module.verbose('Refreshing other sidebars'); 16016 $sidebars = $context.children(selector.sidebar); 16017 }, 16018 16019 repaint: function() { 16020 module.verbose('Forcing repaint event'); 16021 element.style.display = 'none'; 16022 var ignored = element.offsetHeight; 16023 element.scrollTop = element.scrollTop; 16024 element.style.display = ''; 16025 }, 16026 16027 setup: { 16028 cache: function() { 16029 module.cache = { 16030 width : $module.outerWidth(), 16031 height : $module.outerHeight(), 16032 rtl : ($module.css('direction') == 'rtl') 16033 }; 16034 }, 16035 layout: function() { 16036 if( $context.children(selector.pusher).length === 0 ) { 16037 module.debug('Adding wrapper element for sidebar'); 16038 module.error(error.pusher); 16039 $pusher = $('<div class="pusher" />'); 16040 $context 16041 .children() 16042 .not(selector.omitted) 16043 .not($sidebars) 16044 .wrapAll($pusher) 16045 ; 16046 module.refresh(); 16047 } 16048 if($module.nextAll(selector.pusher).length === 0 || $module.nextAll(selector.pusher)[0] !== $pusher[0]) { 16049 module.debug('Moved sidebar to correct parent element'); 16050 module.error(error.movedSidebar, element); 16051 $module.detach().prependTo($context); 16052 module.refresh(); 16053 } 16054 module.clear.cache(); 16055 module.set.pushable(); 16056 module.set.direction(); 16057 } 16058 }, 16059 16060 attachEvents: function(selector, event) { 16061 var 16062 $toggle = $(selector) 16063 ; 16064 event = $.isFunction(module[event]) 16065 ? module[event] 16066 : module.toggle 16067 ; 16068 if($toggle.length > 0) { 16069 module.debug('Attaching sidebar events to element', selector, event); 16070 $toggle 16071 .on('click' + eventNamespace, event) 16072 ; 16073 } 16074 else { 16075 module.error(error.notFound, selector); 16076 } 16077 }, 16078 16079 show: function(callback) { 16080 callback = $.isFunction(callback) 16081 ? callback 16082 : function(){} 16083 ; 16084 if(module.is.hidden()) { 16085 module.refreshSidebars(); 16086 if(settings.overlay) { 16087 module.error(error.overlay); 16088 settings.transition = 'overlay'; 16089 } 16090 module.refresh(); 16091 if(module.othersActive()) { 16092 module.debug('Other sidebars currently visible'); 16093 if(settings.exclusive) { 16094 // if not overlay queue animation after hide 16095 if(settings.transition != 'overlay') { 16096 module.hideOthers(module.show); 16097 return; 16098 } 16099 else { 16100 module.hideOthers(); 16101 } 16102 } 16103 else { 16104 settings.transition = 'overlay'; 16105 } 16106 } 16107 module.pushPage(function() { 16108 callback.call(element); 16109 settings.onShow.call(element); 16110 }); 16111 settings.onChange.call(element); 16112 settings.onVisible.call(element); 16113 } 16114 else { 16115 module.debug('Sidebar is already visible'); 16116 } 16117 }, 16118 16119 hide: function(callback) { 16120 callback = $.isFunction(callback) 16121 ? callback 16122 : function(){} 16123 ; 16124 if(module.is.visible() || module.is.animating()) { 16125 module.debug('Hiding sidebar', callback); 16126 module.refreshSidebars(); 16127 module.pullPage(function() { 16128 callback.call(element); 16129 settings.onHidden.call(element); 16130 }); 16131 settings.onChange.call(element); 16132 settings.onHide.call(element); 16133 } 16134 }, 16135 16136 othersAnimating: function() { 16137 return ($sidebars.not($module).filter('.' + className.animating).length > 0); 16138 }, 16139 othersVisible: function() { 16140 return ($sidebars.not($module).filter('.' + className.visible).length > 0); 16141 }, 16142 othersActive: function() { 16143 return(module.othersVisible() || module.othersAnimating()); 16144 }, 16145 16146 hideOthers: function(callback) { 16147 var 16148 $otherSidebars = $sidebars.not($module).filter('.' + className.visible), 16149 sidebarCount = $otherSidebars.length, 16150 callbackCount = 0 16151 ; 16152 callback = callback || function(){}; 16153 $otherSidebars 16154 .sidebar('hide', function() { 16155 callbackCount++; 16156 if(callbackCount == sidebarCount) { 16157 callback(); 16158 } 16159 }) 16160 ; 16161 }, 16162 16163 toggle: function() { 16164 module.verbose('Determining toggled direction'); 16165 if(module.is.hidden()) { 16166 module.show(); 16167 } 16168 else { 16169 module.hide(); 16170 } 16171 }, 16172 16173 pushPage: function(callback) { 16174 var 16175 transition = module.get.transition(), 16176 $transition = (transition === 'overlay' || module.othersActive()) 16177 ? $module 16178 : $pusher, 16179 animate, 16180 dim, 16181 transitionEnd 16182 ; 16183 callback = $.isFunction(callback) 16184 ? callback 16185 : function(){} 16186 ; 16187 if(settings.transition == 'scale down') { 16188 module.scrollToTop(); 16189 } 16190 module.set.transition(transition); 16191 module.repaint(); 16192 animate = function() { 16193 module.bind.clickaway(); 16194 module.add.inlineCSS(); 16195 module.set.animating(); 16196 module.set.visible(); 16197 }; 16198 dim = function() { 16199 module.set.dimmed(); 16200 }; 16201 transitionEnd = function(event) { 16202 if( event.target == $transition[0] ) { 16203 $transition.off(transitionEvent + elementNamespace, transitionEnd); 16204 module.remove.animating(); 16205 module.bind.scrollLock(); 16206 callback.call(element); 16207 } 16208 }; 16209 $transition.off(transitionEvent + elementNamespace); 16210 $transition.on(transitionEvent + elementNamespace, transitionEnd); 16211 requestAnimationFrame(animate); 16212 if(settings.dimPage && !module.othersVisible()) { 16213 requestAnimationFrame(dim); 16214 } 16215 }, 16216 16217 pullPage: function(callback) { 16218 var 16219 transition = module.get.transition(), 16220 $transition = (transition == 'overlay' || module.othersActive()) 16221 ? $module 16222 : $pusher, 16223 animate, 16224 transitionEnd 16225 ; 16226 callback = $.isFunction(callback) 16227 ? callback 16228 : function(){} 16229 ; 16230 module.verbose('Removing context push state', module.get.direction()); 16231 16232 module.unbind.clickaway(); 16233 module.unbind.scrollLock(); 16234 16235 animate = function() { 16236 module.set.transition(transition); 16237 module.set.animating(); 16238 module.remove.visible(); 16239 if(settings.dimPage && !module.othersVisible()) { 16240 $pusher.removeClass(className.dimmed); 16241 } 16242 }; 16243 transitionEnd = function(event) { 16244 if( event.target == $transition[0] ) { 16245 $transition.off(transitionEvent + elementNamespace, transitionEnd); 16246 module.remove.animating(); 16247 module.remove.transition(); 16248 module.remove.inlineCSS(); 16249 if(transition == 'scale down' || (settings.returnScroll && module.is.mobile()) ) { 16250 module.scrollBack(); 16251 } 16252 callback.call(element); 16253 } 16254 }; 16255 $transition.off(transitionEvent + elementNamespace); 16256 $transition.on(transitionEvent + elementNamespace, transitionEnd); 16257 requestAnimationFrame(animate); 16258 }, 16259 16260 scrollToTop: function() { 16261 module.verbose('Scrolling to top of page to avoid animation issues'); 16262 currentScroll = $(window).scrollTop(); 16263 $module.scrollTop(0); 16264 window.scrollTo(0, 0); 16265 }, 16266 16267 scrollBack: function() { 16268 module.verbose('Scrolling back to original page position'); 16269 window.scrollTo(0, currentScroll); 16270 }, 16271 16272 clear: { 16273 cache: function() { 16274 module.verbose('Clearing cached dimensions'); 16275 module.cache = {}; 16276 } 16277 }, 16278 16279 set: { 16280 16281 // ios only (scroll on html not document). This prevent auto-resize canvas/scroll in ios 16282 // (This is no longer necessary in latest iOS) 16283 ios: function() { 16284 $html.addClass(className.ios); 16285 }, 16286 16287 // container 16288 pushed: function() { 16289 $context.addClass(className.pushed); 16290 }, 16291 pushable: function() { 16292 $context.addClass(className.pushable); 16293 }, 16294 16295 // pusher 16296 dimmed: function() { 16297 $pusher.addClass(className.dimmed); 16298 }, 16299 16300 // sidebar 16301 active: function() { 16302 $module.addClass(className.active); 16303 }, 16304 animating: function() { 16305 $module.addClass(className.animating); 16306 }, 16307 transition: function(transition) { 16308 transition = transition || module.get.transition(); 16309 $module.addClass(transition); 16310 }, 16311 direction: function(direction) { 16312 direction = direction || module.get.direction(); 16313 $module.addClass(className[direction]); 16314 }, 16315 visible: function() { 16316 $module.addClass(className.visible); 16317 }, 16318 overlay: function() { 16319 $module.addClass(className.overlay); 16320 } 16321 }, 16322 remove: { 16323 16324 inlineCSS: function() { 16325 module.debug('Removing inline css styles', $style); 16326 if($style && $style.length > 0) { 16327 $style.remove(); 16328 } 16329 }, 16330 16331 // ios scroll on html not document 16332 ios: function() { 16333 $html.removeClass(className.ios); 16334 }, 16335 16336 // context 16337 pushed: function() { 16338 $context.removeClass(className.pushed); 16339 }, 16340 pushable: function() { 16341 $context.removeClass(className.pushable); 16342 }, 16343 16344 // sidebar 16345 active: function() { 16346 $module.removeClass(className.active); 16347 }, 16348 animating: function() { 16349 $module.removeClass(className.animating); 16350 }, 16351 transition: function(transition) { 16352 transition = transition || module.get.transition(); 16353 $module.removeClass(transition); 16354 }, 16355 direction: function(direction) { 16356 direction = direction || module.get.direction(); 16357 $module.removeClass(className[direction]); 16358 }, 16359 visible: function() { 16360 $module.removeClass(className.visible); 16361 }, 16362 overlay: function() { 16363 $module.removeClass(className.overlay); 16364 } 16365 }, 16366 16367 get: { 16368 direction: function() { 16369 if($module.hasClass(className.top)) { 16370 return className.top; 16371 } 16372 else if($module.hasClass(className.right)) { 16373 return className.right; 16374 } 16375 else if($module.hasClass(className.bottom)) { 16376 return className.bottom; 16377 } 16378 return className.left; 16379 }, 16380 transition: function() { 16381 var 16382 direction = module.get.direction(), 16383 transition 16384 ; 16385 transition = ( module.is.mobile() ) 16386 ? (settings.mobileTransition == 'auto') 16387 ? settings.defaultTransition.mobile[direction] 16388 : settings.mobileTransition 16389 : (settings.transition == 'auto') 16390 ? settings.defaultTransition.computer[direction] 16391 : settings.transition 16392 ; 16393 module.verbose('Determined transition', transition); 16394 return transition; 16395 }, 16396 transitionEvent: function() { 16397 var 16398 element = document.createElement('element'), 16399 transitions = { 16400 'transition' :'transitionend', 16401 'OTransition' :'oTransitionEnd', 16402 'MozTransition' :'transitionend', 16403 'WebkitTransition' :'webkitTransitionEnd' 16404 }, 16405 transition 16406 ; 16407 for(transition in transitions){ 16408 if( element.style[transition] !== undefined ){ 16409 return transitions[transition]; 16410 } 16411 } 16412 } 16413 }, 16414 16415 is: { 16416 16417 ie: function() { 16418 var 16419 isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window), 16420 isIE = ('ActiveXObject' in window) 16421 ; 16422 return (isIE11 || isIE); 16423 }, 16424 16425 ios: function() { 16426 var 16427 userAgent = navigator.userAgent, 16428 isIOS = userAgent.match(regExp.ios), 16429 isMobileChrome = userAgent.match(regExp.mobileChrome) 16430 ; 16431 if(isIOS && !isMobileChrome) { 16432 module.verbose('Browser was found to be iOS', userAgent); 16433 return true; 16434 } 16435 else { 16436 return false; 16437 } 16438 }, 16439 mobile: function() { 16440 var 16441 userAgent = navigator.userAgent, 16442 isMobile = userAgent.match(regExp.mobile) 16443 ; 16444 if(isMobile) { 16445 module.verbose('Browser was found to be mobile', userAgent); 16446 return true; 16447 } 16448 else { 16449 module.verbose('Browser is not mobile, using regular transition', userAgent); 16450 return false; 16451 } 16452 }, 16453 hidden: function() { 16454 return !module.is.visible(); 16455 }, 16456 visible: function() { 16457 return $module.hasClass(className.visible); 16458 }, 16459 // alias 16460 open: function() { 16461 return module.is.visible(); 16462 }, 16463 closed: function() { 16464 return module.is.hidden(); 16465 }, 16466 vertical: function() { 16467 return $module.hasClass(className.top); 16468 }, 16469 animating: function() { 16470 return $context.hasClass(className.animating); 16471 }, 16472 rtl: function () { 16473 if(module.cache.rtl === undefined) { 16474 module.cache.rtl = ($module.css('direction') == 'rtl'); 16475 } 16476 return module.cache.rtl; 16477 } 16478 }, 16479 16480 setting: function(name, value) { 16481 module.debug('Changing setting', name, value); 16482 if( $.isPlainObject(name) ) { 16483 $.extend(true, settings, name); 16484 } 16485 else if(value !== undefined) { 16486 if($.isPlainObject(settings[name])) { 16487 $.extend(true, settings[name], value); 16488 } 16489 else { 16490 settings[name] = value; 16491 } 16492 } 16493 else { 16494 return settings[name]; 16495 } 16496 }, 16497 internal: function(name, value) { 16498 if( $.isPlainObject(name) ) { 16499 $.extend(true, module, name); 16500 } 16501 else if(value !== undefined) { 16502 module[name] = value; 16503 } 16504 else { 16505 return module[name]; 16506 } 16507 }, 16508 debug: function() { 16509 if(!settings.silent && settings.debug) { 16510 if(settings.performance) { 16511 module.performance.log(arguments); 16512 } 16513 else { 16514 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 16515 module.debug.apply(console, arguments); 16516 } 16517 } 16518 },
vendor: 4,339 bytes, lines 16519-16599
16519 verbose: function() { 16520 if(!settings.silent && settings.verbose && settings.debug) { 16521 if(settings.performance) { 16522 module.performance.log(arguments); 16523 } 16524 else { 16525 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 16526 module.verbose.apply(console, arguments); 16527 } 16528 } 16529 }, 16530 error: function() { 16531 if(!settings.silent) { 16532 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 16533 module.error.apply(console, arguments); 16534 } 16535 }, 16536 performance: { 16537 log: function(message) { 16538 var 16539 currentTime, 16540 executionTime, 16541 previousTime 16542 ; 16543 if(settings.performance) { 16544 currentTime = new Date().getTime(); 16545 previousTime = time || currentTime; 16546 executionTime = currentTime - previousTime; 16547 time = currentTime; 16548 performance.push({ 16549 'Name' : message[0], 16550 'Arguments' : [].slice.call(message, 1) || '', 16551 'Element' : element, 16552 'Execution Time' : executionTime 16553 }); 16554 } 16555 clearTimeout(module.performance.timer); 16556 module.performance.timer = setTimeout(module.performance.display, 500); 16557 }, 16558 display: function() { 16559 var 16560 title = settings.name + ':', 16561 totalTime = 0 16562 ; 16563 time = false; 16564 clearTimeout(module.performance.timer); 16565 $.each(performance, function(index, data) { 16566 totalTime += data['Execution Time']; 16567 }); 16568 title += ' ' + totalTime + 'ms'; 16569 if(moduleSelector) { 16570 title += ' \'' + moduleSelector + '\''; 16571 } 16572 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 16573 console.groupCollapsed(title); 16574 if(console.table) { 16575 console.table(performance); 16576 } 16577 else { 16578 $.each(performance, function(index, data) { 16579 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 16580 }); 16581 } 16582 console.groupEnd(); 16583 } 16584 performance = []; 16585 } 16586 }, 16587 invoke: function(query, passedArguments, context) { 16588 var 16589 object = instance, 16590 maxDepth, 16591 found, 16592 response 16593 ; 16594 passedArguments = passedArguments || queryArguments; 16595 context = element || context; 16596 if(typeof query == 'string' && object !== undefined) { 16597 query = query.split(/[\. ]/); 16598 maxDepth = query.length - 1; 16599 $.each(query, function(depth, value) {
16600 var camelCaseValue = (depth != maxDepth) 16601 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 16602 : query 16603 ; 16604 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 16605 object = object[camelCaseValue]; 16606 } 16607 else if( object[camelCaseValue] !== undefined ) { 16608 found = object[camelCaseValue]; 16609 return false; 16610 } 16611 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 16612 object = object[value]; 16613 } 16614 else if( object[value] !== undefined ) { 16615 found = object[value]; 16616 return false; 16617 } 16618 else { 16619 module.error(error.method, query); 16620 return false; 16621 } 16622 }); 16623 } 16624 if ( $.isFunction( found ) ) { 16625 response = found.apply(context, passedArguments); 16626 } 16627 else if(found !== undefined) { 16628 response = found; 16629 } 16630 if($.isArray(returnedValue)) { 16631 returnedValue.push(response); 16632 } 16633 else if(returnedValue !== undefined) { 16634 returnedValue = [returnedValue, response]; 16635 } 16636 else if(response !== undefined) { 16637 returnedValue = response; 16638 } 16639 return found; 16640 } 16641 } 16642 ; 16643 16644 if(methodInvoked) { 16645 if(instance === undefined) { 16646 module.initialize(); 16647 } 16648 module.invoke(query); 16649 } 16650 else { 16651 if(instance !== undefined) { 16652 module.invoke('destroy'); 16653 } 16654 module.initialize(); 16655 } 16656 }); 16657 16658 return (returnedValue !== undefined) 16659 ? returnedValue 16660 : this 16661 ; 16662 }; 16663 16664 $.fn.sidebar.settings = { 16665 16666 name : 'Sidebar', 16667 namespace : 'sidebar', 16668 16669 silent : false, 16670 debug : false, 16671 verbose : false, 16672 performance : true, 16673 16674 transition : 'auto', 16675 mobileTransition : 'auto', 16676 16677 defaultTransition : { 16678 computer: { 16679 left : 'uncover', 16680 right : 'uncover', 16681 top : 'overlay', 16682 bottom : 'overlay' 16683 }, 16684 mobile: { 16685 left : 'uncover', 16686 right : 'uncover', 16687 top : 'overlay', 16688 bottom : 'overlay' 16689 } 16690 }, 16691 16692 context : 'body', 16693 exclusive : false, 16694 closable : true, 16695 dimPage : true, 16696 scrollLock : false, 16697 returnScroll : false, 16698 delaySetup : false, 16699 16700 duration : 500, 16701 16702 onChange : function(){}, 16703 onShow : function(){}, 16704 onHide : function(){}, 16705 16706 onHidden : function(){}, 16707 onVisible : function(){}, 16708 16709 className : { 16710 active : 'active', 16711 animating : 'animating', 16712 dimmed : 'dimmed', 16713 ios : 'ios', 16714 pushable : 'pushable', 16715 pushed : 'pushed', 16716 right : 'right', 16717 top : 'top', 16718 left : 'left', 16719 bottom : 'bottom', 16720 visible : 'visible' 16721 }, 16722 16723 selector: { 16724 fixed : '.fixed', 16725 omitted : 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed', 16726 pusher : '.pusher', 16727 sidebar : '.ui.sidebar' 16728 }, 16729 16730 regExp: { 16731 ios : /(iPad|iPhone|iPod)/g, 16732 mobileChrome : /(CriOS)/g, 16733 mobile : /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolf
vendor: 6,456 bytes, lines 16733-16901
16733in|Dolphin|Skyfire|Zune/g 16734 }, 16735 16736 error : { 16737 method : 'The method you called is not defined.', 16738 pusher : 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element', 16739 movedSidebar : 'Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag', 16740 overlay : 'The overlay setting is no longer supported, use animation: overlay', 16741 notFound : 'There were no elements that matched the specified selector' 16742 } 16743 16744 }; 16745 16746 16747})( jQuery, window, document ); 16748 16749/*! 16750 * # Semantic UI 2.2.12 - Sticky 16751 * http://github.com/semantic-org/semantic-ui/ 16752 * 16753 * 16754 * Released under the MIT license 16755 * http://opensource.org/licenses/MIT 16756 * 16757 */ 16758 16759;(function ($, window, document, undefined) { 16760 16761 "use strict"; 16762 16763 window = (typeof window != 'undefined' && window.Math == Math) 16764 ? window 16765 : (typeof self != 'undefined' && self.Math == Math) 16766 ? self 16767 : Function('return this')() 16768 ; 16769 16770 $.fn.sticky = function(parameters) { 16771 var 16772 $allModules = $(this), 16773 moduleSelector = $allModules.selector || '', 16774 16775 time = new Date().getTime(), 16776 performance = [], 16777 16778 query = arguments[0], 16779 methodInvoked = (typeof query == 'string'), 16780 queryArguments = [].slice.call(arguments, 1), 16781 returnedValue 16782 ; 16783 16784 $allModules 16785 .each(function() { 16786 var 16787 settings = ( $.isPlainObject(parameters) ) 16788 ? $.extend(true, {}, $.fn.sticky.settings, parameters) 16789 : $.extend({}, $.fn.sticky.settings), 16790 16791 className = settings.className, 16792 namespace = settings.namespace, 16793 error = settings.error, 16794 16795 eventNamespace = '.' + namespace, 16796 moduleNamespace = 'module-' + namespace, 16797 16798 $module = $(this), 16799 $window = $(window), 16800 $scroll = $(settings.scrollContext), 16801 $container, 16802 $context, 16803 16804 selector = $module.selector || '', 16805 instance = $module.data(moduleNamespace), 16806 16807 requestAnimationFrame = window.requestAnimationFrame 16808 || window.mozRequestAnimationFrame 16809 || window.webkitRequestAnimationFrame 16810 || window.msRequestAnimationFrame 16811 || function(callback) { setTimeout(callback, 0); }, 16812 16813 element = this, 16814 16815 documentObserver, 16816 observer, 16817 module 16818 ; 16819 16820 module = { 16821 16822 initialize: function() { 16823 16824 module.determineContainer(); 16825 module.determineContext(); 16826 module.verbose('Initializing sticky', settings, $container); 16827 16828 module.save.positions(); 16829 module.checkErrors(); 16830 module.bind.events(); 16831 16832 if(settings.observeChanges) { 16833 module.observeChanges(); 16834 } 16835 module.instantiate(); 16836 }, 16837 16838 instantiate: function() { 16839 module.verbose('Storing instance of module', module); 16840 instance = module; 16841 $module 16842 .data(moduleNamespace, module) 16843 ; 16844 }, 16845 16846 destroy: function() { 16847 module.verbose('Destroying previous instance'); 16848 module.reset(); 16849 if(documentObserver) { 16850 documentObserver.disconnect(); 16851 } 16852 if(observer) { 16853 observer.disconnect(); 16854 } 16855 $window 16856 .off('load' + eventNamespace, module.event.load) 16857 .off('resize' + eventNamespace, module.event.resize) 16858 ; 16859 $scroll 16860 .off('scrollchange' + eventNamespace, module.event.scrollchange) 16861 ; 16862 $module.removeData(moduleNamespace); 16863 }, 16864 16865 observeChanges: function() { 16866 if('MutationObserver' in window) { 16867 documentObserver = new MutationObserver(module.event.documentChanged); 16868 observer = new MutationObserver(module.event.changed); 16869 documentObserver.observe(document, { 16870 childList : true, 16871 subtree : true 16872 }); 16873 observer.observe(element, { 16874 childList : true, 16875 subtree : true 16876 }); 16877 observer.observe($context[0], { 16878 childList : true, 16879 subtree : true 16880 }); 16881 module.debug('Setting up mutation observer', observer); 16882 } 16883 }, 16884 16885 determineContainer: function() { 16886 if(settings.container) { 16887 $container = $(settings.container); 16888 } 16889 else { 16890 $container = $module.offsetParent(); 16891 } 16892 }, 16893 16894 determineContext: function() { 16895 if(settings.context) { 16896 $context = $(settings.context); 16897 } 16898 else { 16899 $context = $container; 16900 } 16901 if($context.length === 0) {
vendor: 28,881 bytes, lines 16902-17492
16902 module.error(error.invalidContext, settings.context, $module); 16903 return; 16904 } 16905 }, 16906 16907 checkErrors: function() { 16908 if( module.is.hidden() ) { 16909 module.error(error.visible, $module); 16910 } 16911 if(module.cache.element.height > module.cache.context.height) { 16912 module.reset(); 16913 module.error(error.elementSize, $module); 16914 return; 16915 } 16916 }, 16917 16918 bind: { 16919 events: function() { 16920 $window 16921 .on('load' + eventNamespace, module.event.load) 16922 .on('resize' + eventNamespace, module.event.resize) 16923 ; 16924 // pub/sub pattern 16925 $scroll 16926 .off('scroll' + eventNamespace) 16927 .on('scroll' + eventNamespace, module.event.scroll) 16928 .on('scrollchange' + eventNamespace, module.event.scrollchange) 16929 ; 16930 } 16931 }, 16932 16933 event: { 16934 changed: function(mutations) { 16935 clearTimeout(module.timer); 16936 module.timer = setTimeout(function() { 16937 module.verbose('DOM tree modified, updating sticky menu', mutations); 16938 module.refresh(); 16939 }, 100); 16940 }, 16941 documentChanged: function(mutations) { 16942 [].forEach.call(mutations, function(mutation) { 16943 if(mutation.removedNodes) { 16944 [].forEach.call(mutation.removedNodes, function(node) { 16945 if(node == element || $(node).find(element).length > 0) { 16946 module.debug('Element removed from DOM, tearing down events'); 16947 module.destroy(); 16948 } 16949 }); 16950 } 16951 }); 16952 }, 16953 load: function() { 16954 module.verbose('Page contents finished loading'); 16955 requestAnimationFrame(module.refresh); 16956 }, 16957 resize: function() { 16958 module.verbose('Window resized'); 16959 requestAnimationFrame(module.refresh); 16960 }, 16961 scroll: function() { 16962 requestAnimationFrame(function() { 16963 $scroll.triggerHandler('scrollchange' + eventNamespace, $scroll.scrollTop() ); 16964 }); 16965 }, 16966 scrollchange: function(event, scrollPosition) { 16967 module.stick(scrollPosition); 16968 settings.onScroll.call(element); 16969 } 16970 }, 16971 16972 refresh: function(hardRefresh) { 16973 module.reset(); 16974 if(!settings.context) { 16975 module.determineContext(); 16976 } 16977 if(hardRefresh) { 16978 module.determineContainer(); 16979 } 16980 module.save.positions(); 16981 module.stick(); 16982 settings.onReposition.call(element); 16983 }, 16984 16985 supports: { 16986 sticky: function() { 16987 var 16988 $element = $('<div/>'), 16989 element = $element[0] 16990 ; 16991 $element.addClass(className.supported); 16992 return($element.css('position').match('sticky')); 16993 } 16994 }, 16995 16996 save: { 16997 lastScroll: function(scroll) { 16998 module.lastScroll = scroll; 16999 }, 17000 elementScroll: function(scroll) { 17001 module.elementScroll = scroll; 17002 }, 17003 positions: function() { 17004 var 17005 scrollContext = { 17006 height : $scroll.height() 17007 }, 17008 element = { 17009 margin: { 17010 top : parseInt($module.css('margin-top'), 10), 17011 bottom : parseInt($module.css('margin-bottom'), 10), 17012 }, 17013 offset : $module.offset(), 17014 width : $module.outerWidth(), 17015 height : $module.outerHeight() 17016 }, 17017 context = { 17018 offset : $context.offset(), 17019 height : $context.outerHeight() 17020 }, 17021 container = { 17022 height: $container.outerHeight() 17023 } 17024 ; 17025 if( !module.is.standardScroll() ) { 17026 module.debug('Non-standard scroll. Removing scroll offset from element offset'); 17027 17028 scrollContext.top = $scroll.scrollTop(); 17029 scrollContext.left = $scroll.scrollLeft(); 17030 17031 element.offset.top += scrollContext.top; 17032 context.offset.top += scrollContext.top; 17033 element.offset.left += scrollContext.left; 17034 context.offset.left += scrollContext.left; 17035 } 17036 module.cache = { 17037 fits : ( (element.height + settings.offset) <= scrollContext.height), 17038 sameHeight : (element.height == context.height), 17039 scrollContext : { 17040 height : scrollContext.height 17041 }, 17042 element: { 17043 margin : element.margin, 17044 top : element.offset.top - element.margin.top, 17045 left : element.offset.left, 17046 width : element.width, 17047 height : element.height, 17048 bottom : element.offset.top + element.height 17049 }, 17050 context: { 17051 top : context.offset.top, 17052 height : context.height, 17053 bottom : context.offset.top + context.height 17054 } 17055 }; 17056 module.set.containerSize(); 17057 17058 module.stick(); 17059 module.debug('Caching element positions', module.cache); 17060 } 17061 }, 17062 17063 get: { 17064 direction: function(scroll) { 17065 var 17066 direction = 'down' 17067 ; 17068 scroll = scroll || $scroll.scrollTop(); 17069 if(module.lastScroll !== undefined) { 17070 if(module.lastScroll < scroll) { 17071 direction = 'down'; 17072 } 17073 else if(module.lastScroll > scroll) { 17074 direction = 'up'; 17075 } 17076 } 17077 return direction; 17078 }, 17079 scrollChange: function(scroll) { 17080 scroll = scroll || $scroll.scrollTop(); 17081 return (module.lastScroll) 17082 ? (scroll - module.lastScroll) 17083 : 0 17084 ; 17085 }, 17086 currentElementScroll: function() { 17087 if(module.elementScroll) { 17088 return module.elementScroll; 17089 } 17090 return ( module.is.top() ) 17091 ? Math.abs(parseInt($module.css('top'), 10)) || 0 17092 : Math.abs(parseInt($module.css('bottom'), 10)) || 0 17093 ; 17094 }, 17095 17096 elementScroll: function(scroll) { 17097 scroll = scroll || $scroll.scrollTop(); 17098 var 17099 element = module.cache.element, 17100 scrollContext = module.cache.scrollContext, 17101 delta = module.get.scrollChange(scroll), 17102 maxScroll = (element.height - scrollContext.height + settings.offset), 17103 elementScroll = module.get.currentElementScroll(), 17104 possibleScroll = (elementScroll + delta) 17105 ; 17106 if(module.cache.fits || possibleScroll < 0) { 17107 elementScroll = 0; 17108 } 17109 else if(possibleScroll > maxScroll ) { 17110 elementScroll = maxScroll; 17111 } 17112 else { 17113 elementScroll = possibleScroll; 17114 } 17115 return elementScroll; 17116 } 17117 }, 17118 17119 remove: { 17120 lastScroll: function() { 17121 delete module.lastScroll; 17122 }, 17123 elementScroll: function(scroll) { 17124 delete module.elementScroll; 17125 }, 17126 minimumSize: function() { 17127 $container 17128 .css('min-height', '') 17129 ; 17130 }, 17131 offset: function() { 17132 $module.css('margin-top', ''); 17133 } 17134 }, 17135 17136 set: { 17137 offset: function() { 17138 module.verbose('Setting offset on element', settings.offset); 17139 $module 17140 .css('margin-top', settings.offset) 17141 ; 17142 }, 17143 containerSize: function() { 17144 var 17145 tagName = $container.get(0).tagName 17146 ; 17147 if(tagName === 'HTML' || tagName == 'body') { 17148 // this can trigger for too many reasons 17149 //module.error(error.container, tagName, $module); 17150 module.determineContainer(); 17151 } 17152 else { 17153 if( Math.abs($container.outerHeight() - module.cache.context.height) > settings.jitter) { 17154 module.debug('Context has padding, specifying exact height for container', module.cache.context.height); 17155 $container.css({ 17156 height: module.cache.context.height 17157 }); 17158 } 17159 } 17160 }, 17161 minimumSize: function() { 17162 var 17163 element = module.cache.element 17164 ; 17165 $container 17166 .css('min-height', element.height) 17167 ; 17168 }, 17169 scroll: function(scroll) { 17170 module.debug('Setting scroll on element', scroll); 17171 if(module.elementScroll == scroll) { 17172 return; 17173 } 17174 if( module.is.top() ) { 17175 $module 17176 .css('bottom', '') 17177 .css('top', -scroll) 17178 ; 17179 } 17180 if( module.is.bottom() ) { 17181 $module 17182 .css('top', '') 17183 .css('bottom', scroll) 17184 ; 17185 } 17186 }, 17187 size: function() { 17188 if(module.cache.element.height !== 0 && module.cache.element.width !== 0) { 17189 element.style.setProperty('width', module.cache.element.width + 'px', 'important'); 17190 element.style.setProperty('height', module.cache.element.height + 'px', 'important'); 17191 } 17192 } 17193 }, 17194 17195 is: { 17196 standardScroll: function() { 17197 return ($scroll[0] == window); 17198 }, 17199 top: function() { 17200 return $module.hasClass(className.top); 17201 }, 17202 bottom: function() { 17203 return $module.hasClass(className.bottom); 17204 }, 17205 initialPosition: function() { 17206 return (!module.is.fixed() && !module.is.bound()); 17207 }, 17208 hidden: function() { 17209 return (!$module.is(':visible')); 17210 }, 17211 bound: function() { 17212 return $module.hasClass(className.bound); 17213 }, 17214 fixed: function() { 17215 return $module.hasClass(className.fixed); 17216 } 17217 }, 17218 17219 stick: function(scroll) { 17220 var 17221 cachedPosition = scroll || $scroll.scrollTop(), 17222 cache = module.cache, 17223 fits = cache.fits, 17224 sameHeight = cache.sameHeight, 17225 element = cache.element, 17226 scrollContext = cache.scrollContext, 17227 context = cache.context, 17228 offset = (module.is.bottom() && settings.pushing) 17229 ? settings.bottomOffset 17230 : settings.offset, 17231 scroll = { 17232 top : cachedPosition + offset, 17233 bottom : cachedPosition + offset + scrollContext.height 17234 }, 17235 direction = module.get.direction(scroll.top), 17236 elementScroll = (fits) 17237 ? 0 17238 : module.get.elementScroll(scroll.top), 17239 17240 // shorthand 17241 doesntFit = !fits, 17242 elementVisible = (element.height !== 0) 17243 ; 17244 if(elementVisible && !sameHeight) { 17245 17246 if( module.is.initialPosition() ) { 17247 if(scroll.top >= context.bottom) { 17248 module.debug('Initial element position is bottom of container'); 17249 module.bindBottom(); 17250 } 17251 else if(scroll.top > element.top) { 17252 if( (element.height + scroll.top - elementScroll) >= context.bottom ) { 17253 module.debug('Initial element position is bottom of container'); 17254 module.bindBottom(); 17255 } 17256 else { 17257 module.debug('Initial element position is fixed'); 17258 module.fixTop(); 17259 } 17260 } 17261 17262 } 17263 else if( module.is.fixed() ) { 17264 17265 // currently fixed top 17266 if( module.is.top() ) { 17267 if( scroll.top <= element.top ) { 17268 module.debug('Fixed element reached top of container'); 17269 module.setInitialPosition(); 17270 } 17271 else if( (element.height + scroll.top - elementScroll) >= context.bottom ) { 17272 module.debug('Fixed element reached bottom of container'); 17273 module.bindBottom(); 17274 } 17275 // scroll element if larger than screen 17276 else if(doesntFit) { 17277 module.set.scroll(elementScroll); 17278 module.save.lastScroll(scroll.top); 17279 module.save.elementScroll(elementScroll); 17280 } 17281 } 17282 17283 // currently fixed bottom 17284 else if(module.is.bottom() ) { 17285 17286 // top edge 17287 if( (scroll.bottom - element.height) <= element.top) { 17288 module.debug('Bottom fixed rail has reached top of container'); 17289 module.setInitialPosition(); 17290 } 17291 // bottom edge 17292 else if(scroll.bottom >= context.bottom) { 17293 module.debug('Bottom fixed rail has reached bottom of container'); 17294 module.bindBottom(); 17295 } 17296 // scroll element if larger than screen 17297 else if(doesntFit) { 17298 module.set.scroll(elementScroll); 17299 module.save.lastScroll(scroll.top); 17300 module.save.elementScroll(elementScroll); 17301 } 17302 17303 } 17304 } 17305 else if( module.is.bottom() ) { 17306 if( scroll.top <= element.top ) { 17307 module.debug('Jumped from bottom fixed to top fixed, most likely used home/end button'); 17308 module.setInitialPosition(); 17309 } 17310 else { 17311 if(settings.pushing) { 17312 if(module.is.bound() && scroll.bottom <= context.bottom ) { 17313 module.debug('Fixing bottom attached element to bottom of browser.'); 17314 module.fixBottom(); 17315 } 17316 } 17317 else { 17318 if(module.is.bound() && (scroll.top <= context.bottom - element.height) ) { 17319 module.debug('Fixing bottom attached element to top of browser.'); 17320 module.fixTop(); 17321 } 17322 } 17323 } 17324 } 17325 } 17326 }, 17327 17328 bindTop: function() { 17329 module.debug('Binding element to top of parent container'); 17330 module.remove.offset(); 17331 $module 17332 .css({ 17333 left : '', 17334 top : '', 17335 marginBottom : '' 17336 }) 17337 .removeClass(className.fixed) 17338 .removeClass(className.bottom) 17339 .addClass(className.bound) 17340 .addClass(className.top) 17341 ; 17342 settings.onTop.call(element); 17343 settings.onUnstick.call(element); 17344 }, 17345 bindBottom: function() { 17346 module.debug('Binding element to bottom of parent container'); 17347 module.remove.offset(); 17348 $module 17349 .css({ 17350 left : '', 17351 top : '' 17352 }) 17353 .removeClass(className.fixed) 17354 .removeClass(className.top) 17355 .addClass(className.bound) 17356 .addClass(className.bottom) 17357 ; 17358 settings.onBottom.call(element); 17359 settings.onUnstick.call(element); 17360 }, 17361 17362 setInitialPosition: function() { 17363 module.debug('Returning to initial position'); 17364 module.unfix(); 17365 module.unbind(); 17366 }, 17367 17368 17369 fixTop: function() { 17370 module.debug('Fixing element to top of page'); 17371 if(settings.setSize) { 17372 module.set.size(); 17373 } 17374 module.set.minimumSize(); 17375 module.set.offset(); 17376 $module 17377 .css({ 17378 left : module.cache.element.left, 17379 bottom : '', 17380 marginBottom : '' 17381 }) 17382 .removeClass(className.bound) 17383 .removeClass(className.bottom) 17384 .addClass(className.fixed) 17385 .addClass(className.top) 17386 ; 17387 settings.onStick.call(element); 17388 }, 17389 17390 fixBottom: function() { 17391 module.debug('Sticking element to bottom of page'); 17392 if(settings.setSize) { 17393 module.set.size(); 17394 } 17395 module.set.minimumSize(); 17396 module.set.offset(); 17397 $module 17398 .css({ 17399 left : module.cache.element.left, 17400 bottom : '', 17401 marginBottom : '' 17402 }) 17403 .removeClass(className.bound) 17404 .removeClass(className.top) 17405 .addClass(className.fixed) 17406 .addClass(className.bottom) 17407 ; 17408 settings.onStick.call(element); 17409 }, 17410 17411 unbind: function() { 17412 if( module.is.bound() ) { 17413 module.debug('Removing container bound position on element'); 17414 module.remove.offset(); 17415 $module 17416 .removeClass(className.bound) 17417 .removeClass(className.top) 17418 .removeClass(className.bottom) 17419 ; 17420 } 17421 }, 17422 17423 unfix: function() { 17424 if( module.is.fixed() ) { 17425 module.debug('Removing fixed position on element'); 17426 module.remove.minimumSize(); 17427 module.remove.offset(); 17428 $module 17429 .removeClass(className.fixed) 17430 .removeClass(className.top) 17431 .removeClass(className.bottom) 17432 ; 17433 settings.onUnstick.call(element); 17434 } 17435 }, 17436 17437 reset: function() { 17438 module.debug('Resetting elements position'); 17439 module.unbind(); 17440 module.unfix(); 17441 module.resetCSS(); 17442 module.remove.offset(); 17443 module.remove.lastScroll(); 17444 }, 17445 17446 resetCSS: function() { 17447 $module 17448 .css({ 17449 width : '', 17450 height : '' 17451 }) 17452 ; 17453 $container 17454 .css({ 17455 height: '' 17456 }) 17457 ; 17458 }, 17459 17460 setting: function(name, value) { 17461 if( $.isPlainObject(name) ) { 17462 $.extend(true, settings, name); 17463 } 17464 else if(value !== undefined) { 17465 settings[name] = value; 17466 } 17467 else { 17468 return settings[name]; 17469 } 17470 }, 17471 internal: function(name, value) { 17472 if( $.isPlainObject(name) ) { 17473 $.extend(true, module, name); 17474 } 17475 else if(value !== undefined) { 17476 module[name] = value; 17477 } 17478 else { 17479 return module[name]; 17480 } 17481 }, 17482 debug: function() { 17483 if(!settings.silent && settings.debug) { 17484 if(settings.performance) { 17485 module.performance.log(arguments); 17486 } 17487 else { 17488 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 17489 module.debug.apply(console, arguments); 17490 } 17491 } 17492 },
vendor: 4,337 bytes, lines 17493-17573
17493 verbose: function() { 17494 if(!settings.silent && settings.verbose && settings.debug) { 17495 if(settings.performance) { 17496 module.performance.log(arguments); 17497 } 17498 else { 17499 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 17500 module.verbose.apply(console, arguments); 17501 } 17502 } 17503 }, 17504 error: function() { 17505 if(!settings.silent) { 17506 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 17507 module.error.apply(console, arguments); 17508 } 17509 }, 17510 performance: { 17511 log: function(message) { 17512 var 17513 currentTime, 17514 executionTime, 17515 previousTime 17516 ; 17517 if(settings.performance) { 17518 currentTime = new Date().getTime(); 17519 previousTime = time || currentTime; 17520 executionTime = currentTime - previousTime; 17521 time = currentTime; 17522 performance.push({ 17523 'Name' : message[0], 17524 'Arguments' : [].slice.call(message, 1) || '', 17525 'Element' : element, 17526 'Execution Time' : executionTime 17527 }); 17528 } 17529 clearTimeout(module.performance.timer); 17530 module.performance.timer = setTimeout(module.performance.display, 0); 17531 }, 17532 display: function() { 17533 var 17534 title = settings.name + ':', 17535 totalTime = 0 17536 ; 17537 time = false; 17538 clearTimeout(module.performance.timer); 17539 $.each(performance, function(index, data) { 17540 totalTime += data['Execution Time']; 17541 }); 17542 title += ' ' + totalTime + 'ms'; 17543 if(moduleSelector) { 17544 title += ' \'' + moduleSelector + '\''; 17545 } 17546 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 17547 console.groupCollapsed(title); 17548 if(console.table) { 17549 console.table(performance); 17550 } 17551 else { 17552 $.each(performance, function(index, data) { 17553 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 17554 }); 17555 } 17556 console.groupEnd(); 17557 } 17558 performance = []; 17559 } 17560 }, 17561 invoke: function(query, passedArguments, context) { 17562 var 17563 object = instance, 17564 maxDepth, 17565 found, 17566 response 17567 ; 17568 passedArguments = passedArguments || queryArguments; 17569 context = element || context; 17570 if(typeof query == 'string' && object !== undefined) { 17571 query = query.split(/[\. ]/); 17572 maxDepth = query.length - 1; 17573 $.each(query, function(depth, value) {
vendor: 4,783 bytes, lines 17574-17697
17574 var camelCaseValue = (depth != maxDepth) 17575 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 17576 : query 17577 ; 17578 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 17579 object = object[camelCaseValue]; 17580 } 17581 else if( object[camelCaseValue] !== undefined ) { 17582 found = object[camelCaseValue]; 17583 return false; 17584 } 17585 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 17586 object = object[value]; 17587 } 17588 else if( object[value] !== undefined ) { 17589 found = object[value]; 17590 return false; 17591 } 17592 else { 17593 return false; 17594 } 17595 }); 17596 } 17597 if ( $.isFunction( found ) ) { 17598 response = found.apply(context, passedArguments); 17599 } 17600 else if(found !== undefined) { 17601 response = found; 17602 } 17603 if($.isArray(returnedValue)) { 17604 returnedValue.push(response); 17605 } 17606 else if(returnedValue !== undefined) { 17607 returnedValue = [returnedValue, response]; 17608 } 17609 else if(response !== undefined) { 17610 returnedValue = response; 17611 } 17612 return found; 17613 } 17614 }; 17615 17616 if(methodInvoked) { 17617 if(instance === undefined) { 17618 module.initialize(); 17619 } 17620 module.invoke(query); 17621 } 17622 else { 17623 if(instance !== undefined) { 17624 instance.invoke('destroy'); 17625 } 17626 module.initialize(); 17627 } 17628 }) 17629 ; 17630 17631 return (returnedValue !== undefined) 17632 ? returnedValue 17633 : this 17634 ; 17635 }; 17636 17637 $.fn.sticky.settings = { 17638 17639 name : 'Sticky', 17640 namespace : 'sticky', 17641 17642 silent : false, 17643 debug : false, 17644 verbose : true, 17645 performance : true, 17646 17647 // whether to stick in the opposite direction on scroll up 17648 pushing : false, 17649 17650 context : false, 17651 container : false, 17652 17653 // Context to watch scroll events 17654 scrollContext : window, 17655 17656 // Offset to adjust scroll 17657 offset : 0, 17658 17659 // Offset to adjust scroll when attached to bottom of screen 17660 bottomOffset : 0, 17661 17662 // will only set container height if difference between context and container is larger than this number 17663 jitter : 5, 17664 17665 // set width of sticky element when it is fixed to page (used to make sure 100% width is maintained if no fixed size set) 17666 setSize : true, 17667 17668 // Whether to automatically observe changes with Mutation Observers 17669 observeChanges : false, 17670 17671 // Called when position is recalculated 17672 onReposition : function(){}, 17673 17674 // Called on each scroll 17675 onScroll : function(){}, 17676 17677 // Called when element is stuck to viewport 17678 onStick : function(){}, 17679 17680 // Called when element is unstuck from viewport 17681 onUnstick : function(){}, 17682 17683 // Called when element reaches top of context 17684 onTop : function(){}, 17685 17686 // Called when element reaches bottom of context 17687 onBottom : function(){}, 17688 17689 error : { 17690 container : 'Sticky element must be inside a relative container', 17691 visible : 'Element is hidden, you must call refresh after element becomes visible. Use silent setting to surpress this warning in production.', 17692 method : 'The method you called is not defined.', 17693 invalidContext : 'Context specified does not exist', 17694 elementSize : 'Sticky element is larger than its container, cannot create sticky.' 17695 }, 17696 17697 className : {
vendor: 4,155 bytes, lines 17698-17827
17698 bound : 'bound', 17699 fixed : 'fixed', 17700 supported : 'native', 17701 top : 'top', 17702 bottom : 'bottom' 17703 } 17704 17705 }; 17706 17707})( jQuery, window, document ); 17708 17709/*! 17710 * # Semantic UI 2.2.12 - Tab 17711 * http://github.com/semantic-org/semantic-ui/ 17712 * 17713 * 17714 * Released under the MIT license 17715 * http://opensource.org/licenses/MIT 17716 * 17717 */ 17718 17719;(function ($, window, document, undefined) { 17720 17721 "use strict"; 17722 17723 window = (typeof window != 'undefined' && window.Math == Math) 17724 ? window 17725 : (typeof self != 'undefined' && self.Math == Math) 17726 ? self 17727 : Function('return this')() 17728 ; 17729 17730 $.fn.tab = function(parameters) { 17731 17732 var 17733 // use window context if none specified 17734 $allModules = $.isFunction(this) 17735 ? $(window) 17736 : $(this), 17737 17738 moduleSelector = $allModules.selector || '', 17739 time = new Date().getTime(), 17740 performance = [], 17741 17742 query = arguments[0], 17743 methodInvoked = (typeof query == 'string'), 17744 queryArguments = [].slice.call(arguments, 1), 17745 17746 initializedHistory = false, 17747 returnedValue 17748 ; 17749 17750 $allModules 17751 .each(function() { 17752 var 17753 17754 settings = ( $.isPlainObject(parameters) ) 17755 ? $.extend(true, {}, $.fn.tab.settings, parameters) 17756 : $.extend({}, $.fn.tab.settings), 17757 17758 className = settings.className, 17759 metadata = settings.metadata, 17760 selector = settings.selector, 17761 error = settings.error, 17762 17763 eventNamespace = '.' + settings.namespace, 17764 moduleNamespace = 'module-' + settings.namespace, 17765 17766 $module = $(this), 17767 $context, 17768 $tabs, 17769 17770 cache = {}, 17771 firstLoad = true, 17772 recursionDepth = 0, 17773 element = this, 17774 instance = $module.data(moduleNamespace), 17775 17776 activeTabPath, 17777 parameterArray, 17778 module, 17779 17780 historyEvent 17781 17782 ; 17783 17784 module = { 17785 17786 initialize: function() { 17787 module.debug('Initializing tab menu item', $module); 17788 module.fix.callbacks(); 17789 module.determineTabs(); 17790 17791 module.debug('Determining tabs', settings.context, $tabs); 17792 // set up automatic routing 17793 if(settings.auto) { 17794 module.set.auto(); 17795 } 17796 module.bind.events(); 17797 17798 if(settings.history && !initializedHistory) { 17799 module.initializeHistory(); 17800 initializedHistory = true; 17801 } 17802 17803 module.instantiate(); 17804 }, 17805 17806 instantiate: function () { 17807 module.verbose('Storing instance of module', module); 17808 instance = module; 17809 $module 17810 .data(moduleNamespace, module) 17811 ; 17812 }, 17813 17814 destroy: function() { 17815 module.debug('Destroying tabs', $module); 17816 $module 17817 .removeData(moduleNamespace) 17818 .off(eventNamespace) 17819 ; 17820 }, 17821 17822 bind: { 17823 events: function() { 17824 // if using $.tab don't add events 17825 if( !$.isWindow( element ) ) { 17826 module.debug('Attaching tab activation events to element', $module); 17827 $module
vendor: 31,968 bytes, lines 17828-18441
17828 .on('click' + eventNamespace, module.event.click) 17829 ; 17830 } 17831 } 17832 }, 17833 17834 determineTabs: function() { 17835 var 17836 $reference 17837 ; 17838 17839 // determine tab context 17840 if(settings.context === 'parent') { 17841 if($module.closest(selector.ui).length > 0) { 17842 $reference = $module.closest(selector.ui); 17843 module.verbose('Using closest UI element as parent', $reference); 17844 } 17845 else { 17846 $reference = $module; 17847 } 17848 $context = $reference.parent(); 17849 module.verbose('Determined parent element for creating context', $context); 17850 } 17851 else if(settings.context) { 17852 $context = $(settings.context); 17853 module.verbose('Using selector for tab context', settings.context, $context); 17854 } 17855 else { 17856 $context = $('body'); 17857 } 17858 // find tabs 17859 if(settings.childrenOnly) { 17860 $tabs = $context.children(selector.tabs); 17861 module.debug('Searching tab context children for tabs', $context, $tabs); 17862 } 17863 else { 17864 $tabs = $context.find(selector.tabs); 17865 module.debug('Searching tab context for tabs', $context, $tabs); 17866 } 17867 }, 17868 17869 fix: { 17870 callbacks: function() { 17871 if( $.isPlainObject(parameters) && (parameters.onTabLoad || parameters.onTabInit) ) { 17872 if(parameters.onTabLoad) { 17873 parameters.onLoad = parameters.onTabLoad; 17874 delete parameters.onTabLoad; 17875 module.error(error.legacyLoad, parameters.onLoad); 17876 } 17877 if(parameters.onTabInit) { 17878 parameters.onFirstLoad = parameters.onTabInit; 17879 delete parameters.onTabInit; 17880 module.error(error.legacyInit, parameters.onFirstLoad); 17881 } 17882 settings = $.extend(true, {}, $.fn.tab.settings, parameters); 17883 } 17884 } 17885 }, 17886 17887 initializeHistory: function() { 17888 module.debug('Initializing page state'); 17889 if( $.address === undefined ) { 17890 module.error(error.state); 17891 return false; 17892 } 17893 else { 17894 if(settings.historyType == 'state') { 17895 module.debug('Using HTML5 to manage state'); 17896 if(settings.path !== false) { 17897 $.address 17898 .history(true) 17899 .state(settings.path) 17900 ; 17901 } 17902 else { 17903 module.error(error.path); 17904 return false; 17905 } 17906 } 17907 $.address 17908 .bind('change', module.event.history.change) 17909 ; 17910 } 17911 }, 17912 17913 event: { 17914 click: function(event) { 17915 var 17916 tabPath = $(this).data(metadata.tab) 17917 ; 17918 if(tabPath !== undefined) { 17919 if(settings.history) { 17920 module.verbose('Updating page state', event); 17921 $.address.value(tabPath); 17922 } 17923 else { 17924 module.verbose('Changing tab', event); 17925 module.changeTab(tabPath); 17926 } 17927 event.preventDefault(); 17928 } 17929 else { 17930 module.debug('No tab specified'); 17931 } 17932 }, 17933 history: { 17934 change: function(event) { 17935 var 17936 tabPath = event.pathNames.join('/') || module.get.initialPath(), 17937 pageTitle = settings.templates.determineTitle(tabPath) || false 17938 ; 17939 module.performance.display(); 17940 module.debug('History change event', tabPath, event); 17941 historyEvent = event; 17942 if(tabPath !== undefined) { 17943 module.changeTab(tabPath); 17944 } 17945 if(pageTitle) { 17946 $.address.title(pageTitle); 17947 } 17948 } 17949 } 17950 }, 17951 17952 refresh: function() { 17953 if(activeTabPath) { 17954 module.debug('Refreshing tab', activeTabPath); 17955 module.changeTab(activeTabPath); 17956 } 17957 }, 17958 17959 cache: { 17960 17961 read: function(cacheKey) { 17962 return (cacheKey !== undefined) 17963 ? cache[cacheKey] 17964 : false 17965 ; 17966 }, 17967 add: function(cacheKey, content) { 17968 cacheKey = cacheKey || activeTabPath; 17969 module.debug('Adding cached content for', cacheKey); 17970 cache[cacheKey] = content; 17971 }, 17972 remove: function(cacheKey) { 17973 cacheKey = cacheKey || activeTabPath; 17974 module.debug('Removing cached content for', cacheKey); 17975 delete cache[cacheKey]; 17976 } 17977 }, 17978 17979 set: { 17980 auto: function() { 17981 var 17982 url = (typeof settings.path == 'string') 17983 ? settings.path.replace(/\/$/, '') + '/{$tab}' 17984 : '/{$tab}' 17985 ; 17986 module.verbose('Setting up automatic tab retrieval from server', url); 17987 if($.isPlainObject(settings.apiSettings)) { 17988 settings.apiSettings.url = url; 17989 } 17990 else { 17991 settings.apiSettings = { 17992 url: url 17993 }; 17994 } 17995 }, 17996 loading: function(tabPath) { 17997 var 17998 $tab = module.get.tabElement(tabPath), 17999 isLoading = $tab.hasClass(className.loading) 18000 ; 18001 if(!isLoading) { 18002 module.verbose('Setting loading state for', $tab); 18003 $tab 18004 .addClass(className.loading) 18005 .siblings($tabs) 18006 .removeClass(className.active + ' ' + className.loading) 18007 ; 18008 if($tab.length > 0) { 18009 settings.onRequest.call($tab[0], tabPath); 18010 } 18011 } 18012 }, 18013 state: function(state) { 18014 $.address.value(state); 18015 } 18016 }, 18017 18018 changeTab: function(tabPath) { 18019 var 18020 pushStateAvailable = (window.history && window.history.pushState), 18021 shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), 18022 remoteContent = (settings.auto || $.isPlainObject(settings.apiSettings) ), 18023 // only add default path if not remote content 18024 pathArray = (remoteContent && !shouldIgnoreLoad) 18025 ? module.utilities.pathToArray(tabPath) 18026 : module.get.defaultPathArray(tabPath) 18027 ; 18028 tabPath = module.utilities.arrayToPath(pathArray); 18029 $.each(pathArray, function(index, tab) { 18030 var 18031 currentPathArray = pathArray.slice(0, index + 1), 18032 currentPath = module.utilities.arrayToPath(currentPathArray), 18033 18034 isTab = module.is.tab(currentPath), 18035 isLastIndex = (index + 1 == pathArray.length), 18036 18037 $tab = module.get.tabElement(currentPath), 18038 $anchor, 18039 nextPathArray, 18040 nextPath, 18041 isLastTab 18042 ; 18043 module.verbose('Looking for tab', tab); 18044 if(isTab) { 18045 module.verbose('Tab was found', tab); 18046 // scope up 18047 activeTabPath = currentPath; 18048 parameterArray = module.utilities.filterArray(pathArray, currentPathArray); 18049 18050 if(isLastIndex) { 18051 isLastTab = true; 18052 } 18053 else { 18054 nextPathArray = pathArray.slice(0, index + 2); 18055 nextPath = module.utilities.arrayToPath(nextPathArray); 18056 isLastTab = ( !module.is.tab(nextPath) ); 18057 if(isLastTab) { 18058 module.verbose('Tab parameters found', nextPathArray); 18059 } 18060 } 18061 if(isLastTab && remoteContent) { 18062 if(!shouldIgnoreLoad) { 18063 module.activate.navigation(currentPath); 18064 module.fetch.content(currentPath, tabPath); 18065 } 18066 else { 18067 module.debug('Ignoring remote content on first tab load', currentPath); 18068 firstLoad = false; 18069 module.cache.add(tabPath, $tab.html()); 18070 module.activate.all(currentPath); 18071 settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent); 18072 settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent); 18073 } 18074 return false; 18075 } 18076 else { 18077 module.debug('Opened local tab', currentPath); 18078 module.activate.all(currentPath); 18079 if( !module.cache.read(currentPath) ) { 18080 module.cache.add(currentPath, true); 18081 module.debug('First time tab loaded calling tab init'); 18082 settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent); 18083 } 18084 settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent); 18085 } 18086 18087 } 18088 else if(tabPath.search('/') == -1 && tabPath !== '') { 18089 // look for in page anchor 18090 $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]'); 18091 currentPath = $anchor.closest('[data-tab]').data(metadata.tab); 18092 $tab = module.get.tabElement(currentPath); 18093 // if anchor exists use parent tab 18094 if($anchor && $anchor.length > 0 && currentPath) { 18095 module.debug('Anchor link used, opening parent tab', $tab, $anchor); 18096 if( !$tab.hasClass(className.active) ) { 18097 setTimeout(function() { 18098 module.scrollTo($anchor); 18099 }, 0); 18100 } 18101 module.activate.all(currentPath); 18102 if( !module.cache.read(currentPath) ) { 18103 module.cache.add(currentPath, true); 18104 module.debug('First time tab loaded calling tab init'); 18105 settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent); 18106 } 18107 settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent); 18108 return false; 18109 } 18110 } 18111 else { 18112 module.error(error.missingTab, $module, $context, currentPath); 18113 return false; 18114 } 18115 }); 18116 }, 18117 18118 scrollTo: function($element) { 18119 var 18120 scrollOffset = ($element && $element.length > 0) 18121 ? $element.offset().top 18122 : false 18123 ; 18124 if(scrollOffset !== false) { 18125 module.debug('Forcing scroll to an in-page link in a hidden tab', scrollOffset, $element); 18126 $(document).scrollTop(scrollOffset); 18127 } 18128 }, 18129 18130 update: { 18131 content: function(tabPath, html, evaluateScripts) { 18132 var 18133 $tab = module.get.tabElement(tabPath), 18134 tab = $tab[0] 18135 ; 18136 evaluateScripts = (evaluateScripts !== undefined) 18137 ? evaluateScripts 18138 : settings.evaluateScripts 18139 ; 18140 if(typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && typeof html !== 'string') { 18141 $tab 18142 .empty() 18143 .append($(html).clone(true)) 18144 ; 18145 } 18146 else { 18147 if(evaluateScripts) { 18148 module.debug('Updating HTML and evaluating inline scripts', tabPath, html); 18149 $tab.html(html); 18150 } 18151 else { 18152 module.debug('Updating HTML', tabPath, html); 18153 tab.innerHTML = html; 18154 } 18155 } 18156 } 18157 }, 18158 18159 fetch: { 18160 18161 content: function(tabPath, fullTabPath) { 18162 var 18163 $tab = module.get.tabElement(tabPath), 18164 apiSettings = { 18165 dataType : 'html', 18166 encodeParameters : false, 18167 on : 'now', 18168 cache : settings.alwaysRefresh, 18169 headers : { 18170 'X-Remote': true 18171 }, 18172 onSuccess : function(response) { 18173 if(settings.cacheType == 'response') { 18174 module.cache.add(fullTabPath, response); 18175 } 18176 module.update.content(tabPath, response); 18177 if(tabPath == activeTabPath) { 18178 module.debug('Content loaded', tabPath); 18179 module.activate.tab(tabPath); 18180 } 18181 else { 18182 module.debug('Content loaded in background', tabPath); 18183 } 18184 settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent); 18185 settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent); 18186 18187 if(settings.loadOnce) { 18188 module.cache.add(fullTabPath, true); 18189 } 18190 else if(typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && $tab.children().length > 0) { 18191 setTimeout(function() { 18192 var 18193 $clone = $tab.children().clone(true) 18194 ; 18195 $clone = $clone.not('script'); 18196 module.cache.add(fullTabPath, $clone); 18197 }, 0); 18198 } 18199 else { 18200 module.cache.add(fullTabPath, $tab.html()); 18201 } 18202 }, 18203 urlData: { 18204 tab: fullTabPath 18205 } 18206 }, 18207 request = $tab.api('get request') || false, 18208 existingRequest = ( request && request.state() === 'pending' ), 18209 requestSettings, 18210 cachedContent 18211 ; 18212 18213 fullTabPath = fullTabPath || tabPath; 18214 cachedContent = module.cache.read(fullTabPath); 18215 18216 18217 if(settings.cache && cachedContent) { 18218 module.activate.tab(tabPath); 18219 module.debug('Adding cached content', fullTabPath); 18220 if(!settings.loadOnce) { 18221 if(settings.evaluateScripts == 'once') { 18222 module.update.content(tabPath, cachedContent, false); 18223 } 18224 else { 18225 module.update.content(tabPath, cachedContent); 18226 } 18227 } 18228 settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent); 18229 } 18230 else if(existingRequest) { 18231 module.set.loading(tabPath); 18232 module.debug('Content is already loading', fullTabPath); 18233 } 18234 else if($.api !== undefined) { 18235 requestSettings = $.extend(true, {}, settings.apiSettings, apiSettings); 18236 module.debug('Retrieving remote content', fullTabPath, requestSettings); 18237 module.set.loading(tabPath); 18238 $tab.api(requestSettings); 18239 } 18240 else { 18241 module.error(error.api); 18242 } 18243 } 18244 }, 18245 18246 activate: { 18247 all: function(tabPath) { 18248 module.activate.tab(tabPath); 18249 module.activate.navigation(tabPath); 18250 }, 18251 tab: function(tabPath) { 18252 var 18253 $tab = module.get.tabElement(tabPath), 18254 $deactiveTabs = (settings.deactivate == 'siblings') 18255 ? $tab.siblings($tabs) 18256 : $tabs.not($tab), 18257 isActive = $tab.hasClass(className.active) 18258 ; 18259 module.verbose('Showing tab content for', $tab); 18260 if(!isActive) { 18261 $tab 18262 .addClass(className.active) 18263 ; 18264 $deactiveTabs 18265 .removeClass(className.active + ' ' + className.loading) 18266 ; 18267 if($tab.length > 0) { 18268 settings.onVisible.call($tab[0], tabPath); 18269 } 18270 } 18271 }, 18272 navigation: function(tabPath) { 18273 var 18274 $navigation = module.get.navElement(tabPath), 18275 $deactiveNavigation = (settings.deactivate == 'siblings') 18276 ? $navigation.siblings($allModules) 18277 : $allModules.not($navigation), 18278 isActive = $navigation.hasClass(className.active) 18279 ; 18280 module.verbose('Activating tab navigation for', $navigation, tabPath); 18281 if(!isActive) { 18282 $navigation 18283 .addClass(className.active) 18284 ; 18285 $deactiveNavigation 18286 .removeClass(className.active + ' ' + className.loading) 18287 ; 18288 } 18289 } 18290 }, 18291 18292 deactivate: { 18293 all: function() { 18294 module.deactivate.navigation(); 18295 module.deactivate.tabs(); 18296 }, 18297 navigation: function() { 18298 $allModules 18299 .removeClass(className.active) 18300 ; 18301 }, 18302 tabs: function() { 18303 $tabs 18304 .removeClass(className.active + ' ' + className.loading) 18305 ; 18306 } 18307 }, 18308 18309 is: { 18310 tab: function(tabName) { 18311 return (tabName !== undefined) 18312 ? ( module.get.tabElement(tabName).length > 0 ) 18313 : false 18314 ; 18315 } 18316 }, 18317 18318 get: { 18319 initialPath: function() { 18320 return $allModules.eq(0).data(metadata.tab) || $tabs.eq(0).data(metadata.tab); 18321 }, 18322 path: function() { 18323 return $.address.value(); 18324 }, 18325 // adds default tabs to tab path 18326 defaultPathArray: function(tabPath) { 18327 return module.utilities.pathToArray( module.get.defaultPath(tabPath) ); 18328 }, 18329 defaultPath: function(tabPath) { 18330 var 18331 $defaultNav = $allModules.filter('[data-' + metadata.tab + '^="' + tabPath + '/"]').eq(0), 18332 defaultTab = $defaultNav.data(metadata.tab) || false 18333 ; 18334 if( defaultTab ) { 18335 module.debug('Found default tab', defaultTab); 18336 if(recursionDepth < settings.maxDepth) { 18337 recursionDepth++; 18338 return module.get.defaultPath(defaultTab); 18339 } 18340 module.error(error.recursion); 18341 } 18342 else { 18343 module.debug('No default tabs found for', tabPath, $tabs); 18344 } 18345 recursionDepth = 0; 18346 return tabPath; 18347 }, 18348 navElement: function(tabPath) { 18349 tabPath = tabPath || activeTabPath; 18350 return $allModules.filter('[data-' + metadata.tab + '="' + tabPath + '"]'); 18351 }, 18352 tabElement: function(tabPath) { 18353 var 18354 $fullPathTab, 18355 $simplePathTab, 18356 tabPathArray, 18357 lastTab 18358 ; 18359 tabPath = tabPath || activeTabPath; 18360 tabPathArray = module.utilities.pathToArray(tabPath); 18361 lastTab = module.utilities.last(tabPathArray); 18362 $fullPathTab = $tabs.filter('[data-' + metadata.tab + '="' + tabPath + '"]'); 18363 $simplePathTab = $tabs.filter('[data-' + metadata.tab + '="' + lastTab + '"]'); 18364 return ($fullPathTab.length > 0) 18365 ? $fullPathTab 18366 : $simplePathTab 18367 ; 18368 }, 18369 tab: function() { 18370 return activeTabPath; 18371 } 18372 }, 18373 18374 utilities: { 18375 filterArray: function(keepArray, removeArray) { 18376 return $.grep(keepArray, function(keepValue) { 18377 return ( $.inArray(keepValue, removeArray) == -1); 18378 }); 18379 }, 18380 last: function(array) { 18381 return $.isArray(array) 18382 ? array[ array.length - 1] 18383 : false 18384 ; 18385 }, 18386 pathToArray: function(pathName) { 18387 if(pathName === undefined) { 18388 pathName = activeTabPath; 18389 } 18390 return typeof pathName == 'string' 18391 ? pathName.split('/') 18392 : [pathName] 18393 ; 18394 }, 18395 arrayToPath: function(pathArray) { 18396 return $.isArray(pathArray) 18397 ? pathArray.join('/') 18398 : false 18399 ; 18400 } 18401 }, 18402 18403 setting: function(name, value) { 18404 module.debug('Changing setting', name, value); 18405 if( $.isPlainObject(name) ) { 18406 $.extend(true, settings, name); 18407 } 18408 else if(value !== undefined) { 18409 if($.isPlainObject(settings[name])) { 18410 $.extend(true, settings[name], value); 18411 } 18412 else { 18413 settings[name] = value; 18414 } 18415 } 18416 else { 18417 return settings[name]; 18418 } 18419 }, 18420 internal: function(name, value) { 18421 if( $.isPlainObject(name) ) { 18422 $.extend(true, module, name); 18423 } 18424 else if(value !== undefined) { 18425 module[name] = value; 18426 } 18427 else { 18428 return module[name]; 18429 } 18430 }, 18431 debug: function() { 18432 if(!settings.silent && settings.debug) { 18433 if(settings.performance) { 18434 module.performance.log(arguments); 18435 } 18436 else { 18437 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 18438 module.debug.apply(console, arguments); 18439 } 18440 } 18441 },
vendor: 4,339 bytes, lines 18442-18522
18442 verbose: function() { 18443 if(!settings.silent && settings.verbose && settings.debug) { 18444 if(settings.performance) { 18445 module.performance.log(arguments); 18446 } 18447 else { 18448 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 18449 module.verbose.apply(console, arguments); 18450 } 18451 } 18452 }, 18453 error: function() { 18454 if(!settings.silent) { 18455 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 18456 module.error.apply(console, arguments); 18457 } 18458 }, 18459 performance: { 18460 log: function(message) { 18461 var 18462 currentTime, 18463 executionTime, 18464 previousTime 18465 ; 18466 if(settings.performance) { 18467 currentTime = new Date().getTime(); 18468 previousTime = time || currentTime; 18469 executionTime = currentTime - previousTime; 18470 time = currentTime; 18471 performance.push({ 18472 'Name' : message[0], 18473 'Arguments' : [].slice.call(message, 1) || '', 18474 'Element' : element, 18475 'Execution Time' : executionTime 18476 }); 18477 } 18478 clearTimeout(module.performance.timer); 18479 module.performance.timer = setTimeout(module.performance.display, 500); 18480 }, 18481 display: function() { 18482 var 18483 title = settings.name + ':', 18484 totalTime = 0 18485 ; 18486 time = false; 18487 clearTimeout(module.performance.timer); 18488 $.each(performance, function(index, data) { 18489 totalTime += data['Execution Time']; 18490 }); 18491 title += ' ' + totalTime + 'ms'; 18492 if(moduleSelector) { 18493 title += ' \'' + moduleSelector + '\''; 18494 } 18495 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 18496 console.groupCollapsed(title); 18497 if(console.table) { 18498 console.table(performance); 18499 } 18500 else { 18501 $.each(performance, function(index, data) { 18502 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 18503 }); 18504 } 18505 console.groupEnd(); 18506 } 18507 performance = []; 18508 } 18509 }, 18510 invoke: function(query, passedArguments, context) { 18511 var 18512 object = instance, 18513 maxDepth, 18514 found, 18515 response 18516 ; 18517 passedArguments = passedArguments || queryArguments; 18518 context = element || context; 18519 if(typeof query == 'string' && object !== undefined) { 18520 query = query.split(/[\. ]/); 18521 maxDepth = query.length - 1; 18522 $.each(query, function(depth, value) {
vendor: 4,133 bytes, lines 18523-18615
18523 var camelCaseValue = (depth != maxDepth) 18524 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 18525 : query 18526 ; 18527 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 18528 object = object[camelCaseValue]; 18529 } 18530 else if( object[camelCaseValue] !== undefined ) { 18531 found = object[camelCaseValue]; 18532 return false; 18533 } 18534 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 18535 object = object[value]; 18536 } 18537 else if( object[value] !== undefined ) { 18538 found = object[value]; 18539 return false; 18540 } 18541 else { 18542 module.error(error.method, query); 18543 return false; 18544 } 18545 }); 18546 } 18547 if ( $.isFunction( found ) ) { 18548 response = found.apply(context, passedArguments); 18549 } 18550 else if(found !== undefined) { 18551 response = found; 18552 } 18553 if($.isArray(returnedValue)) { 18554 returnedValue.push(response); 18555 } 18556 else if(returnedValue !== undefined) { 18557 returnedValue = [returnedValue, response]; 18558 } 18559 else if(response !== undefined) { 18560 returnedValue = response; 18561 } 18562 return found; 18563 } 18564 }; 18565 if(methodInvoked) { 18566 if(instance === undefined) { 18567 module.initialize(); 18568 } 18569 module.invoke(query); 18570 } 18571 else { 18572 if(instance !== undefined) { 18573 instance.invoke('destroy'); 18574 } 18575 module.initialize(); 18576 } 18577 }) 18578 ; 18579 return (returnedValue !== undefined) 18580 ? returnedValue 18581 : this 18582 ; 18583 18584 }; 18585 18586// shortcut for tabbed content with no defined navigation 18587 $.tab = function() { 18588 $(window).tab.apply(this, arguments); 18589 }; 18590 18591 $.fn.tab.settings = { 18592 18593 name : 'Tab', 18594 namespace : 'tab', 18595 18596 silent : false, 18597 debug : false, 18598 verbose : false, 18599 performance : true, 18600 18601 auto : false, // uses pjax style endpoints fetching content from same url with remote-content headers 18602 history : false, // use browser history 18603 historyType : 'hash', // #/ or html5 state 18604 path : false, // base path of url 18605 18606 context : false, // specify a context that tabs must appear inside 18607 childrenOnly : false, // use only tabs that are children of context 18608 maxDepth : 25, // max depth a tab can be nested 18609 18610 deactivate : 'siblings', // whether tabs should deactivate sibling menu elements or all elements initialized together 18611 18612 alwaysRefresh : false, // load tab content new every tab click 18613 cache : true, // cache the content requests to pull locally 18614 loadOnce : false, // Whether tab data should only be loaded once when using remote content 18615 cacheType : 'response', // Whether to cache exact response, or to html c
vendor: 7,736 bytes, lines 18615-18820
18615ache contents after scripts execute 18616 ignoreFirstLoad : false, // don't load remote content on first load 18617 18618 apiSettings : false, // settings for api call 18619 evaluateScripts : 'once', // whether inline scripts should be parsed (true/false/once). Once will not re-evaluate on cached content 18620 18621 onFirstLoad : function(tabPath, parameterArray, historyEvent) {}, // called first time loaded 18622 onLoad : function(tabPath, parameterArray, historyEvent) {}, // called on every load 18623 onVisible : function(tabPath, parameterArray, historyEvent) {}, // called every time tab visible 18624 onRequest : function(tabPath, parameterArray, historyEvent) {}, // called ever time a tab beings loading remote content 18625 18626 templates : { 18627 determineTitle: function(tabArray) {} // returns page title for path 18628 }, 18629 18630 error: { 18631 api : 'You attempted to load content without API module', 18632 method : 'The method you called is not defined', 18633 missingTab : 'Activated tab cannot be found. Tabs are case-sensitive.', 18634 noContent : 'The tab you specified is missing a content url.', 18635 path : 'History enabled, but no path was specified', 18636 recursion : 'Max recursive depth reached', 18637 legacyInit : 'onTabInit has been renamed to onFirstLoad in 2.0, please adjust your code.', 18638 legacyLoad : 'onTabLoad has been renamed to onLoad in 2.0. Please adjust your code', 18639 state : 'History requires Asual\'s Address library <https://github.com/asual/jquery-address>' 18640 }, 18641 18642 metadata : { 18643 tab : 'tab', 18644 loaded : 'loaded', 18645 promise: 'promise' 18646 }, 18647 18648 className : { 18649 loading : 'loading', 18650 active : 'active' 18651 }, 18652 18653 selector : { 18654 tabs : '.ui.tab', 18655 ui : '.ui' 18656 } 18657 18658 }; 18659 18660})( jQuery, window, document ); 18661 18662/*! 18663 * # Semantic UI 2.2.12 - Transition 18664 * http://github.com/semantic-org/semantic-ui/ 18665 * 18666 * 18667 * Released under the MIT license 18668 * http://opensource.org/licenses/MIT 18669 * 18670 */ 18671 18672;(function ($, window, document, undefined) { 18673 18674 "use strict"; 18675 18676 window = (typeof window != 'undefined' && window.Math == Math) 18677 ? window 18678 : (typeof self != 'undefined' && self.Math == Math) 18679 ? self 18680 : Function('return this')() 18681 ; 18682 18683 $.fn.transition = function() { 18684 var 18685 $allModules = $(this), 18686 moduleSelector = $allModules.selector || '', 18687 18688 time = new Date().getTime(), 18689 performance = [], 18690 18691 moduleArguments = arguments, 18692 query = moduleArguments[0], 18693 queryArguments = [].slice.call(arguments, 1), 18694 methodInvoked = (typeof query === 'string'), 18695 18696 requestAnimationFrame = window.requestAnimationFrame 18697 || window.mozRequestAnimationFrame 18698 || window.webkitRequestAnimationFrame 18699 || window.msRequestAnimationFrame 18700 || function(callback) { setTimeout(callback, 0); }, 18701 18702 returnedValue 18703 ; 18704 $allModules 18705 .each(function(index) { 18706 var 18707 $module = $(this), 18708 element = this, 18709 18710 // set at run time 18711 settings, 18712 instance, 18713 18714 error, 18715 className, 18716 metadata, 18717 animationEnd, 18718 animationName, 18719 18720 namespace, 18721 moduleNamespace, 18722 eventNamespace, 18723 module 18724 ; 18725 18726 module = { 18727 18728 initialize: function() { 18729 18730 // get full settings 18731 settings = module.get.settings.apply(element, moduleArguments); 18732 18733 // shorthand 18734 className = settings.className; 18735 error = settings.error; 18736 metadata = settings.metadata; 18737 18738 // define namespace 18739 eventNamespace = '.' + settings.namespace; 18740 moduleNamespace = 'module-' + settings.namespace; 18741 instance = $module.data(moduleNamespace) || module; 18742 18743 // get vendor specific events 18744 animationEnd = module.get.animationEndEvent(); 18745 18746 if(methodInvoked) { 18747 methodInvoked = module.invoke(query); 18748 } 18749 18750 // method not invoked, lets run an animation 18751 if(methodInvoked === false) { 18752 module.verbose('Converted arguments into settings object', settings); 18753 if(settings.interval) { 18754 module.delay(settings.animate); 18755 } 18756 else { 18757 module.animate(); 18758 } 18759 module.instantiate(); 18760 } 18761 }, 18762 18763 instantiate: function() { 18764 module.verbose('Storing instance of module', module); 18765 instance = module; 18766 $module 18767 .data(moduleNamespace, instance) 18768 ; 18769 }, 18770 18771 destroy: function() { 18772 module.verbose('Destroying previous module for', element); 18773 $module 18774 .removeData(moduleNamespace) 18775 ; 18776 }, 18777 18778 refresh: function() { 18779 module.verbose('Refreshing display type on next animation'); 18780 delete module.displayType; 18781 }, 18782 18783 forceRepaint: function() { 18784 module.verbose('Forcing element repaint'); 18785 var 18786 $parentElement = $module.parent(), 18787 $nextElement = $module.next() 18788 ; 18789 if($nextElement.length === 0) { 18790 $module.detach().appendTo($parentElement); 18791 } 18792 else { 18793 $module.detach().insertBefore($nextElement); 18794 } 18795 }, 18796 18797 repaint: function() { 18798 module.verbose('Repainting element'); 18799 var 18800 fakeAssignment = element.offsetWidth 18801 ; 18802 }, 18803 18804 delay: function(interval) { 18805 var 18806 direction = module.get.animationDirection(), 18807 shouldReverse, 18808 delay 18809 ; 18810 if(!direction) { 18811 direction = module.can.transition() 18812 ? module.get.direction() 18813 : 'static' 18814 ; 18815 } 18816 interval = (interval !== undefined) 18817 ? interval 18818 : settings.interval 18819 ; 18820 shouldReverse = (settings.reverse == 'auto' && direction == className.out
vendor: 35,007 bytes, lines 18820-19535
18820ward); 18821 delay = (shouldReverse || settings.reverse == true) 18822 ? ($allModules.length - index) * settings.interval 18823 : index * settings.interval 18824 ; 18825 module.debug('Delaying animation by', delay); 18826 setTimeout(module.animate, delay); 18827 }, 18828 18829 animate: function(overrideSettings) { 18830 settings = overrideSettings || settings; 18831 if(!module.is.supported()) { 18832 module.error(error.support); 18833 return false; 18834 } 18835 module.debug('Preparing animation', settings.animation); 18836 if(module.is.animating()) { 18837 if(settings.queue) { 18838 if(!settings.allowRepeats && module.has.direction() && module.is.occurring() && module.queuing !== true) { 18839 module.debug('Animation is currently occurring, preventing queueing same animation', settings.animation); 18840 } 18841 else { 18842 module.queue(settings.animation); 18843 } 18844 return false; 18845 } 18846 else if(!settings.allowRepeats && module.is.occurring()) { 18847 module.debug('Animation is already occurring, will not execute repeated animation', settings.animation); 18848 return false; 18849 } 18850 else { 18851 module.debug('New animation started, completing previous early', settings.animation); 18852 instance.complete(); 18853 } 18854 } 18855 if( module.can.animate() ) { 18856 module.set.animating(settings.animation); 18857 } 18858 else { 18859 module.error(error.noAnimation, settings.animation, element); 18860 } 18861 }, 18862 18863 reset: function() { 18864 module.debug('Resetting animation to beginning conditions'); 18865 module.remove.animationCallbacks(); 18866 module.restore.conditions(); 18867 module.remove.animating(); 18868 }, 18869 18870 queue: function(animation) { 18871 module.debug('Queueing animation of', animation); 18872 module.queuing = true; 18873 $module 18874 .one(animationEnd + '.queue' + eventNamespace, function() { 18875 module.queuing = false; 18876 module.repaint(); 18877 module.animate.apply(this, settings); 18878 }) 18879 ; 18880 }, 18881 18882 complete: function (event) { 18883 module.debug('Animation complete', settings.animation); 18884 module.remove.completeCallback(); 18885 module.remove.failSafe(); 18886 if(!module.is.looping()) { 18887 if( module.is.outward() ) { 18888 module.verbose('Animation is outward, hiding element'); 18889 module.restore.conditions(); 18890 module.hide(); 18891 } 18892 else if( module.is.inward() ) { 18893 module.verbose('Animation is outward, showing element'); 18894 module.restore.conditions(); 18895 module.show(); 18896 } 18897 else { 18898 module.verbose('Static animation completed'); 18899 module.restore.conditions(); 18900 settings.onComplete.call(element); 18901 } 18902 } 18903 }, 18904 18905 force: { 18906 visible: function() { 18907 var 18908 style = $module.attr('style'), 18909 userStyle = module.get.userStyle(), 18910 displayType = module.get.displayType(), 18911 overrideStyle = userStyle + 'display: ' + displayType + ' !important;', 18912 currentDisplay = $module.css('display'), 18913 emptyStyle = (style === undefined || style === '') 18914 ; 18915 if(currentDisplay !== displayType) { 18916 module.verbose('Overriding default display to show element', displayType); 18917 $module 18918 .attr('style', overrideStyle) 18919 ; 18920 } 18921 else if(emptyStyle) { 18922 $module.removeAttr('style'); 18923 } 18924 }, 18925 hidden: function() { 18926 var 18927 style = $module.attr('style'), 18928 currentDisplay = $module.css('display'), 18929 emptyStyle = (style === undefined || style === '') 18930 ; 18931 if(currentDisplay !== 'none' && !module.is.hidden()) { 18932 module.verbose('Overriding default display to hide element'); 18933 $module 18934 .css('display', 'none') 18935 ; 18936 } 18937 else if(emptyStyle) { 18938 $module 18939 .removeAttr('style') 18940 ; 18941 } 18942 } 18943 }, 18944 18945 has: { 18946 direction: function(animation) { 18947 var 18948 hasDirection = false 18949 ; 18950 animation = animation || settings.animation; 18951 if(typeof animation === 'string') { 18952 animation = animation.split(' '); 18953 $.each(animation, function(index, word){ 18954 if(word === className.inward || word === className.outward) { 18955 hasDirection = true; 18956 } 18957 }); 18958 } 18959 return hasDirection; 18960 }, 18961 inlineDisplay: function() { 18962 var 18963 style = $module.attr('style') || '' 18964 ; 18965 return $.isArray(style.match(/display.*?;/, '')); 18966 } 18967 }, 18968 18969 set: { 18970 animating: function(animation) { 18971 var 18972 animationClass, 18973 direction 18974 ; 18975 // remove previous callbacks 18976 module.remove.completeCallback(); 18977 18978 // determine exact animation 18979 animation = animation || settings.animation; 18980 animationClass = module.get.animationClass(animation); 18981 18982 // save animation class in cache to restore class names 18983 module.save.animation(animationClass); 18984 18985 // override display if necessary so animation appears visibly 18986 module.force.visible(); 18987 18988 module.remove.hidden(); 18989 module.remove.direction(); 18990 18991 module.start.animation(animationClass); 18992 18993 }, 18994 duration: function(animationName, duration) { 18995 duration = duration || settings.duration; 18996 duration = (typeof duration == 'number') 18997 ? duration + 'ms' 18998 : duration 18999 ; 19000 if(duration || duration === 0) { 19001 module.verbose('Setting animation duration', duration); 19002 $module 19003 .css({ 19004 'animation-duration': duration 19005 }) 19006 ; 19007 } 19008 }, 19009 direction: function(direction) { 19010 direction = direction || module.get.direction(); 19011 if(direction == className.inward) { 19012 module.set.inward(); 19013 } 19014 else { 19015 module.set.outward(); 19016 } 19017 }, 19018 looping: function() { 19019 module.debug('Transition set to loop'); 19020 $module 19021 .addClass(className.looping) 19022 ; 19023 }, 19024 hidden: function() { 19025 $module 19026 .addClass(className.transition) 19027 .addClass(className.hidden) 19028 ; 19029 }, 19030 inward: function() { 19031 module.debug('Setting direction to inward'); 19032 $module 19033 .removeClass(className.outward) 19034 .addClass(className.inward) 19035 ; 19036 }, 19037 outward: function() { 19038 module.debug('Setting direction to outward'); 19039 $module 19040 .removeClass(className.inward) 19041 .addClass(className.outward) 19042 ; 19043 }, 19044 visible: function() { 19045 $module 19046 .addClass(className.transition) 19047 .addClass(className.visible) 19048 ; 19049 } 19050 }, 19051 19052 start: { 19053 animation: function(animationClass) { 19054 animationClass = animationClass || module.get.animationClass(); 19055 module.debug('Starting tween', animationClass); 19056 $module 19057 .addClass(animationClass) 19058 .one(animationEnd + '.complete' + eventNamespace, module.complete) 19059 ; 19060 if(settings.useFailSafe) { 19061 module.add.failSafe(); 19062 } 19063 module.set.duration(settings.duration); 19064 settings.onStart.call(element); 19065 } 19066 }, 19067 19068 save: { 19069 animation: function(animation) { 19070 if(!module.cache) { 19071 module.cache = {}; 19072 } 19073 module.cache.animation = animation; 19074 }, 19075 displayType: function(displayType) { 19076 if(displayType !== 'none') { 19077 $module.data(metadata.displayType, displayType); 19078 } 19079 }, 19080 transitionExists: function(animation, exists) { 19081 $.fn.transition.exists[animation] = exists; 19082 module.verbose('Saving existence of transition', animation, exists); 19083 } 19084 }, 19085 19086 restore: { 19087 conditions: function() { 19088 var 19089 animation = module.get.currentAnimation() 19090 ; 19091 if(animation) { 19092 $module 19093 .removeClass(animation) 19094 ; 19095 module.verbose('Removing animation class', module.cache); 19096 } 19097 module.remove.duration(); 19098 } 19099 }, 19100 19101 add: { 19102 failSafe: function() { 19103 var 19104 duration = module.get.duration() 19105 ; 19106 module.timer = setTimeout(function() { 19107 $module.triggerHandler(animationEnd); 19108 }, duration + settings.failSafeDelay); 19109 module.verbose('Adding fail safe timer', module.timer); 19110 } 19111 }, 19112 19113 remove: { 19114 animating: function() { 19115 $module.removeClass(className.animating); 19116 }, 19117 animationCallbacks: function() { 19118 module.remove.queueCallback(); 19119 module.remove.completeCallback(); 19120 }, 19121 queueCallback: function() { 19122 $module.off('.queue' + eventNamespace); 19123 }, 19124 completeCallback: function() { 19125 $module.off('.complete' + eventNamespace); 19126 }, 19127 display: function() { 19128 $module.css('display', ''); 19129 }, 19130 direction: function() { 19131 $module 19132 .removeClass(className.inward) 19133 .removeClass(className.outward) 19134 ; 19135 }, 19136 duration: function() { 19137 $module 19138 .css('animation-duration', '') 19139 ; 19140 }, 19141 failSafe: function() { 19142 module.verbose('Removing fail safe timer', module.timer); 19143 if(module.timer) { 19144 clearTimeout(module.timer); 19145 } 19146 }, 19147 hidden: function() { 19148 $module.removeClass(className.hidden); 19149 }, 19150 visible: function() { 19151 $module.removeClass(className.visible); 19152 }, 19153 looping: function() { 19154 module.debug('Transitions are no longer looping'); 19155 if( module.is.looping() ) { 19156 module.reset(); 19157 $module 19158 .removeClass(className.looping) 19159 ; 19160 } 19161 }, 19162 transition: function() { 19163 $module 19164 .removeClass(className.visible) 19165 .removeClass(className.hidden) 19166 ; 19167 } 19168 }, 19169 get: { 19170 settings: function(animation, duration, onComplete) { 19171 // single settings object 19172 if(typeof animation == 'object') { 19173 return $.extend(true, {}, $.fn.transition.settings, animation); 19174 } 19175 // all arguments provided 19176 else if(typeof onComplete == 'function') { 19177 return $.extend({}, $.fn.transition.settings, { 19178 animation : animation, 19179 onComplete : onComplete, 19180 duration : duration 19181 }); 19182 } 19183 // only duration provided 19184 else if(typeof duration == 'string' || typeof duration == 'number') { 19185 return $.extend({}, $.fn.transition.settings, { 19186 animation : animation, 19187 duration : duration 19188 }); 19189 } 19190 // duration is actually settings object 19191 else if(typeof duration == 'object') { 19192 return $.extend({}, $.fn.transition.settings, duration, { 19193 animation : animation 19194 }); 19195 } 19196 // duration is actually callback 19197 else if(typeof duration == 'function') { 19198 return $.extend({}, $.fn.transition.settings, { 19199 animation : animation, 19200 onComplete : duration 19201 }); 19202 } 19203 // only animation provided 19204 else { 19205 return $.extend({}, $.fn.transition.settings, { 19206 animation : animation 19207 }); 19208 } 19209 }, 19210 animationClass: function(animation) { 19211 var 19212 animationClass = animation || settings.animation, 19213 directionClass = (module.can.transition() && !module.has.direction()) 19214 ? module.get.direction() + ' ' 19215 : '' 19216 ; 19217 return className.animating + ' ' 19218 + className.transition + ' ' 19219 + directionClass 19220 + animationClass 19221 ; 19222 }, 19223 currentAnimation: function() { 19224 return (module.cache && module.cache.animation !== undefined) 19225 ? module.cache.animation 19226 : false 19227 ; 19228 }, 19229 currentDirection: function() { 19230 return module.is.inward() 19231 ? className.inward 19232 : className.outward 19233 ; 19234 }, 19235 direction: function() { 19236 return module.is.hidden() || !module.is.visible() 19237 ? className.inward 19238 : className.outward 19239 ; 19240 }, 19241 animationDirection: function(animation) { 19242 var 19243 direction 19244 ; 19245 animation = animation || settings.animation; 19246 if(typeof animation === 'string') { 19247 animation = animation.split(' '); 19248 // search animation name for out/in class 19249 $.each(animation, function(index, word){ 19250 if(word === className.inward) { 19251 direction = className.inward; 19252 } 19253 else if(word === className.outward) { 19254 direction = className.outward; 19255 } 19256 }); 19257 } 19258 // return found direction 19259 if(direction) { 19260 return direction; 19261 } 19262 return false; 19263 }, 19264 duration: function(duration) { 19265 duration = duration || settings.duration; 19266 if(duration === false) { 19267 duration = $module.css('animation-duration') || 0; 19268 } 19269 return (typeof duration === 'string') 19270 ? (duration.indexOf('ms') > -1) 19271 ? parseFloat(duration) 19272 : parseFloat(duration) * 1000 19273 : duration 19274 ; 19275 }, 19276 displayType: function(shouldDetermine) { 19277 shouldDetermine = (shouldDetermine !== undefined) 19278 ? shouldDetermine 19279 : true 19280 ; 19281 if(settings.displayType) { 19282 return settings.displayType; 19283 } 19284 if(shouldDetermine && $module.data(metadata.displayType) === undefined) { 19285 // create fake element to determine display state 19286 module.can.transition(true); 19287 } 19288 return $module.data(metadata.displayType); 19289 }, 19290 userStyle: function(style) { 19291 style = style || $module.attr('style') || ''; 19292 return style.replace(/display.*?;/, ''); 19293 }, 19294 transitionExists: function(animation) { 19295 return $.fn.transition.exists[animation]; 19296 }, 19297 animationStartEvent: function() { 19298 var 19299 element = document.createElement('div'), 19300 animations = { 19301 'animation' :'animationstart', 19302 'OAnimation' :'oAnimationStart', 19303 'MozAnimation' :'mozAnimationStart', 19304 'WebkitAnimation' :'webkitAnimationStart' 19305 }, 19306 animation 19307 ; 19308 for(animation in animations){ 19309 if( element.style[animation] !== undefined ){ 19310 return animations[animation]; 19311 } 19312 } 19313 return false; 19314 }, 19315 animationEndEvent: function() { 19316 var 19317 element = document.createElement('div'), 19318 animations = { 19319 'animation' :'animationend', 19320 'OAnimation' :'oAnimationEnd', 19321 'MozAnimation' :'mozAnimationEnd', 19322 'WebkitAnimation' :'webkitAnimationEnd' 19323 }, 19324 animation 19325 ; 19326 for(animation in animations){ 19327 if( element.style[animation] !== undefined ){ 19328 return animations[animation]; 19329 } 19330 } 19331 return false; 19332 } 19333 19334 }, 19335 19336 can: { 19337 transition: function(forced) { 19338 var 19339 animation = settings.animation, 19340 transitionExists = module.get.transitionExists(animation), 19341 displayType = module.get.displayType(false), 19342 elementClass, 19343 tagName, 19344 $clone, 19345 currentAnimation, 19346 inAnimation, 19347 directionExists 19348 ; 19349 if( transitionExists === undefined || forced) { 19350 module.verbose('Determining whether animation exists'); 19351 elementClass = $module.attr('class'); 19352 tagName = $module.prop('tagName'); 19353 19354 $clone = $('<' + tagName + ' />').addClass( elementClass ).insertAfter($module); 19355 currentAnimation = $clone 19356 .addClass(animation) 19357 .removeClass(className.inward) 19358 .removeClass(className.outward) 19359 .addClass(className.animating) 19360 .addClass(className.transition) 19361 .css('animationName') 19362 ; 19363 inAnimation = $clone 19364 .addClass(className.inward) 19365 .css('animationName') 19366 ; 19367 if(!displayType) { 19368 displayType = $clone 19369 .attr('class', elementClass) 19370 .removeAttr('style') 19371 .removeClass(className.hidden) 19372 .removeClass(className.visible) 19373 .show() 19374 .css('display') 19375 ; 19376 module.verbose('Determining final display state', displayType); 19377 module.save.displayType(displayType); 19378 } 19379 19380 $clone.remove(); 19381 if(currentAnimation != inAnimation) { 19382 module.debug('Direction exists for animation', animation); 19383 directionExists = true; 19384 } 19385 else if(currentAnimation == 'none' || !currentAnimation) { 19386 module.debug('No animation defined in css', animation); 19387 return; 19388 } 19389 else { 19390 module.debug('Static animation found', animation, displayType); 19391 directionExists = false; 19392 } 19393 module.save.transitionExists(animation, directionExists); 19394 } 19395 return (transitionExists !== undefined) 19396 ? transitionExists 19397 : directionExists 19398 ; 19399 }, 19400 animate: function() { 19401 // can transition does not return a value if animation does not exist 19402 return (module.can.transition() !== undefined); 19403 } 19404 }, 19405 19406 is: { 19407 animating: function() { 19408 return $module.hasClass(className.animating); 19409 }, 19410 inward: function() { 19411 return $module.hasClass(className.inward); 19412 }, 19413 outward: function() { 19414 return $module.hasClass(className.outward); 19415 }, 19416 looping: function() { 19417 return $module.hasClass(className.looping); 19418 }, 19419 occurring: function(animation) { 19420 animation = animation || settings.animation; 19421 animation = '.' + animation.replace(' ', '.'); 19422 return ( $module.filter(animation).length > 0 ); 19423 }, 19424 visible: function() { 19425 return $module.is(':visible'); 19426 }, 19427 hidden: function() { 19428 return $module.css('visibility') === 'hidden'; 19429 }, 19430 supported: function() { 19431 return(animationEnd !== false); 19432 } 19433 }, 19434 19435 hide: function() { 19436 module.verbose('Hiding element'); 19437 if( module.is.animating() ) { 19438 module.reset(); 19439 } 19440 element.blur(); // IE will trigger focus change if element is not blurred before hiding 19441 module.remove.display(); 19442 module.remove.visible(); 19443 module.set.hidden(); 19444 module.force.hidden(); 19445 settings.onHide.call(element); 19446 settings.onComplete.call(element); 19447 // module.repaint(); 19448 }, 19449 19450 show: function(display) { 19451 module.verbose('Showing element', display); 19452 module.remove.hidden(); 19453 module.set.visible(); 19454 module.force.visible(); 19455 settings.onShow.call(element); 19456 settings.onComplete.call(element); 19457 // module.repaint(); 19458 }, 19459 19460 toggle: function() { 19461 if( module.is.visible() ) { 19462 module.hide(); 19463 } 19464 else { 19465 module.show(); 19466 } 19467 }, 19468 19469 stop: function() { 19470 module.debug('Stopping current animation'); 19471 $module.triggerHandler(animationEnd); 19472 }, 19473 19474 stopAll: function() { 19475 module.debug('Stopping all animation'); 19476 module.remove.queueCallback(); 19477 $module.triggerHandler(animationEnd); 19478 }, 19479 19480 clear: { 19481 queue: function() { 19482 module.debug('Clearing animation queue'); 19483 module.remove.queueCallback(); 19484 } 19485 }, 19486 19487 enable: function() { 19488 module.verbose('Starting animation'); 19489 $module.removeClass(className.disabled); 19490 }, 19491 19492 disable: function() { 19493 module.debug('Stopping animation'); 19494 $module.addClass(className.disabled); 19495 }, 19496 19497 setting: function(name, value) { 19498 module.debug('Changing setting', name, value); 19499 if( $.isPlainObject(name) ) { 19500 $.extend(true, settings, name); 19501 } 19502 else if(value !== undefined) { 19503 if($.isPlainObject(settings[name])) { 19504 $.extend(true, settings[name], value); 19505 } 19506 else { 19507 settings[name] = value; 19508 } 19509 } 19510 else { 19511 return settings[name]; 19512 } 19513 }, 19514 internal: function(name, value) { 19515 if( $.isPlainObject(name) ) { 19516 $.extend(true, module, name); 19517 } 19518 else if(value !== undefined) { 19519 module[name] = value; 19520 } 19521 else { 19522 return module[name]; 19523 } 19524 }, 19525 debug: function() { 19526 if(!settings.silent && settings.debug) { 19527 if(settings.performance) { 19528 module.performance.log(arguments); 19529 } 19530 else { 19531 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 19532 module.debug.apply(console, arguments); 19533 } 19534 } 19535 },
vendor: 4,577 bytes, lines 19536-19620
19536 verbose: function() { 19537 if(!settings.silent && settings.verbose && settings.debug) { 19538 if(settings.performance) { 19539 module.performance.log(arguments); 19540 } 19541 else { 19542 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 19543 module.verbose.apply(console, arguments); 19544 } 19545 } 19546 }, 19547 error: function() { 19548 if(!settings.silent) { 19549 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 19550 module.error.apply(console, arguments); 19551 } 19552 }, 19553 performance: { 19554 log: function(message) { 19555 var 19556 currentTime, 19557 executionTime, 19558 previousTime 19559 ; 19560 if(settings.performance) { 19561 currentTime = new Date().getTime(); 19562 previousTime = time || currentTime; 19563 executionTime = currentTime - previousTime; 19564 time = currentTime; 19565 performance.push({ 19566 'Name' : message[0], 19567 'Arguments' : [].slice.call(message, 1) || '', 19568 'Element' : element, 19569 'Execution Time' : executionTime 19570 }); 19571 } 19572 clearTimeout(module.performance.timer); 19573 module.performance.timer = setTimeout(module.performance.display, 500); 19574 }, 19575 display: function() { 19576 var 19577 title = settings.name + ':', 19578 totalTime = 0 19579 ; 19580 time = false; 19581 clearTimeout(module.performance.timer); 19582 $.each(performance, function(index, data) { 19583 totalTime += data['Execution Time']; 19584 }); 19585 title += ' ' + totalTime + 'ms'; 19586 if(moduleSelector) { 19587 title += ' \'' + moduleSelector + '\''; 19588 } 19589 if($allModules.length > 1) { 19590 title += ' ' + '(' + $allModules.length + ')'; 19591 } 19592 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 19593 console.groupCollapsed(title); 19594 if(console.table) { 19595 console.table(performance); 19596 } 19597 else { 19598 $.each(performance, function(index, data) { 19599 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 19600 }); 19601 } 19602 console.groupEnd(); 19603 } 19604 performance = []; 19605 } 19606 }, 19607 // modified for transition to return invoke success 19608 invoke: function(query, passedArguments, context) { 19609 var 19610 object = instance, 19611 maxDepth, 19612 found, 19613 response 19614 ; 19615 passedArguments = passedArguments || queryArguments; 19616 context = element || context; 19617 if(typeof query == 'string' && object !== undefined) { 19618 query = query.split(/[\. ]/); 19619 maxDepth = query.length - 1; 19620 $.each(query, function(depth, value) {
vendor: 12,920 bytes, lines 19621-19967
19621 var camelCaseValue = (depth != maxDepth) 19622 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 19623 : query 19624 ; 19625 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 19626 object = object[camelCaseValue]; 19627 } 19628 else if( object[camelCaseValue] !== undefined ) { 19629 found = object[camelCaseValue]; 19630 return false; 19631 } 19632 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 19633 object = object[value]; 19634 } 19635 else if( object[value] !== undefined ) { 19636 found = object[value]; 19637 return false; 19638 } 19639 else { 19640 return false; 19641 } 19642 }); 19643 } 19644 if ( $.isFunction( found ) ) { 19645 response = found.apply(context, passedArguments); 19646 } 19647 else if(found !== undefined) { 19648 response = found; 19649 } 19650 19651 if($.isArray(returnedValue)) { 19652 returnedValue.push(response); 19653 } 19654 else if(returnedValue !== undefined) { 19655 returnedValue = [returnedValue, response]; 19656 } 19657 else if(response !== undefined) { 19658 returnedValue = response; 19659 } 19660 return (found !== undefined) 19661 ? found 19662 : false 19663 ; 19664 } 19665 }; 19666 module.initialize(); 19667 }) 19668 ; 19669 return (returnedValue !== undefined) 19670 ? returnedValue 19671 : this 19672 ; 19673 }; 19674 19675// Records if CSS transition is available 19676 $.fn.transition.exists = {}; 19677 19678 $.fn.transition.settings = { 19679 19680 // module info 19681 name : 'Transition', 19682 19683 // hide all output from this component regardless of other settings 19684 silent : false, 19685 19686 // debug content outputted to console 19687 debug : false, 19688 19689 // verbose debug output 19690 verbose : false, 19691 19692 // performance data output 19693 performance : true, 19694 19695 // event namespace 19696 namespace : 'transition', 19697 19698 // delay between animations in group 19699 interval : 0, 19700 19701 // whether group animations should be reversed 19702 reverse : 'auto', 19703 19704 // animation callback event 19705 onStart : function() {}, 19706 onComplete : function() {}, 19707 onShow : function() {}, 19708 onHide : function() {}, 19709 19710 // whether timeout should be used to ensure callback fires in cases animationend does not 19711 useFailSafe : true, 19712 19713 // delay in ms for fail safe 19714 failSafeDelay : 100, 19715 19716 // whether EXACT animation can occur twice in a row 19717 allowRepeats : false, 19718 19719 // Override final display type on visible 19720 displayType : false, 19721 19722 // animation duration 19723 animation : 'fade', 19724 duration : false, 19725 19726 // new animations will occur after previous ones 19727 queue : true, 19728 19729 metadata : { 19730 displayType: 'display' 19731 }, 19732 19733 className : { 19734 animating : 'animating', 19735 disabled : 'disabled', 19736 hidden : 'hidden', 19737 inward : 'in', 19738 loading : 'loading', 19739 looping : 'looping', 19740 outward : 'out', 19741 transition : 'transition', 19742 visible : 'visible' 19743 }, 19744 19745 // possible errors 19746 error: { 19747 noAnimation : 'Element is no longer attached to DOM. Unable to animate. Use silent setting to surpress this warning in production.', 19748 repeated : 'That animation is already occurring, cancelling repeated animation', 19749 method : 'The method you called is not defined', 19750 support : 'This browser does not support CSS animations' 19751 } 19752 19753 }; 19754 19755 19756})( jQuery, window, document ); 19757 19758/*! 19759 * # Semantic UI 2.2.12 - API 19760 * http://github.com/semantic-org/semantic-ui/ 19761 * 19762 * 19763 * Released under the MIT license 19764 * http://opensource.org/licenses/MIT 19765 * 19766 */ 19767 19768;(function ($, window, document, undefined) { 19769 19770 "use strict"; 19771 19772 var 19773 window = (typeof window != 'undefined' && window.Math == Math) 19774 ? window 19775 : (typeof self != 'undefined' && self.Math == Math) 19776 ? self 19777 : Function('return this')() 19778 ; 19779 19780 $.api = $.fn.api = function(parameters) { 19781 19782 var 19783 // use window context if none specified 19784 $allModules = $.isFunction(this) 19785 ? $(window) 19786 : $(this), 19787 moduleSelector = $allModules.selector || '', 19788 time = new Date().getTime(), 19789 performance = [], 19790 19791 query = arguments[0], 19792 methodInvoked = (typeof query == 'string'), 19793 queryArguments = [].slice.call(arguments, 1), 19794 19795 returnedValue 19796 ; 19797 19798 $allModules 19799 .each(function() { 19800 var 19801 settings = ( $.isPlainObject(parameters) ) 19802 ? $.extend(true, {}, $.fn.api.settings, parameters) 19803 : $.extend({}, $.fn.api.settings), 19804 19805 // internal aliases 19806 namespace = settings.namespace, 19807 metadata = settings.metadata, 19808 selector = settings.selector, 19809 error = settings.error, 19810 className = settings.className, 19811 19812 // define namespaces for modules 19813 eventNamespace = '.' + namespace, 19814 moduleNamespace = 'module-' + namespace, 19815 19816 // element that creates request 19817 $module = $(this), 19818 $form = $module.closest(selector.form), 19819 19820 // context used for state 19821 $context = (settings.stateContext) 19822 ? $(settings.stateContext) 19823 : $module, 19824 19825 // request details 19826 ajaxSettings, 19827 requestSettings, 19828 url, 19829 data, 19830 requestStartTime, 19831 19832 // standard module 19833 element = this, 19834 context = $context[0], 19835 instance = $module.data(moduleNamespace), 19836 module 19837 ; 19838 19839 module = { 19840 19841 initialize: function() { 19842 if(!methodInvoked) { 19843 module.bind.events(); 19844 } 19845 module.instantiate(); 19846 }, 19847 19848 instantiate: function() { 19849 module.verbose('Storing instance of module', module); 19850 instance = module; 19851 $module 19852 .data(moduleNamespace, instance) 19853 ; 19854 }, 19855 19856 destroy: function() { 19857 module.verbose('Destroying previous module for', element); 19858 $module 19859 .removeData(moduleNamespace) 19860 .off(eventNamespace) 19861 ; 19862 }, 19863 19864 bind: { 19865 events: function() { 19866 var 19867 triggerEvent = module.get.event() 19868 ; 19869 if( triggerEvent ) { 19870 module.verbose('Attaching API events to element', triggerEvent); 19871 $module 19872 .on(triggerEvent + eventNamespace, module.event.trigger) 19873 ; 19874 } 19875 else if(settings.on == 'now') { 19876 module.debug('Querying API endpoint immediately'); 19877 module.query(); 19878 } 19879 } 19880 }, 19881 19882 decode: { 19883 json: function(response) { 19884 if(response !== undefined && typeof response == 'string') { 19885 try { 19886 response = JSON.parse(response); 19887 } 19888 catch(e) { 19889 // isnt json string 19890 } 19891 } 19892 return response; 19893 } 19894 }, 19895 19896 read: { 19897 cachedResponse: function(url) { 19898 var 19899 response 19900 ; 19901 if(window.Storage === undefined) { 19902 module.error(error.noStorage); 19903 return; 19904 } 19905 response = sessionStorage.getItem(url); 19906 module.debug('Using cached response', url, response); 19907 response = module.decode.json(response); 19908 return response; 19909 } 19910 }, 19911 write: { 19912 cachedResponse: function(url, response) { 19913 if(response && response === '') { 19914 module.debug('Response empty, not caching', response); 19915 return; 19916 } 19917 if(window.Storage === undefined) { 19918 module.error(error.noStorage); 19919 return; 19920 } 19921 if( $.isPlainObject(response) ) { 19922 response = JSON.stringify(response); 19923 } 19924 sessionStorage.setItem(url, response); 19925 module.verbose('Storing cached response for url', url, response); 19926 } 19927 }, 19928 19929 query: function() { 19930 19931 if(module.is.disabled()) { 19932 module.debug('Element is disabled API request aborted'); 19933 return; 19934 } 19935 19936 if(module.is.loading()) { 19937 if(settings.interruptRequests) { 19938 module.debug('Interrupting previous request'); 19939 module.abort(); 19940 } 19941 else { 19942 module.debug('Cancelling request, previous request is still pending'); 19943 return; 19944 } 19945 } 19946 19947 // pass element metadata to url (value, text) 19948 if(settings.defaultData) { 19949 $.extend(true, settings.urlData, module.get.defaultData()); 19950 } 19951 19952 // Add form content 19953 if(settings.serializeForm) { 19954 settings.data = module.add.formData(settings.data); 19955 } 19956 19957 // call beforesend and get any settings changes 19958 requestSettings = module.get.settings(); 19959 19960 // check if before send cancelled request 19961 if(requestSettings === false) { 19962 module.cancelled = true; 19963 module.error(error.beforeSend); 19964 return; 19965 } 19966 else { 19967 module.cancelled = false;
vendor: 46,962 bytes, lines 19968-20890
19968 } 19969 19970 // get url 19971 url = module.get.templatedURL(); 19972 19973 if(!url && !module.is.mocked()) { 19974 module.error(error.missingURL); 19975 return; 19976 } 19977 19978 // replace variables 19979 url = module.add.urlData( url ); 19980 // missing url parameters 19981 if( !url && !module.is.mocked()) { 19982 return; 19983 } 19984 19985 requestSettings.url = settings.base + url; 19986 19987 // look for jQuery ajax parameters in settings 19988 ajaxSettings = $.extend(true, {}, settings, { 19989 type : settings.method || settings.type, 19990 data : data, 19991 url : settings.base + url, 19992 beforeSend : settings.beforeXHR, 19993 success : function() {}, 19994 failure : function() {}, 19995 complete : function() {} 19996 }); 19997 19998 module.debug('Querying URL', ajaxSettings.url); 19999 module.verbose('Using AJAX settings', ajaxSettings); 20000 if(settings.cache === 'local' && module.read.cachedResponse(url)) { 20001 module.debug('Response returned from local cache'); 20002 module.request = module.create.request(); 20003 module.request.resolveWith(context, [ module.read.cachedResponse(url) ]); 20004 return; 20005 } 20006 20007 if( !settings.throttle ) { 20008 module.debug('Sending request', data, ajaxSettings.method); 20009 module.send.request(); 20010 } 20011 else { 20012 if(!settings.throttleFirstRequest && !module.timer) { 20013 module.debug('Sending request', data, ajaxSettings.method); 20014 module.send.request(); 20015 module.timer = setTimeout(function(){}, settings.throttle); 20016 } 20017 else { 20018 module.debug('Throttling request', settings.throttle); 20019 clearTimeout(module.timer); 20020 module.timer = setTimeout(function() { 20021 if(module.timer) { 20022 delete module.timer; 20023 } 20024 module.debug('Sending throttled request', data, ajaxSettings.method); 20025 module.send.request(); 20026 }, settings.throttle); 20027 } 20028 } 20029 20030 }, 20031 20032 should: { 20033 removeError: function() { 20034 return ( settings.hideError === true || (settings.hideError === 'auto' && !module.is.form()) ); 20035 } 20036 }, 20037 20038 is: { 20039 disabled: function() { 20040 return ($module.filter(selector.disabled).length > 0); 20041 }, 20042 expectingJSON: function() { 20043 return settings.dataType === 'json' || settings.dataType === 'jsonp'; 20044 }, 20045 form: function() { 20046 return $module.is('form') || $context.is('form'); 20047 }, 20048 mocked: function() { 20049 return (settings.mockResponse || settings.mockResponseAsync || settings.response || settings.responseAsync); 20050 }, 20051 input: function() { 20052 return $module.is('input'); 20053 }, 20054 loading: function() { 20055 return (module.request) 20056 ? (module.request.state() == 'pending') 20057 : false 20058 ; 20059 }, 20060 abortedRequest: function(xhr) { 20061 if(xhr && xhr.readyState !== undefined && xhr.readyState === 0) { 20062 module.verbose('XHR request determined to be aborted'); 20063 return true; 20064 } 20065 else { 20066 module.verbose('XHR request was not aborted'); 20067 return false; 20068 } 20069 }, 20070 validResponse: function(response) { 20071 if( (!module.is.expectingJSON()) || !$.isFunction(settings.successTest) ) { 20072 module.verbose('Response is not JSON, skipping validation', settings.successTest, response); 20073 return true; 20074 } 20075 module.debug('Checking JSON returned success', settings.successTest, response); 20076 if( settings.successTest(response) ) { 20077 module.debug('Response passed success test', response); 20078 return true; 20079 } 20080 else { 20081 module.debug('Response failed success test', response); 20082 return false; 20083 } 20084 } 20085 }, 20086 20087 was: { 20088 cancelled: function() { 20089 return (module.cancelled || false); 20090 }, 20091 succesful: function() { 20092 return (module.request && module.request.state() == 'resolved'); 20093 }, 20094 failure: function() { 20095 return (module.request && module.request.state() == 'rejected'); 20096 }, 20097 complete: function() { 20098 return (module.request && (module.request.state() == 'resolved' || module.request.state() == 'rejected') ); 20099 } 20100 }, 20101 20102 add: { 20103 urlData: function(url, urlData) { 20104 var 20105 requiredVariables, 20106 optionalVariables 20107 ; 20108 if(url) { 20109 requiredVariables = url.match(settings.regExp.required); 20110 optionalVariables = url.match(settings.regExp.optional); 20111 urlData = urlData || settings.urlData; 20112 if(requiredVariables) { 20113 module.debug('Looking for required URL variables', requiredVariables); 20114 $.each(requiredVariables, function(index, templatedString) { 20115 var 20116 // allow legacy {$var} style 20117 variable = (templatedString.indexOf('$') !== -1) 20118 ? templatedString.substr(2, templatedString.length - 3) 20119 : templatedString.substr(1, templatedString.length - 2), 20120 value = ($.isPlainObject(urlData) && urlData[variable] !== undefined) 20121 ? urlData[variable] 20122 : ($module.data(variable) !== undefined) 20123 ? $module.data(variable) 20124 : ($context.data(variable) !== undefined) 20125 ? $context.data(variable) 20126 : urlData[variable] 20127 ; 20128 // remove value 20129 if(value === undefined) { 20130 module.error(error.requiredParameter, variable, url); 20131 url = false; 20132 return false; 20133 } 20134 else { 20135 module.verbose('Found required variable', variable, value); 20136 value = (settings.encodeParameters) 20137 ? module.get.urlEncodedValue(value) 20138 : value 20139 ; 20140 url = url.replace(templatedString, value); 20141 } 20142 }); 20143 } 20144 if(optionalVariables) { 20145 module.debug('Looking for optional URL variables', requiredVariables); 20146 $.each(optionalVariables, function(index, templatedString) { 20147 var 20148 // allow legacy {/$var} style 20149 variable = (templatedString.indexOf('$') !== -1) 20150 ? templatedString.substr(3, templatedString.length - 4) 20151 : templatedString.substr(2, templatedString.length - 3), 20152 value = ($.isPlainObject(urlData) && urlData[variable] !== undefined) 20153 ? urlData[variable] 20154 : ($module.data(variable) !== undefined) 20155 ? $module.data(variable) 20156 : ($context.data(variable) !== undefined) 20157 ? $context.data(variable) 20158 : urlData[variable] 20159 ; 20160 // optional replacement 20161 if(value !== undefined) { 20162 module.verbose('Optional variable Found', variable, value); 20163 url = url.replace(templatedString, value); 20164 } 20165 else { 20166 module.verbose('Optional variable not found', variable); 20167 // remove preceding slash if set 20168 if(url.indexOf('/' + templatedString) !== -1) { 20169 url = url.replace('/' + templatedString, ''); 20170 } 20171 else { 20172 url = url.replace(templatedString, ''); 20173 } 20174 } 20175 }); 20176 } 20177 } 20178 return url; 20179 }, 20180 formData: function(data) { 20181 var 20182 canSerialize = ($.fn.serializeObject !== undefined), 20183 formData = (canSerialize) 20184 ? $form.serializeObject() 20185 : $form.serialize(), 20186 hasOtherData 20187 ; 20188 data = data || settings.data; 20189 hasOtherData = $.isPlainObject(data); 20190 20191 if(hasOtherData) { 20192 if(canSerialize) { 20193 module.debug('Extending existing data with form data', data, formData); 20194 data = $.extend(true, {}, data, formData); 20195 } 20196 else { 20197 module.error(error.missingSerialize); 20198 module.debug('Cant extend data. Replacing data with form data', data, formData); 20199 data = formData; 20200 } 20201 } 20202 else { 20203 module.debug('Adding form data', formData); 20204 data = formData; 20205 } 20206 return data; 20207 } 20208 }, 20209 20210 send: { 20211 request: function() { 20212 module.set.loading(); 20213 module.request = module.create.request(); 20214 if( module.is.mocked() ) { 20215 module.mockedXHR = module.create.mockedXHR(); 20216 } 20217 else { 20218 module.xhr = module.create.xhr(); 20219 } 20220 settings.onRequest.call(context, module.request, module.xhr); 20221 } 20222 }, 20223 20224 event: { 20225 trigger: function(event) { 20226 module.query(); 20227 if(event.type == 'submit' || event.type == 'click') { 20228 event.preventDefault(); 20229 } 20230 }, 20231 xhr: { 20232 always: function() { 20233 // nothing special 20234 }, 20235 done: function(response, textStatus, xhr) { 20236 var 20237 context = this, 20238 elapsedTime = (new Date().getTime() - requestStartTime), 20239 timeLeft = (settings.loadingDuration - elapsedTime), 20240 translatedResponse = ( $.isFunction(settings.onResponse) ) 20241 ? module.is.expectingJSON() 20242 ? settings.onResponse.call(context, $.extend(true, {}, response)) 20243 : settings.onResponse.call(context, response) 20244 : false 20245 ; 20246 timeLeft = (timeLeft > 0) 20247 ? timeLeft 20248 : 0 20249 ; 20250 if(translatedResponse) { 20251 module.debug('Modified API response in onResponse callback', settings.onResponse, translatedResponse, response); 20252 response = translatedResponse; 20253 } 20254 if(timeLeft > 0) { 20255 module.debug('Response completed early delaying state change by', timeLeft); 20256 } 20257 setTimeout(function() { 20258 if( module.is.validResponse(response) ) { 20259 module.request.resolveWith(context, [response, xhr]); 20260 } 20261 else { 20262 module.request.rejectWith(context, [xhr, 'invalid']); 20263 } 20264 }, timeLeft); 20265 }, 20266 fail: function(xhr, status, httpMessage) { 20267 var 20268 context = this, 20269 elapsedTime = (new Date().getTime() - requestStartTime), 20270 timeLeft = (settings.loadingDuration - elapsedTime) 20271 ; 20272 timeLeft = (timeLeft > 0) 20273 ? timeLeft 20274 : 0 20275 ; 20276 if(timeLeft > 0) { 20277 module.debug('Response completed early delaying state change by', timeLeft); 20278 } 20279 setTimeout(function() { 20280 if( module.is.abortedRequest(xhr) ) { 20281 module.request.rejectWith(context, [xhr, 'aborted', httpMessage]); 20282 } 20283 else { 20284 module.request.rejectWith(context, [xhr, 'error', status, httpMessage]); 20285 } 20286 }, timeLeft); 20287 } 20288 }, 20289 request: { 20290 done: function(response, xhr) { 20291 module.debug('Successful API Response', response); 20292 if(settings.cache === 'local' && url) { 20293 module.write.cachedResponse(url, response); 20294 module.debug('Saving server response locally', module.cache); 20295 } 20296 settings.onSuccess.call(context, response, $module, xhr); 20297 }, 20298 complete: function(firstParameter, secondParameter) { 20299 var 20300 xhr, 20301 response 20302 ; 20303 // have to guess callback parameters based on request success 20304 if( module.was.succesful() ) { 20305 response = firstParameter; 20306 xhr = secondParameter; 20307 } 20308 else { 20309 xhr = firstParameter; 20310 response = module.get.responseFromXHR(xhr); 20311 } 20312 module.remove.loading(); 20313 settings.onComplete.call(context, response, $module, xhr); 20314 }, 20315 fail: function(xhr, status, httpMessage) { 20316 var 20317 // pull response from xhr if available 20318 response = module.get.responseFromXHR(xhr), 20319 errorMessage = module.get.errorFromRequest(response, status, httpMessage) 20320 ; 20321 if(status == 'aborted') { 20322 module.debug('XHR Aborted (Most likely caused by page navigation or CORS Policy)', status, httpMessage); 20323 settings.onAbort.call(context, status, $module, xhr); 20324 return true; 20325 } 20326 else if(status == 'invalid') { 20327 module.debug('JSON did not pass success test. A server-side error has most likely occurred', response); 20328 } 20329 else if(status == 'error') { 20330 if(xhr !== undefined) { 20331 module.debug('XHR produced a server error', status, httpMessage); 20332 // make sure we have an error to display to console 20333 if( xhr.status != 200 && httpMessage !== undefined && httpMessage !== '') { 20334 module.error(error.statusMessage + httpMessage, ajaxSettings.url); 20335 } 20336 settings.onError.call(context, errorMessage, $module, xhr); 20337 } 20338 } 20339 20340 if(settings.errorDuration && status !== 'aborted') { 20341 module.debug('Adding error state'); 20342 module.set.error(); 20343 if( module.should.removeError() ) { 20344 setTimeout(module.remove.error, settings.errorDuration); 20345 } 20346 } 20347 module.debug('API Request failed', errorMessage, xhr); 20348 settings.onFailure.call(context, response, $module, xhr); 20349 } 20350 } 20351 }, 20352 20353 create: { 20354 20355 request: function() { 20356 // api request promise 20357 return $.Deferred() 20358 .always(module.event.request.complete) 20359 .done(module.event.request.done) 20360 .fail(module.event.request.fail) 20361 ; 20362 }, 20363 20364 mockedXHR: function () { 20365 var 20366 // xhr does not simulate these properties of xhr but must return them 20367 textStatus = false, 20368 status = false, 20369 httpMessage = false, 20370 responder = settings.mockResponse || settings.response, 20371 asyncResponder = settings.mockResponseAsync || settings.responseAsync, 20372 asyncCallback, 20373 response, 20374 mockedXHR 20375 ; 20376 20377 mockedXHR = $.Deferred() 20378 .always(module.event.xhr.complete) 20379 .done(module.event.xhr.done) 20380 .fail(module.event.xhr.fail) 20381 ; 20382 20383 if(responder) { 20384 if( $.isFunction(responder) ) { 20385 module.debug('Using specified synchronous callback', responder); 20386 response = responder.call(context, requestSettings); 20387 } 20388 else { 20389 module.debug('Using settings specified response', responder); 20390 response = responder; 20391 } 20392 // simulating response 20393 mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]); 20394 } 20395 else if( $.isFunction(asyncResponder) ) { 20396 asyncCallback = function(response) { 20397 module.debug('Async callback returned response', response); 20398 20399 if(response) { 20400 mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]); 20401 } 20402 else { 20403 mockedXHR.rejectWith(context, [{ responseText: response }, status, httpMessage]); 20404 } 20405 }; 20406 module.debug('Using specified async response callback', asyncResponder); 20407 asyncResponder.call(context, requestSettings, asyncCallback); 20408 } 20409 return mockedXHR; 20410 }, 20411 20412 xhr: function() { 20413 var 20414 xhr 20415 ; 20416 // ajax request promise 20417 xhr = $.ajax(ajaxSettings) 20418 .always(module.event.xhr.always) 20419 .done(module.event.xhr.done) 20420 .fail(module.event.xhr.fail) 20421 ; 20422 module.verbose('Created server request', xhr, ajaxSettings); 20423 return xhr; 20424 } 20425 }, 20426 20427 set: { 20428 error: function() { 20429 module.verbose('Adding error state to element', $context); 20430 $context.addClass(className.error); 20431 }, 20432 loading: function() { 20433 module.verbose('Adding loading state to element', $context); 20434 $context.addClass(className.loading); 20435 requestStartTime = new Date().getTime(); 20436 } 20437 }, 20438 20439 remove: { 20440 error: function() { 20441 module.verbose('Removing error state from element', $context); 20442 $context.removeClass(className.error); 20443 }, 20444 loading: function() { 20445 module.verbose('Removing loading state from element', $context); 20446 $context.removeClass(className.loading); 20447 } 20448 }, 20449 20450 get: { 20451 responseFromXHR: function(xhr) { 20452 return $.isPlainObject(xhr) 20453 ? (module.is.expectingJSON()) 20454 ? module.decode.json(xhr.responseText) 20455 : xhr.responseText 20456 : false 20457 ; 20458 }, 20459 errorFromRequest: function(response, status, httpMessage) { 20460 return ($.isPlainObject(response) && response.error !== undefined) 20461 ? response.error // use json error message 20462 : (settings.error[status] !== undefined) // use server error message 20463 ? settings.error[status] 20464 : httpMessage 20465 ; 20466 }, 20467 request: function() { 20468 return module.request || false; 20469 }, 20470 xhr: function() { 20471 return module.xhr || false; 20472 }, 20473 settings: function() { 20474 var 20475 runSettings 20476 ; 20477 runSettings = settings.beforeSend.call(context, settings); 20478 if(runSettings) { 20479 if(runSettings.success !== undefined) { 20480 module.debug('Legacy success callback detected', runSettings); 20481 module.error(error.legacyParameters, runSettings.success); 20482 runSettings.onSuccess = runSettings.success; 20483 } 20484 if(runSettings.failure !== undefined) { 20485 module.debug('Legacy failure callback detected', runSettings); 20486 module.error(error.legacyParameters, runSettings.failure); 20487 runSettings.onFailure = runSettings.failure; 20488 } 20489 if(runSettings.complete !== undefined) { 20490 module.debug('Legacy complete callback detected', runSettings); 20491 module.error(error.legacyParameters, runSettings.complete); 20492 runSettings.onComplete = runSettings.complete; 20493 } 20494 } 20495 if(runSettings === undefined) { 20496 module.error(error.noReturnedValue); 20497 } 20498 if(runSettings === false) { 20499 return runSettings; 20500 } 20501 return (runSettings !== undefined) 20502 ? $.extend(true, {}, runSettings) 20503 : $.extend(true, {}, settings) 20504 ; 20505 }, 20506 urlEncodedValue: function(value) { 20507 var 20508 decodedValue = window.decodeURIComponent(value), 20509 encodedValue = window.encodeURIComponent(value), 20510 alreadyEncoded = (decodedValue !== value) 20511 ; 20512 if(alreadyEncoded) { 20513 module.debug('URL value is already encoded, avoiding double encoding', value); 20514 return value; 20515 } 20516 module.verbose('Encoding value using encodeURIComponent', value, encodedValue); 20517 return encodedValue; 20518 }, 20519 defaultData: function() { 20520 var 20521 data = {} 20522 ; 20523 if( !$.isWindow(element) ) { 20524 if( module.is.input() ) { 20525 data.value = $module.val(); 20526 } 20527 else if( module.is.form() ) { 20528 20529 } 20530 else { 20531 data.text = $module.text(); 20532 } 20533 } 20534 return data; 20535 }, 20536 event: function() { 20537 if( $.isWindow(element) || settings.on == 'now' ) { 20538 module.debug('API called without element, no events attached'); 20539 return false; 20540 } 20541 else if(settings.on == 'auto') { 20542 if( $module.is('input') ) { 20543 return (element.oninput !== undefined) 20544 ? 'input' 20545 : (element.onpropertychange !== undefined) 20546 ? 'propertychange' 20547 : 'keyup' 20548 ; 20549 } 20550 else if( $module.is('form') ) { 20551 return 'submit'; 20552 } 20553 else { 20554 return 'click'; 20555 } 20556 } 20557 else { 20558 return settings.on; 20559 } 20560 }, 20561 templatedURL: function(action) { 20562 action = action || $module.data(metadata.action) || settings.action || false; 20563 url = $module.data(metadata.url) || settings.url || false; 20564 if(url) { 20565 module.debug('Using specified url', url); 20566 return url; 20567 } 20568 if(action) { 20569 module.debug('Looking up url for action', action, settings.api); 20570 if(settings.api[action] === undefined && !module.is.mocked()) { 20571 module.error(error.missingAction, settings.action, settings.api); 20572 return; 20573 } 20574 url = settings.api[action]; 20575 } 20576 else if( module.is.form() ) { 20577 url = $module.attr('action') || $context.attr('action') || false; 20578 module.debug('No url or action specified, defaulting to form action', url); 20579 } 20580 return url; 20581 } 20582 }, 20583 20584 abort: function() { 20585 var 20586 xhr = module.get.xhr() 20587 ; 20588 if( xhr && xhr.state() !== 'resolved') { 20589 module.debug('Cancelling API request'); 20590 xhr.abort(); 20591 } 20592 }, 20593 20594 // reset state 20595 reset: function() { 20596 module.remove.error(); 20597 module.remove.loading(); 20598 }, 20599 20600 setting: function(name, value) { 20601 module.debug('Changing setting', name, value); 20602 if( $.isPlainObject(name) ) { 20603 $.extend(true, settings, name); 20604 } 20605 else if(value !== undefined) { 20606 if($.isPlainObject(settings[name])) { 20607 $.extend(true, settings[name], value); 20608 } 20609 else { 20610 settings[name] = value; 20611 } 20612 } 20613 else { 20614 return settings[name]; 20615 } 20616 }, 20617 internal: function(name, value) { 20618 if( $.isPlainObject(name) ) { 20619 $.extend(true, module, name); 20620 } 20621 else if(value !== undefined) { 20622 module[name] = value; 20623 } 20624 else { 20625 return module[name]; 20626 } 20627 }, 20628 debug: function() { 20629 if(!settings.silent && settings.debug) { 20630 if(settings.performance) { 20631 module.performance.log(arguments); 20632 } 20633 else { 20634 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 20635 module.debug.apply(console, arguments); 20636 } 20637 } 20638 }, 20639 verbose: function() { 20640 if(!settings.silent && settings.verbose && settings.debug) { 20641 if(settings.performance) { 20642 module.performance.log(arguments); 20643 } 20644 else { 20645 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 20646 module.verbose.apply(console, arguments); 20647 } 20648 } 20649 }, 20650 error: function() { 20651 if(!settings.silent) { 20652 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 20653 module.error.apply(console, arguments); 20654 } 20655 }, 20656 performance: { 20657 log: function(message) { 20658 var 20659 currentTime, 20660 executionTime, 20661 previousTime 20662 ; 20663 if(settings.performance) { 20664 currentTime = new Date().getTime(); 20665 previousTime = time || currentTime; 20666 executionTime = currentTime - previousTime; 20667 time = currentTime; 20668 performance.push({ 20669 'Name' : message[0], 20670 'Arguments' : [].slice.call(message, 1) || '', 20671 //'Element' : element, 20672 'Execution Time' : executionTime 20673 }); 20674 } 20675 clearTimeout(module.performance.timer); 20676 module.performance.timer = setTimeout(module.performance.display, 500); 20677 }, 20678 display: function() { 20679 var 20680 title = settings.name + ':', 20681 totalTime = 0 20682 ; 20683 time = false; 20684 clearTimeout(module.performance.timer); 20685 $.each(performance, function(index, data) { 20686 totalTime += data['Execution Time']; 20687 }); 20688 title += ' ' + totalTime + 'ms'; 20689 if(moduleSelector) { 20690 title += ' \'' + moduleSelector + '\''; 20691 } 20692 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 20693 console.groupCollapsed(title); 20694 if(console.table) { 20695 console.table(performance); 20696 } 20697 else { 20698 $.each(performance, function(index, data) { 20699 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 20700 }); 20701 } 20702 console.groupEnd(); 20703 } 20704 performance = []; 20705 } 20706 }, 20707 invoke: function(query, passedArguments, context) { 20708 var 20709 object = instance, 20710 maxDepth, 20711 found, 20712 response 20713 ; 20714 passedArguments = passedArguments || queryArguments; 20715 context = element || context; 20716 if(typeof query == 'string' && object !== undefined) { 20717 query = query.split(/[\. ]/); 20718 maxDepth = query.length - 1; 20719 $.each(query, function(depth, value) { 20720 var camelCaseValue = (depth != maxDepth) 20721 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 20722 : query 20723 ; 20724 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 20725 object = object[camelCaseValue]; 20726 } 20727 else if( object[camelCaseValue] !== undefined ) { 20728 found = object[camelCaseValue]; 20729 return false; 20730 } 20731 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 20732 object = object[value]; 20733 } 20734 else if( object[value] !== undefined ) { 20735 found = object[value]; 20736 return false; 20737 } 20738 else { 20739 module.error(error.method, query); 20740 return false; 20741 } 20742 }); 20743 } 20744 if ( $.isFunction( found ) ) { 20745 response = found.apply(context, passedArguments); 20746 } 20747 else if(found !== undefined) { 20748 response = found; 20749 } 20750 if($.isArray(returnedValue)) { 20751 returnedValue.push(response); 20752 } 20753 else if(returnedValue !== undefined) { 20754 returnedValue = [returnedValue, response]; 20755 } 20756 else if(response !== undefined) { 20757 returnedValue = response; 20758 } 20759 return found; 20760 } 20761 }; 20762 20763 if(methodInvoked) { 20764 if(instance === undefined) { 20765 module.initialize(); 20766 } 20767 module.invoke(query); 20768 } 20769 else { 20770 if(instance !== undefined) { 20771 instance.invoke('destroy'); 20772 } 20773 module.initialize(); 20774 } 20775 }) 20776 ; 20777 20778 return (returnedValue !== undefined) 20779 ? returnedValue 20780 : this 20781 ; 20782 }; 20783 20784 $.api.settings = { 20785 20786 name : 'API', 20787 namespace : 'api', 20788 20789 debug : false, 20790 verbose : false, 20791 performance : true, 20792 20793 // object containing all templates endpoints 20794 api : {}, 20795 20796 // whether to cache responses 20797 cache : true, 20798 20799 // whether new requests should abort previous requests 20800 interruptRequests : true, 20801 20802 // event binding 20803 on : 'auto', 20804 20805 // context for applying state classes 20806 stateContext : false, 20807 20808 // duration for loading state 20809 loadingDuration : 0, 20810 20811 // whether to hide errors after a period of time 20812 hideError : 'auto', 20813 20814 // duration for error state 20815 errorDuration : 2000, 20816 20817 // whether parameters should be encoded with encodeURIComponent 20818 encodeParameters : true, 20819 20820 // API action to use 20821 action : false, 20822 20823 // templated URL to use 20824 url : false, 20825 20826 // base URL to apply to all endpoints 20827 base : '', 20828 20829 // data that will 20830 urlData : {}, 20831 20832 // whether to add default data to url data 20833 defaultData : true, 20834 20835 // whether to serialize closest form 20836 serializeForm : false, 20837 20838 // how long to wait before request should occur 20839 throttle : 0, 20840 20841 // whether to throttle first request or only repeated 20842 throttleFirstRequest : true, 20843 20844 // standard ajax settings 20845 method : 'get', 20846 data : {}, 20847 dataType : 'json', 20848 20849 // mock response 20850 mockResponse : false, 20851 mockResponseAsync : false, 20852 20853 // aliases for mock 20854 response : false, 20855 responseAsync : false, 20856 20857 // callbacks before request 20858 beforeSend : function(settings) { return settings; }, 20859 beforeXHR : function(xhr) {}, 20860 onRequest : function(promise, xhr) {}, 20861 20862 // after request 20863 onResponse : false, // function(response) { }, 20864 20865 // response was successful, if JSON passed validation 20866 onSuccess : function(response, $module) {}, 20867 20868 // request finished without aborting 20869 onComplete : function(response, $module) {}, 20870 20871 // failed JSON success test 20872 onFailure : function(response, $module) {}, 20873 20874 // server error 20875 onError : function(errorMessage, $module) {}, 20876 20877 // request aborted 20878 onAbort : function(errorMessage, $module) {}, 20879 20880 successTest : false, 20881 20882 // errors 20883 error : { 20884 beforeSend : 'The before send function has aborted the request', 20885 error : 'There was an error with your request', 20886 exitConditions : 'API Request Aborted. Exit conditions met', 20887 JSONParse : 'JSON could not be parsed during error handling', 20888 legacyParameters : 'You are using legacy API success callback names', 20889 method : 'The method you called is not defined', 20890 missingAction : 'API action used but no url was defined',
20891 missingSerialize : 'jquery-serialize-object is required to add form data to an existing data object', 20892 missingURL : 'No URL specified for api event', 20893 noReturnedValue : 'The beforeSend callback must return a settings object, beforeSend ignored.', 20894 noStorage : 'Caching responses locally requires session storage', 20895 parseError : 'There was an error parsing your request', 20896 requiredParameter : 'Missing a required URL parameter: ', 20897 statusMessage : 'Server gave an error: ', 20898 timeout : 'Your request timed out' 20899 }, 20900 20901 regExp : { 20902 required : /\{\$*[A-z0-9]+\}/g, 20903 optional : /\{\/\$*[A-z0-9]+\}/g, 20904 }, 20905 20906 className: { 20907 loading : 'loading', 20908 error : 'error' 20909 }, 20910 20911 selector: { 20912 disabled : '.disabled', 20913 form : 'form' 20914 }, 20915 20916 metadata: { 20917 action : 'action', 20918 url : 'url' 20919 } 20920 }; 20921 20922 20923 20924})( jQuery, window, document ); 20925 20926/*! 20927 * # Semantic UI 2.2.12 - State 20928 * http://github.com/semantic-org/semantic-ui/ 20929 * 20930 * 20931 * Released under the MIT license 20932 * http://opensource.org/licenses/MIT 20933 * 20934 */ 20935 20936;(function ($, window, document, undefined) { 20937 20938 "use strict"; 20939 20940 window = (typeof window != 'undefined' && window.Math == Math) 20941 ? window 20942 : (typeof self != 'undefined' && self.Math == Math) 20943 ? self 20944 : Function('return this')() 20945 ; 20946 20947 $.fn.state = function(parameters) { 20948 var 20949 $allModules = $(this), 20950 20951 moduleSelector = $allModules.selector || '', 20952 20953 hasTouch = ('ontouchstart' in document.documentElement), 20954 time = new Date().getTime(), 20955 performance = [], 20956 20957 query = arguments[0], 20958 methodInvoked = (typeof query == 'string'), 20959 queryArguments = [].slice.call(arguments, 1), 20960 20961 returnedValue 20962 ; 20963 $allModules 20964 .each(function() { 20965 var 20966 settings = ( $.isPlainObject(parameters) ) 20967 ? $.extend(true, {}, $.fn.state.settings, parameters) 20968 : $.extend({}, $.fn.state.settings), 20969 20970 error = settings.error, 20971 metadata = settings.metadata, 20972 className = settings.className, 20973 namespace = settings.namespace, 20974 states = settings.states, 20975 text = settings.text, 20976 20977 eventNamespace = '.' + namespace, 20978 moduleNamespace = namespace + '-module', 20979 20980 $module = $(this), 20981 20982 element = this, 20983 instance = $module.data(moduleNamespace), 20984 20985 module 20986 ; 20987 module = { 20988 20989 initialize: function() { 20990 module.verbose('Initializing module'); 20991 20992 // allow module to guess desired state based on element 20993 if(settings.automatic) { 20994 module.add.defaults(); 20995 } 20996 20997 // bind events with delegated events 20998 if(settings.context && moduleSelector !== '') { 20999 $(settings.context) 21000 .on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text) 21001 .on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text) 21002 .on(moduleSelector, 'click' + eventNamespace, module.toggle.state) 21003 ; 21004 } 21005 else { 21006 $module 21007 .on('mouseenter' + eventNamespace, module.change.text) 21008 .on('mouseleave' + eventNamespace, module.reset.text) 21009 .on('click' + eventNamespace, module.toggle.state) 21010 ; 21011 } 21012 module.instantiate(); 21013 }, 21014 21015 instantiate: function() { 21016 module.verbose('Storing instance of module', module); 21017 instance = module; 21018 $module 21019 .data(moduleNamespace, module) 21020 ; 21021 }, 21022 21023 destroy: function() { 21024 module.verbose('Destroying previous module', instance); 21025 $module 21026 .off(eventNamespace) 21027 .removeData(moduleNamespace) 21028 ; 21029 }, 21030 21031 refresh: function() { 21032 module.verbose('Refreshing selector cache'); 21033 $module = $(element); 21034 }, 21035 21036 add: { 21037 defaults: function() { 21038 var 21039 userStates = parameters && $.isPlainObject(parameters.states) 21040 ? parameters.states 21041 : {} 21042 ; 21043 $.each(settings.defaults, function(type, typeStates) { 21044 if( module.is[type] !== undefined && module.is[type]() ) { 21045 module.verbose('Adding default states', type, element); 21046 $.extend(settings.states, typeStates, userStates); 21047 } 21048 }); 21049 } 21050 }, 21051 21052 is: { 21053 21054 active: function() { 21055 return $module.hasClass(className.active); 21056 }, 21057 loading: function() { 21058 return $module.hasClass(className.loading); 21059 }, 21060 inactive: function() { 21061 return !( $module.hasClass(className.active) ); 21062 }, 21063 state: function(state) { 21064 if(className[state] === undefined) { 21065 return false;
vendor: 14,354 bytes, lines 21066-21375
21066 } 21067 return $module.hasClass( className[state] ); 21068 }, 21069 21070 enabled: function() { 21071 return !( $module.is(settings.filter.active) ); 21072 }, 21073 disabled: function() { 21074 return ( $module.is(settings.filter.active) ); 21075 }, 21076 textEnabled: function() { 21077 return !( $module.is(settings.filter.text) ); 21078 }, 21079 21080 // definitions for automatic type detection 21081 button: function() { 21082 return $module.is('.button:not(a, .submit)'); 21083 }, 21084 input: function() { 21085 return $module.is('input'); 21086 }, 21087 progress: function() { 21088 return $module.is('.ui.progress'); 21089 } 21090 }, 21091 21092 allow: function(state) { 21093 module.debug('Now allowing state', state); 21094 states[state] = true; 21095 }, 21096 disallow: function(state) { 21097 module.debug('No longer allowing', state); 21098 states[state] = false; 21099 }, 21100 21101 allows: function(state) { 21102 return states[state] || false; 21103 }, 21104 21105 enable: function() { 21106 $module.removeClass(className.disabled); 21107 }, 21108 21109 disable: function() { 21110 $module.addClass(className.disabled); 21111 }, 21112 21113 setState: function(state) { 21114 if(module.allows(state)) { 21115 $module.addClass( className[state] ); 21116 } 21117 }, 21118 21119 removeState: function(state) { 21120 if(module.allows(state)) { 21121 $module.removeClass( className[state] ); 21122 } 21123 }, 21124 21125 toggle: { 21126 state: function() { 21127 var 21128 apiRequest, 21129 requestCancelled 21130 ; 21131 if( module.allows('active') && module.is.enabled() ) { 21132 module.refresh(); 21133 if($.fn.api !== undefined) { 21134 apiRequest = $module.api('get request'); 21135 requestCancelled = $module.api('was cancelled'); 21136 if( requestCancelled ) { 21137 module.debug('API Request cancelled by beforesend'); 21138 settings.activateTest = function(){ return false; }; 21139 settings.deactivateTest = function(){ return false; }; 21140 } 21141 else if(apiRequest) { 21142 module.listenTo(apiRequest); 21143 return; 21144 } 21145 } 21146 module.change.state(); 21147 } 21148 } 21149 }, 21150 21151 listenTo: function(apiRequest) { 21152 module.debug('API request detected, waiting for state signal', apiRequest); 21153 if(apiRequest) { 21154 if(text.loading) { 21155 module.update.text(text.loading); 21156 } 21157 $.when(apiRequest) 21158 .then(function() { 21159 if(apiRequest.state() == 'resolved') { 21160 module.debug('API request succeeded'); 21161 settings.activateTest = function(){ return true; }; 21162 settings.deactivateTest = function(){ return true; }; 21163 } 21164 else { 21165 module.debug('API request failed'); 21166 settings.activateTest = function(){ return false; }; 21167 settings.deactivateTest = function(){ return false; }; 21168 } 21169 module.change.state(); 21170 }) 21171 ; 21172 } 21173 }, 21174 21175 // checks whether active/inactive state can be given 21176 change: { 21177 21178 state: function() { 21179 module.debug('Determining state change direction'); 21180 // inactive to active change 21181 if( module.is.inactive() ) { 21182 module.activate(); 21183 } 21184 else { 21185 module.deactivate(); 21186 } 21187 if(settings.sync) { 21188 module.sync(); 21189 } 21190 settings.onChange.call(element); 21191 }, 21192 21193 text: function() { 21194 if( module.is.textEnabled() ) { 21195 if(module.is.disabled() ) { 21196 module.verbose('Changing text to disabled text', text.hover); 21197 module.update.text(text.disabled); 21198 } 21199 else if( module.is.active() ) { 21200 if(text.hover) { 21201 module.verbose('Changing text to hover text', text.hover); 21202 module.update.text(text.hover); 21203 } 21204 else if(text.deactivate) { 21205 module.verbose('Changing text to deactivating text', text.deactivate); 21206 module.update.text(text.deactivate); 21207 } 21208 } 21209 else { 21210 if(text.hover) { 21211 module.verbose('Changing text to hover text', text.hover); 21212 module.update.text(text.hover); 21213 } 21214 else if(text.activate){ 21215 module.verbose('Changing text to activating text', text.activate); 21216 module.update.text(text.activate); 21217 } 21218 } 21219 } 21220 } 21221 21222 }, 21223 21224 activate: function() { 21225 if( settings.activateTest.call(element) ) { 21226 module.debug('Setting state to active'); 21227 $module 21228 .addClass(className.active) 21229 ; 21230 module.update.text(text.active); 21231 settings.onActivate.call(element); 21232 } 21233 }, 21234 21235 deactivate: function() { 21236 if( settings.deactivateTest.call(element) ) { 21237 module.debug('Setting state to inactive'); 21238 $module 21239 .removeClass(className.active) 21240 ; 21241 module.update.text(text.inactive); 21242 settings.onDeactivate.call(element); 21243 } 21244 }, 21245 21246 sync: function() { 21247 module.verbose('Syncing other buttons to current state'); 21248 if( module.is.active() ) { 21249 $allModules 21250 .not($module) 21251 .state('activate'); 21252 } 21253 else { 21254 $allModules 21255 .not($module) 21256 .state('deactivate') 21257 ; 21258 } 21259 }, 21260 21261 get: { 21262 text: function() { 21263 return (settings.selector.text) 21264 ? $module.find(settings.selector.text).text() 21265 : $module.html() 21266 ; 21267 }, 21268 textFor: function(state) { 21269 return text[state] || false; 21270 } 21271 }, 21272 21273 flash: { 21274 text: function(text, duration, callback) { 21275 var 21276 previousText = module.get.text() 21277 ; 21278 module.debug('Flashing text message', text, duration); 21279 text = text || settings.text.flash; 21280 duration = duration || settings.flashDuration; 21281 callback = callback || function() {}; 21282 module.update.text(text); 21283 setTimeout(function(){ 21284 module.update.text(previousText); 21285 callback.call(element); 21286 }, duration); 21287 } 21288 }, 21289 21290 reset: { 21291 // on mouseout sets text to previous value 21292 text: function() { 21293 var 21294 activeText = text.active || $module.data(metadata.storedText), 21295 inactiveText = text.inactive || $module.data(metadata.storedText) 21296 ; 21297 if( module.is.textEnabled() ) { 21298 if( module.is.active() && activeText) { 21299 module.verbose('Resetting active text', activeText); 21300 module.update.text(activeText); 21301 } 21302 else if(inactiveText) { 21303 module.verbose('Resetting inactive text', activeText); 21304 module.update.text(inactiveText); 21305 } 21306 } 21307 } 21308 }, 21309 21310 update: { 21311 text: function(text) { 21312 var 21313 currentText = module.get.text() 21314 ; 21315 if(text && text !== currentText) { 21316 module.debug('Updating text', text); 21317 if(settings.selector.text) { 21318 $module 21319 .data(metadata.storedText, text) 21320 .find(settings.selector.text) 21321 .text(text) 21322 ; 21323 } 21324 else { 21325 $module 21326 .data(metadata.storedText, text) 21327 .html(text) 21328 ; 21329 } 21330 } 21331 else { 21332 module.debug('Text is already set, ignoring update', text); 21333 } 21334 } 21335 }, 21336 21337 setting: function(name, value) { 21338 module.debug('Changing setting', name, value); 21339 if( $.isPlainObject(name) ) { 21340 $.extend(true, settings, name); 21341 } 21342 else if(value !== undefined) { 21343 if($.isPlainObject(settings[name])) { 21344 $.extend(true, settings[name], value); 21345 } 21346 else { 21347 settings[name] = value; 21348 } 21349 } 21350 else { 21351 return settings[name]; 21352 } 21353 }, 21354 internal: function(name, value) { 21355 if( $.isPlainObject(name) ) { 21356 $.extend(true, module, name); 21357 } 21358 else if(value !== undefined) { 21359 module[name] = value; 21360 } 21361 else { 21362 return module[name]; 21363 } 21364 }, 21365 debug: function() { 21366 if(!settings.silent && settings.debug) { 21367 if(settings.performance) { 21368 module.performance.log(arguments); 21369 } 21370 else { 21371 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 21372 module.debug.apply(console, arguments); 21373 } 21374 } 21375 },
vendor: 4,339 bytes, lines 21376-21456
21376 verbose: function() { 21377 if(!settings.silent && settings.verbose && settings.debug) { 21378 if(settings.performance) { 21379 module.performance.log(arguments); 21380 } 21381 else { 21382 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 21383 module.verbose.apply(console, arguments); 21384 } 21385 } 21386 }, 21387 error: function() { 21388 if(!settings.silent) { 21389 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 21390 module.error.apply(console, arguments); 21391 } 21392 }, 21393 performance: { 21394 log: function(message) { 21395 var 21396 currentTime, 21397 executionTime, 21398 previousTime 21399 ; 21400 if(settings.performance) { 21401 currentTime = new Date().getTime(); 21402 previousTime = time || currentTime; 21403 executionTime = currentTime - previousTime; 21404 time = currentTime; 21405 performance.push({ 21406 'Name' : message[0], 21407 'Arguments' : [].slice.call(message, 1) || '', 21408 'Element' : element, 21409 'Execution Time' : executionTime 21410 }); 21411 } 21412 clearTimeout(module.performance.timer); 21413 module.performance.timer = setTimeout(module.performance.display, 500); 21414 }, 21415 display: function() { 21416 var 21417 title = settings.name + ':', 21418 totalTime = 0 21419 ; 21420 time = false; 21421 clearTimeout(module.performance.timer); 21422 $.each(performance, function(index, data) { 21423 totalTime += data['Execution Time']; 21424 }); 21425 title += ' ' + totalTime + 'ms'; 21426 if(moduleSelector) { 21427 title += ' \'' + moduleSelector + '\''; 21428 } 21429 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 21430 console.groupCollapsed(title); 21431 if(console.table) { 21432 console.table(performance); 21433 } 21434 else { 21435 $.each(performance, function(index, data) { 21436 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 21437 }); 21438 } 21439 console.groupEnd(); 21440 } 21441 performance = []; 21442 } 21443 }, 21444 invoke: function(query, passedArguments, context) { 21445 var 21446 object = instance, 21447 maxDepth, 21448 found, 21449 response 21450 ; 21451 passedArguments = passedArguments || queryArguments; 21452 context = element || context; 21453 if(typeof query == 'string' && object !== undefined) { 21454 query = query.split(/[\. ]/); 21455 maxDepth = query.length - 1; 21456 $.each(query, function(depth, value) {
21457 var camelCaseValue = (depth != maxDepth) 21458 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 21459 : query 21460 ; 21461 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 21462 object = object[camelCaseValue]; 21463 } 21464 else if( object[camelCaseValue] !== undefined ) { 21465 found = object[camelCaseValue]; 21466 return false; 21467 } 21468 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 21469 object = object[value]; 21470 } 21471 else if( object[value] !== undefined ) { 21472 found = object[value]; 21473 return false; 21474 } 21475 else { 21476 module.error(error.method, query); 21477 return false; 21478 } 21479 }); 21480 } 21481 if ( $.isFunction( found ) ) { 21482 response = found.apply(context, passedArguments); 21483 } 21484 else if(found !== undefined) { 21485 response = found; 21486 } 21487 if($.isArray(returnedValue)) { 21488 returnedValue.push(response); 21489 } 21490 else if(returnedValue !== undefined) { 21491 returnedValue = [returnedValue, response]; 21492 } 21493 else if(response !== undefined) { 21494 returnedValue = response; 21495 } 21496 return found; 21497 } 21498 }; 21499 21500 if(methodInvoked) { 21501 if(instance === undefined) { 21502 module.initialize(); 21503 } 21504 module.invoke(query); 21505 } 21506 else { 21507 if(instance !== undefined) { 21508 instance.invoke('destroy'); 21509 } 21510 module.initialize(); 21511 } 21512 }) 21513 ; 21514 21515 return (returnedValue !== undefined) 21516 ? returnedValue 21517 : this 21518 ; 21519 }; 21520 21521 $.fn.state.settings = { 21522 21523 // module info 21524 name : 'State', 21525 21526 // debug output 21527 debug : false, 21528 21529 // verbose debug output 21530 verbose : false, 21531 21532 // namespace for events 21533 namespace : 'state', 21534 21535 // debug data includes performance 21536 performance : true, 21537 21538 // callback occurs on state change 21539 onActivate : function() {}, 21540 onDeactivate : function() {}, 21541 onChange : function() {}, 21542 21543 // state test functions 21544 activateTest : function() { return true; }, 21545 deactivateTest : function() { return true; }, 21546 21547 // whether to automatically map default states 21548 automatic : true, 21549 21550 // activate / deactivate changes all elements instantiated at same time 21551 sync : false, 21552 21553 // default flash text duration, used for temporarily changing text of an element 21554 flashDuration : 1000, 21555 21556 // selector filter 21557 filter : { 21558 text : '.loading, .disabled', 21559 active : '.disabled' 21560 }, 21561 21562 context : false, 21563 21564 // error 21565 error: { 21566 beforeSend : 'The before send function has cancelled state change', 21567 method : 'The method you called is not defined.' 21568 }, 21569 21570 // metadata 21571 metadata: { 21572 promise : 'promise', 21573 storedText : 'stored-text' 21574 }, 21575 21576 // change class on state 21577 className: { 21578 active : 'active', 21579 disabled : 'disabled', 21580 error : 'error', 21581 loading : 'loading', 21582 success : 'success', 21583 warning : 'warning' 21584 }, 21585 21586 selector: { 21587 // selector for text node 21588 text: false 21589 }, 21590 21591 defaults : { 21592 input: { 21593 disabled : true, 21594 loading : true, 21595 active : true 21596 }, 21597 button: { 21598 disabled : true, 21599 loading : true, 21600 active : true, 21601 }, 21602 progress: { 21603 active : true, 21604 success : true, 21605 warning : true, 21606 error : true 21607 } 21608 }, 21609 21610 states : { 21611 active : true, 21612 disabled : true, 21613 error : true, 21614 loading : true, 21615 success : true, 21616 warning : true 21617 }, 21618 21619 text : { 21620 disabled : false, 21621 flash : false, 21622 hover : false, 21623 active : false, 21624 inactive : false, 21625 activate : false, 21626 deactivate : false 21627 } 21628 21629 }; 21630 21631 21632 21633})( jQuery, window, document ); 21634 21635/*! 21636 * # Semantic UI 2.2.12 - Visibility 21637 * http://github.com/semantic-org/semantic-ui/ 21638 * 21639 * 21640 * Released under the MIT license 21641 * http://opensource.org/licenses/MIT 21642 * 21643 */ 21644 21645;(function ($, window, document, undefined) { 21646 21647 "use strict"; 21648 21649 window = (typeof window != 'undefined' && window.Math == Math) 21650 ? window 21651 : (typeof self != 'undefined' && self.Math == Math) 21652 ? self 21653 : Function('return this')() 21654 ; 21655 21656 $.fn.visibility = function(parameters) { 21657 var 21658 $allModules = $(this), 21659 moduleSelector = $allModules.selector || '', 21660 21661 time = new Date().getTime(), 21662 performance = [], 21663 21664 query = arguments[0], 21665 methodInvoked = (typeof query == 'string'), 21666 queryArguments = [].slice.call(arguments, 1), 21667 returnedValue, 21668
vendor: 47,724 bytes, lines 21669-22659
21669 moduleCount = $allModules.length, 21670 loadedCount = 0 21671 ; 21672 21673 $allModules 21674 .each(function() { 21675 var 21676 settings = ( $.isPlainObject(parameters) ) 21677 ? $.extend(true, {}, $.fn.visibility.settings, parameters) 21678 : $.extend({}, $.fn.visibility.settings), 21679 21680 className = settings.className, 21681 namespace = settings.namespace, 21682 error = settings.error, 21683 metadata = settings.metadata, 21684 21685 eventNamespace = '.' + namespace, 21686 moduleNamespace = 'module-' + namespace, 21687 21688 $window = $(window), 21689 21690 $module = $(this), 21691 $context = $(settings.context), 21692 21693 $placeholder, 21694 21695 selector = $module.selector || '', 21696 instance = $module.data(moduleNamespace), 21697 21698 requestAnimationFrame = window.requestAnimationFrame 21699 || window.mozRequestAnimationFrame 21700 || window.webkitRequestAnimationFrame 21701 || window.msRequestAnimationFrame 21702 || function(callback) { setTimeout(callback, 0); }, 21703 21704 element = this, 21705 disabled = false, 21706 21707 contextObserver, 21708 observer, 21709 module 21710 ; 21711 21712 module = { 21713 21714 initialize: function() { 21715 module.debug('Initializing', settings); 21716 21717 module.setup.cache(); 21718 21719 if( module.should.trackChanges() ) { 21720 21721 if(settings.type == 'image') { 21722 module.setup.image(); 21723 } 21724 if(settings.type == 'fixed') { 21725 module.setup.fixed(); 21726 } 21727 21728 if(settings.observeChanges) { 21729 module.observeChanges(); 21730 } 21731 module.bind.events(); 21732 } 21733 21734 module.save.position(); 21735 if( !module.is.visible() ) { 21736 module.error(error.visible, $module); 21737 } 21738 21739 if(settings.initialCheck) { 21740 module.checkVisibility(); 21741 } 21742 module.instantiate(); 21743 }, 21744 21745 instantiate: function() { 21746 module.debug('Storing instance', module); 21747 $module 21748 .data(moduleNamespace, module) 21749 ; 21750 instance = module; 21751 }, 21752 21753 destroy: function() { 21754 module.verbose('Destroying previous module'); 21755 if(observer) { 21756 observer.disconnect(); 21757 } 21758 if(contextObserver) { 21759 contextObserver.disconnect(); 21760 } 21761 $window 21762 .off('load' + eventNamespace, module.event.load) 21763 .off('resize' + eventNamespace, module.event.resize) 21764 ; 21765 $context 21766 .off('scroll' + eventNamespace, module.event.scroll) 21767 .off('scrollchange' + eventNamespace, module.event.scrollchange) 21768 ; 21769 if(settings.type == 'fixed') { 21770 module.resetFixed(); 21771 module.remove.placeholder(); 21772 } 21773 $module 21774 .off(eventNamespace) 21775 .removeData(moduleNamespace) 21776 ; 21777 }, 21778 21779 observeChanges: function() { 21780 if('MutationObserver' in window) { 21781 contextObserver = new MutationObserver(module.event.contextChanged); 21782 observer = new MutationObserver(module.event.changed); 21783 contextObserver.observe(document, { 21784 childList : true, 21785 subtree : true 21786 }); 21787 observer.observe(element, { 21788 childList : true, 21789 subtree : true 21790 }); 21791 module.debug('Setting up mutation observer', observer); 21792 } 21793 }, 21794 21795 bind: { 21796 events: function() { 21797 module.verbose('Binding visibility events to scroll and resize'); 21798 if(settings.refreshOnLoad) { 21799 $window 21800 .on('load' + eventNamespace, module.event.load) 21801 ; 21802 } 21803 $window 21804 .on('resize' + eventNamespace, module.event.resize) 21805 ; 21806 // pub/sub pattern 21807 $context 21808 .off('scroll' + eventNamespace) 21809 .on('scroll' + eventNamespace, module.event.scroll) 21810 .on('scrollchange' + eventNamespace, module.event.scrollchange) 21811 ; 21812 } 21813 }, 21814 21815 event: { 21816 changed: function(mutations) { 21817 module.verbose('DOM tree modified, updating visibility calculations'); 21818 module.timer = setTimeout(function() { 21819 module.verbose('DOM tree modified, updating sticky menu'); 21820 module.refresh(); 21821 }, 100); 21822 }, 21823 contextChanged: function(mutations) { 21824 [].forEach.call(mutations, function(mutation) { 21825 if(mutation.removedNodes) { 21826 [].forEach.call(mutation.removedNodes, function(node) { 21827 if(node == element || $(node).find(element).length > 0) { 21828 module.debug('Element removed from DOM, tearing down events'); 21829 module.destroy(); 21830 } 21831 }); 21832 } 21833 }); 21834 }, 21835 resize: function() { 21836 module.debug('Window resized'); 21837 if(settings.refreshOnResize) { 21838 requestAnimationFrame(module.refresh); 21839 } 21840 }, 21841 load: function() { 21842 module.debug('Page finished loading'); 21843 requestAnimationFrame(module.refresh); 21844 }, 21845 // publishes scrollchange event on one scroll 21846 scroll: function() { 21847 if(settings.throttle) { 21848 clearTimeout(module.timer); 21849 module.timer = setTimeout(function() { 21850 $context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]); 21851 }, settings.throttle); 21852 } 21853 else { 21854 requestAnimationFrame(function() { 21855 $context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]); 21856 }); 21857 } 21858 }, 21859 // subscribes to scrollchange 21860 scrollchange: function(event, scrollPosition) { 21861 module.checkVisibility(scrollPosition); 21862 }, 21863 }, 21864 21865 precache: function(images, callback) { 21866 if (!(images instanceof Array)) { 21867 images = [images]; 21868 } 21869 var 21870 imagesLength = images.length, 21871 loadedCounter = 0, 21872 cache = [], 21873 cacheImage = document.createElement('img'), 21874 handleLoad = function() { 21875 loadedCounter++; 21876 if (loadedCounter >= images.length) { 21877 if ($.isFunction(callback)) { 21878 callback(); 21879 } 21880 } 21881 } 21882 ; 21883 while (imagesLength--) { 21884 cacheImage = document.createElement('img'); 21885 cacheImage.onload = handleLoad; 21886 cacheImage.onerror = handleLoad; 21887 cacheImage.src = images[imagesLength]; 21888 cache.push(cacheImage); 21889 } 21890 }, 21891 21892 enableCallbacks: function() { 21893 module.debug('Allowing callbacks to occur'); 21894 disabled = false; 21895 }, 21896 21897 disableCallbacks: function() { 21898 module.debug('Disabling all callbacks temporarily'); 21899 disabled = true; 21900 }, 21901 21902 should: { 21903 trackChanges: function() { 21904 if(methodInvoked) { 21905 module.debug('One time query, no need to bind events'); 21906 return false; 21907 } 21908 module.debug('Callbacks being attached'); 21909 return true; 21910 } 21911 }, 21912 21913 setup: { 21914 cache: function() { 21915 module.cache = { 21916 occurred : {}, 21917 screen : {}, 21918 element : {}, 21919 }; 21920 }, 21921 image: function() { 21922 var 21923 src = $module.data(metadata.src) 21924 ; 21925 if(src) { 21926 module.verbose('Lazy loading image', src); 21927 settings.once = true; 21928 settings.observeChanges = false; 21929 21930 // show when top visible 21931 settings.onOnScreen = function() { 21932 module.debug('Image on screen', element); 21933 module.precache(src, function() { 21934 module.set.image(src, function() { 21935 loadedCount++; 21936 if(loadedCount == moduleCount) { 21937 settings.onAllLoaded.call(this); 21938 } 21939 settings.onLoad.call(this); 21940 }); 21941 }); 21942 }; 21943 } 21944 }, 21945 fixed: function() { 21946 module.debug('Setting up fixed'); 21947 settings.once = false; 21948 settings.observeChanges = false; 21949 settings.initialCheck = true; 21950 settings.refreshOnLoad = true; 21951 if(!parameters.transition) { 21952 settings.transition = false; 21953 } 21954 module.create.placeholder(); 21955 module.debug('Added placeholder', $placeholder); 21956 settings.onTopPassed = function() { 21957 module.debug('Element passed, adding fixed position', $module); 21958 module.show.placeholder(); 21959 module.set.fixed(); 21960 if(settings.transition) { 21961 if($.fn.transition !== undefined) { 21962 $module.transition(settings.transition, settings.duration); 21963 } 21964 } 21965 }; 21966 settings.onTopPassedReverse = function() { 21967 module.debug('Element returned to position, removing fixed', $module); 21968 module.hide.placeholder(); 21969 module.remove.fixed(); 21970 }; 21971 } 21972 }, 21973 21974 create: { 21975 placeholder: function() { 21976 module.verbose('Creating fixed position placeholder'); 21977 $placeholder = $module 21978 .clone(false) 21979 .css('display', 'none') 21980 .addClass(className.placeholder) 21981 .insertAfter($module) 21982 ; 21983 } 21984 }, 21985 21986 show: { 21987 placeholder: function() { 21988 module.verbose('Showing placeholder'); 21989 $placeholder 21990 .css('display', 'block') 21991 .css('visibility', 'hidden') 21992 ; 21993 } 21994 }, 21995 hide: { 21996 placeholder: function() { 21997 module.verbose('Hiding placeholder'); 21998 $placeholder 21999 .css('display', 'none') 22000 .css('visibility', '') 22001 ; 22002 } 22003 }, 22004 22005 set: { 22006 fixed: function() { 22007 module.verbose('Setting element to fixed position'); 22008 $module 22009 .addClass(className.fixed) 22010 .css({ 22011 position : 'fixed', 22012 top : settings.offset + 'px', 22013 left : 'auto', 22014 zIndex : settings.zIndex 22015 }) 22016 ; 22017 settings.onFixed.call(element); 22018 }, 22019 image: function(src, callback) { 22020 $module 22021 .attr('src', src) 22022 ; 22023 if(settings.transition) { 22024 if( $.fn.transition !== undefined) { 22025 if($module.hasClass(className.visible)) { 22026 module.debug('Transition already occurred on this image, skipping animation'); 22027 return; 22028 } 22029 $module.transition(settings.transition, settings.duration, callback); 22030 } 22031 else { 22032 $module.fadeIn(settings.duration, callback); 22033 } 22034 } 22035 else { 22036 $module.show(); 22037 } 22038 } 22039 }, 22040 22041 is: { 22042 onScreen: function() { 22043 var 22044 calculations = module.get.elementCalculations() 22045 ; 22046 return calculations.onScreen; 22047 }, 22048 offScreen: function() { 22049 var 22050 calculations = module.get.elementCalculations() 22051 ; 22052 return calculations.offScreen; 22053 }, 22054 visible: function() { 22055 if(module.cache && module.cache.element) { 22056 return !(module.cache.element.width === 0 && module.cache.element.offset.top === 0); 22057 } 22058 return false; 22059 }, 22060 verticallyScrollableContext: function() { 22061 var 22062 overflowY = ($context.get(0) !== window) 22063 ? $context.css('overflow-y') 22064 : false 22065 ; 22066 return (overflowY == 'auto' || overflowY == 'scroll'); 22067 }, 22068 horizontallyScrollableContext: function() { 22069 var 22070 overflowX = ($context.get(0) !== window) 22071 ? $context.css('overflow-x') 22072 : false 22073 ; 22074 return (overflowX == 'auto' || overflowX == 'scroll'); 22075 } 22076 }, 22077 22078 refresh: function() { 22079 module.debug('Refreshing constants (width/height)'); 22080 if(settings.type == 'fixed') { 22081 module.resetFixed(); 22082 } 22083 module.reset(); 22084 module.save.position(); 22085 if(settings.checkOnRefresh) { 22086 module.checkVisibility(); 22087 } 22088 settings.onRefresh.call(element); 22089 }, 22090 22091 resetFixed: function () { 22092 module.remove.fixed(); 22093 module.remove.occurred(); 22094 }, 22095 22096 reset: function() { 22097 module.verbose('Resetting all cached values'); 22098 if( $.isPlainObject(module.cache) ) { 22099 module.cache.screen = {}; 22100 module.cache.element = {}; 22101 } 22102 }, 22103 22104 checkVisibility: function(scroll) { 22105 module.verbose('Checking visibility of element', module.cache.element); 22106 22107 if( !disabled && module.is.visible() ) { 22108 22109 // save scroll position 22110 module.save.scroll(scroll); 22111 22112 // update calculations derived from scroll 22113 module.save.calculations(); 22114 22115 // percentage 22116 module.passed(); 22117 22118 // reverse (must be first) 22119 module.passingReverse(); 22120 module.topVisibleReverse(); 22121 module.bottomVisibleReverse(); 22122 module.topPassedReverse(); 22123 module.bottomPassedReverse(); 22124 22125 // one time 22126 module.onScreen(); 22127 module.offScreen(); 22128 module.passing(); 22129 module.topVisible(); 22130 module.bottomVisible(); 22131 module.topPassed(); 22132 module.bottomPassed(); 22133 22134 // on update callback 22135 if(settings.onUpdate) { 22136 settings.onUpdate.call(element, module.get.elementCalculations()); 22137 } 22138 } 22139 }, 22140 22141 passed: function(amount, newCallback) { 22142 var 22143 calculations = module.get.elementCalculations(), 22144 amountInPixels 22145 ; 22146 // assign callback 22147 if(amount && newCallback) { 22148 settings.onPassed[amount] = newCallback; 22149 } 22150 else if(amount !== undefined) { 22151 return (module.get.pixelsPassed(amount) > calculations.pixelsPassed); 22152 } 22153 else if(calculations.passing) { 22154 $.each(settings.onPassed, function(amount, callback) { 22155 if(calculations.bottomVisible || calculations.pixelsPassed > module.get.pixelsPassed(amount)) { 22156 module.execute(callback, amount); 22157 } 22158 else if(!settings.once) { 22159 module.remove.occurred(callback); 22160 } 22161 }); 22162 } 22163 }, 22164 22165 onScreen: function(newCallback) { 22166 var 22167 calculations = module.get.elementCalculations(), 22168 callback = newCallback || settings.onOnScreen, 22169 callbackName = 'onScreen' 22170 ; 22171 if(newCallback) { 22172 module.debug('Adding callback for onScreen', newCallback); 22173 settings.onOnScreen = newCallback; 22174 } 22175 if(calculations.onScreen) { 22176 module.execute(callback, callbackName); 22177 } 22178 else if(!settings.once) { 22179 module.remove.occurred(callbackName); 22180 } 22181 if(newCallback !== undefined) { 22182 return calculations.onOnScreen; 22183 } 22184 }, 22185 22186 offScreen: function(newCallback) { 22187 var 22188 calculations = module.get.elementCalculations(), 22189 callback = newCallback || settings.onOffScreen, 22190 callbackName = 'offScreen' 22191 ; 22192 if(newCallback) { 22193 module.debug('Adding callback for offScreen', newCallback); 22194 settings.onOffScreen = newCallback; 22195 } 22196 if(calculations.offScreen) { 22197 module.execute(callback, callbackName); 22198 } 22199 else if(!settings.once) { 22200 module.remove.occurred(callbackName); 22201 } 22202 if(newCallback !== undefined) { 22203 return calculations.onOffScreen; 22204 } 22205 }, 22206 22207 passing: function(newCallback) { 22208 var 22209 calculations = module.get.elementCalculations(), 22210 callback = newCallback || settings.onPassing, 22211 callbackName = 'passing' 22212 ; 22213 if(newCallback) { 22214 module.debug('Adding callback for passing', newCallback); 22215 settings.onPassing = newCallback; 22216 } 22217 if(calculations.passing) { 22218 module.execute(callback, callbackName); 22219 } 22220 else if(!settings.once) { 22221 module.remove.occurred(callbackName); 22222 } 22223 if(newCallback !== undefined) { 22224 return calculations.passing; 22225 } 22226 }, 22227 22228 22229 topVisible: function(newCallback) { 22230 var 22231 calculations = module.get.elementCalculations(), 22232 callback = newCallback || settings.onTopVisible, 22233 callbackName = 'topVisible' 22234 ; 22235 if(newCallback) { 22236 module.debug('Adding callback for top visible', newCallback); 22237 settings.onTopVisible = newCallback; 22238 } 22239 if(calculations.topVisible) { 22240 module.execute(callback, callbackName); 22241 } 22242 else if(!settings.once) { 22243 module.remove.occurred(callbackName); 22244 } 22245 if(newCallback === undefined) { 22246 return calculations.topVisible; 22247 } 22248 }, 22249 22250 bottomVisible: function(newCallback) { 22251 var 22252 calculations = module.get.elementCalculations(), 22253 callback = newCallback || settings.onBottomVisible, 22254 callbackName = 'bottomVisible' 22255 ; 22256 if(newCallback) { 22257 module.debug('Adding callback for bottom visible', newCallback); 22258 settings.onBottomVisible = newCallback; 22259 } 22260 if(calculations.bottomVisible) { 22261 module.execute(callback, callbackName); 22262 } 22263 else if(!settings.once) { 22264 module.remove.occurred(callbackName); 22265 } 22266 if(newCallback === undefined) { 22267 return calculations.bottomVisible; 22268 } 22269 }, 22270 22271 topPassed: function(newCallback) { 22272 var 22273 calculations = module.get.elementCalculations(), 22274 callback = newCallback || settings.onTopPassed, 22275 callbackName = 'topPassed' 22276 ; 22277 if(newCallback) { 22278 module.debug('Adding callback for top passed', newCallback); 22279 settings.onTopPassed = newCallback; 22280 } 22281 if(calculations.topPassed) { 22282 module.execute(callback, callbackName); 22283 } 22284 else if(!settings.once) { 22285 module.remove.occurred(callbackName); 22286 } 22287 if(newCallback === undefined) { 22288 return calculations.topPassed; 22289 } 22290 }, 22291 22292 bottomPassed: function(newCallback) { 22293 var 22294 calculations = module.get.elementCalculations(), 22295 callback = newCallback || settings.onBottomPassed, 22296 callbackName = 'bottomPassed' 22297 ; 22298 if(newCallback) { 22299 module.debug('Adding callback for bottom passed', newCallback); 22300 settings.onBottomPassed = newCallback; 22301 } 22302 if(calculations.bottomPassed) { 22303 module.execute(callback, callbackName); 22304 } 22305 else if(!settings.once) { 22306 module.remove.occurred(callbackName); 22307 } 22308 if(newCallback === undefined) { 22309 return calculations.bottomPassed; 22310 } 22311 }, 22312 22313 passingReverse: function(newCallback) { 22314 var 22315 calculations = module.get.elementCalculations(), 22316 callback = newCallback || settings.onPassingReverse, 22317 callbackName = 'passingReverse' 22318 ; 22319 if(newCallback) { 22320 module.debug('Adding callback for passing reverse', newCallback); 22321 settings.onPassingReverse = newCallback; 22322 } 22323 if(!calculations.passing) { 22324 if(module.get.occurred('passing')) { 22325 module.execute(callback, callbackName); 22326 } 22327 } 22328 else if(!settings.once) { 22329 module.remove.occurred(callbackName); 22330 } 22331 if(newCallback !== undefined) { 22332 return !calculations.passing; 22333 } 22334 }, 22335 22336 22337 topVisibleReverse: function(newCallback) { 22338 var 22339 calculations = module.get.elementCalculations(), 22340 callback = newCallback || settings.onTopVisibleReverse, 22341 callbackName = 'topVisibleReverse' 22342 ; 22343 if(newCallback) { 22344 module.debug('Adding callback for top visible reverse', newCallback); 22345 settings.onTopVisibleReverse = newCallback; 22346 } 22347 if(!calculations.topVisible) { 22348 if(module.get.occurred('topVisible')) { 22349 module.execute(callback, callbackName); 22350 } 22351 } 22352 else if(!settings.once) { 22353 module.remove.occurred(callbackName); 22354 } 22355 if(newCallback === undefined) { 22356 return !calculations.topVisible; 22357 } 22358 }, 22359 22360 bottomVisibleReverse: function(newCallback) { 22361 var 22362 calculations = module.get.elementCalculations(), 22363 callback = newCallback || settings.onBottomVisibleReverse, 22364 callbackName = 'bottomVisibleReverse' 22365 ; 22366 if(newCallback) { 22367 module.debug('Adding callback for bottom visible reverse', newCallback); 22368 settings.onBottomVisibleReverse = newCallback; 22369 } 22370 if(!calculations.bottomVisible) { 22371 if(module.get.occurred('bottomVisible')) { 22372 module.execute(callback, callbackName); 22373 } 22374 } 22375 else if(!settings.once) { 22376 module.remove.occurred(callbackName); 22377 } 22378 if(newCallback === undefined) { 22379 return !calculations.bottomVisible; 22380 } 22381 }, 22382 22383 topPassedReverse: function(newCallback) { 22384 var 22385 calculations = module.get.elementCalculations(), 22386 callback = newCallback || settings.onTopPassedReverse, 22387 callbackName = 'topPassedReverse' 22388 ; 22389 if(newCallback) { 22390 module.debug('Adding callback for top passed reverse', newCallback); 22391 settings.onTopPassedReverse = newCallback; 22392 } 22393 if(!calculations.topPassed) { 22394 if(module.get.occurred('topPassed')) { 22395 module.execute(callback, callbackName); 22396 } 22397 } 22398 else if(!settings.once) { 22399 module.remove.occurred(callbackName); 22400 } 22401 if(newCallback === undefined) { 22402 return !calculations.onTopPassed; 22403 } 22404 }, 22405 22406 bottomPassedReverse: function(newCallback) { 22407 var 22408 calculations = module.get.elementCalculations(), 22409 callback = newCallback || settings.onBottomPassedReverse, 22410 callbackName = 'bottomPassedReverse' 22411 ; 22412 if(newCallback) { 22413 module.debug('Adding callback for bottom passed reverse', newCallback); 22414 settings.onBottomPassedReverse = newCallback; 22415 } 22416 if(!calculations.bottomPassed) { 22417 if(module.get.occurred('bottomPassed')) { 22418 module.execute(callback, callbackName); 22419 } 22420 } 22421 else if(!settings.once) { 22422 module.remove.occurred(callbackName); 22423 } 22424 if(newCallback === undefined) { 22425 return !calculations.bottomPassed; 22426 } 22427 }, 22428 22429 execute: function(callback, callbackName) { 22430 var 22431 calculations = module.get.elementCalculations(), 22432 screen = module.get.screenCalculations() 22433 ; 22434 callback = callback || false; 22435 if(callback) { 22436 if(settings.continuous) { 22437 module.debug('Callback being called continuously', callbackName, calculations); 22438 callback.call(element, calculations, screen); 22439 } 22440 else if(!module.get.occurred(callbackName)) { 22441 module.debug('Conditions met', callbackName, calculations); 22442 callback.call(element, calculations, screen); 22443 } 22444 } 22445 module.save.occurred(callbackName); 22446 }, 22447 22448 remove: { 22449 fixed: function() { 22450 module.debug('Removing fixed position'); 22451 $module 22452 .removeClass(className.fixed) 22453 .css({ 22454 position : '', 22455 top : '', 22456 left : '', 22457 zIndex : '' 22458 }) 22459 ; 22460 settings.onUnfixed.call(element); 22461 }, 22462 placeholder: function() { 22463 module.debug('Removing placeholder content'); 22464 if($placeholder) { 22465 $placeholder.remove(); 22466 } 22467 }, 22468 occurred: function(callback) { 22469 if(callback) { 22470 var 22471 occurred = module.cache.occurred 22472 ; 22473 if(occurred[callback] !== undefined && occurred[callback] === true) { 22474 module.debug('Callback can now be called again', callback); 22475 module.cache.occurred[callback] = false; 22476 } 22477 } 22478 else { 22479 module.cache.occurred = {}; 22480 } 22481 } 22482 }, 22483 22484 save: { 22485 calculations: function() { 22486 module.verbose('Saving all calculations necessary to determine positioning'); 22487 module.save.direction(); 22488 module.save.screenCalculations(); 22489 module.save.elementCalculations(); 22490 }, 22491 occurred: function(callback) { 22492 if(callback) { 22493 if(module.cache.occurred[callback] === undefined || (module.cache.occurred[callback] !== true)) { 22494 module.verbose('Saving callback occurred', callback); 22495 module.cache.occurred[callback] = true; 22496 } 22497 } 22498 }, 22499 scroll: function(scrollPosition) { 22500 scrollPosition = scrollPosition + settings.offset || $context.scrollTop() + settings.offset; 22501 module.cache.scroll = scrollPosition; 22502 }, 22503 direction: function() { 22504 var 22505 scroll = module.get.scroll(), 22506 lastScroll = module.get.lastScroll(), 22507 direction 22508 ; 22509 if(scroll > lastScroll && lastScroll) { 22510 direction = 'down'; 22511 } 22512 else if(scroll < lastScroll && lastScroll) { 22513 direction = 'up'; 22514 } 22515 else { 22516 direction = 'static'; 22517 } 22518 module.cache.direction = direction; 22519 return module.cache.direction; 22520 }, 22521 elementPosition: function() { 22522 var 22523 element = module.cache.element, 22524 screen = module.get.screenSize() 22525 ; 22526 module.verbose('Saving element position'); 22527 // (quicker than $.extend) 22528 element.fits = (element.height < screen.height); 22529 element.offset = $module.offset(); 22530 element.width = $module.outerWidth(); 22531 element.height = $module.outerHeight(); 22532 // compensate for scroll in context 22533 if(module.is.verticallyScrollableContext()) { 22534 element.offset.top += $context.scrollTop() - $context.offset().top; 22535 } 22536 if(module.is.horizontallyScrollableContext()) { 22537 element.offset.left += $context.scrollLeft - $context.offset().left; 22538 } 22539 // store 22540 module.cache.element = element; 22541 return element; 22542 }, 22543 elementCalculations: function() { 22544 var 22545 screen = module.get.screenCalculations(), 22546 element = module.get.elementPosition() 22547 ; 22548 // offset 22549 if(settings.includeMargin) { 22550 element.margin = {}; 22551 element.margin.top = parseInt($module.css('margin-top'), 10); 22552 element.margin.bottom = parseInt($module.css('margin-bottom'), 10); 22553 element.top = element.offset.top - element.margin.top; 22554 element.bottom = element.offset.top + element.height + element.margin.bottom; 22555 } 22556 else { 22557 element.top = element.offset.top; 22558 element.bottom = element.offset.top + element.height; 22559 } 22560 22561 // visibility 22562 element.topPassed = (screen.top >= element.top); 22563 element.bottomPassed = (screen.top >= element.bottom); 22564 element.topVisible = (screen.bottom >= element.top) && !element.bottomPassed; 22565 element.bottomVisible = (screen.bottom >= element.bottom) && !element.topPassed; 22566 element.pixelsPassed = 0; 22567 element.percentagePassed = 0; 22568 22569 // meta calculations 22570 element.onScreen = (element.topVisible && !element.bottomPassed); 22571 element.passing = (element.topPassed && !element.bottomPassed); 22572 element.offScreen = (!element.onScreen); 22573 22574 // passing calculations 22575 if(element.passing) { 22576 element.pixelsPassed = (screen.top - element.top); 22577 element.percentagePassed = (screen.top - element.top) / element.height; 22578 } 22579 module.cache.element = element; 22580 module.verbose('Updated element calculations', element); 22581 return element; 22582 }, 22583 screenCalculations: function() { 22584 var 22585 scroll = module.get.scroll() 22586 ; 22587 module.save.direction(); 22588 module.cache.screen.top = scroll; 22589 module.cache.screen.bottom = scroll + module.cache.screen.height; 22590 return module.cache.screen; 22591 }, 22592 screenSize: function() { 22593 module.verbose('Saving window position'); 22594 module.cache.screen = { 22595 height: $context.height() 22596 }; 22597 }, 22598 position: function() { 22599 module.save.screenSize(); 22600 module.save.elementPosition(); 22601 } 22602 }, 22603 22604 get: { 22605 pixelsPassed: function(amount) { 22606 var 22607 element = module.get.elementCalculations() 22608 ; 22609 if(amount.search('%') > -1) { 22610 return ( element.height * (parseInt(amount, 10) / 100) ); 22611 } 22612 return parseInt(amount, 10); 22613 }, 22614 occurred: function(callback) { 22615 return (module.cache.occurred !== undefined) 22616 ? module.cache.occurred[callback] || false 22617 : false 22618 ; 22619 }, 22620 direction: function() { 22621 if(module.cache.direction === undefined) { 22622 module.save.direction(); 22623 } 22624 return module.cache.direction; 22625 }, 22626 elementPosition: function() { 22627 if(module.cache.element === undefined) { 22628 module.save.elementPosition(); 22629 } 22630 return module.cache.element; 22631 }, 22632 elementCalculations: function() { 22633 if(module.cache.element === undefined) { 22634 module.save.elementCalculations(); 22635 } 22636 return module.cache.element; 22637 }, 22638 screenCalculations: function() { 22639 if(module.cache.screen === undefined) { 22640 module.save.screenCalculations(); 22641 } 22642 return module.cache.screen; 22643 }, 22644 screenSize: function() { 22645 if(module.cache.screen === undefined) { 22646 module.save.screenSize(); 22647 } 22648 return module.cache.screen; 22649 }, 22650 scroll: function() { 22651 if(module.cache.scroll === undefined) { 22652 module.save.scroll(); 22653 } 22654 return module.cache.scroll; 22655 }, 22656 lastScroll: function() { 22657 if(module.cache.screen === undefined) { 22658 module.debug('First scroll event, no last scroll could be found'); 22659 return false;
vendor: 5,952 bytes, lines 22660-22778
22660 } 22661 return module.cache.screen.top; 22662 } 22663 }, 22664 22665 setting: function(name, value) { 22666 if( $.isPlainObject(name) ) { 22667 $.extend(true, settings, name); 22668 } 22669 else if(value !== undefined) { 22670 settings[name] = value; 22671 } 22672 else { 22673 return settings[name]; 22674 } 22675 }, 22676 internal: function(name, value) { 22677 if( $.isPlainObject(name) ) { 22678 $.extend(true, module, name); 22679 } 22680 else if(value !== undefined) { 22681 module[name] = value; 22682 } 22683 else { 22684 return module[name]; 22685 } 22686 }, 22687 debug: function() { 22688 if(!settings.silent && settings.debug) { 22689 if(settings.performance) { 22690 module.performance.log(arguments); 22691 } 22692 else { 22693 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 22694 module.debug.apply(console, arguments); 22695 } 22696 } 22697 }, 22698 verbose: function() { 22699 if(!settings.silent && settings.verbose && settings.debug) { 22700 if(settings.performance) { 22701 module.performance.log(arguments); 22702 } 22703 else { 22704 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 22705 module.verbose.apply(console, arguments); 22706 } 22707 } 22708 }, 22709 error: function() { 22710 if(!settings.silent) { 22711 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 22712 module.error.apply(console, arguments); 22713 } 22714 }, 22715 performance: { 22716 log: function(message) { 22717 var 22718 currentTime, 22719 executionTime, 22720 previousTime 22721 ; 22722 if(settings.performance) { 22723 currentTime = new Date().getTime(); 22724 previousTime = time || currentTime; 22725 executionTime = currentTime - previousTime; 22726 time = currentTime; 22727 performance.push({ 22728 'Name' : message[0], 22729 'Arguments' : [].slice.call(message, 1) || '', 22730 'Element' : element, 22731 'Execution Time' : executionTime 22732 }); 22733 } 22734 clearTimeout(module.performance.timer); 22735 module.performance.timer = setTimeout(module.performance.display, 500); 22736 }, 22737 display: function() { 22738 var 22739 title = settings.name + ':', 22740 totalTime = 0 22741 ; 22742 time = false; 22743 clearTimeout(module.performance.timer); 22744 $.each(performance, function(index, data) { 22745 totalTime += data['Execution Time']; 22746 }); 22747 title += ' ' + totalTime + 'ms'; 22748 if(moduleSelector) { 22749 title += ' \'' + moduleSelector + '\''; 22750 } 22751 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 22752 console.groupCollapsed(title); 22753 if(console.table) { 22754 console.table(performance); 22755 } 22756 else { 22757 $.each(performance, function(index, data) { 22758 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 22759 }); 22760 } 22761 console.groupEnd(); 22762 } 22763 performance = []; 22764 } 22765 }, 22766 invoke: function(query, passedArguments, context) { 22767 var 22768 object = instance, 22769 maxDepth, 22770 found, 22771 response 22772 ; 22773 passedArguments = passedArguments || queryArguments; 22774 context = element || context; 22775 if(typeof query == 'string' && object !== undefined) { 22776 query = query.split(/[\. ]/); 22777 maxDepth = query.length - 1; 22778 $.each(query, function(depth, value) {
vendor: 5,951 bytes, lines 22779-22945
22779 var camelCaseValue = (depth != maxDepth) 22780 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 22781 : query 22782 ; 22783 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 22784 object = object[camelCaseValue]; 22785 } 22786 else if( object[camelCaseValue] !== undefined ) { 22787 found = object[camelCaseValue]; 22788 return false; 22789 } 22790 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 22791 object = object[value]; 22792 } 22793 else if( object[value] !== undefined ) { 22794 found = object[value]; 22795 return false; 22796 } 22797 else { 22798 module.error(error.method, query); 22799 return false; 22800 } 22801 }); 22802 } 22803 if ( $.isFunction( found ) ) { 22804 response = found.apply(context, passedArguments); 22805 } 22806 else if(found !== undefined) { 22807 response = found; 22808 } 22809 if($.isArray(returnedValue)) { 22810 returnedValue.push(response); 22811 } 22812 else if(returnedValue !== undefined) { 22813 returnedValue = [returnedValue, response]; 22814 } 22815 else if(response !== undefined) { 22816 returnedValue = response; 22817 } 22818 return found; 22819 } 22820 }; 22821 22822 if(methodInvoked) { 22823 if(instance === undefined) { 22824 module.initialize(); 22825 } 22826 instance.save.scroll(); 22827 instance.save.calculations(); 22828 module.invoke(query); 22829 } 22830 else { 22831 if(instance !== undefined) { 22832 instance.invoke('destroy'); 22833 } 22834 module.initialize(); 22835 } 22836 }) 22837 ; 22838 22839 return (returnedValue !== undefined) 22840 ? returnedValue 22841 : this 22842 ; 22843 }; 22844 22845 $.fn.visibility.settings = { 22846 22847 name : 'Visibility', 22848 namespace : 'visibility', 22849 22850 debug : false, 22851 verbose : false, 22852 performance : true, 22853 22854 // whether to use mutation observers to follow changes 22855 observeChanges : true, 22856 22857 // check position immediately on init 22858 initialCheck : true, 22859 22860 // whether to refresh calculations after all page images load 22861 refreshOnLoad : true, 22862 22863 // whether to refresh calculations after page resize event 22864 refreshOnResize : true, 22865 22866 // should call callbacks on refresh event (resize, etc) 22867 checkOnRefresh : true, 22868 22869 // callback should only occur one time 22870 once : true, 22871 22872 // callback should fire continuously whe evaluates to true 22873 continuous : false, 22874 22875 // offset to use with scroll top 22876 offset : 0, 22877 22878 // whether to include margin in elements position 22879 includeMargin : false, 22880 22881 // scroll context for visibility checks 22882 context : window, 22883 22884 // visibility check delay in ms (defaults to animationFrame) 22885 throttle : false, 22886 22887 // special visibility type (image, fixed) 22888 type : false, 22889 22890 // z-index to use with visibility 'fixed' 22891 zIndex : '10', 22892 22893 // image only animation settings 22894 transition : 'fade in', 22895 duration : 1000, 22896 22897 // array of callbacks for percentage 22898 onPassed : {}, 22899 22900 // standard callbacks 22901 onOnScreen : false, 22902 onOffScreen : false, 22903 onPassing : false, 22904 onTopVisible : false, 22905 onBottomVisible : false, 22906 onTopPassed : false, 22907 onBottomPassed : false, 22908 22909 // reverse callbacks 22910 onPassingReverse : false, 22911 onTopVisibleReverse : false, 22912 onBottomVisibleReverse : false, 22913 onTopPassedReverse : false, 22914 onBottomPassedReverse : false, 22915 22916 // special callbacks for image 22917 onLoad : function() {}, 22918 onAllLoaded : function() {}, 22919 22920 // special callbacks for fixed position 22921 onFixed : function() {}, 22922 onUnfixed : function() {}, 22923 22924 // utility callbacks 22925 onUpdate : false, // disabled by default for performance 22926 onRefresh : function(){}, 22927 22928 metadata : { 22929 src: 'src' 22930 }, 22931 22932 className: { 22933 fixed : 'fixed', 22934 placeholder : 'placeholder', 22935 visible : 'visible' 22936 }, 22937 22938 error : { 22939 method : 'The method you called is not defined.', 22940 visible : 'Element is hidden, you must call refresh after element becomes visible' 22941 } 22942 22943 }; 22944 22945})( jQuery, window, document );
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.