vendor: 19,990 bytes, lines 1-610
1/*! 2 * # Semantic UI 2.2.10 - Accordion 3 * http://github.com/semantic-org/semantic-ui/ 4 * 5 * 6 * Released under the MIT license 7 * http://opensource.org/licenses/MIT 8 * 9 */ 10 11;(function ($, window, document, undefined) { 12 13"use strict"; 14 15window = (typeof window != 'undefined' && window.Math == Math) 16 ? window 17 : (typeof self != 'undefined' && self.Math == Math) 18 ? self 19 : Function('return this')() 20; 21 22$.fn.accordion = function(parameters) { 23 var 24 $allModules = $(this), 25 26 time = new Date().getTime(), 27 performance = [], 28 29 query = arguments[0], 30 methodInvoked = (typeof query == 'string'), 31 queryArguments = [].slice.call(arguments, 1), 32 33 requestAnimationFrame = window.requestAnimationFrame 34 || window.mozRequestAnimationFrame 35 || window.webkitRequestAnimationFrame 36 || window.msRequestAnimationFrame 37 || function(callback) { setTimeout(callback, 0); }, 38 39 returnedValue 40 ; 41 $allModules 42 .each(function() { 43 var 44 settings = ( $.isPlainObject(parameters) ) 45 ? $.extend(true, {}, $.fn.accordion.settings, parameters) 46 : $.extend({}, $.fn.accordion.settings), 47 48 className = settings.className, 49 namespace = settings.namespace, 50 selector = settings.selector, 51 error = settings.error, 52 53 eventNamespace = '.' + namespace, 54 moduleNamespace = 'module-' + namespace, 55 moduleSelector = $allModules.selector || '', 56 57 $module = $(this), 58 $title = $module.find(selector.title), 59 $content = $module.find(selector.content), 60 61 element = this, 62 instance = $module.data(moduleNamespace), 63 observer, 64 module 65 ; 66 67 module = { 68 69 initialize: function() { 70 module.debug('Initializing', $module); 71 module.bind.events(); 72 if(settings.observeChanges) { 73 module.observeChanges(); 74 } 75 module.instantiate(); 76 }, 77 78 instantiate: function() { 79 instance = module; 80 $module 81 .data(moduleNamespace, module) 82 ; 83 }, 84 85 destroy: function() { 86 module.debug('Destroying previous instance', $module); 87 $module 88 .off(eventNamespace) 89 .removeData(moduleNamespace) 90 ; 91 }, 92 93 refresh: function() { 94 $title = $module.find(selector.title); 95 $content = $module.find(selector.content); 96 }, 97 98 observeChanges: function() { 99 if('MutationObserver' in window) { 100 observer = new MutationObserver(function(mutations) { 101 module.debug('DOM tree modified, updating selector cache'); 102 module.refresh(); 103 }); 104 observer.observe(element, { 105 childList : true, 106 subtree : true 107 }); 108 module.debug('Setting up mutation observer', observer); 109 } 110 }, 111 112 bind: { 113 events: function() { 114 module.debug('Binding delegated events'); 115 $module 116 .on(settings.on + eventNamespace, selector.trigger, module.event.click) 117 ; 118 } 119 }, 120 121 event: { 122 click: function() { 123 module.toggle.call(this); 124 } 125 }, 126 127 toggle: function(query) { 128 var 129 $activeTitle = (query !== undefined) 130 ? (typeof query === 'number') 131 ? $title.eq(query) 132 : $(query).closest(selector.title) 133 : $(this).closest(selector.title), 134 $activeContent = $activeTitle.next($content), 135 isAnimating = $activeContent.hasClass(className.animating), 136 isActive = $activeContent.hasClass(className.active), 137 isOpen = (isActive && !isAnimating), 138 isOpening = (!isActive && isAnimating) 139 ; 140 module.debug('Toggling visibility of content', $activeTitle); 141 if(isOpen || isOpening) { 142 if(settings.collapsible) { 143 module.close.call($activeTitle); 144 } 145 else { 146 module.debug('Cannot close accordion content collapsing is disabled'); 147 } 148 } 149 else { 150 module.open.call($activeTitle); 151 } 152 }, 153 154 open: function(query) { 155 var 156 $activeTitle = (query !== undefined) 157 ? (typeof query === 'number') 158 ? $title.eq(query) 159 : $(query).closest(selector.title) 160 : $(this).closest(selector.title), 161 $activeContent = $activeTitle.next($content), 162 isAnimating = $activeContent.hasClass(className.animating), 163 isActive = $activeContent.hasClass(className.active), 164 isOpen = (isActive || isAnimating) 165 ; 166 if(isOpen) { 167 module.debug('Accordion already open, skipping', $activeContent); 168 return; 169 } 170 module.debug('Opening accordion content', $activeTitle); 171 settings.onOpening.call($activeContent); 172 if(settings.exclusive) { 173 module.closeOthers.call($activeTitle); 174 } 175 $activeTitle 176 .addClass(className.active) 177 ; 178 $activeContent 179 .stop(true, true) 180 .addClass(className.animating) 181 ; 182 if(settings.animateChildren) { 183 if($.fn.transition !== undefined && $module.transition('is supported')) { 184 $activeContent 185 .children() 186 .transition({ 187 animation : 'fade in', 188 queue : false, 189 useFailSafe : true, 190 debug : settings.debug, 191 verbose : settings.verbose, 192 duration : settings.duration 193 }) 194 ; 195 } 196 else { 197 $activeContent 198 .children() 199 .stop(true, true) 200 .animate({ 201 opacity: 1 202 }, settings.duration, module.resetOpacity) 203 ; 204 } 205 } 206 $activeContent 207 .slideDown(settings.duration, settings.easing, function() { 208 $activeContent 209 .removeClass(className.animating) 210 .addClass(className.active) 211 ; 212 module.reset.display.call(this); 213 settings.onOpen.call(this); 214 settings.onChange.call(this); 215 }) 216 ; 217 }, 218 219 close: function(query) { 220 var 221 $activeTitle = (query !== undefined) 222 ? (typeof query === 'number') 223 ? $title.eq(query) 224 : $(query).closest(selector.title) 225 : $(this).closest(selector.title), 226 $activeContent = $activeTitle.next($content), 227 isAnimating = $activeContent.hasClass(className.animating), 228 isActive = $activeContent.hasClass(className.active), 229 isOpening = (!isActive && isAnimating), 230 isClosing = (isActive && isAnimating) 231 ; 232 if((isActive || isOpening) && !isClosing) { 233 module.debug('Closing accordion content', $activeContent); 234 settings.onClosing.call($activeContent); 235 $activeTitle 236 .removeClass(className.active) 237 ; 238 $activeContent 239 .stop(true, true) 240 .addClass(className.animating) 241 ; 242 if(settings.animateChildren) { 243 if($.fn.transition !== undefined && $module.transition('is supported')) { 244 $activeContent 245 .children() 246 .transition({ 247 animation : 'fade out', 248 queue : false, 249 useFailSafe : true, 250 debug : settings.debug, 251 verbose : settings.verbose, 252 duration : settings.duration 253 }) 254 ; 255 } 256 else { 257 $activeContent 258 .children() 259 .stop(true, true) 260 .animate({ 261 opacity: 0 262 }, settings.duration, module.resetOpacity) 263 ; 264 } 265 } 266 $activeContent 267 .slideUp(settings.duration, settings.easing, function() { 268 $activeContent 269 .removeClass(className.animating) 270 .removeClass(className.active) 271 ; 272 module.reset.display.call(this); 273 settings.onClose.call(this); 274 settings.onChange.call(this); 275 }) 276 ; 277 } 278 }, 279 280 closeOthers: function(index) { 281 var 282 $activeTitle = (index !== undefined) 283 ? $title.eq(index) 284 : $(this).closest(selector.title), 285 $parentTitles = $activeTitle.parents(selector.content).prev(selector.title), 286 $activeAccordion = $activeTitle.closest(selector.accordion), 287 activeSelector = selector.title + '.' + className.active + ':visible', 288 activeContent = selector.content + '.' + className.active + ':visible', 289 $openTitles, 290 $nestedTitles, 291 $openContents 292 ; 293 if(settings.closeNested) { 294 $openTitles = $activeAccordion.find(activeSelector).not($parentTitles); 295 $openContents = $openTitles.next($content); 296 } 297 else { 298 $openTitles = $activeAccordion.find(activeSelector).not($parentTitles); 299 $nestedTitles = $activeAccordion.find(activeContent).find(activeSelector).not($parentTitles); 300 $openTitles = $openTitles.not($nestedTitles); 301 $openContents = $openTitles.next($content); 302 } 303 if( ($openTitles.length > 0) ) { 304 module.debug('Exclusive enabled, closing other content', $openTitles); 305 $openTitles 306 .removeClass(className.active) 307 ; 308 $openContents 309 .removeClass(className.animating) 310 .stop(true, true) 311 ; 312 if(settings.animateChildren) { 313 if($.fn.transition !== undefined && $module.transition('is supported')) { 314 $openContents 315 .children() 316 .transition({ 317 animation : 'fade out', 318 useFailSafe : true, 319 debug : settings.debug, 320 verbose : settings.verbose, 321 duration : settings.duration 322 }) 323 ; 324 } 325 else { 326 $openContents 327 .children() 328 .stop(true, true) 329 .animate({ 330 opacity: 0 331 }, settings.duration, module.resetOpacity) 332 ; 333 } 334 } 335 $openContents 336 .slideUp(settings.duration , settings.easing, function() { 337 $(this).removeClass(className.active); 338 module.reset.display.call(this); 339 }) 340 ; 341 } 342 }, 343 344 reset: { 345 346 display: function() { 347 module.verbose('Removing inline display from element', this); 348 $(this).css('display', ''); 349 if( $(this).attr('style') === '') { 350 $(this) 351 .attr('style', '') 352 .removeAttr('style') 353 ; 354 } 355 }, 356 357 opacity: function() { 358 module.verbose('Removing inline opacity from element', this); 359 $(this).css('opacity', ''); 360 if( $(this).attr('style') === '') { 361 $(this) 362 .attr('style', '') 363 .removeAttr('style') 364 ; 365 } 366 }, 367 368 }, 369 370 setting: function(name, value) { 371 module.debug('Changing setting', name, value); 372 if( $.isPlainObject(name) ) { 373 $.extend(true, settings, name); 374 } 375 else if(value !== undefined) { 376 if($.isPlainObject(settings[name])) { 377 $.extend(true, settings[name], value); 378 } 379 else { 380 settings[name] = value; 381 } 382 } 383 else { 384 return settings[name]; 385 } 386 }, 387 internal: function(name, value) { 388 module.debug('Changing internal', name, value); 389 if(value !== undefined) { 390 if( $.isPlainObject(name) ) { 391 $.extend(true, module, name); 392 } 393 else { 394 module[name] = value; 395 } 396 } 397 else { 398 return module[name]; 399 } 400 }, 401 debug: function() { 402 if(!settings.silent && settings.debug) { 403 if(settings.performance) { 404 module.performance.log(arguments); 405 } 406 else { 407 module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); 408 module.debug.apply(console, arguments); 409 } 410 } 411 }, 412 verbose: function() { 413 if(!settings.silent && settings.verbose && settings.debug) { 414 if(settings.performance) { 415 module.performance.log(arguments); 416 } 417 else { 418 module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); 419 module.verbose.apply(console, arguments); 420 } 421 } 422 }, 423 error: function() { 424 if(!settings.silent) { 425 module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); 426 module.error.apply(console, arguments); 427 } 428 }, 429 performance: { 430 log: function(message) { 431 var 432 currentTime, 433 executionTime, 434 previousTime 435 ; 436 if(settings.performance) { 437 currentTime = new Date().getTime(); 438 previousTime = time || currentTime; 439 executionTime = currentTime - previousTime; 440 time = currentTime; 441 performance.push({ 442 'Name' : message[0], 443 'Arguments' : [].slice.call(message, 1) || '', 444 'Element' : element, 445 'Execution Time' : executionTime 446 }); 447 } 448 clearTimeout(module.performance.timer); 449 module.performance.timer = setTimeout(module.performance.display, 500); 450 }, 451 display: function() { 452 var 453 title = settings.name + ':', 454 totalTime = 0 455 ; 456 time = false; 457 clearTimeout(module.performance.timer); 458 $.each(performance, function(index, data) { 459 totalTime += data['Execution Time']; 460 }); 461 title += ' ' + totalTime + 'ms'; 462 if(moduleSelector) { 463 title += ' \'' + moduleSelector + '\''; 464 } 465 if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { 466 console.groupCollapsed(title); 467 if(console.table) { 468 console.table(performance); 469 } 470 else { 471 $.each(performance, function(index, data) { 472 console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); 473 }); 474 } 475 console.groupEnd(); 476 } 477 performance = []; 478 } 479 }, 480 invoke: function(query, passedArguments, context) { 481 var 482 object = instance, 483 maxDepth, 484 found, 485 response 486 ; 487 passedArguments = passedArguments || queryArguments; 488 context = element || context; 489 if(typeof query == 'string' && object !== undefined) { 490 query = query.split(/[\. ]/); 491 maxDepth = query.length - 1; 492 $.each(query, function(depth, value) { 493 var camelCaseValue = (depth != maxDepth) 494 ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) 495 : query 496 ; 497 if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { 498 object = object[camelCaseValue]; 499 } 500 else if( object[camelCaseValue] !== undefined ) { 501 found = object[camelCaseValue]; 502 return false; 503 } 504 else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { 505 object = object[value]; 506 } 507 else if( object[value] !== undefined ) { 508 found = object[value]; 509 return false; 510 } 511 else { 512 module.error(error.method, query); 513 return false; 514 } 515 }); 516 } 517 if ( $.isFunction( found ) ) { 518 response = found.apply(context, passedArguments); 519 } 520 else if(found !== undefined) { 521 response = found; 522 } 523 if($.isArray(returnedValue)) { 524 returnedValue.push(response); 525 } 526 else if(returnedValue !== undefined) { 527 returnedValue = [returnedValue, response]; 528 } 529 else if(response !== undefined) { 530 returnedValue = response; 531 } 532 return found; 533 } 534 }; 535 if(methodInvoked) { 536 if(instance === undefined) { 537 module.initialize(); 538 } 539 module.invoke(query); 540 } 541 else { 542 if(instance !== undefined) { 543 instance.invoke('destroy'); 544 } 545 module.initialize(); 546 } 547 }) 548 ; 549 return (returnedValue !== undefined) 550 ? returnedValue 551 : this 552 ; 553}; 554 555$.fn.accordion.settings = { 556 557 name : 'Accordion', 558 namespace : 'accordion', 559 560 silent : false, 561 debug : false, 562 verbose : false, 563 performance : true, 564 565 on : 'click', // event on title that opens accordion 566 567 observeChanges : true, // whether accordion should automatically refresh on DOM insertion 568 569 exclusive : true, // whether a single accordion content panel should be open at once 570 collapsible : true, // whether accordion content can be closed 571 closeNested : false, // whether nested content should be closed when a panel is closed 572 animateChildren : true, // whether children opacity should be animated 573 574 duration : 350, // duration of animation 575 easing : 'easeOutQuad', // easing equation for animation 576 577 578 onOpening : function(){}, // callback before open animation 579 onOpen : function(){}, // callback after open animation 580 onClosing : function(){}, // callback before closing animation 581 onClose : function(){}, // callback after closing animation 582 onChange : function(){}, // callback after closing or opening animation 583 584 error: { 585 method : 'The method you called is not defined' 586 }, 587 588 className : { 589 active : 'active', 590 animating : 'animating' 591 }, 592 593 selector : { 594 accordion : '.accordion', 595 title : '.title', 596 trigger : '.title', 597 content : '.content' 598 } 599 600}; 601 602// Adds easing 603$.extend( $.easing, { 604 easeOutQuad: function (x, t, b, c, d) { 605 return -c *(t/=d)*(t-2) + b; 606 } 607}); 608 609})( jQuery, window, document ); 610
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.