From ca09b77d620896e202fa5eb4da4d30eed0c92ba3 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 9 Jan 2010 13:05:24 +0100 Subject: Avoid whitespace because of toolbar pickers FS#1841 --- lib/scripts/edit.js | 1 + lib/scripts/linkwiz.js | 3 +++ lib/scripts/toolbar.js | 3 +++ 3 files changed, 7 insertions(+) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index ef0a9a106..a80c8a06e 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -68,6 +68,7 @@ function createPicker(id,props,edid){ picker.id = id; picker.style.position = 'absolute'; picker.style.marginLeft = '-10000px'; // no display:none, to keep access keys working + picker.style.marginTop = '-10000px'; for(var key in list){ if (!list.hasOwnProperty(key)) continue; diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index d687ebbeb..4528d9591 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -30,6 +30,7 @@ var linkwiz = { linkwiz.wiz.style.top = (findPosY(textArea)+20)+'px'; linkwiz.wiz.style.left = (findPosX(textArea)+80)+'px'; linkwiz.wiz.style.marginLeft = '-10000px'; + linkwiz.wiz.style.marginTop = '-10000px'; linkwiz.wiz.innerHTML = ''+ '
'+LANG['linkto']+'
'+ ''; - textArea.form.parentNode.appendChild(linkwiz.wiz); + $('dw__editform').parentNode.appendChild(linkwiz.wiz); linkwiz.textArea = textArea; linkwiz.result = $('link__wiz_result'); linkwiz.entry = $('link__wiz_entry'); -- cgit v1.2.3 From 7e783d07e8533b7e27cec02dd2227ddc83d26d47 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 9 Mar 2010 10:07:09 +0100 Subject: Introduce toolbar buttons for headers and stuff --- lib/scripts/toolbar.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/scripts') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 37987c21a..3f967448c 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -18,6 +18,10 @@ function initToolbar(tbid,edid,tb, allowblock){ if(!edit) return; if(edit.readOnly) return; + if (typeof allowblock === 'undefined') { + allowblock = true; + } + //empty the toolbar area: toolbar.innerHTML=''; -- cgit v1.2.3 From a958c48cfeaefd8e8c1aeebcd04e9c862f014a6d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 12 Mar 2010 14:35:43 +0100 Subject: removed dead leftover code from media search --- lib/scripts/media.js | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/media.js b/lib/scripts/media.js index f14db63d7..95b1ab69e 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -147,33 +147,6 @@ var media_manager = { media_manager.updatehide(); }, - /** - * Opens the searchfield - * - * @author Tobias Sarnowski - */ - showsearchfield: function(event,link){ - // prepare an AJAX call to fetch the search - var ajax = new sack(DOKU_BASE + 'lib/exe/ajax.php'); - ajax.AjaxFailedAlert = ''; - ajax.encodeURIString = false; - if(ajax.failed) return true; - - cleanMsgArea(); - - var content = $('media__content'); - content.innerHTML = '...'; - - ajax.elementObj = content; - ajax.afterCompletion = function(){ - media_manager.selectorattach(content); - media_manager.confirmattach(content); - media_manager.updatehide(); - }; - ajax.runAJAX(link.search.substr(1)+'&call=mediasearchlist'); - return false; - }, - /** * Toggles the keep open state * -- cgit v1.2.3 From fda42deb082e4bdb560818a9c23b96f9312176d5 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 15 Mar 2010 16:57:38 +0100 Subject: Various JavaScript fixes * Syntax error fixed * lock refresh event is now attached to the whole edit form since it bubbles up and we cannot be sure that the wikitext input exists on all edit forms * Updated findPos(X|Y) * Easier and less error-prone way of getting the section edit button in the highlight mouseover event handler --- lib/scripts/drag.js | 3 +-- lib/scripts/edit.js | 3 +-- lib/scripts/script.js | 16 +++++++--------- 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/drag.js b/lib/scripts/drag.js index 254eab4a6..169be5219 100644 --- a/lib/scripts/drag.js +++ b/lib/scripts/drag.js @@ -83,6 +83,5 @@ var drag = { this.obj.style.top = (e.pageY+this.oY-this.eY+'px'); this.obj.style.left = (e.pageX+this.oX-this.eX+'px'); } - }, - + } }; diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 58433f25c..b756e9488 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -386,8 +386,7 @@ var locktimer = new locktimer_class(); locktimer.sack.onCompletion = locktimer.refreshed; // register refresh event - addEvent($('dw__editform').elements.wikitext,'keypress',function(){locktimer.refresh();}); - + addEvent($('dw__editform'),'keypress',function(){locktimer.refresh();}); // start timer locktimer.reset(); }; diff --git a/lib/scripts/script.js b/lib/scripts/script.js index bf6f41ce5..27d088584 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -78,16 +78,15 @@ function getElementsByClass(searchClass,node,tag) { /** * Get the X offset of the top left corner of the given object * - * @link http://www.quirksmode.org/index.html?/js/findpos.html + * @link http://www.quirksmode.org/js/findpos.html */ function findPosX(object){ var curleft = 0; var obj = $(object); if (obj.offsetParent){ - while (obj.offsetParent){ + do { curleft += obj.offsetLeft; - obj = obj.offsetParent; - } + } while (obj = obj.offsetParent); } else if (obj.x){ curleft += obj.x; @@ -98,16 +97,15 @@ function findPosX(object){ /** * Get the Y offset of the top left corner of the given object * - * @link http://www.quirksmode.org/index.html?/js/findpos.html + * @link http://www.quirksmode.org/js/findpos.html */ function findPosY(object){ var curtop = 0; var obj = $(object); if (obj.offsetParent){ - while (obj.offsetParent){ + do { curtop += obj.offsetTop; - obj = obj.offsetParent; - } + } while (obj = obj.offsetParent); } else if (obj.y){ curtop += obj.y; @@ -535,7 +533,7 @@ addInitEvent(function(){ var btns = getElementsByClass('btn_secedit',document,'form'); for(var i=0; i Date: Mon, 22 Mar 2010 17:00:02 +0100 Subject: Really remove edit highlighting on mouseout --- lib/scripts/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 27d088584..25b10205c 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -552,7 +552,7 @@ addInitEvent(function(){ addEvent(btns[i],'mouseout',function(e){ var secs = getElementsByClass('section_highlight'); for(var j=0; j Date: Mon, 22 Mar 2010 20:30:44 +0100 Subject: fixed Safari browser detection --- lib/scripts/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 25b10205c..205d3f706 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -9,7 +9,7 @@ var clientPC = navigator.userAgent.toLowerCase(); // Get client info var is_macos = navigator.appVersion.indexOf('Mac') != -1; var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1) && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1)); -var is_safari = ((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1)); +var is_safari = ((clientPC.indexOf('applewebkit')!=-1) && (clientPC.indexOf('spoofer')==-1)); var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled )); if (clientPC.indexOf('opera')!=-1) { var is_opera = true; -- cgit v1.2.3 From 26ee1edf9c1750df399baebcb70afb49778b4a92 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 25 Mar 2010 15:01:25 +0100 Subject: Rewrite JavaScript change check --- lib/scripts/edit.js | 59 +++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 33 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index b756e9488..eeca27353 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -260,9 +260,9 @@ var textChanged = false; /** * Check for changes before leaving the page */ -function changeCheck(msg){ +function changeCheck(){ if(textChanged){ - var ok = confirm(msg); + var ok = confirm(LANG.notsavedyet); if(ok){ // remove a possibly saved draft using ajax var dwform = $('dw__editform'); @@ -289,57 +289,50 @@ function changeCheck(msg){ * JSnocheck class), add handlers to monitor changes * * Sets focus to the editbox as well - * - * @fixme this is old and crappy code. needs to be redone */ -function initChangeCheck(msg){ - var edit_text = document.getElementById('wiki__text'); - if(!edit_text) return; - if(edit_text.readOnly) return; - if(!$('dw__editform')) return; +addInitEvent(function (){ + var editform = $('dw__editform'); + if (!editform) return; + + var edit_text = $('wiki__text'); + if(edit_text) { + if(edit_text.readOnly) return; + + // set focus + edit_text.focus(); + } + + var checkfunc = function(){ + textChanged = true; //global var + summaryCheck(); + }; + addEvent(editform, 'change', checkfunc); + addEvent(editform, 'keydown', checkfunc); // add change check for links var links = document.getElementsByTagName('a'); for(var i=0; i < links.length; i++){ if(links[i].className.indexOf('JSnocheck') == -1){ - links[i].onclick = function(){ - var rc = changeCheck(msg); - if(window.event) window.event.returnValue = rc; - return rc; - }; + addEvent(links[i], 'click', changeCheck); } } // add change check for forms var forms = document.forms; for(i=0; i < forms.length; i++){ if(forms[i].className.indexOf('JSnocheck') == -1){ - forms[i].onsubmit = function(){ - var rc = changeCheck(msg); - if(window.event) window.event.returnValue = rc; - return rc; - }; + addEvent(forms[i], 'submit', changeCheck); } } // reset change memory var on submit - var btn_save = document.getElementById('edbtn__save'); - btn_save.onclick = function(){ textChanged = false; }; - var btn_prev = document.getElementById('edbtn__preview'); - btn_prev.onclick = function(){ textChanged = false; }; + addEvent($('edbtn__save'), 'click', function(){ textChanged = false; }); + addEvent($('edbtn__preview'), 'click', function(){ textChanged = false; }); - // add change memory setter - edit_text.onchange = function(){ - textChanged = true; //global var - summaryCheck(); - }; - var summary = document.getElementById('edit__summary'); + var summary = $('edit__summary'); addEvent(summary, 'change', summaryCheck); addEvent(summary, 'keyup', summaryCheck); if (textChanged) summaryCheck(); - - // set focus - edit_text.focus(); -} +}); /** * Checks if a summary was entered - if not the style is changed -- cgit v1.2.3 From 7d54a99ffcfd517bfc9bc5e18eb3f87922617077 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 25 Mar 2010 15:45:54 +0100 Subject: Do not try to save a draft in alternative editors --- lib/scripts/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index eeca27353..9437aa14e 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -420,7 +420,7 @@ var locktimer = new locktimer_class(); // refresh every minute only if(now.getTime() - locktimer.lasttime.getTime() > 30*1000){ //FIXME decide on time var params = 'call=lock&id='+encodeURIComponent(locktimer.pageid); - if(locktimer.draft){ + if(locktimer.draft && dwform.elements.wikitext){ var dwform = $('dw__editform'); params += '&prefix='+encodeURIComponent(dwform.elements.prefix.value); params += '&wikitext='+encodeURIComponent(dwform.elements.wikitext.value); -- cgit v1.2.3 From cd12dcad1a482ea805f8dcc58b364e9c6cddc667 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 2 Feb 2010 16:20:17 +0100 Subject: JavaScript syntax fixes --- lib/scripts/events.js | 8 ++++---- lib/scripts/helpers.js | 4 ++-- lib/scripts/textselection.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/events.js b/lib/scripts/events.js index 2ea619085..df46cc1cf 100644 --- a/lib/scripts/events.js +++ b/lib/scripts/events.js @@ -107,8 +107,8 @@ window.fireoninit = function() { } // for Internet Explorer (using conditional comments) - /*@cc_on @*/ - /*@if (@_win32) + /*@cc_on + @if (@_win32) document.write("<\/script>"); var script = document.getElementById("__ie_init"); script.onreadystatechange = function() { @@ -116,7 +116,7 @@ window.fireoninit = function() { window.fireoninit(); // call the onload handler } }; - /*@end @*/ + @end @*/ // for Safari if (/WebKit/i.test(navigator.userAgent)) { // sniff @@ -176,5 +176,5 @@ function bind (fnc) { var args = Array.prototype.slice.call(arguments, 1); return function() { return fnc.apply(this, args); - } + }; } diff --git a/lib/scripts/helpers.js b/lib/scripts/helpers.js index 8d4f3ea78..129964d29 100644 --- a/lib/scripts/helpers.js +++ b/lib/scripts/helpers.js @@ -109,7 +109,7 @@ function isEmpty (prop /* :Object */) /* :Boolean */ { if (isRegExp(prop) && new RegExp("").toString() == prop.toString()) return true; if (isString(prop) || isNumber(prop)) return !prop; if (Boolean(prop)&&false != prop) { - for (var i in prop) if(prop.hasOwnProperty(i)) return false + for (var i in prop) if(prop.hasOwnProperty(i)) return false; } return true; } @@ -124,7 +124,7 @@ function isEmpty (prop /* :Object */) /* :Boolean */ { if ('undefined' == typeof Object.hasOwnProperty) { Object.prototype.hasOwnProperty = function (prop) { return !('undefined' == typeof this[prop] || this.constructor && this.constructor.prototype[prop] && this[prop] === this.constructor.prototype[prop]); - } + }; } /** diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 76cc6bcbb..5e4602f85 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -24,7 +24,7 @@ function selection_class(){ this.getText = function(){ if(!this.obj) return ''; return this.obj.value.substring(this.start,this.end); - } + }; } /** -- cgit v1.2.3 From ea6dfbca91f6afe89ff631ac28eae023bcc52853 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 26 Mar 2010 15:17:26 +0100 Subject: Rewrite footnote popup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Popup now shows up relative to the link, not the mouse position * Easier handling of mouseout’s bubbling * Factor out popup creation to allow plugins to use it --- lib/scripts/script.js | 82 +++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 51 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 205d3f706..99dade692 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -234,57 +234,51 @@ function toggleToc() { } /** - * Display an insitu footnote popup - * - * @author Andreas Gohr - * @author Chris Smith + * Create JavaScript mouseover popup */ -function footnote(e){ - var obj = e.target; - var id = obj.id.substr(5); +function insitu_popup(target, popup_id) { - // get or create the footnote popup div - var fndiv = $('insitu__fn'); + // get or create the popup div + var fndiv = $(popup_id); if(!fndiv){ fndiv = document.createElement('div'); - fndiv.id = 'insitu__fn'; + fndiv.id = popup_id; fndiv.className = 'insitu-footnote JSpopup dokuwiki'; // autoclose on mouseout - ignoring bubbled up events addEvent(fndiv,'mouseout',function(e){ - if(e.target != fndiv){ - e.stopPropagation(); - return; + var p = e.relatedTarget || e.toElement; + while (p && p !== this) { + p = p.parentNode; } - // check if the element was really left - if(e.pageX){ // Mozilla - var bx1 = findPosX(fndiv); - var bx2 = bx1 + fndiv.offsetWidth; - var by1 = findPosY(fndiv); - var by2 = by1 + fndiv.offsetHeight; - var x = e.pageX; - var y = e.pageY; - if(x > bx1 && x < bx2 && y > by1 && y < by2){ - // we're still inside boundaries - e.stopPropagation(); - return; - } - }else{ // IE - if(e.offsetX > 0 && e.offsetX < fndiv.offsetWidth-1 && - e.offsetY > 0 && e.offsetY < fndiv.offsetHeight-1){ - // we're still inside boundaries - e.stopPropagation(); - return; - } + if (p === this) { + return; } // okay, hide it - fndiv.style.display='none'; + this.style.display='none'; }); - document.body.appendChild(fndiv); + getElementsByClass('dokuwiki', document.body, 'div')[0].appendChild(fndiv); } + // position the div and make it visible + fndiv.style.position = 'absolute'; + fndiv.style.left = findPosX(target)+'px'; + fndiv.style.top = (findPosY(target)+target.scrollHeight * 1.5) + 'px'; + fndiv.style.display = ''; + return fndiv; +} + +/** + * Display an insitu footnote popup + * + * @author Andreas Gohr + * @author Chris Smith + */ +function footnote(e){ + var fndiv = insitu_popup(e.target, 'insitu__fn'); + // locate the footnote anchor element - var a = $( "fn__"+id ); + var a = $("fn__" + e.target.id.substr(5)); if (!a){ return; } // anchor parent is the footnote container, get its innerHTML @@ -295,24 +289,10 @@ function footnote(e){ content = content.replace(/^\s+(,\s+)+/,''); // prefix ids on any elements with "insitu__" to ensure they remain unique - content = content.replace(/\bid=\"(.*?)\"/gi,'id="insitu__$1'); + content = content.replace(/\bid=(['"])([^"']+)\1/gi,'id="insitu__$2'); // now put the content into the wrapper fndiv.innerHTML = content; - - // position the div and make it visible - var x; var y; - if(e.pageX){ // Mozilla - x = e.pageX; - y = e.pageY; - }else{ // IE - x = e.offsetX; - y = e.offsetY; - } - fndiv.style.position = 'absolute'; - fndiv.style.left = (x+2)+'px'; - fndiv.style.top = (y+2)+'px'; - fndiv.style.display = ''; } /** -- cgit v1.2.3 From 2a98590b375e0acfd24fb0da343eb09a3ff76ff3 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 29 Mar 2010 16:58:14 +0200 Subject: Better footnote popup positioning --- lib/scripts/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 99dade692..d8205b876 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -263,7 +263,7 @@ function insitu_popup(target, popup_id) { // position the div and make it visible fndiv.style.position = 'absolute'; fndiv.style.left = findPosX(target)+'px'; - fndiv.style.top = (findPosY(target)+target.scrollHeight * 1.5) + 'px'; + fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5) + 'px'; fndiv.style.display = ''; return fndiv; } -- cgit v1.2.3 From 288007e19d34550294a9ad820b6ffa11bba0e5b3 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 26 Apr 2010 16:18:20 +0200 Subject: Fix lock refresh and draft saving --- lib/scripts/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 9437aa14e..e66154f83 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -420,8 +420,8 @@ var locktimer = new locktimer_class(); // 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){ - var dwform = $('dw__editform'); params += '&prefix='+encodeURIComponent(dwform.elements.prefix.value); params += '&wikitext='+encodeURIComponent(dwform.elements.wikitext.value); params += '&suffix='+encodeURIComponent(dwform.elements.suffix.value); -- cgit v1.2.3 From 28f6aae1adeef509aa7be8895088cc9f47018054 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 29 Apr 2010 13:08:15 +0200 Subject: Support getSelection in input fields in IE --- lib/scripts/textselection.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 5e4602f85..0378b544d 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -41,7 +41,6 @@ function getSelection(textArea) { sel.obj = textArea; sel.start = textArea.value.length; sel.end = textArea.value.length; - textArea.focus(); if(document.getSelection) { // Mozilla et al. sel.start = textArea.selectionStart; @@ -57,9 +56,13 @@ function getSelection(textArea) { // The current selection sel.rangeCopy = document.selection.createRange().duplicate(); - - var before_range = document.body.createTextRange(); - before_range.moveToElementText(textArea); // Selects all the text + if (textArea.tagName === 'INPUT') { + var before_range = textArea.createTextRange(); + before_range.expand('textedit'); // Selects all the text + } else { + var before_range = document.body.createTextRange(); + before_range.moveToElementText(textArea); // Selects all the text + } before_range.setEndPoint("EndToStart", sel.rangeCopy); // Moves the end where we need it var before_finished = false, selection_finished = false; -- cgit v1.2.3 From dc62d03d27d24a66840b83c5333221f5123ad203 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 30 Apr 2010 06:20:41 +0200 Subject: optimized SMB link warning thingy --- lib/scripts/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/script.js b/lib/scripts/script.js index d8205b876..57917aeb5 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -482,14 +482,14 @@ addInitEvent(function(){ */ function checkWindowsShares() { if(!LANG['nosmblinks']) return true; + if(document.all != null) return true; + var elems = getElementsByClass('windows',document,'a'); if(elems){ for(var i=0; i Date: Tue, 27 Apr 2010 00:40:25 +0200 Subject: Reimplementation of Accesskeys in JavaScript (FS#1809) --- lib/scripts/hotkeys.js | 265 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 lib/scripts/hotkeys.js (limited to 'lib/scripts') diff --git a/lib/scripts/hotkeys.js b/lib/scripts/hotkeys.js new file mode 100644 index 000000000..d062118fb --- /dev/null +++ b/lib/scripts/hotkeys.js @@ -0,0 +1,265 @@ +/** + * Some of these scripts were taken from TinyMCE (http://tinymce.moxiecode.com/) and were modified for DokuWiki + * + * Class handles accesskeys using javascript and also provides ability + * to register and use other hotkeys as well. + * + * @author Marek Sacha + */ +function Hotkeys() { + + this.shortcuts = new Array(); + + /** + * Set modifier keys, for instance: + * this.modifier = 'ctrl'; + * this.modifier = 'ctrl+shift'; + * this.modifier = 'ctrl+alt+shift'; + * this.modifier = 'alt'; + * this.modifier = 'alt+shift'; + */ + this.modifier = 'ctrl'; + + /** + * Initialization + * + * This function looks up all the accesskeys used in the current page + * (at anchor elements and input elements [type="submit"]) and registers + * appropriate shortcuts. + * + * @author Marek Sacha + */ + this.initialize = function() { + var t = this; + /** + * Lookup all anchors with accesskey and register event - go to anchor + * target. + */ + var anchors = document.getElementsByTagName("a"); + t.each(anchors, function(a) { + if (a.accessKey != "") { + t.addShortcut(t.modifier + '+' + a.accessKey, function() { + window.location.href = a.href; + }); + } + }); + + /** + * Lookup all input [type="submit"] with accesskey and register event - + * perform "click" on a button. + */ + var inputs = document.getElementsByTagName("input"); + t.each(inputs, function(i) { + if (i.type == "submit") { + t.addShortcut(t.modifier + '+' + i.accessKey, function() { + i.click(); + }); + } + }); + }; + + /** + * Keyup processing function + * Function returns true if keyboard event has registered handler, and + * executes the handler function. + * + * @param e KeyboardEvent + * @author Marek Sacha + * @return b boolean + */ + this.onkeyup = function(e) { + var t = this; + var v = t.findShortcut(e); + if (v != null && v != false) { + v.func.call(t); + return false; + } + return true; + }; + + /** + * Keydown processing function + * Function returns true if keyboard event has registered handler + * + * @param e KeyboardEvent + * @author Marek Sacha + * @return b boolean + */ + this.onkeydown = function(e) { + var t = this; + var v = t.findShortcut(e); + if (v != null && v != false) { + return false; + } + return true; + }; + + /** + * Keypress processing function + * Function returns true if keyboard event has registered handler + * + * @param e KeyboardEvent + * @author Marek Sacha + * @return b + */ + this.onkeypress = function(e) { + var t = this; + var v = t.findShortcut(e); + if (v != null && v != false) { + return false; + } + return true; + }; + + /** + * Register new shortcut + * + * This function registers new shortcuts, each shortcut is defined by its + * modifier keys and a key (with + as delimiter). If shortcut is pressed + * cmd_function is performed. + * + * For example: + * pa = "ctrl+alt+p"; + * pa = "shift+alt+s"; + * + * Full example of method usage: + * hotkeys.addShortcut('ctrl+s',function() { + * document.getElementByID('form_1').submit(); + * }); + * + * @param pa String description of the shortcut (ctrl+a, ctrl+shift+p, .. ) + * @param cmd_func Function to be called if shortcut is pressed + * @author Marek Sacha + */ + this.addShortcut = function(pa, cmd_func) { + var t = this; + + var o = { + func : cmd_func, + alt : false, + ctrl : false, + shift : false + }; + + t.each(t.explode(pa, '+'), function(v) { + switch (v) { + case 'alt': + case 'ctrl': + case 'shift': + o[v] = true; + break; + + default: + o.charCode = v.charCodeAt(0); + o.keyCode = v.toUpperCase().charCodeAt(0); + } + }); + + t.shortcuts.push((o.ctrl ? 'ctrl' : '') + ',' + (o.alt ? 'alt' : '') + ',' + (o.shift ? 'shift' : '') + ',' + o.keyCode, o); + + return true; + }; + + /** + * @property isMac + */ + this.isMac = (navigator.userAgent.indexOf('Mac') != -1); + + /** + * Apply function cb on each element of o in the namespace of s + * @param o Array of objects + * @param cb Function to be called on each object + * @param s Namespace to be used during call of cb (default namespace is o) + * @author Marek Sacha + */ + this.each = function(o, cb, s) { + var n, l; + + if (!o) + return 0; + + s = s || o; + + if (o.length !== undefined) { + // Indexed arrays, needed for Safari + for (n=0, l = o.length; n < l; n++) { + if (cb.call(s, o[n], n, o) === false) + return 0; + } + } else { + // Hashtables + for (n in o) { + if (o.hasOwnProperty(n)) { + if (cb.call(s, o[n], n, o) === false) + return 0; + } + } + } + + return 1; + }; + + /** + * Explode string according to delimiter + * @param s String + * @param d Delimiter (default ',') + * @author Marek Sacha + * @return a Array of tokens + */ + this.explode = function(s, d) { + return s.split(d || ','); + }; + + /** + * Find if the shortcut was registered + * + * @param e KeyboardEvent + * @author Marek Sacha + * @return v Shortcut structure or null if not found + */ + this.findShortcut = function (e) { + var t = this; + var v = null; + + /* No modifier key used - shortcut does not exist */ + if (!e.altKey && !e.ctrlKey && !e.metaKey) { + return v; + } + + t.each(t.shortcuts, function(o) { + if (t.isMac && o.ctrl != e.metaKey) + return; + else if (!t.isMac && o.ctrl != e.ctrlKey) + return; + + if (o.alt != e.altKey) + return; + + if (o.shift != e.shiftKey) + return; + + if (e.keyCode == o.keyCode || (e.charCode && e.charCode == o.charCode)) { + v = o; + return; + } + }); + return v; + }; +} + +addInitEvent(function(){ + var hotkeys = new Hotkeys(); + hotkeys.initialize(); + + addEvent(document,'keyup',function (e) { + return hotkeys.onkeyup.call(hotkeys,e); + }); + + addEvent(document,'keypress',function (e) { + return hotkeys.onkeypress.call(hotkeys,e); + }); + + addEvent(document,'keydown',function (e) { + return hotkeys.onkeydown.call(hotkeys,e); + }); +}); \ No newline at end of file -- cgit v1.2.3 From 4062d3d5c0c566751a1f098495e9aa836e8db9de Mon Sep 17 00:00:00 2001 From: Marek Sacha Date: Fri, 30 Apr 2010 17:18:40 +0200 Subject: Reimplementation of Accesskeys in javascript (FS#1809), toolbar accesskyes fix. --- lib/scripts/hotkeys.js | 58 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/hotkeys.js b/lib/scripts/hotkeys.js index d062118fb..9e2b9cb83 100644 --- a/lib/scripts/hotkeys.js +++ b/lib/scripts/hotkeys.js @@ -27,6 +27,9 @@ function Hotkeys() { * (at anchor elements and input elements [type="submit"]) and registers * appropriate shortcuts. * + * Secondly, initialization registers listeners on document to catch all + * keyboard events. + * * @author Marek Sacha */ this.initialize = function() { @@ -39,7 +42,7 @@ function Hotkeys() { t.each(anchors, function(a) { if (a.accessKey != "") { t.addShortcut(t.modifier + '+' + a.accessKey, function() { - window.location.href = a.href; + a.click(); }); } }); @@ -50,12 +53,41 @@ function Hotkeys() { */ var inputs = document.getElementsByTagName("input"); t.each(inputs, function(i) { - if (i.type == "submit") { + if (i.type == "submit" && i.accessKey != "") { t.addShortcut(t.modifier + '+' + i.accessKey, function() { i.click(); }); } }); + + /** + * Lookup all buttons with accesskey and register event - + * perform "click" on a button. + */ + var buttons = document.getElementsByTagName("button"); + t.each(buttons, function(b) { + if (b.accessKey != "") { + t.addShortcut(t.modifier + '+' + b.accessKey, function() { + b.click(); + }); + } + }); + + /** + * Register listeners on document to catch keyboard events. + */ + + addEvent(document,'keyup',function (e) { + return t.onkeyup.call(t,e); + }); + + addEvent(document,'keypress',function (e) { + return t.onkeypress.call(t,e); + }); + + addEvent(document,'keydown',function (e) { + return t.onkeydown.call(t,e); + }); }; /** @@ -247,19 +279,13 @@ function Hotkeys() { }; } -addInitEvent(function(){ +/** + * Init function for hotkeys. Called from js.php, to ensure hotkyes are initialized after toolbar. + * Call of addInitEvent(initializeHotkeys) is unnecessary now. + * + * @author Marek Sacha + */ +function initializeHotkeys() { var hotkeys = new Hotkeys(); hotkeys.initialize(); - - addEvent(document,'keyup',function (e) { - return hotkeys.onkeyup.call(hotkeys,e); - }); - - addEvent(document,'keypress',function (e) { - return hotkeys.onkeypress.call(hotkeys,e); - }); - - addEvent(document,'keydown',function (e) { - return hotkeys.onkeydown.call(hotkeys,e); - }); -}); \ No newline at end of file +} \ No newline at end of file -- cgit v1.2.3 From dd512d246ef7a200ca1137bb267aee87380a2f6c Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 8 May 2010 12:09:19 +0200 Subject: use ALT as hotkey modifier --- lib/scripts/hotkeys.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/hotkeys.js b/lib/scripts/hotkeys.js index 9e2b9cb83..2b696e78d 100644 --- a/lib/scripts/hotkeys.js +++ b/lib/scripts/hotkeys.js @@ -18,7 +18,7 @@ function Hotkeys() { * this.modifier = 'alt'; * this.modifier = 'alt+shift'; */ - this.modifier = 'ctrl'; + this.modifier = 'alt'; /** * Initialization @@ -288,4 +288,4 @@ function Hotkeys() { function initializeHotkeys() { var hotkeys = new Hotkeys(); hotkeys.initialize(); -} \ No newline at end of file +} -- cgit v1.2.3 From 7e1f9fd36044e5c651c71348897a3a3dc103d15a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 26 Jun 2010 13:54:29 +0200 Subject: Hotkey trigger is now CTRL-ALT FS#1958 Tests and feedbacks please! --- lib/scripts/hotkeys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/hotkeys.js b/lib/scripts/hotkeys.js index 2b696e78d..2b6fb6d96 100644 --- a/lib/scripts/hotkeys.js +++ b/lib/scripts/hotkeys.js @@ -18,7 +18,7 @@ function Hotkeys() { * this.modifier = 'alt'; * this.modifier = 'alt+shift'; */ - this.modifier = 'alt'; + this.modifier = 'ctrl+alt'; /** * Initialization -- cgit v1.2.3 From 40f3c0b59813d467030d51948d518069141fd998 Mon Sep 17 00:00:00 2001 From: Gina Haeussge Date: Sun, 27 Jun 2010 12:25:15 +0200 Subject: FS#433: Editor now uses onbeforeunload event to capture ANY leaving of it besides via Save or Preview button. This has been successfully tested in FF, Chrome and IE6/7/8. Opera does not support onbeforeunload, therefore the draft is kept if the user navigates away from the editor. Please test this. --- lib/scripts/edit.js | 59 ++++++++++++++++++++------------------------------ lib/scripts/tw-sack.js | 5 +++-- 2 files changed, 26 insertions(+), 38 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index e66154f83..5178dba4c 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -258,35 +258,30 @@ function currentHeadlineLevel(textboxId){ var textChanged = false; /** - * Check for changes before leaving the page + * Delete the draft before leaving the page */ -function changeCheck(){ - if(textChanged){ - var ok = confirm(LANG.notsavedyet); - if(ok){ - // remove a possibly saved draft using ajax - var dwform = $('dw__editform'); - if(dwform){ - var params = 'call=draftdel'; - params += '&id='+encodeURIComponent(dwform.elements.id.value); - - var sackobj = new sack(DOKU_BASE + 'lib/exe/ajax.php'); - sackobj.AjaxFailedAlert = ''; - sackobj.encodeURIString = false; - sackobj.runAJAX(params); - // we send this request blind without waiting for - // and handling the returned data - } +function deleteDraft() { + if (is_opera) return; + + // remove a possibly saved draft using ajax + var dwform = $('dw__editform'); + if(dwform){ + var params = 'call=draftdel'; + params += '&id='+encodeURIComponent(dwform.elements.id.value); + + var sackobj = new sack(DOKU_BASE + 'lib/exe/ajax.php'); + // this needs to be synchronous and GET to not be aborted upon page unload + sackobj.asynchronous = false; + sackobj.method = 'GET'; + sackobj.AjaxFailedAlert = ''; + sackobj.encodeURIString = false; + sackobj.runAJAX(params); } - return ok; - }else{ - return true; - } } /** - * Add changeCheck to all Links and Forms (except those with a - * JSnocheck class), add handlers to monitor changes + * Activate "not saved" dialog, add draft deletion to page unload, + * add handlers to monitor changes * * Sets focus to the editbox as well */ @@ -309,20 +304,12 @@ addInitEvent(function (){ addEvent(editform, 'change', checkfunc); addEvent(editform, 'keydown', checkfunc); - // add change check for links - var links = document.getElementsByTagName('a'); - for(var i=0; i < links.length; i++){ - if(links[i].className.indexOf('JSnocheck') == -1){ - addEvent(links[i], 'click', changeCheck); - } - } - // add change check for forms - var forms = document.forms; - for(i=0; i < forms.length; i++){ - if(forms[i].className.indexOf('JSnocheck') == -1){ - addEvent(forms[i], 'submit', changeCheck); + window.onbeforeunload = function(){ + if(textChanged) { + return LANG.notsavedyet; } } + window.onunload = deleteDraft; // reset change memory var on submit addEvent($('edbtn__save'), 'click', function(){ textChanged = false; }); diff --git a/lib/scripts/tw-sack.js b/lib/scripts/tw-sack.js index cfcbe0ea9..b5a5c8861 100644 --- a/lib/scripts/tw-sack.js +++ b/lib/scripts/tw-sack.js @@ -10,6 +10,7 @@ function sack(file){ this.URLString = ""; this.encodeURIString = true; this.execute = false; + this.asynchronous = true; this.onLoading = function() { }; this.onLoaded = function() { }; @@ -86,9 +87,9 @@ function sack(file){ var self = this; if (this.method == "GET") { var totalurlstring = this.requestFile + "?" + this.URLString; - this.xmlhttp.open(this.method, totalurlstring, true); + this.xmlhttp.open(this.method, totalurlstring, this.asynchronous); } else { - this.xmlhttp.open(this.method, this.requestFile, true); + this.xmlhttp.open(this.method, this.requestFile, this.asynchronous); } if (this.method == "POST"){ try { -- cgit v1.2.3 From bbbf585321cf3464191ccd772baef4ee26a24e3b Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 27 Jun 2010 15:16:39 +0200 Subject: Added missing ";" in edit.js --- lib/scripts/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 5178dba4c..b9767fdc0 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -308,7 +308,7 @@ addInitEvent(function (){ if(textChanged) { return LANG.notsavedyet; } - } + }; window.onunload = deleteDraft; // reset change memory var on submit -- cgit v1.2.3 From 136982455ae0eddc18744176db33fbd7b421e11c Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 27 Jun 2010 18:34:57 +0200 Subject: Fixed automatic insertion of listbullets in Opera FS#1877 The keydown event can't be prevented in Opera (see http://www.quirksmode.org/dom/events/keys.html) so this switches back to keypress in Opera (keypress doesn't give the correct key codes in Firefox). Furthermore Opera replaces '\n' by '\r\n' when inserting text, thus the offset for cursor/selection placement was wrong. --- lib/scripts/edit.js | 10 ++++++++-- lib/scripts/textselection.js | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index b9767fdc0..b507e804b 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -169,7 +169,7 @@ function keyHandler(e){ var scroll = field.scrollHeight; var match2 = search.match(/^\n +[\*-]\s*$/); // Cancel list if the last item is empty (i. e. two times enter) - if (match2 && field.value.substr(selection.start).match(/^($|\n)/)) { + if (match2 && field.value.substr(selection.start).match(/^($|\r?\n)/)) { field.value = field.value.substr(0, linestart) + "\n" + field.value.substr(selection.start); selection.start = linestart + 1; @@ -222,7 +222,13 @@ function keyHandler(e){ addInitEvent(function(){ var field = $('wiki__text'); if(!field) return; - addEvent(field,'keydown',keyHandler); + // in Firefox, keypress doesn't send the correct keycodes, + // in Opera, the default of keydown can't be prevented + if (is_opera) { + addEvent(field,'keypress',keyHandler); + } else { + addEvent(field,'keydown',keyHandler); + } }); /** diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 0378b544d..742338785 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -161,7 +161,12 @@ function pasteText(selection,text,opts){ selection.obj.value.substring(selection.end, selection.obj.value.length); // set new selection - selection.end = selection.start + text.length; + if (is_opera) { + // Opera replaces \n by \r\n when inserting text. + selection.end = selection.start + text.replace(/\r?\n/g, '\r\n').length; + } else { + selection.end = selection.start + text.length; + } // modify the new selection if wanted if(opts.startofs) selection.start += opts.startofs; -- cgit v1.2.3 From ce19c3413a33bcdabb5d71ec713555b540b12c84 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 27 Jun 2010 20:52:45 +0200 Subject: Use OS based Hotkey-Modifier FS#1958 Because ALT-GR fires a CTRL-ALT event on Windows systems, but ALT-GR is needed to write square brackets on German Keyboards, CTRL-ALT can not be used as modifier. This patch introdues OS dependent modifiers. Mac systems continue to use CTRL-ALT, all other systems use only ALT. Let's hope this works out. --- lib/scripts/hotkeys.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/hotkeys.js b/lib/scripts/hotkeys.js index 2b6fb6d96..c340c7f02 100644 --- a/lib/scripts/hotkeys.js +++ b/lib/scripts/hotkeys.js @@ -1,6 +1,6 @@ /** * Some of these scripts were taken from TinyMCE (http://tinymce.moxiecode.com/) and were modified for DokuWiki - * + * * Class handles accesskeys using javascript and also provides ability * to register and use other hotkeys as well. * @@ -17,6 +17,8 @@ function Hotkeys() { * this.modifier = 'ctrl+alt+shift'; * this.modifier = 'alt'; * this.modifier = 'alt+shift'; + * + * overwritten in intitialize (see below) */ this.modifier = 'ctrl+alt'; @@ -34,6 +36,14 @@ function Hotkeys() { */ this.initialize = function() { var t = this; + + //switch modifier key based on OS FS#1958 + if(is_macos){ + t.modifier = 'ctrl+alt'; + }else{ + t.modifier = 'alt'; + } + /** * Lookup all anchors with accesskey and register event - go to anchor * target. @@ -97,7 +107,7 @@ function Hotkeys() { * * @param e KeyboardEvent * @author Marek Sacha - * @return b boolean + * @return b boolean */ this.onkeyup = function(e) { var t = this; -- cgit v1.2.3 From f48ee0bd5efcf14944440e5dcb4042b14301f8ef Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 28 Jul 2010 15:52:20 +0200 Subject: Do not cancel event bubble in drag --- lib/scripts/drag.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/drag.js b/lib/scripts/drag.js index 169be5219..2212fb6c1 100644 --- a/lib/scripts/drag.js +++ b/lib/scripts/drag.js @@ -58,8 +58,6 @@ var drag = { addEvent(document,'mousemove', this.mousehandlers[0]); addEvent(document,'mouseup', this.mousehandlers[1]); - e.preventDefault(); - e.stopPropagation(); return false; }, -- cgit v1.2.3 From 76b21ebd4cee931022ca883426b6d9770c7f5e20 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 28 Jul 2010 15:52:08 +0200 Subject: remove unused IE hack --- lib/scripts/pngbehavior.htc | 53 --------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 lib/scripts/pngbehavior.htc (limited to 'lib/scripts') diff --git a/lib/scripts/pngbehavior.htc b/lib/scripts/pngbehavior.htc deleted file mode 100644 index d1db8e765..000000000 --- a/lib/scripts/pngbehavior.htc +++ /dev/null @@ -1,53 +0,0 @@ -// this is an ugly fix to make Internet Explorer work with transparent -// PNG images - do your self a favour and use a real browser! - - - - - -- cgit v1.2.3 From 16c2466cff13dc43e2f66c5cb1071a2457d4dee3 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 30 Jul 2010 14:37:00 +0200 Subject: Fix event.pageX and pageY correctly --- lib/scripts/events.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/events.js b/lib/scripts/events.js index df46cc1cf..498ec21ff 100644 --- a/lib/scripts/events.js +++ b/lib/scripts/events.js @@ -56,8 +56,9 @@ function fixEvent(event) { // fix target event.target = event.srcElement; // fix coords - event.pageX = (typeof event.pageX !== 'undefined') ? event.pageX : event.clientX + document.body.scrollTop; - event.pageY = (typeof event.pageY !== 'undefined') ? event.pageY : event.clientY + document.body.scrollTop; + var base = (document.documentElement.scrollTop?document.documentElement:document.body); + event.pageX = (typeof event.pageX !== 'undefined') ? event.pageX : event.clientX + base.scrollLeft; + event.pageY = (typeof event.pageY !== 'undefined') ? event.pageY : event.clientY + base.scrollTop; return event; }; -- cgit v1.2.3 From ca0095d06dade6118afd8205b99001892b7f1296 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 30 Jul 2010 12:58:07 +0200 Subject: Fix currentTarget in fixevent --- lib/scripts/events.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/events.js b/lib/scripts/events.js index 498ec21ff..a1fcac718 100644 --- a/lib/scripts/events.js +++ b/lib/scripts/events.js @@ -35,26 +35,26 @@ function removeEvent(element, type, handler) { function handleEvent(event) { var returnValue = true; // grab the event object (IE uses a global event object) - event = event || fixEvent(window.event); + event = event || fixEvent(window.event, this); // get a reference to the hash table of event handlers var handlers = this.events[event.type]; // execute each event handler for (var i in handlers) { if (!handlers.hasOwnProperty(i)) continue; - this.$$handleEvent = handlers[i]; - if (this.$$handleEvent(event) === false) { + if (handlers[i].call(this, event) === false) { returnValue = false; } } return returnValue; }; -function fixEvent(event) { +function fixEvent(event, _this) { // add W3C standard event methods event.preventDefault = fixEvent.preventDefault; event.stopPropagation = fixEvent.stopPropagation; // fix target event.target = event.srcElement; + event.currentTarget = _this; // fix coords var base = (document.documentElement.scrollTop?document.documentElement:document.body); event.pageX = (typeof event.pageX !== 'undefined') ? event.pageX : event.clientX + base.scrollLeft; -- cgit v1.2.3 From b6bf4d661c4578a596f249f1a21ee588be6e4262 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 9 Aug 2010 21:55:45 +0200 Subject: remove accesskey once a JS handler was registered FS#2007 --- lib/scripts/hotkeys.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/scripts') diff --git a/lib/scripts/hotkeys.js b/lib/scripts/hotkeys.js index c340c7f02..356b691ea 100644 --- a/lib/scripts/hotkeys.js +++ b/lib/scripts/hotkeys.js @@ -54,6 +54,7 @@ function Hotkeys() { t.addShortcut(t.modifier + '+' + a.accessKey, function() { a.click(); }); + a.accessKey = ''; } }); @@ -67,6 +68,7 @@ function Hotkeys() { t.addShortcut(t.modifier + '+' + i.accessKey, function() { i.click(); }); + i.accessKey = ''; } }); @@ -80,6 +82,7 @@ function Hotkeys() { t.addShortcut(t.modifier + '+' + b.accessKey, function() { b.click(); }); + b.accessKey = ''; } }); -- cgit v1.2.3 From d259f728f887b2ad76a2531705eac51b7dda8676 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 11 Aug 2010 14:01:40 +0200 Subject: fixed locktimer/draft saving on new pages When creating new pages, no date field is added in the edit form. --- lib/scripts/edit.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index b507e804b..01262bcef 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -418,7 +418,9 @@ var locktimer = new locktimer_class(); params += '&prefix='+encodeURIComponent(dwform.elements.prefix.value); params += '&wikitext='+encodeURIComponent(dwform.elements.wikitext.value); params += '&suffix='+encodeURIComponent(dwform.elements.suffix.value); - params += '&date='+encodeURIComponent(dwform.elements.date.value); + if(dwform.elements.date){ + params += '&date='+encodeURIComponent(dwform.elements.date.value); + } } locktimer.sack.runAJAX(params); locktimer.lasttime = now; -- cgit v1.2.3