From 6b0ec830e5ac0044252908630e52d4494f1df570 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 21 Jul 2013 22:59:27 +0200 Subject: In debug mode: catch and log JS errors with file information When debugging is enabled (allowdebug enabled) JS errors are now catched for each non-core JS file and logged with the additional information from which file they came. This should make it easier to find out which plugin is the cause for broken JS code. The feature isn't enabled by default as defining functions inside try-clauses isn't allowed in strict mode and causes a warning at least in Firefox. --- lib/scripts/helpers.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/scripts') diff --git a/lib/scripts/helpers.js b/lib/scripts/helpers.js index d6f36967d..fdac13b71 100644 --- a/lib/scripts/helpers.js +++ b/lib/scripts/helpers.js @@ -68,3 +68,18 @@ function bind(fnc/*, ... */) { static_args.concat(Aps.call(arguments, 0))); }; } + +/** + * Report an error from a JS file to the console + * + * @param e The error object + * @param file The file in which the error occurred + */ +function logError(e, file) { + if (window.console && console.error) { + console.error('The error "%s: %s" occurred in file "%s". ' + + 'If this is in a plugin try updating or disabling the plugin, ' + + 'if this is in a template try updating the template or switching to the "default" or "dokuwiki" template.', + e.name, e.message, file); + } +} \ No newline at end of file -- cgit v1.2.3 From c6f665dd924dfa715fc19140c26d25eddcef9841 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 30 Jul 2013 17:50:17 +0200 Subject: Don't recommend the deprecated default template for JS debugging --- lib/scripts/helpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/helpers.js b/lib/scripts/helpers.js index fdac13b71..677abbad7 100644 --- a/lib/scripts/helpers.js +++ b/lib/scripts/helpers.js @@ -79,7 +79,7 @@ function logError(e, file) { if (window.console && console.error) { console.error('The error "%s: %s" occurred in file "%s". ' + 'If this is in a plugin try updating or disabling the plugin, ' + - 'if this is in a template try updating the template or switching to the "default" or "dokuwiki" template.', + 'if this is in a template try updating the template or switching to the "dokuwiki" template.', e.name, e.message, file); } -} \ No newline at end of file +} -- cgit v1.2.3 From 0e1777cbe86faf809f67198704842a01034a1a98 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Wed, 31 Jul 2013 17:05:07 +0100 Subject: added aria attributes to tree and show/hide functions --- lib/scripts/behaviour.js | 2 ++ lib/scripts/tree.js | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js index f1c46bf4c..85ddf503e 100644 --- a/lib/scripts/behaviour.js +++ b/lib/scripts/behaviour.js @@ -5,6 +5,7 @@ * @author Adrian Lang */ jQuery.fn.dw_hide = function(fn) { + this.attr('aria-expanded', 'false'); return this.slideUp('fast', fn); }; @@ -15,6 +16,7 @@ jQuery.fn.dw_hide = function(fn) { * @author Adrian Lang */ jQuery.fn.dw_show = function(fn) { + this.attr('aria-expanded', 'true'); return this.slideDown('fast', fn); }; diff --git a/lib/scripts/tree.js b/lib/scripts/tree.js index 96763053d..c4e1da3f7 100644 --- a/lib/scripts/tree.js +++ b/lib/scripts/tree.js @@ -14,6 +14,12 @@ jQuery.fn.dw_tree = function(overrides) { init: function () { this.$obj.delegate(this.toggle_selector, 'click', this, this.toggle); + jQuery('ul:first', this.$obj).attr('role', 'tree'); + jQuery('ul', this.$obj).not(':first').attr('role', 'group'); + jQuery('li', this.$obj).attr('role', 'treeitem'); + jQuery('li.open > ul', this.$obj).attr('aria-expanded', 'true'); + jQuery('li.closed > ul', this.$obj).attr('aria-expanded', 'false'); + jQuery('li.closed', this.$obj).attr('aria-live', 'assertive'); }, /** @@ -35,8 +41,14 @@ jQuery.fn.dw_tree = function(overrides) { $listitem = $clicky.closest('li'); $sublist = $listitem.find('ul').first(); opening = $listitem.hasClass('closed'); - $listitem.toggleClass('open closed'); dw_tree.toggle_display($clicky, opening); + if ($sublist.is(':visible')) { + $listitem.removeClass('open').addClass('closed'); + $sublist.attr('aria-expanded', 'false'); + } else { + $listitem.removeClass('closed').addClass('open'); + $sublist.attr('aria-expanded', 'true'); + } // if already open, close by hiding the sublist if (!opening) { @@ -48,6 +60,8 @@ jQuery.fn.dw_tree = function(overrides) { $sublist.hide(); if (typeof data !== 'undefined') { $sublist.html(data); + $sublist.parent().attr('aria-busy', 'false').removeAttr('aria-live'); + jQuery('li.closed', $sublist).attr('aria-live', 'assertive'); } if ($listitem.hasClass('open')) { // Only show if user didn’t close the list since starting @@ -63,11 +77,11 @@ jQuery.fn.dw_tree = function(overrides) { } //prepare the new ul - $sublist = jQuery('
    '); + $sublist = jQuery('
      '); $listitem.append($sublist); timeout = window.setTimeout( - bind(show_sublist, '
    • loading...
    • '), dw_tree.throbber_delay); + bind(show_sublist, '
    • loading...
    • '), dw_tree.throbber_delay); dw_tree.load_data(function (data) { window.clearTimeout(timeout); -- cgit v1.2.3 From 5a99d25b24f7e14f137084100f40325b7a2a71b4 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Thu, 1 Aug 2013 16:38:02 +0100 Subject: added aria attributes to edit mode --- lib/scripts/edit.js | 9 ++++++--- lib/scripts/editor.js | 1 + lib/scripts/toolbar.js | 29 ++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 5a5e829bd..b1dbff683 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -23,7 +23,7 @@ function createToolButton(icon,label,key,id,classname){ $btn.addClass(classname); } - $btn.attr('title', label); + $btn.attr('title', label).attr('aria-controls', 'wiki__text'); if(key){ $btn.attr('title', label + ' ['+key.toUpperCase()+']') .attr('accessKey', key); @@ -40,6 +40,7 @@ function createToolButton(icon,label,key,id,classname){ icon = DOKU_BASE + 'lib/images/toolbar/' + icon; } $ico.attr('src', icon); + $ico.attr('alt', ''); $ico.attr('width', 16); $ico.attr('height', 16); $btn.append($ico); @@ -76,6 +77,7 @@ function createPicker(id,props,edid){ function $makebutton(title) { var $btn = jQuery(document.createElement('button')) .addClass('pickerbutton').attr('title', title) + .attr('aria-controls', edid) .bind('click', bind(pickerInsert, title, edid)) .appendTo($picker); return $btn; @@ -93,6 +95,7 @@ function createPicker(id,props,edid){ } jQuery(document.createElement('img')) .attr('src', item) + .attr('alt', '') .appendTo($makebutton(key)); }else if (typeof item == 'string'){ // a list of text -> treat as text picker @@ -132,9 +135,9 @@ function pickerInsert(text,edid){ function addBtnActionSignature($btn, props, edid) { if(typeof SIG != 'undefined' && SIG != ''){ $btn.bind('click', bind(insertAtCarret,edid,SIG)); - return true; + return edid; } - return false; + return ''; } /** diff --git a/lib/scripts/editor.js b/lib/scripts/editor.js index 042e34608..2c0924eb7 100644 --- a/lib/scripts/editor.js +++ b/lib/scripts/editor.js @@ -65,6 +65,7 @@ var dw_editor = { ], function (_, img) { jQuery(document.createElement('IMG')) .attr('src', DOKU_BASE+'lib/images/' + img[0] + '.gif') + .attr('alt', '') .click(img[1]) .appendTo($ctl); }); diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 6d75215e0..5fc4d835e 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -52,8 +52,13 @@ function initToolbar(tbid,edid,tb, allowblock){ // type is a init function -> execute it actionFunc = 'addBtnAction'+val.type.charAt(0).toUpperCase()+val.type.substring(1); if( jQuery.isFunction(window[actionFunc]) ){ - if(window[actionFunc]($btn, val, edid)){ + var pickerid = window[actionFunc]($btn, val, edid); + if(pickerid !== ''){ $toolbar.append($btn); + $btn.attr('aria-controls', pickerid); + if (actionFunc === 'addBtnActionPicker') { + $btn.attr('aria-haspopup', 'true'); + } } return; } @@ -190,16 +195,17 @@ function tb_autohead(btn, props, edid){ */ function addBtnActionPicker($btn, props, edid) { var pickerid = 'picker'+(pickercounter++); - createPicker(pickerid, props, edid); + var picker = createPicker(pickerid, props, edid); + jQuery(picker).attr('aria-hidden', 'true'); $btn.click( function() { pickerToggle(pickerid,$btn); - return false; + return ''; } ); - return true; + return pickerid; } /** @@ -215,22 +221,26 @@ function addBtnActionLinkwiz(btn, props, edid) { dw_linkwiz.init(jQuery('#'+edid)); jQuery(btn).click(function(){ dw_linkwiz.toggle(); - return false; + return ''; }); - return true; + return 'link__wiz'; } /** - * Show/Hide a previosly created picker window + * Show/Hide a previously created picker window * * @author Andreas Gohr */ function pickerToggle(pickerid,$btn){ var $picker = jQuery('#' + pickerid), pos = $btn.offset(); - $picker.toggleClass('a11y') - .offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3}); + if ($picker.hasClass('a11y')) { + $picker.removeClass('a11y').attr('aria-hidden', 'false'); + } else { + $picker.addClass('a11y').attr('aria-hidden', 'true'); + } + $picker.offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3}); } /** @@ -252,4 +262,5 @@ function fixtxt(str){ jQuery(function () { initToolbar('tool__bar','wiki__text',toolbar); + jQuery('#tool__bar').attr('role', 'toolbar'); }); -- cgit v1.2.3 From 193e22801d763e715f03f241b135a2e249c6132e Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Thu, 1 Aug 2013 16:42:31 +0100 Subject: removed unused and old hasFlash() JS function --- lib/scripts/helpers.js | 19 ------------------- lib/scripts/media.js | 19 ------------------- 2 files changed, 38 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/helpers.js b/lib/scripts/helpers.js index d6f36967d..632c4bff2 100644 --- a/lib/scripts/helpers.js +++ b/lib/scripts/helpers.js @@ -2,25 +2,6 @@ * Various helper functions */ -/** - * Very simplistic Flash plugin check, probably works for Flash 8 and higher only - * - * @author Andreas Gohr - */ -function hasFlash(version){ - var ver = 0; - try{ - if(navigator.plugins != null && navigator.plugins.length > 0){ - ver = navigator.plugins["Shockwave Flash"].description.split(' ')[2].split('.')[0]; - }else{ - ver = (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) - .GetVariable("$version").split(' ')[1].split(',')[0]; - } - }catch(e){ } - - return ver >= version; -} - /** * A PHP-style substr_replace * diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 182d5fefe..8ca21ecab 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -921,23 +921,4 @@ var dw_mediamanager = { } }; -// moved from helpers.js temporarily here -/** - * Very simplistic Flash plugin check, probably works for Flash 8 and higher only - * - */ -function hasFlash(version){ - var ver = 0, axo; - try{ - if(navigator.plugins !== null && navigator.plugins.length > 0){ - ver = navigator.plugins["Shockwave Flash"].description.split(' ')[2].split('.')[0]; - }else{ - axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); - ver = axo.GetVariable("$version").split(' ')[1].split(',')[0]; - } - }catch(e){ } - - return ver >= version; -} - jQuery(dw_mediamanager.init); -- cgit v1.2.3 From 763ffe58812aba9b1e6fe2bca4bb74187ab16ea3 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Thu, 1 Aug 2013 17:11:29 +0100 Subject: added aria attributes for footnote tooltips --- lib/scripts/page.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/page.js b/lib/scripts/page.js index 4ab0bf9b5..7b4958d82 100644 --- a/lib/scripts/page.js +++ b/lib/scripts/page.js @@ -62,7 +62,9 @@ dw_page = { $fndiv = jQuery(document.createElement('div')) .attr('id', popup_id) .addClass('insitu-footnote JSpopup') - .mouseleave(function () {jQuery(this).hide();}); + .attr('aria-hidden', 'true') + .mouseleave(function () {jQuery(this).hide().attr('aria-hidden', 'true');}) + .attr('role', 'tooltip'); jQuery('.dokuwiki:first').append($fndiv); } @@ -97,7 +99,7 @@ dw_page = { content = content.replace(/\bid=(['"])([^"']+)\1/gi,'id="insitu__$2'); // now put the content into the wrapper - dw_page.insituPopup(this, 'insitu__fn').html(content).show(); + dw_page.insituPopup(this, 'insitu__fn').html(content).show().attr('aria-hidden', 'false'); }, /** -- cgit v1.2.3 From 9805efa058358e0fcbd3976fa553901cabe0b2e0 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Thu, 1 Aug 2013 17:20:25 +0100 Subject: added aria roles to search and acl manager --- lib/scripts/tw-sack.js | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/scripts') diff --git a/lib/scripts/tw-sack.js b/lib/scripts/tw-sack.js index cc988f5be..b0e570151 100644 --- a/lib/scripts/tw-sack.js +++ b/lib/scripts/tw-sack.js @@ -2,6 +2,7 @@ /* ©2005 Gregory Wild-Smith */ /* www.twilightuniverse.com */ /* Software licenced under a modified X11 licence, see documentation or authors website for more details */ +/* @deprecated */ function sack(file){ this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n"; -- cgit v1.2.3