diff --git a/modules/ve/ui/styles/ve.ui.Context.css b/modules/ve/ui/styles/ve.ui.Context.css index 1d43a02a47..8a1088807b 100644 --- a/modules/ve/ui/styles/ve.ui.Context.css +++ b/modules/ve/ui/styles/ve.ui.Context.css @@ -5,12 +5,12 @@ * @license The MIT License (MIT); see LICENSE.txt */ -.es-contextView { +.ve-ui-context { position: absolute; z-index: 2; } -.es-contextView-icon { +.ve-ui-context-icon { position: absolute; background-repeat: no-repeat; width: 15px; @@ -29,53 +29,53 @@ z-index: 4; } -.es-contextView-position-start .es-contextView-icon { +.ve-ui-context-position-start .ve-ui-context-icon { top: -12px; left: -8px; } -.es-contextView-position-end .es-contextView-icon { +.ve-ui-context-position-end .ve-ui-context-icon { top: -6px; left: -8px; } -.es-contextView-position-above .es-contextView-icon { +.ve-ui-context-position-above .ve-ui-context-icon { /* @embed */ background-image: url(images/arrow-up.png); background-position: 50% 4px; } -.es-contextView-position-below .es-contextView-icon { +.ve-ui-context-position-below .ve-ui-context-icon { /* @embed */ background-image: url(images/arrow-down.png); background-position: 50% 5px; } -.es-contextView-position-above .es-contextView-icon:hover, -.es-contextView-position-below .es-contextView-icon:hover { +.ve-ui-context-position-above .ve-ui-context-icon:hover, +.ve-ui-context-position-below .ve-ui-context-icon:hover { border-color: #b3d6f6; } -.es-contextView-position-above .es-menuView { +.ve-ui-context-position-above .ve-menuView { bottom: 2px; } -.es-contextView-position-below .es-menuView { +.ve-ui-context-position-below .ve-menuView { top: 2px; } -.es-contextView-inspectors { +.ve-ui-context-inspectors { position: absolute; } -.es-contextView-position-above .es-contextView-inspectors { +.ve-ui-context-position-above .ve-ui-context-inspectors { bottom: -8px; } -.es-contextView-position-below .es-contextView-inspectors { +.ve-ui-context-position-below .ve-ui-context-inspectors { top: 2px; } -.es-contextView-panels { +.ve-ui-context-panels { position: absolute; border: solid 1px #ccc; -webkit-border-radius: 0.25em; @@ -89,16 +89,16 @@ padding: 0.33em 0; } -.es-contextView-panel { +.ve-ui-context-panel { display: none; padding: 1em; } -.es-contextView-toolbar { +.ve-ui-context-toolbar { padding: 0.33em 0.66em; white-space: nowrap; } -.es-contextView .es-toolbarGroup { +.ve-ui-context .es-toolbarGroup { border: none; } diff --git a/modules/ve/ui/ve.ui.Context.js b/modules/ve/ui/ve.ui.Context.js index 807dad98b0..0ca2f2af51 100644 --- a/modules/ve/ui/ve.ui.Context.js +++ b/modules/ve/ui/ve.ui.Context.js @@ -24,18 +24,31 @@ ve.ui.Context = function ( surfaceView, $overlay ) { this.inspector = null; this.position = null; this.clicking = false; - this.$ = $( '
' ).appendTo( $overlay || $( 'body' ) ); - this.$toolbar = $( '
' ); - // Create iframe which will contain context inspectors. - this.setupInspectorFrame(); + // Default to body as parent. + $overlay = $overlay || $( 'body' ); - this.$icon = $( '
' ).appendTo( this.$ ); + // Setup contextView + this.$ = $( '
' ).prop( 'class', 've-ui-context' ); + $overlay.append( this.$ ); + + // Icon + this.$icon = $( '
' ) + .prop( 'class' , 've-ui-context-icon' ) + .appendTo( this.$ ); + + // Toolbar + this.$toolbar = $( '
' ) + .prop( 'class', 've-ui-context-toolbar'); + + // Toolbar view this.toolbarView = new ve.ui.Toolbar( this.$toolbar, this.surfaceView, [{ 'name': 'textStyle', 'items' : [ 'bold', 'italic', 'link', 'clear' ] }] ); + + // Context Menu this.menuView = new ve.ui.Menu( [ // Example menu items { 'name': 'tools', '$': this.$toolbar } @@ -54,43 +67,39 @@ ve.ui.Context = function ( surfaceView, $overlay ) { 'blur': ve.bind( this.onDocumentBlur, this ) } ); - // Intitialize link inspector - this.addInspector( 'link', new ve.ui.LinkInspector( this.toolbarView, this ) ); + // Setup Inspectors. + this.setupInspectorSpace(); }; /* Methods */ -ve.ui.Context.prototype.setupInspectorFrame = function () { +ve.ui.Context.prototype.setupInspectorSpace = function () { var $styleLink; // Inspector container - this.$inspectors = $( '
' ) - .addClass( 'es-contextView-inspectors' ) + this.$inspectors = $( '
' ) + .prop( 'class', 've-ui-context-inspectors' ) .appendTo( this.$ ); - // Iframe overlay - this.$iframeOverlay = $('
') - .addClass( 've-iframe-overlay' ) + // Overlay in main document scope for positioning elements over iframe. + this.$iframeOverlay = $( '
' ) + .prop( 'class', 've-iframe-overlay' ) .appendTo( this.$inspectors ); - // Create and append an iframe for inspectors. - // Use of iframe is required to retain selection while inspector controls are focused. - this.$inspectorFrame = $( '' ) - .attr({ - 'frameborder': '0' - }) - .appendTo( this.$inspectors ); + // Create and append an iframe to contain inspectors. + // NOTE: Inspectors are required to be inside the iframe to prevent loss of content selection. + this.$inspectorFrame = $( '