mediawiki-extensions-Visual.../modules/ve/ui/ve.ui.InspectorFactory.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

76 lines
1.8 KiB
JavaScript

/*!
* VisualEditor UserInterface InspectorFactory class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* UserInterface inspector factory.
*
* @class
* @extends ve.Factory
* @constructor
*/
ve.ui.InspectorFactory = function VeUiInspectorFactory() {
// Parent constructor
ve.Factory.call( this );
};
/* Inheritance */
ve.inheritClass( ve.ui.InspectorFactory, ve.Factory );
/* Methods */
/**
* Get an inspector constructor for a given annotation type.
*
* @method
* @param {string} name Symbolic name of inspector to get pattern for
* @returns {RegExp} Regular expression matching annotations relevant to a given inspector
* @throws {Error} Unknown inspector
*/
ve.ui.InspectorFactory.prototype.getTypePattern = function ( name ) {
if ( name in this.registry ) {
return this.registry[name].static.typePattern;
}
throw new Error( 'Unknown inspector: ' + name );
};
/**
* Get a list of inspectors from a set of annotations.
*
* @method
* @param {ve.dm.AnnotationSet} annotations Annotations to be inspected
* @returns {string[]} Symbolic names of inspectors that can be used to inspect annotations
*/
ve.ui.InspectorFactory.prototype.getInspectorsForAnnotations = function ( annotations ) {
if ( annotations.isEmpty() ) {
return [];
}
var i, len, j, annotation,
matches = [],
inspectors = this.entries.slice( 0 ),
inspector,
arr = annotations.get();
for ( i = 0, len = arr.length; i < len; i++ ) {
annotation = arr[i];
j = inspectors.length;
while ( inspectors[--j] ) {
inspector = inspectors[j];
if ( this.registry[inspector].static.typePattern.test( annotation.name ) ) {
matches.push( inspector );
break;
}
}
}
return matches;
};
/* Initialization */
ve.ui.inspectorFactory = new ve.ui.InspectorFactory();