mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-12-18 11:01:36 +00:00
Merge "Remove $controls / $tabs / $buttons interfaces"
This commit is contained in:
commit
804d18d428
|
@ -90,7 +90,6 @@
|
||||||
"dialogReplace.html": "templates/dialogReplace.html"
|
"dialogReplace.html": "templates/dialogReplace.html"
|
||||||
},
|
},
|
||||||
"messages": [
|
"messages": [
|
||||||
"wikieditor-wikitext-tab",
|
|
||||||
"wikieditor-toolbar-tool-bold",
|
"wikieditor-toolbar-tool-bold",
|
||||||
"wikieditor-toolbar-tool-bold-example",
|
"wikieditor-toolbar-tool-bold-example",
|
||||||
"wikieditor-toolbar-tool-italic",
|
"wikieditor-toolbar-tool-italic",
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
},
|
},
|
||||||
"wikieditor": "Advanced wikitext editing interface",
|
"wikieditor": "Advanced wikitext editing interface",
|
||||||
"wikieditor-desc": "Provides an advanced, extensible wikitext editing interface",
|
"wikieditor-desc": "Provides an advanced, extensible wikitext editing interface",
|
||||||
"wikieditor-wikitext-tab": "Wikitext",
|
|
||||||
"wikieditor-toolbar": "Editing toolbar",
|
"wikieditor-toolbar": "Editing toolbar",
|
||||||
"wikieditor-toolbar-desc": "Edit page toolbar with enhanced usability",
|
"wikieditor-toolbar-desc": "Edit page toolbar with enhanced usability",
|
||||||
"wikieditor-toolbar-preference": "Enable the editing toolbar",
|
"wikieditor-toolbar-preference": "Enable the editing toolbar",
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
},
|
},
|
||||||
"wikieditor": "An extension to provide an advanced, extensible wikitext editing interface.\nhttps://www.mediawiki.org/wiki/Extension:WikiEditor",
|
"wikieditor": "An extension to provide an advanced, extensible wikitext editing interface.\nhttps://www.mediawiki.org/wiki/Extension:WikiEditor",
|
||||||
"wikieditor-desc": "Sorry, the documentation apears out of date:\n\n\n{{desc|name=WikiEditor|url=https://www.mediawiki.org/wiki/Extension:WikiEditor}}",
|
"wikieditor-desc": "Sorry, the documentation apears out of date:\n\n\n{{desc|name=WikiEditor|url=https://www.mediawiki.org/wiki/Extension:WikiEditor}}",
|
||||||
"wikieditor-wikitext-tab": "Caption of the tab containing the edit box\n{{Identical|Wikitext}}",
|
|
||||||
"wikieditor-toolbar": "A customizable toolbar for the WikiEditor.\nFor more information, see https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization",
|
"wikieditor-toolbar": "A customizable toolbar for the WikiEditor.\nFor more information, see https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization",
|
||||||
"wikieditor-toolbar-desc": "Unused at this time.",
|
"wikieditor-toolbar-desc": "Unused at this time.",
|
||||||
"wikieditor-toolbar-preference": "Label for the checkbox user preference to enable the editor. By default this is checked.",
|
"wikieditor-toolbar-preference": "Label for the checkbox user preference to enable the editor. By default this is checked.",
|
||||||
|
|
|
@ -388,79 +388,6 @@ $.fn.wikiEditor = function () {
|
||||||
return returnFromModules;
|
return returnFromModules;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a button to the UI
|
|
||||||
*
|
|
||||||
* @param {Object} options
|
|
||||||
* @return {jQuery}
|
|
||||||
*/
|
|
||||||
addButton: function ( options ) {
|
|
||||||
// Ensure that buttons and tabs are visible
|
|
||||||
context.$controls.show();
|
|
||||||
context.$buttons.show();
|
|
||||||
return $( '<button>' )
|
|
||||||
.text( $.wikiEditor.autoMsg( options, 'caption' ) )
|
|
||||||
.on( 'click', options.action )
|
|
||||||
.appendTo( context.$buttons );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a view to the UI, which is accessed using a set of tabs. Views are mutually exclusive and by default a
|
|
||||||
* wikitext view will be present. Only when more than one view exists will the tabs will be visible.
|
|
||||||
*
|
|
||||||
* @param {Object} options
|
|
||||||
* @return {jQuery}
|
|
||||||
*/
|
|
||||||
addView: function ( options ) {
|
|
||||||
// Adds a tab
|
|
||||||
function addTab( opts ) {
|
|
||||||
// Ensure that buttons and tabs are visible
|
|
||||||
context.$controls.show();
|
|
||||||
context.$tabs.show();
|
|
||||||
|
|
||||||
// Return the newly appended tab
|
|
||||||
return $( '<div>' )
|
|
||||||
.attr( 'rel', 'wikiEditor-ui-view-' + opts.name )
|
|
||||||
.addClass( context.view === opts.name ? 'current' : null )
|
|
||||||
.append( $( '<a>' )
|
|
||||||
.attr( 'tabindex', 0 )
|
|
||||||
// No dragging!
|
|
||||||
.on( 'mousedown', () => false )
|
|
||||||
.on( 'click keydown', ( event ) => {
|
|
||||||
if (
|
|
||||||
event.type === 'click' ||
|
|
||||||
event.type === 'keydown' && event.key === 'Enter'
|
|
||||||
) {
|
|
||||||
context.$ui.find( '.wikiEditor-ui-view' ).hide();
|
|
||||||
context.$ui.find( '.' + $( event.target ).parent().attr( 'rel' ) ).show();
|
|
||||||
context.$tabs.find( 'div' ).removeClass( 'current' );
|
|
||||||
$( event.target ).parent().addClass( 'current' );
|
|
||||||
$( event.target ).trigger( 'blur' );
|
|
||||||
if ( 'init' in opts && typeof opts.init === 'function' ) {
|
|
||||||
opts.init( context );
|
|
||||||
}
|
|
||||||
event.preventDefault();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} )
|
|
||||||
.text( $.wikiEditor.autoMsg( opts, 'title' ) )
|
|
||||||
)
|
|
||||||
.appendTo( context.$tabs );
|
|
||||||
}
|
|
||||||
// Automatically add the previously not-needed wikitext tab
|
|
||||||
if ( !context.$tabs.children().length ) {
|
|
||||||
addTab( { name: 'wikitext', title: mw.message( 'wikieditor-wikitext-tab' ).parse() } );
|
|
||||||
}
|
|
||||||
// Add the tab for the view we were actually asked to add
|
|
||||||
addTab( options );
|
|
||||||
// Return newly appended view
|
|
||||||
// eslint-disable-next-line mediawiki/class-doc
|
|
||||||
return $( '<div>' )
|
|
||||||
.addClass( 'wikiEditor-ui-view wikiEditor-ui-view-' + options.name )
|
|
||||||
.hide()
|
|
||||||
.appendTo( context.$ui );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save text selection
|
* Save text selection
|
||||||
*/
|
*/
|
||||||
|
@ -499,7 +426,7 @@ $.fn.wikiEditor = function () {
|
||||||
// Encapsulate the textarea with some containers for layout
|
// Encapsulate the textarea with some containers for layout
|
||||||
context.$textarea
|
context.$textarea
|
||||||
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui' ) )
|
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui' ) )
|
||||||
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-view wikiEditor-ui-view-wikitext' ) )
|
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-view' ) )
|
||||||
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-left' ) )
|
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-left' ) )
|
||||||
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-bottom' ) )
|
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-bottom' ) )
|
||||||
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-text' ) );
|
.wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-text' ) );
|
||||||
|
@ -514,18 +441,7 @@ $.fn.wikiEditor = function () {
|
||||||
// Get references to some of the newly created containers
|
// Get references to some of the newly created containers
|
||||||
context.$ui = context.$textarea.parent().parent().parent().parent().parent();
|
context.$ui = context.$textarea.parent().parent().parent().parent().parent();
|
||||||
context.$wikitext = context.$textarea.parent().parent().parent().parent();
|
context.$wikitext = context.$textarea.parent().parent().parent().parent();
|
||||||
// Add in tab and button containers
|
|
||||||
context.$wikitext.before(
|
|
||||||
$( '<div>' ).addClass( 'wikiEditor-ui-controls' ).append(
|
|
||||||
$( '<div>' ).addClass( 'wikiEditor-ui-tabs' ).hide(),
|
|
||||||
$( '<div>' ).addClass( 'wikiEditor-ui-buttons' )
|
|
||||||
),
|
|
||||||
$( '<div>' ).addClass( 'wikiEditor-ui-clear' )
|
|
||||||
);
|
|
||||||
// Get references to some of the newly created containers
|
|
||||||
context.$controls = context.$ui.find( '.wikiEditor-ui-buttons' ).hide();
|
|
||||||
context.$buttons = context.$ui.find( '.wikiEditor-ui-buttons' );
|
|
||||||
context.$tabs = context.$ui.find( '.wikiEditor-ui-tabs' );
|
|
||||||
// Clear all floating after the UI
|
// Clear all floating after the UI
|
||||||
context.$ui.after( $( '<div>' ).addClass( 'wikiEditor-ui-clear' ) );
|
context.$ui.after( $( '<div>' ).addClass( 'wikiEditor-ui-clear' ) );
|
||||||
// Attach a right container
|
// Attach a right container
|
||||||
|
|
|
@ -43,68 +43,3 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.wikiEditor-wikitext {
|
|
||||||
float: left;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wikiEditor-ui-controls {
|
|
||||||
float: left;
|
|
||||||
width: 100%;
|
|
||||||
background-color: @background-color-base;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wikiEditor-ui-tabs {
|
|
||||||
float: left;
|
|
||||||
height: 2.5em;
|
|
||||||
margin-right: -1px;
|
|
||||||
background-color: @background-color-base;
|
|
||||||
border-left: @border-subtle;
|
|
||||||
border-top: @border-subtle;
|
|
||||||
|
|
||||||
div {
|
|
||||||
float: left;
|
|
||||||
height: 2.5em;
|
|
||||||
background-color: @background-color-interactive-subtle;
|
|
||||||
border-right: @border-subtle;
|
|
||||||
border-bottom: @border-subtle;
|
|
||||||
|
|
||||||
a {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 0 0.75em;
|
|
||||||
line-height: 2.5em;
|
|
||||||
color: @color-progressive;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.current {
|
|
||||||
border-bottom: 1px solid #fff;
|
|
||||||
background-color: @background-color-base;
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: @color-base;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wikiEditor-ui-buttons {
|
|
||||||
float: right;
|
|
||||||
height: 2.5em;
|
|
||||||
margin-right: -1px;
|
|
||||||
background-color: @background-color-base;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-top: 1px solid #fff;
|
|
||||||
|
|
||||||
button {
|
|
||||||
margin-left: 0.5em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wikiEditor-view-wikitext {
|
|
||||||
line-height: 1em;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue