diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 8a5770f1651cc902bf4c5f87bcaf9052aa87d428..29d3e5db0389f3fb208fc1620446a76885c1a46c 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); } /**