diff --git a/extension.json b/extension.json index 498cd54a..1d6a80b6 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "WikiEditor", - "version": "0.5.1", + "version": "0.5.2", "author": [ "Derk-Jan Hartman", "Trevor Parscal", diff --git a/modules/jquery.wikiEditor.toolbar.js b/modules/jquery.wikiEditor.toolbar.js index c701ad58..d1260c07 100644 --- a/modules/jquery.wikiEditor.toolbar.js +++ b/modules/jquery.wikiEditor.toolbar.js @@ -305,7 +305,7 @@ return $group; }, buildTool: function ( context, id, tool ) { - var i, label, $button, icon, $select, $options, oouiButton, + var i, label, $button, config, icon, $select, $options, oouiButton, option, optionLabel; if ( 'filters' in tool ) { for ( i = 0; i < tool.filters.length; i++ ) { @@ -317,13 +317,19 @@ label = $.wikiEditor.autoMsg( tool, 'label' ); switch ( tool.type ) { case 'button': + case 'toggle': if ( tool.oouiIcon ) { - oouiButton = new OO.ui.ButtonWidget( { + config = { framed: false, classes: [ 'tool' ], icon: tool.oouiIcon, title: label - } ); + }; + if ( tool.type === 'button' ) { + oouiButton = new OO.ui.ButtonWidget( config ); + } else if ( tool.type === 'toggle' ) { + oouiButton = new OO.ui.ToggleButtonWidget( config ); + } $button = oouiButton.$element; $button.attr( 'rel', id ); $button.data( 'ooui', oouiButton ); @@ -349,8 +355,8 @@ $button.toggleClass( 'tool-active', active ); // OOUI button - if ( $button.data( 'ooui' ) ) { - $button.data( 'ooui' ).setFlags( { progressive: active } ); + if ( $button.data( 'ooui' ) && tool.type === 'toggle' ) { + $button.data( 'ooui' ).setValue( active ); } } ); if ( 'action' in tool ) { @@ -361,14 +367,22 @@ // No dragging! e.preventDefault(); return false; - } ) - .click( function ( e ) { + } ); + if ( $button.data( 'ooui' ) ) { + $button.data( 'ooui' ).on( 'click', function () { $.wikiEditor.modules.toolbar.fn.doAction( - $( this ).data( 'context' ), $( this ).data( 'action' ), $( this ) + context, tool.action + ); + } ); + } else { + $button.on( 'click', function ( e ) { + $.wikiEditor.modules.toolbar.fn.doAction( + context, tool.action ); e.preventDefault(); return false; } ); + } } return $button; case 'select':