mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 10:59:56 +00:00
278e5f7640
* Fix 404 error for ve.ui.Icons-{raster,vector}.css
Follows-up 9563f08
/ I840f72426f9a.
makeStaticLoader.php:
* Clean up old code.
* Error out early for missing module.
* Put i18n stuff in the right place
(some modules access ve.msg from the global scope to
assign status variables, for standalone on demos this was
failing due to wrong load order)
Change-Id: Idbff4c5136d567da747d9ae373cd2f6c3ee7fb1c
64 lines
1.6 KiB
JavaScript
64 lines
1.6 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
|
|
*/
|
|
|
|
/**
|
|
* I-Frame 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.createFrame( this.$frame, $container );
|
|
this.$ = this.$$( '.ve-ui-frame-container' );
|
|
|
|
// Initialization
|
|
if ( 'stylesheets' in config ) {
|
|
for ( i = 0, len = config.stylesheets.length; i < len; i++ ) {
|
|
this.loadStylesheet( config.stylesheets[i] );
|
|
}
|
|
}
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
ve.ui.Frame.prototype.setSize = function ( width, height ) {
|
|
this.$frame.css( { 'width': width, 'height': height } );
|
|
};
|
|
|
|
ve.ui.Frame.prototype.$$ = function ( selector ) {
|
|
return $( selector, this.frameDocument );
|
|
};
|
|
|
|
ve.ui.Frame.prototype.createFrame = 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;
|
|
};
|
|
|
|
ve.ui.Frame.prototype.loadStylesheet = function ( path ) {
|
|
// Append style elements to head.
|
|
this.$$( 'head' ).append(
|
|
this.$$( '<link rel="stylesheet">' ).attr( 'href', path )
|
|
);
|
|
};
|