From aa5d3d8e43bc72ed30ab9279f6160d0d4fe2df49 Mon Sep 17 00:00:00 2001 From: Pierre Spring Date: Sun, 10 Oct 2010 20:57:08 +0200 Subject: minimaly jQueryfied link wizard --- lib/scripts/toolbar.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 3f967448c..f969cee64 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -214,11 +214,7 @@ function addBtnActionPicker(btn, props, edid) { * @author Andreas Gohr */ function addBtnActionLinkwiz(btn, props, edid) { - linkwiz.init($(edid)); - addEvent(btn,'click',function(){ - linkwiz.toggle(); - return false; - }); + jQuery(btn).linkwiz($(edid)); return true; } -- cgit v1.2.3 From 11bf24d856a6a4cb606bc6fe10ebcbd844f4127f Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Sun, 27 Mar 2011 13:57:35 +0200 Subject: helpers.js was removed - it basically contained functions they are implemented in jQuery library --- lib/scripts/toolbar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 795e105df..9b6afef30 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -42,7 +42,7 @@ function initToolbar(tbid,edid,tb, allowblock){ // type is a tb function -> assign it as onclick actionFunc = 'tb_'+tb[i]['type']; - if( isFunction(window[actionFunc]) ){ + if( jQuery.isFunction(window[actionFunc]) ){ addEvent(btn,'click', bind(window[actionFunc],btn,tb[i],edid)); toolbar.appendChild(btn); continue; @@ -50,7 +50,7 @@ function initToolbar(tbid,edid,tb, allowblock){ // type is a init function -> execute it actionFunc = 'addBtnAction'+tb[i]['type'].charAt(0).toUpperCase()+tb[i]['type'].substring(1); - if( isFunction(window[actionFunc]) ){ + if( jQuery.isFunction(window[actionFunc]) ){ if(window[actionFunc](btn, tb[i], edid)){ toolbar.appendChild(btn); } -- cgit v1.2.3 From 5d3db6eb90125ae50cd1bf8d6e94f4ca22d7e976 Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Wed, 30 Mar 2011 14:18:52 +0200 Subject: toolbar.js is jQueryfied --- lib/scripts/toolbar.js | 95 ++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 41 deletions(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 9b6afef30..6beb07c5b 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -12,54 +12,62 @@ var pickercounter=0; * @author Andreas Gohr */ function initToolbar(tbid,edid,tb, allowblock){ - var toolbar = $(tbid); - if(!toolbar) return; - var edit = $(edid); - if(!edit) return; - if(edit.readOnly) return; + var $ = jQuery; + if (typeof tbid == 'string') { + var toolbar = $('#' + tbid); + } else { + var toolbar = $(tbid); + } + + if(toolbar.length == 0) return; + + var edit = $('#' + edid); + if(edit.length == 0) return; + + if(edit.attr('readOnly')) return; if (typeof allowblock === 'undefined') { allowblock = true; } //empty the toolbar area: - toolbar.innerHTML=''; + toolbar.html(''); - var cnt = tb.length; + var cnt = tb.length; + for(var i=0; i assign it as onclick actionFunc = 'tb_'+tb[i]['type']; - if( jQuery.isFunction(window[actionFunc]) ){ - addEvent(btn,'click', bind(window[actionFunc],btn,tb[i],edid)); - toolbar.appendChild(btn); + if( $.isFunction(window[actionFunc]) ){ + btn.bind('click', bind(window[actionFunc],btn,tb[i],edid) ); + toolbar.append(btn); continue; } - + // type is a init function -> execute it actionFunc = 'addBtnAction'+tb[i]['type'].charAt(0).toUpperCase()+tb[i]['type'].substring(1); - if( jQuery.isFunction(window[actionFunc]) ){ + if( $.isFunction(window[actionFunc]) ){ if(window[actionFunc](btn, tb[i], edid)){ - toolbar.appendChild(btn); - } + toolbar.append(btn); + } continue; } - + alert('unknown toolbar type: '+tb[i]['type']+' '+actionFunc); } // end for - + } /** @@ -197,10 +205,14 @@ function tb_autohead(btn, props, edid){ function addBtnActionPicker(btn, props, edid) { var pickerid = 'picker'+(pickercounter++); createPicker(pickerid, props, edid); - addEvent(btn,'click',function(){ - pickerToggle(pickerid,btn); - return false; - }); + + btn.click( + function() { + pickerToggle(pickerid,btn); + return false; + } + ); + return true; } @@ -214,7 +226,7 @@ function addBtnActionPicker(btn, props, edid) { * @author Andreas Gohr */ function addBtnActionLinkwiz(btn, props, edid) { - jQuery(btn).linkwiz($(edid)); + jQuery(btn).linkwiz(jQuery('#' + edid)); return true; } @@ -224,17 +236,18 @@ function addBtnActionLinkwiz(btn, props, edid) { * @author Andreas Gohr */ function pickerToggle(pickerid,btn){ - var picker = $(pickerid); - if(picker.style.marginLeft == '-10000px'){ - var x = findPosX(btn); - var y = findPosY(btn); - picker.style.left = (x+3)+'px'; - picker.style.top = (y+btn.offsetHeight+3)+'px'; - picker.style.marginLeft = '0px'; - picker.style.marginTop = '0px'; - }else{ - picker.style.marginLeft = '-10000px'; - picker.style.marginTop = '-10000px'; + var picker = jQuery('#' + pickerid); + if (picker.css('marginLeft') == '-10000px'){ + var x = findPosX(btn[0]); + var y = findPosY(btn[0]); + + picker.css('left',(x+3)+'px') + .css('top', (y+btn[0].offsetHeight+3)+'px') + .css('marginLeft', '0px') + .css('marginTop', '0px'); + } else { + picker.css('marginLeft', '-10000px') + .css('marginTop', '-10000px'); } } @@ -244,10 +257,10 @@ function pickerToggle(pickerid,btn){ * @author Andreas Gohr */ function pickerClose(){ - var pobjs = getElementsByClass('picker'); + var pobjs = jQuery('#picker'); for(var i=0; i Date: Fri, 8 Jul 2011 00:22:27 +0200 Subject: some initial refactoring of the linkwizard --- lib/scripts/toolbar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index c8dfe394d..fc95340f5 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -226,10 +226,15 @@ function addBtnActionPicker(btn, props, edid) { * @author Andreas Gohr */ function addBtnActionLinkwiz(btn, props, edid) { - jQuery(btn).linkwiz(jQuery('#' + edid)); + linkwiz.init(jQuery('#'+edid)); + jQuery(btn).click(function(){ + linkwiz.toggle(); + return false; + }); return true; } + /** * Show/Hide a previosly created picker window * -- cgit v1.2.3 From d57b00771430e5ae76d25920e2a49d8a0adda651 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 8 Jul 2011 11:39:45 +0200 Subject: renamed linkwiz object --- lib/scripts/toolbar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index fc95340f5..2306ef5db 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -226,9 +226,9 @@ function addBtnActionPicker(btn, props, edid) { * @author Andreas Gohr */ function addBtnActionLinkwiz(btn, props, edid) { - linkwiz.init(jQuery('#'+edid)); + dw_linkwiz.init(jQuery('#'+edid)); jQuery(btn).click(function(){ - linkwiz.toggle(); + dw_linkwiz.toggle(); return false; }); return true; -- cgit v1.2.3 From ba6c070edd92ca0fc8a6ee85d51769d64a19ee7c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 4 Sep 2011 13:52:43 +0200 Subject: tmp --- lib/scripts/toolbar.js | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 2306ef5db..7a113ecbf 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -1,4 +1,3 @@ - // used to identify pickers var pickercounter=0; @@ -202,13 +201,13 @@ function tb_autohead(btn, props, edid){ * @return boolean If button should be appended * @author Gabriel Birke */ -function addBtnActionPicker(btn, props, edid) { +function addBtnActionPicker($btn, props, edid) { var pickerid = 'picker'+(pickercounter++); createPicker(pickerid, props, edid); - btn.click( + $btn.click( function() { - pickerToggle(pickerid,btn); + pickerToggle(pickerid,$btn); return false; } ); @@ -240,19 +239,17 @@ function addBtnActionLinkwiz(btn, props, edid) { * * @author Andreas Gohr */ -function pickerToggle(pickerid,btn){ - var picker = jQuery('#' + pickerid); - if (picker.css('marginLeft') == '-10000px'){ - var x = findPosX(btn[0]); - var y = findPosY(btn[0]); - - picker.css('left',(x+3)+'px') - .css('top', (y+btn[0].offsetHeight+3)+'px') - .css('marginLeft', '0px') - .css('marginTop', '0px'); +function pickerToggle(pickerid,$btn){ + var $picker = jQuery('#' + pickerid); + if ($picker.hasClass('hiddenpicker')) { + var pos = $btn.offset(); + $picker.hide().removeClass('hiddenpicker') + .dw_show() + .offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3}) } else { - picker.css('marginLeft', '-10000px') - .css('marginTop', '-10000px'); + $picker.dw_hide(function () { + jQuery(this).addClass('hiddenpicker').show(); + }); } } @@ -262,11 +259,7 @@ function pickerToggle(pickerid,btn){ * @author Andreas Gohr */ function pickerClose(){ - var pobjs = jQuery('#picker'); - for(var i=0; i Date: Sun, 4 Sep 2011 15:32:41 +0200 Subject: Revert tmp commits This reverts commit ba6c070edd92ca0fc8a6ee85d51769d64a19ee7c. This reverts commit 923510088dda99cb2790b15308593e47369d4f01. --- lib/scripts/toolbar.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 7a113ecbf..2306ef5db 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -1,3 +1,4 @@ + // used to identify pickers var pickercounter=0; @@ -201,13 +202,13 @@ function tb_autohead(btn, props, edid){ * @return boolean If button should be appended * @author Gabriel Birke */ -function addBtnActionPicker($btn, props, edid) { +function addBtnActionPicker(btn, props, edid) { var pickerid = 'picker'+(pickercounter++); createPicker(pickerid, props, edid); - $btn.click( + btn.click( function() { - pickerToggle(pickerid,$btn); + pickerToggle(pickerid,btn); return false; } ); @@ -239,17 +240,19 @@ function addBtnActionLinkwiz(btn, props, edid) { * * @author Andreas Gohr */ -function pickerToggle(pickerid,$btn){ - var $picker = jQuery('#' + pickerid); - if ($picker.hasClass('hiddenpicker')) { - var pos = $btn.offset(); - $picker.hide().removeClass('hiddenpicker') - .dw_show() - .offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3}) +function pickerToggle(pickerid,btn){ + var picker = jQuery('#' + pickerid); + if (picker.css('marginLeft') == '-10000px'){ + var x = findPosX(btn[0]); + var y = findPosY(btn[0]); + + picker.css('left',(x+3)+'px') + .css('top', (y+btn[0].offsetHeight+3)+'px') + .css('marginLeft', '0px') + .css('marginTop', '0px'); } else { - $picker.dw_hide(function () { - jQuery(this).addClass('hiddenpicker').show(); - }); + picker.css('marginLeft', '-10000px') + .css('marginTop', '-10000px'); } } @@ -259,7 +262,11 @@ function pickerToggle(pickerid,$btn){ * @author Andreas Gohr */ function pickerClose(){ - jQuery('.picker').addClass('hiddenpicker'); + var pobjs = jQuery('#picker'); + for(var i=0; i Date: Fri, 9 Sep 2011 22:26:16 +0200 Subject: Various JavaScript improvements, JSLint, jQuery --- lib/scripts/toolbar.js | 146 +++++++++++++++++++++---------------------------- 1 file changed, 61 insertions(+), 85 deletions(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 2306ef5db..6cae9455a 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -1,4 +1,3 @@ - // used to identify pickers var pickercounter=0; @@ -12,62 +11,55 @@ var pickercounter=0; * @author Andreas Gohr */ function initToolbar(tbid,edid,tb, allowblock){ - var $ = jQuery; + var $toolbar, $edit; if (typeof tbid == 'string') { - var toolbar = $('#' + tbid); + $toolbar = jQuery('#' + tbid); } else { - var toolbar = $(tbid); + $toolbar = jQuery(tbid); } - if(toolbar.length == 0) return; - - var edit = $('#' + edid); - if(edit.length == 0) return; + $edit = jQuery('#' + edid); - if(edit.attr('readOnly')) return; + if ($toolbar.length == 0 || $edit.length == 0 || $edit.attr('readOnly')) { + return; + } if (typeof allowblock === 'undefined') { allowblock = true; } //empty the toolbar area: - toolbar.html(''); - - var cnt = tb.length; + $toolbar.html(''); - for(var i=0; i assign it as onclick - actionFunc = 'tb_'+tb[i]['type']; - if( $.isFunction(window[actionFunc]) ){ - btn.bind('click', bind(window[actionFunc],btn,tb[i],edid) ); - toolbar.append(btn); - continue; + actionFunc = 'tb_'+val.type; + if( jQuery.isFunction(window[actionFunc]) ){ + $btn.bind('click', bind(window[actionFunc],$btn,val,edid) ); + $toolbar.append($btn); + return; } // type is a init function -> execute it - actionFunc = 'addBtnAction'+tb[i]['type'].charAt(0).toUpperCase()+tb[i]['type'].substring(1); - if( $.isFunction(window[actionFunc]) ){ - if(window[actionFunc](btn, tb[i], edid)){ - toolbar.append(btn); + actionFunc = 'addBtnAction'+val.type.charAt(0).toUpperCase()+val.type.substring(1); + if( jQuery.isFunction(window[actionFunc]) ){ + if(window[actionFunc]($btn, val, edid)){ + $toolbar.append($btn); } - continue; + return; } - alert('unknown toolbar type: '+tb[i]['type']+' '+actionFunc); - } // end for - + alert('unknown toolbar type: '+val.type+' '+actionFunc); + }); } /** @@ -80,13 +72,10 @@ function initToolbar(tbid,edid,tb, allowblock){ * @author Andreas Gohr */ function tb_format(btn, props, edid) { - var sample = props['title']; - if(props['sample']){ - sample = props['sample']; - } + var sample = props.title || props.sample; insertTags(edid, - fixtxt(props['open']), - fixtxt(props['close']), + fixtxt(props.open), + fixtxt(props.close), fixtxt(sample)); pickerClose(); return false; @@ -105,30 +94,27 @@ function tb_format(btn, props, edid) { * @author Andreas Gohr */ function tb_formatln(btn, props, edid) { - var sample = props['title']; - if(props['sample']){ - sample = props['sample']; - } - sample = fixtxt(sample); + var sample = props.title || props.sample, + opts, + selection = getSelection(jQuery('#'+edid)[0]); - props['open'] = fixtxt(props['open']); - props['close'] = fixtxt(props['close']); + sample = fixtxt(sample); + props.open = fixtxt(props.open); + props.close = fixtxt(props.close); // is something selected? - var opts; - var selection = getSelection($(edid)); if(selection.getLength()){ sample = selection.getText(); opts = {nosel: true}; }else{ opts = { - startofs: props['open'].length, - endofs: props['close'].length + startofs: props.open.length, + endofs: props.close.length }; } - sample = sample.split("\n").join(props['close']+"\n"+props['open']); - sample = props['open']+sample+props['close']; + sample = sample.split("\n").join(props.close+"\n"+props.open); + sample = props.open+sample+props.close; pasteText(selection,sample,opts); @@ -146,7 +132,7 @@ function tb_formatln(btn, props, edid) { * @author Andreas Gohr */ function tb_insert(btn, props, edid) { - insertAtCarret(edid,fixtxt(props['insert'])); + insertAtCarret(edid,fixtxt(props.insert)); pickerClose(); return false; } @@ -161,9 +147,9 @@ function tb_insert(btn, props, edid) { */ function tb_mediapopup(btn, props, edid) { window.open( - DOKU_BASE+props['url']+encodeURIComponent(NS)+'&edid='+encodeURIComponent(edid), - props['name'], - props['options']); + DOKU_BASE+props.url+encodeURIComponent(NS)+'&edid='+encodeURIComponent(edid), + props.name, + props.options); return false; } @@ -178,16 +164,16 @@ function tb_mediapopup(btn, props, edid) { * @author Andreas Gohr */ function tb_autohead(btn, props, edid){ - var lvl = currentHeadlineLevel(edid); + var lvl = currentHeadlineLevel(edid), + tags; // determine new level - lvl += props['mod']; + lvl += props.mod; if(lvl < 1) lvl = 1; if(lvl > 5) lvl = 5; - var tags = '='; - for(var i=0; i<=5-lvl; i++) tags += '='; - insertTags(edid, tags+' ', ' '+tags+"\n", props['text']); + tags = (new Array(8 - lvl)).join('='); + insertTags(edid, tags+' ', ' '+tags+"\n", props.text); pickerClose(); return false; } @@ -196,19 +182,19 @@ function tb_autohead(btn, props, edid){ /** * Add button action for picker buttons and create picker element * - * @param DOMElement btn Button element to add the action to + * @param jQuery btn Button element to add the action to * @param array props Associative array of button properties * @param string edid ID of the editor textarea * @return boolean If button should be appended * @author Gabriel Birke */ -function addBtnActionPicker(btn, props, edid) { +function addBtnActionPicker($btn, props, edid) { var pickerid = 'picker'+(pickercounter++); createPicker(pickerid, props, edid); - btn.click( + $btn.click( function() { - pickerToggle(pickerid,btn); + pickerToggle(pickerid,$btn); return false; } ); @@ -240,20 +226,11 @@ function addBtnActionLinkwiz(btn, props, edid) { * * @author Andreas Gohr */ -function pickerToggle(pickerid,btn){ - var picker = jQuery('#' + pickerid); - if (picker.css('marginLeft') == '-10000px'){ - var x = findPosX(btn[0]); - var y = findPosY(btn[0]); - - picker.css('left',(x+3)+'px') - .css('top', (y+btn[0].offsetHeight+3)+'px') - .css('marginLeft', '0px') - .css('marginTop', '0px'); - } else { - picker.css('marginLeft', '-10000px') - .css('marginTop', '-10000px'); - } +function pickerToggle(pickerid,$btn){ + var $picker = jQuery('#' + pickerid), + pos = $btn.offset(); + $picker.toggleClass('hidden_with_access_keys') + .offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3}); } /** @@ -262,11 +239,7 @@ function pickerToggle(pickerid,btn){ * @author Andreas Gohr */ function pickerClose(){ - var pobjs = jQuery('#picker'); - for(var i=0; i Date: Thu, 15 Sep 2011 23:31:43 +0200 Subject: Use jQuery UI Dialog for linkwiz --- lib/scripts/toolbar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/scripts/toolbar.js') diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 6cae9455a..04d30c1a6 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -229,7 +229,7 @@ function addBtnActionLinkwiz(btn, props, edid) { function pickerToggle(pickerid,$btn){ var $picker = jQuery('#' + pickerid), pos = $btn.offset(); - $picker.toggleClass('hidden_with_access_keys') + $picker.toggleClass('a11y') .offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3}); } @@ -239,7 +239,7 @@ function pickerToggle(pickerid,$btn){ * @author Andreas Gohr */ function pickerClose(){ - jQuery('.picker').addClass('hidden_with_access_keys'); + jQuery('.picker').addClass('a11y'); } -- cgit v1.2.3