summaryrefslogtreecommitdiff
path: root/lib/scripts
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2006-05-25 17:23:57 +0200
committerAndreas Gohr <andi@splitbrain.org>2006-05-25 17:23:57 +0200
commit276b8bd9566cbdcc99b7c3ab8349e8c06843c23d (patch)
tree3ec361a2767c2dbf2f301e9b56800bdd7e8c044a /lib/scripts
parentcf6894df38261b3b92c75d441bbe0a0ba58d963e (diff)
downloadrpg-276b8bd9566cbdcc99b7c3ab8349e8c06843c23d.tar.gz
rpg-276b8bd9566cbdcc99b7c3ab8349e8c06843c23d.tar.bz2
javascript to toggle editor wrapping
This patch adds a way to sisable and enable the automating wrapping in the editor textarea. Disabling the wrapping is especially useful when editing large tables. darcs-hash:20060525152357-7ad00-ced566c5d640cc521877d4b3325640c3fcd3ded9.gz
Diffstat (limited to 'lib/scripts')
-rw-r--r--lib/scripts/script.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js
index df12a29fb..1f5a71e78 100644
--- a/lib/scripts/script.js
+++ b/lib/scripts/script.js
@@ -339,12 +339,16 @@ function initSizeCtl(ctlid,edid){
var l = document.createElement('img');
var s = document.createElement('img');
+ var w = document.createElement('img');
l.src = DOKU_BASE+'lib/images/larger.gif';
s.src = DOKU_BASE+'lib/images/smaller.gif';
+ w.src = DOKU_BASE+'lib/images/wrap.gif';
addEvent(l,'click',function(){sizeCtl(edid,100);});
addEvent(s,'click',function(){sizeCtl(edid,-100);});
+ addEvent(w,'click',function(){toggleWrap(edid);});
ctl.appendChild(l);
ctl.appendChild(s);
+ ctl.appendChild(w);
}
/**
@@ -360,6 +364,29 @@ function sizeCtl(edid,val){
}
/**
+ * Toggle the wrapping mode of a textarea
+ *
+ * @author Fluffy Convict <fluffyconvict@hotmail.com>
+ * @link http://news.hping.org/comp.lang.javascript.archive/12265.html
+ * @author <shutdown@flashmail.com>
+ * @link https://bugzilla.mozilla.org/show_bug.cgi?id=302710#c2
+ */
+function toggleWrap(edid){
+ var txtarea = $(edid);
+ var wrap = txtarea.getAttribute('wrap');
+ if(wrap && wrap.toLowerCase() == 'off'){
+ txtarea.setAttribute('wrap', 'soft');
+ }else{
+ txtarea.setAttribute('wrap', 'off');
+ }
+ // Fix display for mozilla
+ var parNod = txtarea.parentNode;
+ var nxtSib = txtarea.nextSibling;
+ parNod.removeChild(txtarea);
+ parNod.insertBefore(txtarea, nxtSib);
+}
+
+/**
* Handler to close all open Popups
*/
function closePopups(){