mediawiki-extensions-Visual.../modules/ve/ui/ve.ui.Inspector.js
Timo Tijhof 71020f7175 Remainder JSHint fixes on modules/ve/*
[jshint]
ce/ve.ce.Surface.js: line 670, col 9, Too many var statements.
ce/ve.ce.Surface.js: line 695, col 6, Missing semicolon.
ce/ve.ce.Surface.js: line 726, col 22, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 726, col 41, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 733, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 734, col 24, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 1013, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 1019, col 17, Too many var statements.
ce/ve.ce.Surface.js: line 1023, col 18, Too many ar statements.
ce/ve.ce.Surface.js: line 1027, col 13, Too many var statements.
dm/annotations/ve.dm.LinkAnnotation.js: line 70, col 52, Insecure '.'.
dm/ve.dm.Converter.js: line 383, col 29, Empty block.
dm/ve.dm.Converter.js: line 423, col 33, Empty block.

Commands:
 * jshint .
 * ack '(if|else|function|switch|for|while)\('
 * Sublime Text 2:
   Find(*): (if|else|function|switch|for|while)\(
   Replace: $1 (
 * ack '  ' -Q # double spaces, except in certain comments

Change-Id: I8e34bf2924bc8688fdf8acef08bbc4f6707e93be
2012-09-05 13:45:09 -07:00

102 lines
2.1 KiB
JavaScript

/**
* VisualEditor user interface Inspector class.
*
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Creates an ve.ui.Inspector object.
*
* @class
* @constructor
* @param {ve.ui.Toolbar} toolbar
* @param {String} name
*/
ve.ui.Inspector = function ( toolbar, context ) {
var inspector = this;
// Inheritance
ve.EventEmitter.call( this );
if ( !toolbar || !context ) {
return;
}
// Properties
this.toolbar = toolbar;
this.context = context;
this.$ = $( '<div class="ve-ui-inspector"></div>', context.inspectorDoc );
this.$closeButton = $(
'<div class="ve-ui-inspector-button ve-ui-inspector-closeButton"></div>',
context.inspectorDoc
);
this.$acceptButton = $(
'<div class="ve-ui-inspector-button ve-ui-inspector-acceptButton"></div>',
context.inspectorDoc
);
this.$form = $( '<form>', context.inspectorDoc );
// DOM Changes
this.$.append( this.$closeButton, this.$acceptButton, this.$form );
// Events
this.$closeButton.on( {
'click': function () {
context.closeInspector( false );
}
} );
this.$acceptButton.on( {
'click': function () {
context.closeInspector ( true );
}
} );
this.$form.on( {
'submit': ve.bind( this.onSubmit, this ),
'keydown': ve.bind( this.onKeyDown, this )
} );
};
/* Methods */
ve.ui.Inspector.prototype.onSubmit = function ( e ) {
e.preventDefault();
this.context.closeInspector( true );
return false;
};
ve.ui.Inspector.prototype.onKeyDown = function ( e ) {
// Escape
if ( e.which === 27 ) {
this.context.closeInspector( false );
e.preventDefault();
return false;
}
};
ve.ui.Inspector.prototype.open = function () {
// Prepare to open
if ( this.prepareOpen ) {
this.prepareOpen();
}
// Show
this.$.show();
this.context.closeMenu();
// Open
if ( this.onOpen ) {
this.onOpen();
}
this.emit( 'open' );
};
ve.ui.Inspector.prototype.close = function ( accept ) {
this.$.hide();
if ( this.onClose ) {
this.onClose( accept );
}
this.emit( 'close' );
};
/* Inheritance */
ve.extendClass( ve.ui.Inspector, ve.EventEmitter );