diff options
author | Dmitry Katsubo <dma_k@mail.ru> | 2008-10-07 21:23:42 +0200 |
---|---|---|
committer | Dmitry Katsubo <dma_k@mail.ru> | 2008-10-07 21:23:42 +0200 |
commit | a14197f130933e5df7499d4531ce7b0c2dad0306 (patch) | |
tree | b8d99030df0aafbde2c3af3e21d72380c0da91bd /lib | |
parent | 33ec8c3fc69d52bc632a8b7a3cd59f92a1ee88b7 (diff) | |
download | rpg-a14197f130933e5df7499d4531ce7b0c2dad0306.tar.gz rpg-a14197f130933e5df7499d4531ce7b0c2dad0306.tar.bz2 |
preserve "wrap textarea" setting state in cookie
darcs-hash:20081007192342-2c343-ea27e0a0396da425af69a6d0fcd8857b033cb8e6.gz
Diffstat (limited to 'lib')
-rw-r--r-- | lib/scripts/script.js | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 8a5770f16..29d3e5db0 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -411,6 +411,11 @@ function initSizeCtl(ctlid,edid){ textarea.style.height = '300px'; } + var wrp = DokuCookie.getValue('wrapCtl'); + if(wrp){ + setWrap(textarea, wrp); + } // else use default value + var l = document.createElement('img'); var s = document.createElement('img'); var w = document.createElement('img'); @@ -439,25 +444,35 @@ 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'); + var textarea = $(edid); + var wrap = textarea.getAttribute('wrap'); if(wrap && wrap.toLowerCase() == 'off'){ - txtarea.setAttribute('wrap', 'soft'); + setWrap(textarea, 'soft'); }else{ - txtarea.setAttribute('wrap', 'off'); + setWrap(textarea, 'off'); } + + DokuCookie.setValue('wrapCtl',textarea.getAttribute('wrap')); +} + +/** + * Set the wrapping mode of a textarea + * + * @author Fluffy Convict <fluffyconvict@hotmail.com> + * @author <shutdown@flashmail.com> + * @link http://news.hping.org/comp.lang.javascript.archive/12265.html + * @link https://bugzilla.mozilla.org/show_bug.cgi?id=41464 + */ +function setWrap(textarea, wrapAttrValue){ + textarea.setAttribute('wrap', wrapAttrValue); + // Fix display for mozilla - var parNod = txtarea.parentNode; - var nxtSib = txtarea.nextSibling; - parNod.removeChild(txtarea); - parNod.insertBefore(txtarea, nxtSib); + var parNod = textarea.parentNode; + var nxtSib = textarea.nextSibling; + parNod.removeChild(textarea); + parNod.insertBefore(textarea, nxtSib); } /** |