From ebb29737d32bc331541f78a1a47f33ba33919938 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sat, 13 Nov 2010 13:59:17 +0100 Subject: fixed mediamanager options + ie6 fix (FS#2074) --- lib/scripts/media.js | 123 +++++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 59 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 8eb19ce6b..5b9372b68 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -206,7 +206,7 @@ var media_manager = { media_manager.id = id; if(!opener){ // if we don't run in popup display example - var ex = $('ex_'+id.replace(/:/g,'_')); + var ex = $('ex'+id.replace(/:/g,'_')); if(ex.style.display == ''){ ex.style.display = 'none'; } else { @@ -217,10 +217,10 @@ var media_manager = { // FIXME these lines deactivate the media options dialog and restore // the old behavior according to FS#2047 - opener.insertTags('wiki__text','{{'+id+'|','}}',''); - if(!media_manager.keepopen) window.close(); - opener.focus(); - return false; + //opener.insertTags('wiki__text','{{'+id+'|','}}',''); + //if(!media_manager.keepopen) window.close(); + //opener.focus(); + //return false; media_manager.ext = false; @@ -242,21 +242,11 @@ var media_manager = { media_manager.popup.style.top = event.pageY + 'px'; // set all buttons to outset - media_manager.outSet('media__linkbtn1'); - media_manager.outSet('media__linkbtn2'); - media_manager.outSet('media__linkbtn3'); - media_manager.outSet('media__linkbtn4'); - - media_manager.outSet('media__alignbtn0'); - media_manager.outSet('media__alignbtn1'); - media_manager.outSet('media__alignbtn2'); - media_manager.outSet('media__alignbtn3'); - - media_manager.outSet('media__sizebtn1'); - media_manager.outSet('media__sizebtn2'); - media_manager.outSet('media__sizebtn3'); - media_manager.outSet('media__sizebtn4'); - + for (var i = 1; i < 5; i++) { + media_manager.outSet('media__linkbtn' + i); + media_manager.outSet('media__alignbtn' + i); + media_manager.outSet('media__sizebtn' + i); + } if (ext == '.swf') { media_manager.ext = 'swf'; @@ -266,7 +256,7 @@ var media_manager = { $('media__linkbtn2').style.display = 'none'; // set the link button to default - if (media_manager.link != false) { + if (media_manager.link !== false) { if ( media_manager.link == '2' || media_manager.link == '1') { media_manager.inSet('media__linkbtn3'); media_manager.link = '3'; @@ -293,6 +283,11 @@ var media_manager = { // disable button for original size $('media__sizebtn4').style.display = 'none'; + if (media_manager.size == 4) { + media_manager.size = 2; + DokuCookie.setValue('size', '2'); + media_manager.inSet('media__sizebtn2'); + } } else { media_manager.ext = 'img'; @@ -306,7 +301,7 @@ var media_manager = { if (DokuCookie.getValue('link')) { media_manager.link = DokuCookie.getValue('link'); } - if (media_manager.link == false) { + if (!media_manager.link) { // default case media_manager.link = '1'; DokuCookie.setValue('link','1'); @@ -324,23 +319,23 @@ var media_manager = { $('media__size').style.display = 'block'; // set the align button to default - if (media_manager.align != false) { + if (media_manager.align !== false) { media_manager.inSet('media__alignbtn'+media_manager.align); } else if (DokuCookie.getValue('align')) { media_manager.inSet('media__alignbtn'+DokuCookie.getValue('align')); media_manager.align = DokuCookie.getValue('align'); } else { // default case - media_manager.align = '0'; - media_manager.inSet('media__alignbtn0'); - DokuCookie.setValue('align','0'); + media_manager.align = '1'; + media_manager.inSet('media__alignbtn1'); + DokuCookie.setValue('align','1'); } // set the size button to default if (DokuCookie.getValue('size')) { media_manager.size = DokuCookie.getValue('size'); } - if (media_manager.size == false || (media_manager.size === '4' && ext === '.swf')) { + if (!media_manager.size || (media_manager.size === '4' && ext === '.swf')) { // default case media_manager.size = '2'; DokuCookie.setValue('size','2'); @@ -364,7 +359,7 @@ var media_manager = { media_manager.popup.setAttribute('id','media__popup'); var root = document.getElementById('media__manager'); - if (root == null) return; + if (root === null) return; root.appendChild(media_manager.popup); var headline = document.createElement('h1'); @@ -394,8 +389,7 @@ var media_manager = { for (var i = 0 ; i < linkbtns.length ; ++i) { var linkbtn = document.createElement('button'); linkbtn.className = 'button'; - linkbtn.value = i + 1; - linkbtn.id = "media__linkbtn" + (i + 1); + linkbtn.id = "media__linkbtn" + (i+1); linkbtn.title = LANG['media' + linkbtns[i]]; linkbtn.style.borderStyle = 'outset'; addEvent(linkbtn,'click',function(event){ return media_manager.setlink(event,this); }); @@ -427,8 +421,7 @@ var media_manager = { var alignimg = document.createElement('img'); alignimg.src = DOKU_BASE + 'lib/images/media_align_' + alignbtns[n] + '.png'; - alignbtn.id = "media__alignbtn" + n; - alignbtn.value = n; + alignbtn.id = "media__alignbtn" + (n+1); alignbtn.title = LANG['media' + alignbtns[n]]; alignbtn.className = 'button'; alignbtn.appendChild(alignimg); @@ -462,7 +455,6 @@ var media_manager = { sizebtn.className = 'button'; sizebtn.appendChild(sizeimg); - sizebtn.value = size + 1; sizebtn.id = 'media__sizebtn' + (size + 1); sizebtn.title = LANG['media' + sizebtns[size]]; sizebtn.style.borderStyle = 'outset'; @@ -516,7 +508,7 @@ var media_manager = { optsstart = true; } - var s = parseInt(media_manager.size); + var s = parseInt(media_manager.size, 10); if (s && s >= 1) { opts += (optsstart)?'&':'?'; @@ -537,15 +529,15 @@ var media_manager = { } } } - if (media_manager.align == '1') { + if (media_manager.align == '2') { alignleft = ''; alignright = ' '; } - if (media_manager.align == '2') { + if (media_manager.align == '3') { alignleft = ' '; alignright = ' '; } - if (media_manager.align == '3') { + if (media_manager.align == '4') { alignleft = ' '; alignright = ''; } @@ -671,14 +663,15 @@ var media_manager = { * @author Dominik Eckelmann */ setalign: function(event,cb){ - if(cb.value){ - DokuCookie.setValue('align',cb.value); - media_manager.align = cb.value; - media_manager.outSet("media__alignbtn0"); - media_manager.outSet("media__alignbtn1"); - media_manager.outSet("media__alignbtn2"); - media_manager.outSet("media__alignbtn3"); - media_manager.inSet("media__alignbtn"+cb.value); + + var id = cb.id.substring(cb.id.length -1); + if(id){ + DokuCookie.setValue('align',id); + media_manager.align = id; + for (var i = 1; i<=4; i++) { + media_manager.outSet("media__alignbtn" + i); + } + media_manager.inSet("media__alignbtn"+id); }else{ DokuCookie.setValue('align',''); media_manager.align = false; @@ -690,23 +683,34 @@ var media_manager = { * @author Dominik Eckelmann */ setlink: function(event,cb){ - if(cb.value){ - DokuCookie.setValue('link',cb.value); - media_manager.link = cb.value; - media_manager.outSet("media__linkbtn1"); - media_manager.outSet("media__linkbtn2"); - media_manager.outSet("media__linkbtn3"); - media_manager.outSet("media__linkbtn4"); - media_manager.inSet("media__linkbtn"+cb.value); + var id = cb.id.substring(cb.id.length -1); + if(id){ + DokuCookie.setValue('link',id); + for (var i = 1; i<=4; i++) { + media_manager.outSet("media__linkbtn"+i); + } + media_manager.inSet("media__linkbtn"+id); + var size = document.getElementById("media__size"); var align = document.getElementById("media__align"); - if (cb.value != '4') { + if (id != '4') { size.style.display = "block"; align.style.display = "block"; + if (media_manager.link == '4') { + media_manager.align = '1'; + DokuCookie.setValue('align', '1'); + media_manager.inSet('media__alignbtn1'); + + media_manager.size = '2'; + DokuCookie.setValue('size', '2'); + media_manager.inSet('media__sizebtn2'); + } + } else { size.style.display = "none"; align.style.display = "none"; } + media_manager.link = id; }else{ DokuCookie.setValue('link',''); media_manager.link = false; @@ -755,13 +759,14 @@ var media_manager = { * @author Dominik Eckelmann */ setsize: function(event,cb){ - if (cb.value) { - DokuCookie.setValue('size',cb.value); - media_manager.size = cb.value; - for (var i = 1 ; i <= 4 ; ++i) { + var id = cb.id.substring(cb.id.length -1); + if (id) { + DokuCookie.setValue('size',id); + media_manager.size = id; + for (var i = 1 ; i <=4 ; ++i) { media_manager.outSet("media__sizebtn" + i); } - media_manager.inSet("media__sizebtn"+cb.value); + media_manager.inSet("media__sizebtn"+id); } else { DokuCookie.setValue('size',''); media_manager.width = false; -- cgit v1.2.3 From cdf966f1270532404b2a6d2343ed75db32fc0b16 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sat, 13 Nov 2010 15:48:24 +0100 Subject: removed fixme comment --- lib/scripts/media.js | 8 -------- 1 file changed, 8 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 5b9372b68..ab64298ae 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -215,14 +215,6 @@ var media_manager = { return false; } - // FIXME these lines deactivate the media options dialog and restore - // the old behavior according to FS#2047 - //opener.insertTags('wiki__text','{{'+id+'|','}}',''); - //if(!media_manager.keepopen) window.close(); - //opener.focus(); - //return false; - - media_manager.ext = false; var dot = id.lastIndexOf("."); if (dot != -1) { -- cgit v1.2.3 From 8079aa0b7aaf494a7b249671919159fd628b5dc0 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sat, 13 Nov 2010 17:09:56 +0100 Subject: initialised media options modal popup with display:none in JS --- lib/scripts/media.js | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/scripts') diff --git a/lib/scripts/media.js b/lib/scripts/media.js index ab64298ae..b90f7047b 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -349,6 +349,7 @@ var media_manager = { media_manager.popup = document.createElement('div'); media_manager.popup.setAttribute('id','media__popup'); + media_manager.popup.style.display = 'none'; var root = document.getElementById('media__manager'); if (root === null) return; -- cgit v1.2.3 From 5ba8d196ffe346ef6fbd8e6ffc11f0c849537ed3 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Jan 2011 12:20:19 +0100 Subject: shorten quicksearch namespaces in JavaScript This patch moves the shortening of namespaces in the quicksearch results to JavaScript. This makes it independend from used template and will always try to fill the width of the result pane correctly. Things missing: * Make it work with RTL-languages * Check Browser compatibility (only tested in Chrome so far) --- lib/scripts/ajax.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'lib/scripts') diff --git a/lib/scripts/ajax.js b/lib/scripts/ajax.js index de009d448..761329f0f 100644 --- a/lib/scripts/ajax.js +++ b/lib/scripts/ajax.js @@ -31,6 +31,47 @@ addInitEvent(function () { outObj.innerHTML = data; outObj.style.display = 'block'; + outObj.style['white-space'] = 'nowrap'; + + // shorten namespaces if too long + var width = outObj.clientWidth; + var links = outObj.getElementsByTagName('a'); + for(var i=0; i 3) && links[i].offsetWidth > max ){ + if(runaway++ > 500) return; // just in case something went wrong + + if(eli){ + // elipsis already inserted + if( (eli - nsL) > (nsR - eli) ){ + // cut left + links[i].innerText = links[i].innerText.substring(0,eli-2)+ + links[i].innerText.substring(eli); + }else{ + // cut right + links[i].innerText = links[i].innerText.substring(0,eli+1)+ + links[i].innerText.substring(eli+2); + } + }else{ + // replace middle with ellipsis + var mid = Math.floor( nsL + ((nsR-nsL)/2) ); + links[i].innerText = links[i].innerText.substring(0,mid)+'…'+ + links[i].innerText.substring(mid+1); + } + eli = links[i].innerText.indexOf('…'); + nsL = links[i].innerText.indexOf('('); + nsR = links[i].innerText.indexOf(')'); + } + } + }; // attach eventhandler to search field -- cgit v1.2.3 From 301971b3769a2d1a440cf58fd84f2c100a1348e3 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Jan 2011 13:59:23 +0100 Subject: correctly(?) shorten namespaces for RTL langunages in quicksearch --- lib/scripts/ajax.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/ajax.js b/lib/scripts/ajax.js index 761329f0f..d752edb38 100644 --- a/lib/scripts/ajax.js +++ b/lib/scripts/ajax.js @@ -38,15 +38,23 @@ addInitEvent(function () { var links = outObj.getElementsByTagName('a'); for(var i=0; i 0) continue; var nsL = links[i].innerText.indexOf('('); var nsR = links[i].innerText.indexOf(')'); var eli = 0; var runaway = 0; - while( (nsR - nsL > 3) && links[i].offsetWidth > max ){ + while( (nsR - nsL > 3) && + ( + (!isRTL && links[i].offsetWidth > max) || + (isRTL && links[i].offsetLeft < 0) + ) + ){ if(runaway++ > 500) return; // just in case something went wrong if(eli){ -- cgit v1.2.3 From a8254dfa8d8e02d4ac011fe915f3dcb4fdf7a361 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 10:29:42 +0100 Subject: made ajax quicksearch its own object This makes it possible for plugin and template authors to overwrite or extend the quicksearch JavaScript logic. --- lib/scripts/ajax.js | 79 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 29 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/ajax.js b/lib/scripts/ajax.js index d752edb38..44dcee999 100644 --- a/lib/scripts/ajax.js +++ b/lib/scripts/ajax.js @@ -5,30 +5,58 @@ * @author Andreas Gohr * @author Adrian Lang */ -addInitEvent(function () { +var ajax_quicksearch = { - var inID = 'qsearch__in'; - var outID = 'qsearch__out'; + inObj: null, + outObj: null, + sackObj: null, + delay: null, - var inObj = document.getElementById(inID); - var outObj = document.getElementById(outID); + init: function(inID, outID) { - // objects found? - if (inObj === null){ return; } - if (outObj === null){ return; } + this.inObj = $(inID); + this.outObj = $(outID); - function clear_results(){ - outObj.style.display = 'none'; - outObj.innerHTML = ''; - } + // objects found? + if (this.inObj === null) return; + if (this.outObj === null) return; + + // prepare AJAX + this.sackObj = new sack(DOKU_BASE + 'lib/exe/ajax.php'); + this.sackObj.AjaxFailedAlert = ''; + this.sackObj.encodeURIString = false; + this.sackObj.onCompletion = ajax_quicksearch.onCompletion; + + // attach eventhandler to search field + this.delay = new Delay(function () { + ajax_quicksearch.clear_results(); + var value = ajax_quicksearch.inObj.value; + if(value === ''){ return; } + ajax_quicksearch.sackObj.runAJAX('call=qsearch&q=' + encodeURI(value)); + }); + + addEvent(this.inObj, 'keyup', function () { + ajax_quicksearch.clear_results(); + ajax_quicksearch.delay.start(); + }); + + // attach eventhandler to output field + addEvent(this.outObj, 'click', function () { + ajax_quicksearch.outObj.style.display = 'none'; + }); + }, - var sack_obj = new sack(DOKU_BASE + 'lib/exe/ajax.php'); - sack_obj.AjaxFailedAlert = ''; - sack_obj.encodeURIString = false; - sack_obj.onCompletion = function () { - var data = sack_obj.response; + clear_results: function(){ + ajax_quicksearch.outObj.style.display = 'none'; + ajax_quicksearch.outObj.innerHTML = ''; + }, + + onCompletion: function() { + var data = this.response; // 'this' is sack context if (data === '') { return; } + var outObj = ajax_quicksearch.outObj; + outObj.innerHTML = data; outObj.style.display = 'block'; outObj.style['white-space'] = 'nowrap'; @@ -79,19 +107,12 @@ addInitEvent(function () { nsR = links[i].innerText.indexOf(')'); } } + } - }; - - // attach eventhandler to search field - var delay = new Delay(function () { - clear_results(); - var value = inObj.value; - if(value === ''){ return; } - sack_obj.runAJAX('call=qsearch&q=' + encodeURI(value)); - }); +}; - addEvent(inObj, 'keyup', function () {clear_results(); delay.start(); }); - // attach eventhandler to output field - addEvent(outObj, 'click', function () {outObj.style.display = 'none'; }); +addInitEvent(function(){ + ajax_quicksearch.init('qsearch__in','qsearch__out'); }); + -- cgit v1.2.3 From ceea734a6e745087356b0119fc7a4acac821c5aa Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 31 Jan 2011 13:49:10 +0100 Subject: Made the auto submit script more versatile When a tag has the class "quickselect", this script will + * automatically submit its parent form when the select value changes. + * It also hides the submit button of the form. * * @author Andreas Gohr */ addInitEvent(function(){ - var selector = $('action__selector'); - if(!selector) return; - - addEvent(selector,'change',function(e){ - this.form.submit(); - }); - - $('action__selectorbtn').style.display = 'none'; + var selects = getElementsByClass('quickselect',document,'select'); + for(var i=0; i Date: Sun, 6 Feb 2011 10:03:34 +0100 Subject: moved locktimer class to its own file I also adjusted the coding style to match our other JS classes --- lib/scripts/edit.js | 101 ----------------------------------------------- lib/scripts/locktimer.js | 98 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 101 deletions(-) create mode 100644 lib/scripts/locktimer.js (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 01262bcef..3276c9e06 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -341,104 +341,3 @@ 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 = ''; -}; -var locktimer = new locktimer_class(); - locktimer.init = function(timeout,msg,draft){ - // init values - locktimer.timeout = timeout*1000; - locktimer.msg = msg; - locktimer.draft = draft; - 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'),'keypress',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.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() > 30*1000){ //FIXME decide on time - var params = 'call=lock&id='+encodeURIComponent(locktimer.pageid); - var dwform = $('dw__editform'); - if(locktimer.draft && dwform.elements.wikitext){ - params += '&prefix='+encodeURIComponent(dwform.elements.prefix.value); - params += '&wikitext='+encodeURIComponent(dwform.elements.wikitext.value); - params += '&suffix='+encodeURIComponent(dwform.elements.suffix.value); - if(dwform.elements.date){ - params += '&date='+encodeURIComponent(dwform.elements.date.value); - } - } - locktimer.sack.runAJAX(params); - locktimer.lasttime = now; - } - }; - - - /** - * Callback. Resets the warning timer - */ - locktimer.refreshed = function(){ - var data = this.response; - var error = data.charAt(0); - data = data.substring(1); - - $('draft__status').innerHTML=data; - if(error != '1') return; // locking failed - locktimer.reset(); - }; -// end of locktimer class functions - diff --git a/lib/scripts/locktimer.js b/lib/scripts/locktimer.js new file mode 100644 index 000000000..1cd9d29db --- /dev/null +++ b/lib/scripts/locktimer.js @@ -0,0 +1,98 @@ +/** + * Class managing the timer to display a warning on a expiring lock + */ +var locktimer = { + sack: null, + timeout: 0, + timerID: null, + lasttime: null, + msg: '', + pageid: '', + + init: function(timeout,msg,draft){ + // init values + locktimer.timeout = timeout*1000; + locktimer.msg = msg; + locktimer.draft = draft; + 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'),'keypress',function(){locktimer.refresh();}); + // start timer + locktimer.reset(); + }, + + /** + * (Re)start the warning timer + */ + reset: function(){ + locktimer.clear(); + locktimer.timerID = window.setTimeout("locktimer.warning()", locktimer.timeout); + }, + + /** + * Display the warning about the expiring lock + */ + warning: function(){ + locktimer.clear(); + alert(locktimer.msg); + }, + + /** + * Remove the current warning timer + */ + 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 + */ + refresh: function(){ + var now = new Date(); + // refresh every minute only + if(now.getTime() - locktimer.lasttime.getTime() > 30*1000){ + var params = 'call=lock&id='+encodeURIComponent(locktimer.pageid); + var dwform = $('dw__editform'); + if(locktimer.draft && dwform.elements.wikitext){ + params += '&prefix='+encodeURIComponent(dwform.elements.prefix.value); + params += '&wikitext='+encodeURIComponent(dwform.elements.wikitext.value); + params += '&suffix='+encodeURIComponent(dwform.elements.suffix.value); + if(dwform.elements.date){ + params += '&date='+encodeURIComponent(dwform.elements.date.value); + } + } + locktimer.sack.runAJAX(params); + locktimer.lasttime = now; + } + }, + + /** + * Callback. Resets the warning timer + */ + refreshed: function(){ + var data = this.response; + var error = data.charAt(0); + data = data.substring(1); + + $('draft__status').innerHTML=data; + if(error != '1') return; // locking failed + locktimer.reset(); + }, +}; + -- cgit v1.2.3 From dba09ad209b14cfb149a1a14c9aa1370537d69d1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 6 Feb 2011 10:11:30 +0100 Subject: don't show lock timer in readonly mode FS#2146 --- lib/scripts/locktimer.js | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/scripts') diff --git a/lib/scripts/locktimer.js b/lib/scripts/locktimer.js index 1cd9d29db..51d533056 100644 --- a/lib/scripts/locktimer.js +++ b/lib/scripts/locktimer.js @@ -19,6 +19,7 @@ var locktimer = { if(!$('dw__editform')) return; locktimer.pageid = $('dw__editform').elements.id.value; if(!locktimer.pageid) return; + if($('wiki__text').readOnly) return; // init ajax component locktimer.sack = new sack(DOKU_BASE + 'lib/exe/ajax.php'); -- cgit v1.2.3 From bf14d727a44e746ad142636acbb19f59fb075b13 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 6 Feb 2011 10:42:28 +0100 Subject: keep drafts on preview FS#2116 --- lib/scripts/edit.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 3276c9e06..45c1fb111 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -268,6 +268,7 @@ var textChanged = false; */ function deleteDraft() { if (is_opera) return; + if (window.keepDraft) return; // remove a possibly saved draft using ajax var dwform = $('dw__editform'); @@ -318,8 +319,13 @@ addInitEvent(function (){ window.onunload = deleteDraft; // reset change memory var on submit - addEvent($('edbtn__save'), 'click', function(){ textChanged = false; }); - addEvent($('edbtn__preview'), 'click', function(){ textChanged = false; }); + addEvent($('edbtn__save'), 'click', function(){ + textChanged = false; + }); + addEvent($('edbtn__preview'), 'click', function(){ + textChanged = false; + window.keepDraft = true; // needed to keep draft on page unload + }); var summary = $('edit__summary'); addEvent(summary, 'change', summaryCheck); -- cgit v1.2.3 From 999913b8ccbcd63a3bc3d3350c8eb9a17bcdf305 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 6 Feb 2011 20:38:08 +0100 Subject: no final comma in class members or IE craps out --- lib/scripts/locktimer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/locktimer.js b/lib/scripts/locktimer.js index 51d533056..f5ba1c60d 100644 --- a/lib/scripts/locktimer.js +++ b/lib/scripts/locktimer.js @@ -94,6 +94,6 @@ var locktimer = { $('draft__status').innerHTML=data; if(error != '1') return; // locking failed locktimer.reset(); - }, + } }; -- cgit v1.2.3 From 4c5a5d3dd4fcc2636b2861f06d52a2ac32ad5544 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 6 Feb 2011 20:41:58 +0100 Subject: JS: Add style helper and fix footnotes in non-static containers --- lib/scripts/script.js | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/script.js b/lib/scripts/script.js index b9b324f96..2cc1246f9 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -113,6 +113,20 @@ function findPosY(object){ return curtop; } //end findPosY function +/** + * Get the computed style of a node. + * + * @link https://acidmartin.wordpress.com/2008/08/26/style-get-any-css-property-value-of-an-object/ + * @link http://svn.dojotoolkit.org/src/dojo/trunk/_base/html.js + */ +function gcs(node){ + if(node.currentStyle){ + return node.currentStyle; + }else{ + return node.ownerDocument.defaultView.getComputedStyle(node, null); + } +} + /** * Escape special chars in JavaScript * @@ -260,10 +274,32 @@ function insitu_popup(target, popup_id) { getElementsByClass('dokuwiki', document.body, 'div')[0].appendChild(fndiv); } + var non_static_parent = fndiv.parentNode; + while (non_static_parent != document && gcs(non_static_parent)['position'] == 'static') { + non_static_parent = non_static_parent.parentNode; + } + + var fixed_target_parent = target; + while (fixed_target_parent != document && gcs(fixed_target_parent)['position'] != 'fixed') { + fixed_target_parent = fixed_target_parent.parentNode; + } + // position the div and make it visible - fndiv.style.position = 'absolute'; - fndiv.style.left = findPosX(target)+'px'; - fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5) + 'px'; + if (fixed_target_parent != document) { + // the target has position fixed, that means the footnote needs to be fixed, too + fndiv.style.position = 'fixed'; + } else { + fndiv.style.position = 'absolute'; + } + + if (fixed_target_parent != document || non_static_parent == document) { + fndiv.style.left = findPosX(target)+'px'; + fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5) + 'px'; + } else { + fndiv.style.left = (findPosX(target) - findPosX(non_static_parent)) +'px'; + fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5 - findPosY(non_static_parent)) + 'px'; + } + fndiv.style.display = ''; return fndiv; } -- cgit v1.2.3 From dea1115b59e771c401882590426074c08fed3a87 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 6 Mar 2011 14:33:50 +0100 Subject: Pass edid to the mediamanager --- lib/scripts/media.js | 4 +++- lib/scripts/toolbar.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/media.js b/lib/scripts/media.js index b90f7047b..57f599163 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -536,7 +536,9 @@ var media_manager = { } } } - opener.insertTags('wiki__text','{{'+alignleft+id+opts+alignright+'|','}}',''); + var edid = String.prototype.match.call(document.location, /&edid=([^&]+)/); + edid = edid ? edid[1] : 'wiki__text'; + opener.insertTags(edid,'{{'+alignleft+id+opts+alignright+'|','}}',''); if(!media_manager.keepopen) window.close(); opener.focus(); diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 3f967448c..d458960ab 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -153,7 +153,7 @@ function tb_insert(btn, props, edid) { */ function tb_mediapopup(btn, props, edid) { window.open( - DOKU_BASE+props['url']+encodeURIComponent(NS), + DOKU_BASE+props['url']+encodeURIComponent(NS)+'&edid='+encodeURIComponent(edid), props['name'], props['options']); return false; -- cgit v1.2.3 From 02097e2a6cbd4191438781890d484326aa60af19 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 17 Apr 2011 09:09:10 +0200 Subject: attach textChanged property to window attempt to fix FS#2196 --- lib/scripts/edit.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 45c1fb111..eaa3030e9 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -261,7 +261,7 @@ function currentHeadlineLevel(textboxId){ /** * global var used for not saved yet warning */ -var textChanged = false; +window.textChanged = false; /** * Delete the draft before leaving the page @@ -305,14 +305,14 @@ addInitEvent(function (){ } var checkfunc = function(){ - textChanged = true; //global var + window.textChanged = true; //global var summaryCheck(); }; addEvent(editform, 'change', checkfunc); addEvent(editform, 'keydown', checkfunc); window.onbeforeunload = function(){ - if(textChanged) { + if(window.textChanged) { return LANG.notsavedyet; } }; @@ -320,17 +320,17 @@ addInitEvent(function (){ // reset change memory var on submit addEvent($('edbtn__save'), 'click', function(){ - textChanged = false; + window.textChanged = false; }); addEvent($('edbtn__preview'), 'click', function(){ - textChanged = false; + window.textChanged = false; window.keepDraft = true; // needed to keep draft on page unload }); var summary = $('edit__summary'); addEvent(summary, 'change', summaryCheck); addEvent(summary, 'keyup', summaryCheck); - if (textChanged) summaryCheck(); + if (window.textChanged) summaryCheck(); }); /** -- cgit v1.2.3 From 7d643c17962849f1c9953b0936b37e8d2175a9d6 Mon Sep 17 00:00:00 2001 From: Guy Brand Date: Sun, 17 Apr 2011 16:04:10 +0200 Subject: Trap onbeforeunload when event fired (attempt to fix FS#2196) --- lib/scripts/edit.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index eaa3030e9..e8a59deb9 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -320,9 +320,11 @@ addInitEvent(function (){ // reset change memory var on submit addEvent($('edbtn__save'), 'click', function(){ + window.onbeforeunload = ''; window.textChanged = false; }); addEvent($('edbtn__preview'), 'click', function(){ + window.onbeforeunload = ''; window.textChanged = false; window.keepDraft = true; // needed to keep draft on page unload }); -- cgit v1.2.3 From 342e58c8c048bfd5f57f10bd88cee95aa2732e96 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 17 Apr 2011 22:39:21 +0200 Subject: correctly disable unfinished media options popup We disabled the media options shortly before the last release because of an unfixed bug. The disabling was not complete which caused problems with templates not incorporating the needed CSS. Since the option dialog hasn't been fixed yet, this patch also disables the creation of the corresponding HTML to avoid the mentioned template problems. --- lib/scripts/media.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 57f599163..530e93055 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -774,6 +774,6 @@ addInitEvent(function(){ media_manager.selectorattach($('media__content')); media_manager.confirmattach($('media__content')); media_manager.attachoptions($('media__opts')); - media_manager.initpopup(); + //media_manager.initpopup(); media_manager.initFlashUpload(); }); -- cgit v1.2.3 From 1f663d37c117a05d8343a100b7fac1736d24512c Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 18 Apr 2011 20:23:08 +0200 Subject: Revert "correctly disable unfinished media options popup" This reverts commit 342e58c8c048bfd5f57f10bd88cee95aa2732e96. The options code had already been fixed. My mistake. --- lib/scripts/media.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 530e93055..57f599163 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -774,6 +774,6 @@ addInitEvent(function(){ media_manager.selectorattach($('media__content')); media_manager.confirmattach($('media__content')); media_manager.attachoptions($('media__opts')); - //media_manager.initpopup(); + media_manager.initpopup(); media_manager.initFlashUpload(); }); -- cgit v1.2.3 From 4b1755bd15d9e5427c81f638e2b06d4716cd8642 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 21 Apr 2011 09:18:05 +0200 Subject: Make locktimer more robust If no HTML element with the id wiki__text exists, locktimer.init led to a JavaScript error. --- lib/scripts/locktimer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/locktimer.js b/lib/scripts/locktimer.js index f5ba1c60d..0db7d2b15 100644 --- a/lib/scripts/locktimer.js +++ b/lib/scripts/locktimer.js @@ -9,7 +9,11 @@ var locktimer = { msg: '', pageid: '', - init: function(timeout,msg,draft){ + init: function(timeout,msg,draft,edid){ + var edit = $(edid); + if(!edit) return; + if(edit.readOnly) return; + // init values locktimer.timeout = timeout*1000; locktimer.msg = msg; @@ -19,7 +23,6 @@ var locktimer = { if(!$('dw__editform')) return; locktimer.pageid = $('dw__editform').elements.id.value; if(!locktimer.pageid) return; - if($('wiki__text').readOnly) return; // init ajax component locktimer.sack = new sack(DOKU_BASE + 'lib/exe/ajax.php'); -- cgit v1.2.3