1/** 2 * Accordion, jQuery Plugin 3 * 4 * This plugin provides an accordion with cookie support. 5 * 6 * Copyright (c) 2011 John Snyder (snyderplace.com) 7 * @license http://www.snyderplace.com/accordion/license.txt New BSD 8 * @version 1.1 9 */ 10(function($) { 11 $.fn.accordion = function(options) { 12 13 //firewalling 14 if (!this || this.length < 1) { 15 return this; 16 } 17 18 initialize(this, options); 19 20 }; 21 22 //create the initial accordion 23 function initialize(obj, options) { 24 25 //build main options before element iteration 26 var opts = $.extend({}, $.fn.accordion.defaults, options); 27 28 //store any opened default values to set cookie later 29 var opened = ''; 30 31 //iterate each matched object, bind, and open/close 32 obj.each(function() { 33 var $this = $(this); 34 saveOpts($this, opts); 35 36 //bind it to the event 37 if (opts.bind == 'mouseenter') { 38 $this.bind('mouseenter', function(e) { 39 e.preventDefault(); 40 toggle($this, opts); 41 }); 42 } 43 44 //bind it to the event 45 if (opts.bind == 'mouseover') { 46 $this.bind('mouseover',function(e) { 47 e.preventDefault(); 48 toggle($this, opts); 49 }); 50 } 51 52 //bind it to the event 53 if (opts.bind == 'click') { 54 $this.bind('click', function(e) { 55 e.preventDefault(); 56 toggle($this, opts); 57 }); 58 } 59 60 //bind it to the event 61 if (opts.bind == 'dblclick') { 62 $this.bind('dblclick', function(e) { 63 e.preventDefault(); 64 toggle($this, opts); 65 }); 66 } 67 68 //initialize the panels 69 //get the id for this element 70 id = $this.attr('id'); 71 72 //if not using cookies, open defaults 73 if (!useCookies(opts)) { 74 //close it if not defaulted to open 75 if (id != opts.defaultOpen) { 76 $this.addClass(opts.cssClose); 77 opts.loadClose($this, opts); 78 } else { //its a default open, open it 79 $this.addClass(opts.cssOpen); 80 opts.loadOpen($this, opts); 81 opened = id; 82 } 83 } else { //can use cookies, use them now 84 //has a cookie been set, this overrides default open 85 if (issetCookie(opts)) { 86 if (inCookie(id, opts) === false) { 87 $this.addClass(opts.cssClose); 88 opts.loadClose($this, opts); 89 } else { 90 $this.addClass(opts.cssOpen); 91 opts.loadOpen($this, opts); 92 opened = id; 93 } 94 } else { //a cookie hasn't been set open defaults 95 if (id != opts.defaultOpen) { 96 $this.addClass(opts.cssClose); 97 opts.loadClose($this, opts); 98 } else { //its a default open, open it 99 $this.addClass(opts.cssOpen); 100 opts.loadOpen($this, opts); 101 opened = id; 102 } 103 } 104 } 105 }); 106 107 //now that the loop is done, set the cookie 108 if (opened.length > 0 && useCookies(opts)) { 109 setCookie(opened, opts); 110 } else { //there are none open, set cookie 111 setCookie('', opts); 112 } 113 114 return obj; 115 }; 116 117 //load opts from object 118 function loadOpts($this) { 119 return $this.data('accordion-opts'); 120 } 121 122 //save opts into object 123 function saveOpts($this, opts) { 124 return $this.data('accordion-opts', opts); 125 } 126 127 //hides a accordion panel 128 function close(opts) { 129 opened = $(document).find('.' + opts.cssOpen); 130 $.each(opened, function() { 131 //give the proper class to the linked element 132 $(this).addClass(opts.cssClose).removeClass(opts.cssOpen); 133 opts.animateClose($(this), opts); 134 }); 135 } 136 137 //opens a accordion panel 138 function open($this, opts) { 139 close(opts); 140 //give the proper class to the linked element 141 $this.removeClass(opts.cssClose).addClass(opts.cssOpen); 142 143 //open the element 144 opts.animateOpen($this, opts); 145 146 //do cookies if plugin available 147 if (useCookies(opts)) { 148 // split the cookieOpen string by "," 149 id = $this.attr('id');
150 setCookie(id, opts); 151 } 152 } 153 154 //toggle a accordion on an event 155 function toggle($this, opts) { 156 // close the only open item 157 if ($this.hasClass(opts.cssOpen)) 158 { 159 close(opts); 160 //do cookies if plugin available 161 if (useCookies(opts)) { 162 // split the cookieOpen string by "," 163 setCookie('', opts); 164 } 165 return false; 166 } 167 close(opts); 168 //open a closed element 169 open($this, opts); 170 return false; 171 } 172 173 //use cookies? 174 function useCookies(opts) { 175 //return false if cookie plugin not present or if a cookie name is not provided 176 if (!$.cookie || opts.cookieName == '') { 177 return false; 178 } 179 180 //we can use cookies 181 return true; 182 } 183 184 //set a cookie 185 function setCookie(value, opts) 186 { 187 //can use the cookie plugin 188 if (!useCookies(opts)) { //no, quit here 189 return false; 190 } 191 192 //cookie plugin is available, lets set the cookie 193 $.cookie(opts.cookieName, value, opts.cookieOptions); 194 } 195 196 //check if a accordion is in the cookie 197 function inCookie(value, opts) 198 { 199 //can use the cookie plugin 200 if (!useCookies(opts)) { 201 return false; 202 } 203 204 //if its not there we don't need to remove from it 205 if (!issetCookie(opts)) { //quit here, don't have a cookie 206 return false; 207 } 208 209 //unescape it 210 cookie = unescape($.cookie(opts.cookieName)); 211 212 //is this value in the cookie arrray 213 if (cookie != value) { //no, quit here 214 return false; 215 } 216 217 return true; 218 } 219 220 //check if a cookie is set 221 function issetCookie(opts) 222 { 223 //can we use the cookie plugin 224 if (!useCookies(opts)) { //no, quit here 225 return false; 226 } 227 228 //is the cookie set 229 if ($.cookie(opts.cookieName) == null) { //no, quit here 230 return false; 231 } 232 233 return true; 234 } 235 236 // settings 237 $.fn.accordion.defaults = { 238 cssClose: 'accordion-close', //class you want to assign to a closed accordion header 239 cssOpen: 'accordion-open', //class you want to assign an opened accordion header 240 cookieName: 'accordion', //name of the cookie you want to set for this accordion 241 cookieOptions: { //cookie options, see cookie plugin for details 242 path: '/', 243 expires: 7, 244 domain: '', 245 secure: '' 246 }, 247 defaultOpen: '', //id that you want opened by default 248 speed: 'slow', //speed of the slide effect 249 bind: 'click', //event to bind to, supports click, dblclick, mouseover and mouseenter 250 animateOpen: function (elem, opts) { //replace the standard slideDown with custom function 251 elem.next().stop(true, true).slideDown(opts.speed); 252 }, 253 animateClose: function (elem, opts) { //replace the standard slideUp with custom function 254 elem.next().stop(true, true).slideUp(opts.speed); 255 }, 256 loadOpen: function (elem, opts) { //replace the default open state with custom function 257 elem.next().show(); 258 }, 259 loadClose: function (elem, opts) { //replace the default close state with custom function 260 elem.next().hide(); 261 } 262 }; 263})(jQuery); 264 265 266/** 267 * Accordion, jQuery Plugin 268 * 269 * This plugin provides an accordion with cookie support. 270 * 271 * Copyright (c) 2011 John Snyder (snyderplace.com) 272 * @license http://www.snyderplace.com/accordion/license.txt New BSD 273 * @version 1.1 274 */ 275(function($) { 276 $.fn.accordion2 = function(options) { 277 278 //firewalling 279 if (!this || this.length < 1) { 280 return this; 281 } 282 283 initialize(this, options); 284 285 }; 286 287 //create the initial accordion 288 function initialize(obj, options) { 289 290 //build main options before element iteration 291 var opts = $.extend({}, $.fn.accordion2.defaults, options); 292 293 //store any opened default values to set cookie later 294 var opened = ''; 295 296 //iterate each matched object, bind, and open/close 297 obj.each(function() { 298 var $this = $(this); 299 saveOpts($this, opts); 300 301 //bind it to the event 302 if (opts.bind == 'mouseenter') { 303 $this.bind('mouseenter', function(e) { 304 e.preventDefault(); 305 toggle($this, opts); 306 }); 307 } 308 309 //bind it to the event 310 if (opts.bind == 'mouseover') { 311 $this.bind('mouseover',function(e) { 312 e.preventDefault(); 313 toggle($this, opts); 314 }); 315 } 316 317 //bind it to the event 318 if (opts.bind == 'click') { 319 $this.bind('click', function(e) { 320 e.preventDefault(); 321 toggle($this, opts); 322 }); 323 } 324 325 //bind it to the event 326 if (opts.bind == 'dblclick') { 327 $this.bind('dblclick', function(e) { 328 e.preventDefault(); 329 toggle($this, opts); 330 }); 331 } 332 333 //initialize the panels 334 //get the id for this element 335 id = $this.attr('id'); 336 337 //if not using cookies, open defaults 338 if (!useCookies(opts)) { 339 //close it if not defaulted to open 340 if (id != opts.defaultOpen) { 341 $this.addClass(opts.cssClose); 342 opts.loadClose($this, opts); 343 } else { //its a default open, open it 344 $this.addClass(opts.cssOpen); 345 opts.loadOpen($this, opts); 346 opened = id; 347 } 348 } else { //can use cookies, use them now 349 //has a cookie been set, this overrides default open 350 if (issetCookie(opts)) { 351 if (inCookie(id, opts) === false) { 352 $this.addClass(opts.cssClose); 353 opts.loadClose($this, opts); 354 } else { 355 $this.addClass(opts.cssOpen); 356 opts.loadOpen($this, opts); 357 opened = id; 358 } 359 } else { //a cookie hasn't been set open defaults 360 if (id != opts.defaultOpen) { 361 $this.addClass(opts.cssClose); 362 opts.loadClose($this, opts); 363 } else { //its a default open, open it 364 $this.addClass(opts.cssOpen); 365 opts.loadOpen($this, opts); 366 opened = id; 367 } 368 } 369 } 370 }); 371 372 //now that the loop is done, set the cookie 373 if (opened.length > 0 && useCookies(opts)) {
374 setCookie(opened, opts); 375 } else { //there are none open, set cookie 376 setCookie('', opts); 377 } 378 379 return obj; 380 }; 381 382 //load opts from object 383 function loadOpts($this) { 384 return $this.data('accordion2-opts'); 385 } 386 387 //save opts into object 388 function saveOpts($this, opts) { 389 return $this.data('accordion2-opts', opts); 390 } 391 392 //hides a accordion panel 393 function close(opts) { 394 opened = $(document).find('.' + opts.cssOpen); 395 $.each(opened, function() { 396 //give the proper class to the linked element 397 $(this).addClass(opts.cssClose).removeClass(opts.cssOpen); 398 opts.animateClose($(this), opts); 399 }); 400 } 401 402 //opens a accordion panel 403 function open($this, opts) { 404 close(opts); 405 //give the proper class to the linked element 406 $this.removeClass(opts.cssClose).addClass(opts.cssOpen); 407 408 //open the element 409 opts.animateOpen($this, opts); 410 411 //do cookies if plugin available 412 if (useCookies(opts)) { 413 // split the cookieOpen string by "," 414 id = $this.attr('id'); 415 setCookie(id, opts); 416 } 417 } 418 419 //toggle a accordion on an event 420 function toggle($this, opts) { 421 // close the only open item 422 if ($this.hasClass(opts.cssOpen)) 423 { 424 close(opts); 425 //do cookies if plugin available 426 if (useCookies(opts)) { 427 // split the cookieOpen string by "," 428 setCookie('', opts); 429 } 430 return false; 431 } 432 close(opts); 433 //open a closed element 434 open($this, opts); 435 return false; 436 } 437 438 //use cookies? 439 function useCookies(opts) { 440 //return false if cookie plugin not present or if a cookie name is not provided 441 if (!$.cookie || opts.cookieName == '') { 442 return false; 443 } 444 445 //we can use cookies 446 return true; 447 } 448 449 //set a cookie 450 function setCookie(value, opts) 451 { 452 //can use the cookie plugin 453 if (!useCookies(opts)) { //no, quit here 454 return false; 455 } 456 457 //cookie plugin is available, lets set the cookie 458 $.cookie(opts.cookieName, value, opts.cookieOptions); 459 } 460 461 //check if a accordion is in the cookie 462 function inCookie(value, opts) 463 { 464 //can use the cookie plugin 465 if (!useCookies(opts)) { 466 return false; 467 } 468 469 //if its not there we don't need to remove from it 470 if (!issetCookie(opts)) { //quit here, don't have a cookie 471 return false; 472 } 473 474 //unescape it 475 cookie = unescape($.cookie(opts.cookieName)); 476 477 //is this value in the cookie arrray 478 if (cookie != value) { //no, quit here 479 return false; 480 } 481 482 return true; 483 } 484 485 //check if a cookie is set 486 function issetCookie(opts) 487 { 488 //can we use the cookie plugin 489 if (!useCookies(opts)) { //no, quit here 490 return false; 491 } 492 493 //is the cookie set 494 if ($.cookie(opts.cookieName) == null) { //no, quit here 495 return false; 496 } 497 498 return true; 499 } 500 501 // settings 502 $.fn.accordion2.defaults = { 503 cssClose: 'accordion2-close', //class you want to assign to a closed accordion header 504 cssOpen: 'accordion2-open', //class you want to assign an opened accordion header 505 cookieName: 'accordion2', //name of the cookie you want to set for this accordion 506 cookieOptions: { //cookie options, see cookie plugin for details 507 path: '/', 508 expires: 7, 509 domain: '', 510 secure: '' 511 }, 512 defaultOpen: '', //id that you want opened by default 513 speed: 'slow', //speed of the slide effect 514 bind: 'click', //event to bind to, supports click, dblclick, mouseover and mouseenter 515 animateOpen: function (elem, opts) { //replace the standard slideDown with custom function 516 elem.next().stop(true, true).slideDown(opts.speed); 517 }, 518 animateClose: function (elem, opts) { //replace the standard slideUp with custom function
519 elem.next().stop(true, true).slideUp(opts.speed); 520 }, 521 loadOpen: function (elem, opts) { //replace the default open state with custom function 522 elem.next().show(); 523 }, 524 loadClose: function (elem, opts) { //replace the default close state with custom function 525 elem.next().hide(); 526 } 527 }; 528})(jQuery); 529 530 531/** 532 * Accordion, jQuery Plugin 533 * 534 * This plugin provides an accordion with cookie support. 535 * 536 * Copyright (c) 2011 John Snyder (snyderplace.com) 537 * @license http://www.snyderplace.com/accordion/license.txt New BSD 538 * @version 1.1 539 */ 540(function($) { 541 $.fn.accordion3 = function(options) { 542 543 //firewalling 544 if (!this || this.length < 1) { 545 return this; 546 } 547 548 initialize(this, options); 549 550 }; 551 552 //create the initial accordion 553 function initialize(obj, options) { 554 555 //build main options before element iteration 556 var opts = $.extend({}, $.fn.accordion3.defaults, options); 557 558 //store any opened default values to set cookie later 559 var opened = ''; 560 561 //iterate each matched object, bind, and open/close 562 obj.each(function() { 563 var $this = $(this); 564 saveOpts($this, opts); 565 566 //bind it to the event 567 if (opts.bind == 'mouseenter') { 568 $this.bind('mouseenter', function(e) { 569 e.preventDefault(); 570 toggle($this, opts); 571 }); 572 } 573 574 //bind it to the event 575 if (opts.bind == 'mouseover') { 576 $this.bind('mouseover',function(e) { 577 e.preventDefault(); 578 toggle($this, opts); 579 }); 580 } 581 582 //bind it to the event 583 if (opts.bind == 'click') { 584 $this.bind('click', function(e) { 585 e.preventDefault(); 586 toggle($this, opts); 587 }); 588 } 589 590 //bind it to the event 591 if (opts.bind == 'dblclick') { 592 $this.bind('dblclick', function(e) { 593 e.preventDefault(); 594 toggle($this, opts); 595 }); 596 } 597 598 //initialize the panels 599 //get the id for this element 600 id = $this.attr('id'); 601 602 //if not using cookies, open defaults 603 if (!useCookies(opts)) { 604 //close it if not defaulted to open 605 if (id != opts.defaultOpen) { 606 $this.addClass(opts.cssClose); 607 opts.loadClose($this, opts); 608 } else { //its a default open, open it 609 $this.addClass(opts.cssOpen); 610 opts.loadOpen($this, opts); 611 opened = id; 612 } 613 } else { //can use cookies, use them now 614 //has a cookie been set, this overrides default open 615 if (issetCookie(opts)) { 616 if (inCookie(id, opts) === false) { 617 $this.addClass(opts.cssClose); 618 opts.loadClose($this, opts); 619 } else { 620 $this.addClass(opts.cssOpen); 621 opts.loadOpen($this, opts); 622 opened = id; 623 } 624 } else { //a cookie hasn't been set open defaults 625 if (id != opts.defaultOpen) { 626 $this.addClass(opts.cssClose); 627 opts.loadClose($this, opts); 628 } else { //its a default open, open it 629 $this.addClass(opts.cssOpen); 630 opts.loadOpen($this, opts); 631 opened = id; 632 } 633 } 634 } 635 }); 636 637 //now that the loop is done, set the cookie 638 if (opened.length > 0 && useCookies(opts)) { 639 setCookie(opened, opts); 640 } else { //there are none open, set cookie 641 setCookie('', opts); 642 } 643 644 return obj; 645 }; 646 647 //load opts from object 648 function loadOpts($this) { 649 return $this.data('accordion3-opts'); 650 } 651 652 //save opts into object 653 function saveOpts($this, opts) { 654 return $this.data('accordion3-opts', opts); 655 } 656 657 //hides a accordion panel 658 function close(opts) { 659 opened = $(document).find('.' + opts.cssOpen); 660 $.each(opened, function() { 661 //give the proper class to the linked element 662 $(this).addClass(opts.cssClose).removeClass(opts.cssOpen); 663 opts.animateClose($(this), opts); 664 }); 665 } 666 667 //opens a accordion panel 668 function open($this, opts) { 669 close(opts); 670 //give the proper class to the linked element 671 $this.removeClass(opts.cssClose).addClass(opts.cssOpen); 672 673 //open the element 674 opts.animateOpen($this, opts); 675 676 //do cookies if plugin available 677 if (useCookies(opts)) { 678 // split the cookieOpen string by "," 679 id = $this.attr('id');
680 setCookie(id, opts); 681 } 682 } 683 684 //toggle a accordion on an event 685 function toggle($this, opts) { 686 // close the only open item 687 if ($this.hasClass(opts.cssOpen)) 688 { 689 close(opts); 690 //do cookies if plugin available 691 if (useCookies(opts)) { 692 // split the cookieOpen string by "," 693 setCookie('', opts); 694 } 695 return false; 696 } 697 close(opts); 698 //open a closed element 699 open($this, opts); 700 return false; 701 } 702 703 //use cookies? 704 function useCookies(opts) { 705 //return false if cookie plugin not present or if a cookie name is not provided 706 if (!$.cookie || opts.cookieName == '') { 707 return false; 708 } 709 710 //we can use cookies 711 return true; 712 } 713 714 //set a cookie 715 function setCookie(value, opts) 716 { 717 //can use the cookie plugin 718 if (!useCookies(opts)) { //no, quit here 719 return false; 720 } 721 722 //cookie plugin is available, lets set the cookie 723 $.cookie(opts.cookieName, value, opts.cookieOptions); 724 } 725 726 //check if a accordion is in the cookie 727 function inCookie(value, opts) 728 { 729 //can use the cookie plugin 730 if (!useCookies(opts)) { 731 return false; 732 } 733 734 //if its not there we don't need to remove from it 735 if (!issetCookie(opts)) { //quit here, don't have a cookie 736 return false; 737 } 738 739 //unescape it 740 cookie = unescape($.cookie(opts.cookieName)); 741 742 //is this value in the cookie arrray 743 if (cookie != value) { //no, quit here 744 return false; 745 } 746 747 return true; 748 } 749 750 //check if a cookie is set 751 function issetCookie(opts) 752 { 753 //can we use the cookie plugin 754 if (!useCookies(opts)) { //no, quit here 755 return false; 756 } 757 758 //is the cookie set 759 if ($.cookie(opts.cookieName) == null) { //no, quit here 760 return false; 761 } 762 763 return true; 764 } 765 766 // settings 767 $.fn.accordion3.defaults = { 768 cssClose: 'accordion3-close', //class you want to assign to a closed accordion header 769 cssOpen: 'accordion3-open', //class you want to assign an opened accordion header 770 cookieName: 'accordion3', //name of the cookie you want to set for this accordion 771 cookieOptions: { //cookie options, see cookie plugin for details 772 path: '/', 773 expires: 7, 774 domain: '', 775 secure: '' 776 }, 777 defaultOpen: '', //id that you want opened by default 778 speed: 'slow', //speed of the slide effect 779 bind: 'click', //event to bind to, supports click, dblclick, mouseover and mouseenter 780 animateOpen: function (elem, opts) { //replace the standard slideDown with custom function 781 elem.next().stop(true, true).slideDown(opts.speed); 782 }, 783 animateClose: function (elem, opts) { //replace the standard slideUp with custom function 784 elem.next().stop(true, true).slideUp(opts.speed); 785 }, 786 loadOpen: function (elem, opts) { //replace the default open state with custom function 787 elem.next().show(); 788 }, 789 loadClose: function (elem, opts) { //replace the default close state with custom function 790 elem.next().hide(); 791 } 792 }; 793})(jQuery);
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.