mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
f31dc45da8
Objectives: * Make the link inspector easier to use * Try to resolve a few bugs (bug 43841, bug 43063, bug 42986) * Stop using jquery.multiSuggest (which didn't really understand annotations) * Better divide MediaWiki specifics from generic implementations Changes: VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php * Updated links to files ve.Registry * Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object ve.Factory * Removed duplicate initialization of registry property * Added entries property, which is an array that's appended to for tracking the order of registrations ve.CommandRegistry * Added mwLink command which opens the mwLink inspector ve.ui.TextInputWidget * Added basic widget class for text inputs ve.ui.TextInputMenuWidget * Added widget that provides a menu of options for a text input widget ve.ui.MWLinkTargetInputWidget * Added MediaWiki specific link target widget ve.ui.MenuWidget * Converted ve.ui.Menu into a widget * Moved the body of onSelect to onMouseUp ve.ui.LinkTargetInputWidget * Added link target widget which adds link annotation functionality to a normal text input ve.ui.InputWidget * Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value ve.ui.Widget * Added base widget class * Widgets can be used in any frame ve.ui.Tool * Fixed line length issues ve.ui.InspectorFactory * Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation ve.ui.Inspector * Added auto-focus on the first visible input element on open * Moved afterClose event to after re-focus on document on close * Added documentation ve.ui.Frame * Adjusted documentation * Added binding of $$ to the frame context so it can be passed around * Added documentation ve.ui.Context * Added ve.ui.Widget.css to iframes * Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget * Removed unused positionBelowOverlay method * Added CSS settings to set overlay left and width properties according to context size * Added documentation ve.ui.DropdownTool * Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget ve.ui.FormatDropdownTool * Added documentation ve.ui.MWLinkButtonTool * Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector ve.ui.Widget.css * Added styles for all widgets ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css * Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget ve.ui.Menu.css * Deleted (merged into ve.ui.Widget.css) ve.ui.Menu.css * Deleted suggest styles (no longer used) pending.gif, pending.psd * Added diagonal stripe animation to indicate a pending request to the API ve.ui.MWLinkInspector * Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets ve.ui.LinkInspector * Removed mw global hint (not needed anymore) * Switched from comparing targets to annotations (since the target text is ambiguous in some situations) * Switched to using input widget, which is configured using a static property * Removed use of jquery.multiSuggest * Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector) ve.init.mw.ViewPageTarget * Added MediaWiki specific toolbar and command options Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
94 lines
2.3 KiB
JavaScript
94 lines
2.3 KiB
JavaScript
/*!
|
|
* VisualEditor user interface Frame class.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* HTML Iframe abstraction.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
*/
|
|
ve.ui.Frame = function VeUiFrame( config, $container ) {
|
|
var i, len;
|
|
|
|
// Properties
|
|
this.$frame = $( '<iframe frameborder="0" scrolling="no"></iframe>' );
|
|
this.frameDocument = this.attachFrame( this.$frame, $container );
|
|
this.$ = this.$$( '.ve-ui-frame-container' );
|
|
this.$$ = ve.bind( this.$$, this );
|
|
|
|
// Initialization
|
|
if ( 'stylesheets' in config ) {
|
|
for ( i = 0, len = config.stylesheets.length; i < len; i++ ) {
|
|
this.loadStylesheet( config.stylesheets[i] );
|
|
}
|
|
}
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Sets the size of the frame.
|
|
*
|
|
* @method
|
|
* @param {number} width Frame width in pixels
|
|
* @param {number} height Frame height in pixels
|
|
*/
|
|
ve.ui.Frame.prototype.setSize = function ( width, height ) {
|
|
this.$frame.css( { 'width': width, 'height': height } );
|
|
};
|
|
|
|
/**
|
|
* Execute jQuery function within the context of this frame.
|
|
*
|
|
* @method
|
|
* @param {string} selector jQuery selector
|
|
* @returns {jQuery} jQuery selection
|
|
*/
|
|
ve.ui.Frame.prototype.$$ = function ( selector ) {
|
|
return $( selector, this.frameDocument );
|
|
};
|
|
|
|
/**
|
|
* Attaches and initializes a frame within a given container.
|
|
*
|
|
* @method
|
|
* @private
|
|
* @param {jQuery} $frame Frame to attach and initialize
|
|
* @param {jQuery} $container Container to append frame to
|
|
* @returns {HTMLDocument} Frame document
|
|
*/
|
|
ve.ui.Frame.prototype.attachFrame = function ( $frame, $container ) {
|
|
var doc;
|
|
// Attach to a document to initialze for real
|
|
$container.append( $frame );
|
|
// Get the frame document
|
|
doc = $frame.prop( 'contentWindow' ).document;
|
|
// Create an inner frame container
|
|
doc.write( '<div class="ve-ui-frame-container"></div>' );
|
|
// Finish the frame to make all browsers happy
|
|
doc.close();
|
|
// Basic styles
|
|
$( 'body', doc ).css( {
|
|
'padding': 0,
|
|
'margin': 0
|
|
} );
|
|
return doc;
|
|
};
|
|
|
|
/**
|
|
* Adds a stylesheet to the frame.
|
|
*
|
|
* @method
|
|
* @param {string} path Full path to stylesheet
|
|
*/
|
|
ve.ui.Frame.prototype.loadStylesheet = function ( path ) {
|
|
// Append style elements to head.
|
|
this.$$( 'head' ).append(
|
|
this.$$( '<link rel="stylesheet">' ).attr( 'href', path )
|
|
);
|
|
};
|