diff options
Diffstat (limited to 'lib/scripts')
-rw-r--r-- | lib/scripts/script.js | 27 |
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(){ |