diff options
Diffstat (limited to 'lib/scripts/toolbar.js')
-rw-r--r-- | lib/scripts/toolbar.js | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 599386fb8..46f6ad789 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -33,13 +33,7 @@ function initToolbar(tbid,edid,tb){ // type is a tb function -> assign it as onclick actionFunc = 'tb_'+tb[i]['type']; if( isFunction(window[actionFunc]) ){ - addEvent(btn,'click', function(func,btn, props, edid){ - return function(){ - window[func](btn, props, edid); - return false; - } - }(actionFunc,btn,tb[i],edid) ); - //above fixes the scope problem as descried at http://www.mennovanslooten.nl/blog/post/62 + addEvent(btn,'click', bind(window[actionFunc],btn,tb[i],edid)); toolbar.appendChild(btn); continue; } @@ -136,6 +130,48 @@ function tb_formatln(btn, props, edid) { function tb_insert(btn, props, edid) { insertAtCarret(edid,fixtxt(props['insert'])); pickerClose(); + return false; +} + +/** + * Button action for the media popup + * + * @param DOMElement btn Button element to add the action to + * @param array props Associative array of button properties + * @param string edid ID of the editor textarea + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tb_mediapopup(btn, props, edid) { + window.open( + DOKU_BASE+props['url']+encodeURIComponent(NS), + props['name'], + props['options']); + return false; +} + +/** + * Button action for automatic headlines + * + * Insert a new headline based on the current section level + * + * @param DOMElement btn Button element to add the action to + * @param array props Associative array of button properties + * @param string edid ID of the editor textarea + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tb_autohead(btn, props, edid){ + var lvl = currentHeadlineLevel(edid); + + // determine new level + 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']); + pickerClose(); + return false; } |