Skip to content
Snippets Groups Projects
Commit a14197f1 authored by Dmitry Katsubo's avatar Dmitry Katsubo
Browse files

preserve "wrap textarea" setting state in cookie

darcs-hash:20081007192342-2c343-ea27e0a0396da425af69a6d0fcd8857b033cb8e6.gz
parent 33ec8c3f
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment