2011-12-09 01:28:44 +00:00
|
|
|
/**
|
|
|
|
* Creates an es.Inspector object.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @param {es.ToolbarView} toolbar
|
|
|
|
* @param {String} name
|
|
|
|
*/
|
|
|
|
es.Inspector = function( toolbar, context ) {
|
|
|
|
// Inheritance
|
|
|
|
es.EventEmitter.call( this );
|
|
|
|
if ( !toolbar || !context ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.toolbar = toolbar;
|
|
|
|
this.context = context;
|
|
|
|
this.$ = $( '<div class="es-inspector"></div>' );
|
2011-12-09 23:04:55 +00:00
|
|
|
this.$closeButton = $( '<div class="es-inspector-button es-inspector-closeButton"></div>' )
|
|
|
|
.appendTo( this.$ );
|
|
|
|
this.$acceptButton = $( '<div class="es-inspector-button es-inspector-acceptButton"></div>' )
|
|
|
|
.appendTo( this.$ );
|
2011-12-09 19:01:05 +00:00
|
|
|
this.$form = $( '<form></form>' ).appendTo( this.$ );
|
2011-12-09 01:28:44 +00:00
|
|
|
|
|
|
|
// Events
|
|
|
|
var _this = this;
|
|
|
|
this.$closeButton.click( function() {
|
2011-12-09 23:04:55 +00:00
|
|
|
_this.context.closeInspector( false );
|
|
|
|
} );
|
|
|
|
this.$acceptButton.click( function() {
|
|
|
|
_this.context.closeInspector( true );
|
2011-12-09 01:28:44 +00:00
|
|
|
} );
|
2011-12-09 19:01:05 +00:00
|
|
|
this.$form.submit( function( e ) {
|
2011-12-09 23:04:55 +00:00
|
|
|
_this.context.closeInspector( true );
|
2011-12-09 19:01:05 +00:00
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
} );
|
2011-12-09 01:28:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
es.Inspector.prototype.open = function() {
|
|
|
|
this.$.show();
|
|
|
|
this.context.closeMenu();
|
|
|
|
if ( this.onOpen ) {
|
|
|
|
this.onOpen();
|
|
|
|
}
|
|
|
|
this.emit( 'open' );
|
|
|
|
};
|
|
|
|
|
2011-12-09 23:04:55 +00:00
|
|
|
es.Inspector.prototype.close = function( accept ) {
|
2011-12-09 01:28:44 +00:00
|
|
|
this.$.hide();
|
|
|
|
if ( this.onClose ) {
|
2011-12-09 23:04:55 +00:00
|
|
|
this.onClose( accept );
|
2011-12-09 01:28:44 +00:00
|
|
|
}
|
|
|
|
this.emit( 'close' );
|
2011-12-09 20:46:12 +00:00
|
|
|
surfaceView.$input.focus();
|
2011-12-09 01:28:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
es.extendClass( es.Inspector, es.EventEmitter );
|