From 00af43495b745fddf021f9dcc2a7b931217b9c1c Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 6 Jun 2014 11:04:24 +0100 Subject: [PATCH] Update VE core submodule to master (155f4ab) Use new setupToolbar and setupDebugbar methods in base target. New changes: 7ff523d Localisation updates from https://translatewiki.net. 3815224 [BREAKING CHANGE] Debug bar refactor 155f4ab Edit HTML mode in demo Change-Id: I554ce51eae872ab0f741a913bf10394c2a8c3e52 --- .docs/categories.json | 2 +- VisualEditor.php | 4 ++-- lib/ve | 2 +- .../ve.init.mw.ViewPageTarget-vector-hd.css | 2 +- .../ve.init.mw.ViewPageTarget-vector.css | 4 ++-- .../targets/ve.init.mw.MobileViewTarget.js | 4 ++-- .../targets/ve.init.mw.ViewPageTarget.init.js | 13 +---------- .../init/targets/ve.init.mw.ViewPageTarget.js | 17 ++++++++++++-- modules/ve-mw/init/ve.init.mw.Target.js | 22 +++++++++---------- 9 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.docs/categories.json b/.docs/categories.json index a8ac37a61a..25ef88524c 100644 --- a/.docs/categories.json +++ b/.docs/categories.json @@ -38,7 +38,6 @@ "ve.init", "ve.init.Platform", "ve.init.Target", - "ve.init.DebugBar", "ve.init.sa*" ] }, @@ -99,6 +98,7 @@ "ve.ui.MobileContext", "ve.ui.Toolbar", "ve.ui.TargetToolbar", + "ve.ui.DebugBar", "ve.ui.WindowSet", "ve.ui.Action", "ve.ui.Trigger", diff --git a/VisualEditor.php b/VisualEditor.php index 001913ecc0..f5aa14ee93 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -457,7 +457,7 @@ $wgResourceModules += array( 'lib/ve/modules/ve/ui/inspectors/ve.ui.SpecialCharacterInspector.js', ), 'debugScripts' => array( - 'lib/ve/modules/ve/init/ve.init.DebugBar.js', + 'lib/ve/modules/ve/ui/ve.ui.DebugBar.js', ), 'styles' => array( // ce @@ -486,7 +486,7 @@ $wgResourceModules += array( 'lib/ve/modules/ve/ui/styles/ve.ui.Toolbar.css', // TODO: add debugStyles to ResourceLoader - 'lib/ve/modules/ve/init/styles/ve.init.DebugBar.css', + 'lib/ve/modules/ve/ui/styles/ve.ui.DebugBar.css', ), 'skinStyles' => array( 'default' => array( diff --git a/lib/ve b/lib/ve index 89820e514d..155f4abc8b 160000 --- a/lib/ve +++ b/lib/ve @@ -1 +1 @@ -Subproject commit 89820e514d4096c4168a37a04fc25015aa23092d +Subproject commit 155f4abc8be392b231de3a3c6410b831ee1903db diff --git a/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget-vector-hd.css b/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget-vector-hd.css index 55ad301ded..d564e99774 100644 --- a/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget-vector-hd.css +++ b/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget-vector-hd.css @@ -9,7 +9,7 @@ margin: -1.25em -1.5em 1.5em -1.5em; } -.ve-init-debugBar { +.ve-ui-debugBar { padding: 1.5em; margin: 1em -1.5em -1.5em -1.5em; } diff --git a/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget-vector.css b/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget-vector.css index fa379e5e84..b15274264f 100644 --- a/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget-vector.css +++ b/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget-vector.css @@ -35,14 +35,14 @@ position: relative; } -.ve-init-debugBar { +.ve-ui-debugBar { padding: 1em; margin: 1em -1em -1em -1em; border-top: solid 1px #ccc; box-shadow: 0 10px 10px -10px rgba(0, 0, 0, 0.15) inset; } -.ve-init-debugBar ol { +.ve-ui-debugBar ol { margin-left: 0; } diff --git a/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js b/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js index 1a22580f91..79d38b0f00 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js @@ -88,9 +88,9 @@ ve.init.mw.MobileViewTarget.prototype.createSurface = function ( dmDoc, config ) /** * @inheritdoc */ -ve.init.mw.MobileViewTarget.prototype.setUpToolbar = function () { +ve.init.mw.MobileViewTarget.prototype.setupToolbar = function () { // Parent method - ve.init.mw.Target.prototype.setUpToolbar.call( this ); + ve.init.mw.Target.prototype.setupToolbar.call( this ); this.toolbar.$element // FIXME shouldn't be using viewPageTarget styles diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js index 0fede33be3..5d35340d8e 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js @@ -33,20 +33,9 @@ getTargetDeferred = $.Deferred(); loadTargetDeferred = $.Deferred() .done( function () { - var debugBar, target = new ve.init.mw.ViewPageTarget(); + var target = new ve.init.mw.ViewPageTarget(); ve.init.mw.targets.push( target ); - if ( ve.debug ) { - debugBar = new ve.init.DebugBar(); - target.on( 'surfaceReady', function () { - $( '#content' ).append( debugBar.$element.show() ); - debugBar.attachToSurface( target.surface ); - target.surface.on( 'destroy', function () { - debugBar.$element.hide(); - } ); - } ); - } - // Tee tracked events to MediaWiki firehose, if available (1.23+). if ( mw.track ) { ve.trackSubscribeAll( function ( topic, data ) { diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index 9e801f93df..972c68cdd6 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -193,10 +193,10 @@ ve.init.mw.ViewPageTarget.prototype.verifyPopState = function ( popState ) { /** * @inheritdoc */ -ve.init.mw.ViewPageTarget.prototype.setUpToolbar = function () { +ve.init.mw.ViewPageTarget.prototype.setupToolbar = function () { var $firstHeading; // Parent method - ve.init.mw.Target.prototype.setUpToolbar.call( this ); + ve.init.mw.Target.prototype.setupToolbar.call( this ); // Keep it hidden so that we can slide it down smoothly (avoids sudden // offset flash when original content is hidden, and replaced in-place with a @@ -1069,6 +1069,7 @@ ve.init.mw.ViewPageTarget.prototype.startSanityCheck = function () { ve.init.mw.ViewPageTarget.prototype.tearDownSurface = function () { // Update UI this.tearDownToolbar(); + this.tearDownDebugBar(); this.restoreDocumentTitle(); if ( this.surface.mwTocWidget ) { this.surface.mwTocWidget.teardown(); @@ -1376,6 +1377,18 @@ ve.init.mw.ViewPageTarget.prototype.tearDownToolbar = function () { }, this ) ); }; +/** + * Hide the debug bar. + * + * @method + */ +ve.init.mw.ViewPageTarget.prototype.tearDownDebugBar = function () { + this.debugBar.$element.slideUp( 'fast', ve.bind( function () { + this.debugBar.$element.remove(); + this.debugBar = null; + }, this ) ); +}; + /** * Transform the page title into a VE-style title. * diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 636a12c094..bc11bed6fb 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -489,7 +489,7 @@ ve.init.mw.Target.prototype.onReady = function () { this.onNoticesReady(); this.loading = false; this.edited = false; - this.setUpSurface( this.doc, ve.bind( function () { + this.setupSurface( this.doc, ve.bind( function () { this.startSanityCheck(); this.emit( 'surfaceReady' ); }, this ) ); @@ -1301,7 +1301,7 @@ ve.init.mw.Target.prototype.getEditNotices = function () { * @param {HTMLDocument} doc HTML DOM to edit * @param {Function} [callback] Callback to call when done */ -ve.init.mw.Target.prototype.setUpSurface = function ( doc, callback ) { +ve.init.mw.Target.prototype.setupSurface = function ( doc, callback ) { var target = this; setTimeout( function () { // Build model @@ -1317,6 +1317,7 @@ ve.init.mw.Target.prototype.setUpSurface = function ( doc, callback ) { target.surface = surface; surface.$element.addClass( 've-init-mw-viewPageTarget-surface' ) .addClass( target.protectedClasses ); + surface.addCommands( target.constructor.static.surfaceCommands ); setTimeout( function () { var surfaceView = surface.getView(), $documentNode = surfaceView.getDocument().getDocumentNode().$element; @@ -1324,7 +1325,10 @@ ve.init.mw.Target.prototype.setUpSurface = function ( doc, callback ) { // Initialize surface surface.getContext().hide(); target.$element.append( surface.$element ); - target.setUpToolbar(); + target.setupToolbar(); + if ( ve.debug ) { + target.setupDebugBar(); + } // Apply mw-body-content to the view (ve-ce-surface). // Not to surface (ve-ui-surface), since that contains both the view @@ -1346,15 +1350,11 @@ ve.init.mw.Target.prototype.setUpSurface = function ( doc, callback ) { }; /** - * Set up the toolbar and insert it into the DOM. - * - * The default implementation inserts it before the surface, but subclasses can override this. + * @inheritdoc */ -ve.init.mw.Target.prototype.setUpToolbar = function () { - this.toolbar = new ve.ui.TargetToolbar( this, this.surface, { 'shadow': true, 'actions': true } ); - this.toolbar.setup( this.constructor.static.toolbarGroups ); - this.surface.addCommands( this.constructor.static.surfaceCommands ); - this.toolbar.$element.insertBefore( this.surface.$element ); +ve.init.mw.Target.prototype.setupToolbar = function () { + // Parent method + ve.init.Target.prototype.setupToolbar.call( this, { 'shadow': true, 'actions': true } ); }; /**