1/*-------------------------------------------------------------- 2# Copyright (C) joomla-monster.com 3# License: http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only 4# Website: http://www.joomla-monster.com 5# Support: [email protected] 6---------------------------------------------------------------*/ 7 8//Document Text Resizer script (May 14th, 08'): By JavaScript Kit: http://www.javascriptkit.com 9 10var documenttextsizer = { 11 12 prevcontrol : '', //remember last control clicked on/ selected 13 existingclasses : '', 14 15setpageclass : function(control, newclass) { 16 if (this.prevcontrol != '') 17 this.css(this.prevcontrol, 'selectedtoggler', 'remove') 18 //de-select previous control, by removing 'selectedtoggler' from it 19 document.documentElement.className = this.existingclasses + ' ' + newclass//apply new class to document 20 this.css(control, 'selectedtoggler', 'add')//select current control 21 this.setCookie('pagesetting', newclass, 5)//remember new class added to document for 5 days 22 this.prevcontrol = control 23 }, 24 25 css : function(el, targetclass, action) { 26 var needle = new RegExp("(^|\\s+)" + targetclass + "($|\\s+)", "ig") 27 if (action == "check") 28 return needle.test(el.className) 29 else if (action == "remove") 30 el.className = el.className.replace(needle, "") 31 else if (action == "add") 32 el.className += " " + targetclass 33 }, 34 35 getCookie : function(Name) { 36 var re = new RegExp(Name + "=[^;]+", "i"); 37 //construct RE to search for target name/value pair 38 if (document.cookie.match(re))//if cookie found 39 return document.cookie.match(re)[0].split("=")[1] 40 //return its value 41 return null 42 }, 43 44 setCookie : function(name, value, days) { 45 if ( typeof days != "undefined") {//if set persistent cookie 46 var expireDate = new Date() 47 var expstring = expireDate.setDate(expireDate.getDate() + days) 48 document.cookie = name + "=" + value + "; path=/; expires=" + expireDate.toGMTString() 49 } else//else if this is a session only cookie 50 document.cookie = name + "=" + value 51 }, 52 53 setup : function(targetclass) { 54 this.existingclasses = document.documentElement.className//store existing CSS classes on HTML element, if any 55 var persistedsetting = this.getCookie('pagesetting') 56 var alllinks = document.getElementsByTagName("a") 57 for (var i = 0; i < alllinks.length; i++) { 58 if (this.css(alllinks[i], targetclass, "check")) { 59 if (alllinks[i].getAttribute("rel") == persistedsetting)//if this control's rel attribute matches persisted doc CSS class name 60 this.setpageclass(alllinks[i], alllinks[i].getAttribute("rel")) 61 //apply persisted class to document 62 alllinks[i].onclick = function() { 63 documenttextsizer.setpageclass(this, this.getAttribute("rel")) 64 return false 65 } 66 } 67 } 68 } 69}
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.