/* ** TextAreaResizer script by Jason Johnston (jj@lojjic.net) ** Created August 2003. Use freely, but give me credit. ** ** This script adds a handle below textareas that the user ** can drag with the mouse to resize the textarea. */ function TextAreaResizer(elt) { this.element = elt; this.create(); } TextAreaResizer.prototype = { create : function() { var elt = this.element; var thisRef = this; var h = this.handle = document.createElement("div"); h.className = "textarea-resizer"; h.title = "Drag to resize text box"; h.addEventListener("mousedown", function(evt){thisRef.dragStart(evt);}, false); elt.parentNode.insertBefore(h, elt.nextSibling); }, dragStart : function(evt) { var thisRef = this; this.dragStartY = evt.clientY; this.dragStartH = parseFloat(document.defaultView.getComputedStyle(this.element, null).getPropertyValue("height")); document.addEventListener("mousemove", this.dragMoveHdlr=function(evt){thisRef.dragMove(evt);}, false); document.addEventListener("mouseup", this.dragStopHdlr=function(evt){thisRef.dragStop(evt);}, false); }, dragMove : function(evt) { this.element.style.height = this.dragStartH + evt.clientY - this.dragStartY + "px"; }, dragStop : function(evt) { document.removeEventListener("mousemove", this.dragMoveHdlr, false); document.removeEventListener("mouseup", this.dragStopHdlr, false); }, destroy : function() { var elt = this.element; elt.parentNode.removeChild(this.handle); elt.style.height = ""; } }; TextAreaResizer.scriptSheetSelector = "textarea"; /* ** ScriptSheet script by Jason Johnston (jj@lojjic.net) created July 2003. ** ** This script provides a framework for creating scripts that are applied ** to documents in a separate CSS-like presentation layer. There is also ** a StyleChooser widget for switching between styles; the preferred ** style choice is persisted. For usage and other details see the ** documentation at http://lojjic.net/script-library/ScriptSheet-doc.html ** ** The contents of this file are subject to the Mozilla Public License ** Version 1.1; for more details see the documentation file. */ function ScriptSheet(title, script) { this.title = title; this.script = window[script]; var i = ScriptSheet.instances; i[i.length] = this; } ScriptSheet.prototype = { enable : function() { this.disable(); var s = this.script; if(!s) return; if(!s.enableScriptSheet) s.enableScriptSheet = ScriptSheet.enableScriptSheetDefault; s.enableScriptSheet(); }, disable : function() { var s = this.script; if(!s) return; var inst = this.scriptSheetInstances; if(!s.disableScriptSheet) s.disableScriptSheet = ScriptSheet.disableScriptSheetDefault; s.disableScriptSheet(); } }; ScriptSheet.enableScriptSheetDefault = function() { this.disableScriptSheet(); var sel = this.scriptSheetSelector; if(!sel) return; var elts; if(typeof sel == "function") elts = sel(); if(typeof sel == "string") elts = ScriptSheet.matchSelector(sel); var inst = this.scriptSheetInstances; for(var i=0; i\+=])\s*/g, "$1") //strip extra whitespace around combinators .replace(/^\s*(\S*)\s*$/, "$1") //and at start and end of string + ",") //add comma on end to mark end of selector .replace(/([ >\+])([\.\[#])/g, "$1*$2"); //insert universal selector where it is optionally omitted //Split string into array of significant parts: //var parts = sel.split(/([#\. >\+,]|\[[^\]]*\])/); //Fails in IE var parts = []; while(sel.length > 0) { switch(sel.charAt(0)) { case "#": case ".": case " ": case ">": case "+": case ",": parts[parts.length] = sel.charAt(0); sel = sel.substring(1); break; case "[": i = sel.indexOf("]")+1; parts[parts.length] = sel.substring(0,i); sel = sel.substring(i); break; default: a = sel.match(/^([^#\. >\+\[,]+)(.*)$/); parts[parts.length] = a[1]; sel = a[2]; } } var allElts = []; var elts = [document]; for(var p=0; p": //child for(i=0; i 0) { sheets[sheets.length-1].disable(); sheets.length--; } for(i=0; (lnk=lnks[i]); i++) { rel = lnk.getAttribute("rel"); ttl = lnk.getAttribute("title"); hrf = lnk.getAttribute("href"); if(rel && (match=rel.match(/^\s*((alternat(e|ive))\s+)?(script|style)sheet\s*$/i)) && hrf) { if(match[4]=="style") lnk.disabled = !(ttl == title || (!ttl && title != "[null]")); //handle stylesheets else { hrf = hrf.substring(hrf.indexOf("#")+1); if(!lnk.scriptSheet) lnk.scriptSheet = new ScriptSheet(ttl, hrf); if(ttl == title || (!ttl && title != "[null]")) sheets[sheets.length] = lnk.scriptSheet; //add to list } } } //enable all matching scripts: for(i=0; i