diff options
Diffstat (limited to 'lib/scripts/edit.js')
-rw-r--r-- | lib/scripts/edit.js | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 9a317a85c..22d040610 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -49,13 +49,13 @@ function createToolButton(icon,label,key,id){ */ function createPicker(id,list,icobase,edid){ var cnt = list.length; - + var picker = document.createElement('div'); picker.className = 'picker'; picker.id = id; picker.style.position = 'absolute'; picker.style.display = 'none'; - + for(var key in list){ var btn = document.createElement('button'); @@ -139,7 +139,7 @@ function initToolbar(tbid,edid,tb){ case 'format': var sample = tb[i]['title']; if(tb[i]['sample']){ sample = tb[i]['sample']; } - + eval("btn.onclick = function(){insertTags('"+ jsEscape(edid)+"','"+ jsEscape(tb[i]['open'])+"','"+ @@ -207,7 +207,7 @@ function insertTags(edid,tagOpen, tagClose, sampleText) { theSelection=sampleText; } txtarea.focus(); - + // This has change var text = theSelection; if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any @@ -240,14 +240,14 @@ function insertTags(edid,tagOpen, tagClose, sampleText) { txtarea.value = txtarea.value.substring(0, startPos) + subst + txtarea.value.substring(endPos, txtarea.value.length); txtarea.focus(); - + //set new selection if(replaced){ var cPos=startPos+(tagOpen.length+myText.length+tagClose.length); txtarea.selectionStart=cPos; txtarea.selectionEnd=cPos; }else{ - txtarea.selectionStart=startPos+tagOpen.length; + txtarea.selectionStart=startPos+tagOpen.length; txtarea.selectionEnd=startPos+tagOpen.length+myText.length; } txtarea.scrollTop=scrollTop; @@ -363,21 +363,21 @@ function initChangeCheck(msg){ } // reset change memory var on submit - var btn_save = document.getElementById('edbtn_save'); + var btn_save = document.getElementById('edbtn__save'); btn_save.onclick = function(){ textChanged = false; }; btn_save.onkeypress = function(){ textChanged = false; }; - var btn_prev = document.getElementById('edbtn_preview'); + var btn_prev = document.getElementById('edbtn__preview'); btn_prev.onclick = function(){ textChanged = false; }; btn_prev.onkeypress = function(){ textChanged = false; }; // add change memory setter - var edit_text = document.getElementById('wikitext'); + var edit_text = document.getElementById('wiki__text'); edit_text.onchange = function(){ textChanged = true; //global var summaryCheck(); }; edit_text.onkeyup = summaryCheck; - var summary = document.getElementById('summary'); + var summary = document.getElementById('edit__summary'); summary.onchange = summaryCheck; summary.onkeyup = summaryCheck; @@ -391,7 +391,7 @@ function initChangeCheck(msg){ * @author Andreas Gohr <andi@splitbrain.org> */ function summaryCheck(){ - var sum = document.getElementById('summary'); + var sum = document.getElementById('edit__summary'); if(sum.value === ''){ sum.className='missing'; }else{ @@ -404,84 +404,84 @@ function summaryCheck(){ * Class managing the timer to display a warning on a expiring lock */ function locktimer_class(){ - this.sack = null; - this.timeout = 0; - this.timerID = null; - this.lasttime = null; - this.msg = ''; - this.pageid = ''; + this.sack = null; + this.timeout = 0; + this.timerID = null; + this.lasttime = null; + this.msg = ''; + this.pageid = ''; }; var locktimer = new locktimer_class(); - locktimer.init = function(timeout,msg){ - // init values - locktimer.timeout = timeout*1000; - locktimer.msg = msg; - locktimer.lasttime = new Date(); - - if(!$('dw__editform')) return; - locktimer.pageid = $('dw__editform').elements.id.value; - if(!locktimer.pageid) return; - - // init ajax component - locktimer.sack = new sack(DOKU_BASE + 'lib/exe/ajax.php'); - locktimer.sack.AjaxFailedAlert = ''; - locktimer.sack.encodeURIString = false; - locktimer.sack.onCompletion = locktimer.refreshed; - - // register refresh event - addEvent($('dw__editform').elements.wikitext,'keyup',function(){locktimer.refresh();}); - - // start timer - locktimer.reset(); - }; - - /** + locktimer.init = function(timeout,msg){ + // init values + locktimer.timeout = timeout*1000; + locktimer.msg = msg; + locktimer.lasttime = new Date(); + + if(!$('dw__editform')) return; + locktimer.pageid = $('dw__editform').elements.id.value; + if(!locktimer.pageid) return; + + // init ajax component + locktimer.sack = new sack(DOKU_BASE + 'lib/exe/ajax.php'); + locktimer.sack.AjaxFailedAlert = ''; + locktimer.sack.encodeURIString = false; + locktimer.sack.onCompletion = locktimer.refreshed; + + // register refresh event + addEvent($('dw__editform').elements.wikitext,'keyup',function(){locktimer.refresh();}); + + // start timer + locktimer.reset(); + }; + + /** * (Re)start the warning timer */ - locktimer.reset = function(){ - locktimer.clear(); - locktimer.timerID = window.setTimeout("locktimer.warning()", locktimer.timeout); - }; - - /** - * Display the warning about the expiring lock - */ - locktimer.warning = function(){ - locktimer.clear(); - alert(locktimer.msg); - }; - - /** - * Remove the current warning timer + locktimer.reset = function(){ + locktimer.clear(); + locktimer.timerID = window.setTimeout("locktimer.warning()", locktimer.timeout); + }; + + /** + * Display the warning about the expiring lock + */ + locktimer.warning = function(){ + locktimer.clear(); + alert(locktimer.msg); + }; + + /** + * Remove the current warning timer */ - locktimer.clear = function(){ - if(locktimer.timerID !== null){ - window.clearTimeout(locktimer.timerID); - locktimer.timerID = null; - } - }; - - /** + locktimer.clear = function(){ + if(locktimer.timerID !== null){ + window.clearTimeout(locktimer.timerID); + locktimer.timerID = null; + } + }; + + /** * Refresh the lock via AJAX * * Called on keypresses in the edit area */ - locktimer.refresh = function(){ - var now = new Date(); - // refresh every minute only - if(now.getTime() - locktimer.lasttime.getTime() > 60*1000){ - locktimer.sack.runAJAX('call=lock&id='+encodeURI(locktimer.pageid)); - locktimer.lasttime = now; - } - }; + locktimer.refresh = function(){ + var now = new Date(); + // refresh every minute only + if(now.getTime() - locktimer.lasttime.getTime() > 60*1000){ + locktimer.sack.runAJAX('call=lock&id='+encodeURI(locktimer.pageid)); + locktimer.lasttime = now; + } + }; - /** + /** * Callback. Resets the warning timer */ - locktimer.refreshed = function(){ - if(this.response != '1') return; // locking failed - locktimer.reset(); - }; + locktimer.refreshed = function(){ + if(this.response != '1') return; // locking failed + locktimer.reset(); + }; // end of locktimer class functions |