mediawiki-extensions-Visual.../modules/ve/ui/ve.ui.Dialog.js
Trevor Parscal 148b6bf8a8 Media dialog support
*/index.php
* Added links to new files

VisualEditor.php
* Added links to new files
* Removed keys of non-existent messages

ve.ui.ContentDialog.js, ve.ui.MetaDialog.js
* Removed redundant comments

ve.ui.MediaDialog.js
* New dialog, just for media

icons.ai, picture.png, picture.svg, ve.ui.Icons-*.css
* Added picture icon

ve.ui.MediaButtonTool.js
* New button, just for media (shows up in the context toolbar)

ve.ui.DialogButtonTool.js
* New base class for dialog buttons

ve.ui.Context.js
* Added basic support for showing dialog buttons, in addition to
  annotation buttons, in the context toolbar - to test, select only an
  image node

ve.ui.Dialog.js
* Prevent clicks on the click-block from changing focus
* Moved initialize to below the event handlers and updated its
  documentation

ve.ui.DialogFactory.js
* Added a way to get the names of dialogs that can be used to edit a
  node

ve.ui.Inspector.js
* Removed close handler which set focus, this is done already in window

ve.ui.InspectorFactory.js
* Fixed comment so it's not telling lies anymore

ve.ui.Window.js
* Removed auto-focus on frame, it's changing the focus in the parent
  document which blows-away the focus in CE, and it really isn't needed
  as it turns out

VisualEditor.18n.php
* Added media dialog title message
* Added media tool tooltip message

Bug: 37870
Change-Id: I9150c46b3e292910fed899fa60d6da433049ca45
2013-04-05 11:52:57 -07:00

93 lines
1.9 KiB
JavaScript

/*!
* VisualEditor UserInterface Dialog class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* UserInterface dialog.
*
* @class
* @abstract
* @extends ve.ui.Window
*
* @constructor
* @param {ve.Surface} surface
*/
ve.ui.Dialog = function VeUiDialog( surface ) {
// Parent constructor
ve.ui.Window.call( this, surface );
// Properties
this.visible = false;
// Initialization
this.$.addClass( 've-ui-dialog' );
this.$.on( 'mousedown', ve.bind( this.onMouseDown, this ) );
};
/* Inheritance */
ve.inheritClass( ve.ui.Dialog, ve.ui.Window );
/* Static Properties */
ve.ui.Dialog.static.stylesheets =
ve.ui.Dialog.static.stylesheets.concat( [ 've.ui.Dialog.css' ] );
/* Methods */
/**
* Handle mouse down events.
*
* @method
* @param {jQuery.Event} e Mouse down event
*/
ve.ui.Dialog.prototype.onMouseDown = function () {
return false;
};
/**
* Handle cancel button click events.
*
* @method
*/
ve.ui.Dialog.prototype.onCancelButtonClick = function () {
this.close();
};
/**
* Handle apply button click events.
*
* @method
*/
ve.ui.Dialog.prototype.onApplyButtonClick = function () {
this.close( true );
};
/**
* Initialize frame contents.
*
* @method
*/
ve.ui.Dialog.prototype.initialize = function () {
// Call parent method
ve.ui.Window.prototype.initialize.call( this );
// Properties
this.cancelButton = new ve.ui.ButtonWidget( {
'$$': this.$$, 'label': ve.msg( 'visualeditor-dialog-action-cancel' )
} );
this.applyButton = new ve.ui.ButtonWidget( {
'$$': this.$$, 'label': ve.msg( 'visualeditor-dialog-action-apply' ), 'flags': ['primary']
} );
// Events
this.cancelButton.on( 'click', ve.bind( this.onCancelButtonClick, this ) );
this.applyButton.on( 'click', ve.bind( this.onApplyButtonClick, this ) );
// Initialization
this.$head.append( this.applyButton.$, this.cancelButton.$ );
};