1/*-------------------------------------------------------------------- 2 * Copyright (c) 2009 Vision Master Designs 3 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) 4 5 * JQuery Plugin : "Switch Stylesheet" 6 * Author : Michael (http://www.visionmasterdesigns.com) 7 * Version : 1.0 8 * Description : Based on the superb stylesheet switcher plugin by By Kelvin Luck ( http://www.kelvinluck.com/ ). 9 Can create multiple groups of alternate stylesheets to change 10 11Ex : 12Alternate Stylesheets : 13<!-- alternate css for colors --> 14<link href="green.css" type="text/css" rel="alternate stylesheet" title="green-color" /> 15<link href="blue.css" type="text/css" rel="alternate stylesheet" title="blue-color" /> 16 17JS Code : 18<script type="text/javascript"> 19$(document).ready(function(){ 20 $(".changecolor").switchstylesheet( { seperator:"color"} ); 21}); 22</script> 23 24Usage : 25<a href="#" class="changecolor" title="red-color">Red</a> | 26<a href="#" class="changecolor" title="green-color">Green</a> | 27<a href="#" class="changecolor" title="blue-color">Blue</a> 28 29------------------------------------------------------------------------*/ 30 31$.fn.switchstylesheet = function(options) { 32 33 //default vals 34 defaults = { 35 seperator : 'alt' 36 }; 37 38 var options = $.extend(defaults, options); 39 40 //read the style 41 var c = cookie.readCookie(options.seperator); 42 if (c) switchss(c); 43 44 //goes thru the links to find out the ones having the selector 45 $(this).click(function() { 46 var title = $(this).attr('title'); //gets the title=? 47 switchss(title); 48 }); 49 50 function switchss(title) { 51 //goes thru all the styles having seperator - alt 52 $('link[rel*=style][title*='+options.seperator+']').each(function(i) { 53 this.disabled = true; 54 if ($(this).attr('title') == title) { 55 this.disabled = false; 56 } 57 }); 58 //create a cookie to store the style 59 cookie.createCookie(options.seperator, title, 365); 60 } 61}; 62 63//cookie functions 64var cookie; 65(function($) { 66 cookie = { 67 createCookie: function(name,value,days) { 68 if (days) 69 { 70 var date = new Date(); 71 date.setTime(date.getTime()+(days*24*60*60*1000)); 72 var expires = "; expires="+date.toGMTString(); 73 } 74 else var expires = ""; 75 document.cookie = name+"="+value+expires+"; path=/"; 76 }, 77 78 readCookie: function(name) { 79 var nameEQ = name + "="; 80 var ca = document.cookie.split(';'); 81 for(var i=0;i < ca.length;i++) 82 { 83 var c = ca[i]; 84 while (c.charAt(0)==' ') c = c.substring(1,c.length); 85 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 86 } 87 return null; 88 } 89 }; 90})(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.