1/* 2 * jQuery styleSwitcher Plugin 3 * Examples and documentation at: 4 * http://www.immortalwolf.com/demo/jquery-style-switcher/ 5 * Copyright (c) 2011 immortal wolf 6 * Version: 1.4 (27-JAN-2011) 7 * Dual licensed under the MIT and GPL licenses. 8 * http://en.wikipedia.org/wiki/Gpl 9 * http://en.wikipedia.org/wiki/MIT_License 10 * Requires: jQuery v1.2.6 or later 11 * 12 * @version 1.4 changelog: 13 * - added cookie support 14 * - allow usage of either JavaScript or PHP for 15 * cookie management via jQuery config options 16 */ 17 18(function($) { 19 $.fn.styleSwitcher = function(options){ 20 var defaults = { 21 slidein: true, preview: false, container: this.selector, directory: "css/", useCookie: true, cookieExpires: 30, manageCookieLoad:true 22 }; 23 var opts = $.extend(defaults, options); 24 // if using cookies and using JavaScript to load css 25 if (opts.useCookie && opts.manageCookieLoad) { 26 // check if css is set in cookie 27 var isCookie = readCookie("style_selected") 28 if(isCookie){ 29 var newStyle = opts.directory + isCookie + ".css"; 30 $("link[id=theme]").attr("href",newStyle); 31 baseStyle = newStyle; 32 } 33 else{ 34 35 } 36 } 37 // if using slidein 38 if(opts.slidein){ 39 $(opts.container).slideDown("slow"); 40 } 41 else{ 42 $(opts.container).show(); 43 } 44 var baseStyle = $("link[id=theme]").attr("href"); 45 if(opts.preview){ 46 $(opts.container + " a").hover( 47 function () { 48 var newStyle = opts.directory + this.id + ".css"; 49 $("link[id=theme]").attr("href",newStyle); 50 }, 51 function () { 52 $("link[id=theme]").attr("href",baseStyle); 53 } 54 ); 55 } 56 57 $(opts.container + " a").click( 58 function () { 59 var newStyle = opts.directory + this.id + ".css"; 60 $("link[id=theme]").attr("href",newStyle); 61 baseStyle = newStyle; 62 if(opts.useCookie){ 63 createCookie("style_selected",this.id,opts.cookieExpires) 64 } 65 } 66 ); 67 68 }; 69 function createCookie(name,value,days) { 70 if (days) { 71 var date = new Date(); 72 date.setTime(date.getTime()+(days*24*60*60*1000)); 73 var expires = "; expires="+date.toGMTString(); 74 } 75 else var expires = ""; 76 document.cookie = name+"="+value+expires+"; path=/"; 77 } 78 function readCookie(name) { 79 var nameEQ = name + "="; 80 var ca = document.cookie.split(';'); 81 for(var i=0;i < ca.length;i++) { 82 var c = ca[i]; 83 while (c.charAt(0)==' ') c = c.substring(1,c.length); 84 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 85 } 86 return null; 87 } 88 function eraseCookie(name) { 89 createCookie(name,"",-1); 90 } 91})(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.