jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/365598 )
Change subject: BSVisualEditor: Improved readablity of __NOEDITOR__ logic
......................................................................
BSVisualEditor: Improved readablity of __NOEDITOR__ logic
Also removed a legacy file that is not needed anymore but pollutes grep results
ATTENTION: This change does not fix anything. It just improves semantics
of the code. There is no particular need to merge this before RELEASE 2.27.2
NEEDS CHERRY-PICK TO REL1_27
Change-Id: Ied3d7a6fe52de20d3106117cd3a1133742570bd1
---
M VisualEditor/VisualEditor.class.php
D VisualEditor/doc/legacy/bluespice.visualEditor.js
M VisualEditor/resources/bluespice.visualEditor.js
3 files changed, 12 insertions(+), 239 deletions(-)
Approvals:
Pwirth: Looks good to me, approved
jenkins-bot: Verified
diff --git a/VisualEditor/VisualEditor.class.php
b/VisualEditor/VisualEditor.class.php
index 9bdbf04..ac289e4 100644
--- a/VisualEditor/VisualEditor.class.php
+++ b/VisualEditor/VisualEditor.class.php
@@ -349,8 +349,9 @@
$this->bStartEditor = false;
//Overwrite user setting
- $this->getOutput()->addJsConfigVars('bsVisualEditorUse', false);
- BsConfig::set('MW::VisualEditor::Use', false, true); //This
seems to be too late
+ $this->getOutput()->addJsConfigVars(
+ 'bsVisualEditor__NOEDITOR__', true
+ );
}
/**
diff --git a/VisualEditor/doc/legacy/bluespice.visualEditor.js
b/VisualEditor/doc/legacy/bluespice.visualEditor.js
deleted file mode 100644
index 9bc07d7..0000000
--- a/VisualEditor/doc/legacy/bluespice.visualEditor.js
+++ /dev/null
@@ -1,235 +0,0 @@
-/**
- * VisualEditor extension
- *
- * @author Markus Glaser <[email protected]>
- * @version 1.20.0
-
- * @package Bluespice_Extensions
- * @subpackage VisualEditor
- * @copyright Copyright (C) 2016 Hallo Welt! GmbH, All rights reserved.
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or
later
- * @filesource
- */
-
-/*
-Ideen:
-- Links rot oder blau. Per Ajax nachfragen.
-/*
- * Determine mode of editor (full or reduced)
- */
-offsetTop = 0;
-$(window).scroll(function(){
- var toobar = $('#wpTextbox1_toolbargroup');
- if( toobar.length == 0 ) return;
- if(offsetTop == 0){
- offsetTop = toobar.position().top;
- }
- if( window.scrollY > offsetTop ) {
- if( toobar.hasClass('bs-ve-fixed') == false ) {
- toobar.addClass('bs-ve-fixed');
- toobar.parent().height( toobar.height() );
- toobar.width( toobar.parent().width() );
- }
- }
- else {
- toobar.removeClass('bs-ve-fixed');
- toobar.parent().height( null );
- }
-});
-
-mw.loader.using('ext.bluespice.visualEditor', function() {
- $('#edit_button').click(function(){
- toggleEditorMode('wpTextbox1');
- });
-
- var bsVisualEditorTinyMCEPlugins = mw.config.get(
'bsVisualEditorTinyMCEPlugins' );
- for( var plugin in bsVisualEditorTinyMCEPlugins ) {
- tinyMCE.PluginManager.load(
- plugin,
- mw.config.get('wgScriptPath') +
bsVisualEditorTinyMCEPlugins[plugin]
- );
- }
-
- // merge(extends/overwrites) standard config with overwrite config
- // if a property of the first object is itself an object or array,
- // it will be completely overwritten by a property with the same key
- // in the second object.
- var temp = {};
- var currentSiteCSS = [];
- //We collect the CSS Links from this document and set them as
content_css
- //for TinyMCE
- $('link[rel=stylesheet]').each(function(){
- var cssBaseURL = '';
- var cssUrl = $(this).attr('href');
- //Conditionally make urls absolute to avoid conflict with
tinymce.baseURL
- if( cssUrl.startsWith( '/' ) ) cssBaseURL =
mw.config.get('wgServer');
- currentSiteCSS.push( cssBaseURL + cssUrl );
- });
-
- var bsVisualEditorConfigStandard = mw.config.get(
'bsVisualEditorConfigStandard' );
- var bsVisualEditorConfigOverwrite = mw.config.get(
'bsVisualEditorConfigOverwrite' );
- var bsVisualEditorTinyMCETableStyles = mw.config.get(
'bsVisualEditorTinyMCETableStyles' );
-
- bsVisualEditorConfigStandard.content_css = currentSiteCSS.join(',');
- bsVisualEditorConfigStandard.table_styles =
bsVisualEditorTinyMCETableStyles;
- var lang = mw.user.options.get('language');
- lang = lang === 'de-formal' ? 'de': lang;
- bsVisualEditorConfigStandard.language = lang;
-
- $.extend(true, temp, bsVisualEditorConfigStandard,
bsVisualEditorConfigOverwrite);
- bsVisualEditorConfigOverwrite = temp;
-
- //We need to set the baseURL to alow lazy loading of tinyMCE plugins
- tinymce.baseURL =
mw.config.get('wgScriptPath')+'/extensions/BlueSpiceExtensions/VisualEditor/resources/tiny_mce';
- var bsVisualEditorUseLimited = mw.config.get(
'bsVisualEditorUseLimited' );
- var bsVisualEditorUseForceLimited = mw.config.get(
'bsVisualEditorUseForceLimited' );
- if( bsVisualEditorConfigOverwrite && ( bsVisualEditorUseLimited ||
bsVisualEditorUseForceLimited ) ) {
- tinymce.init( bsVisualEditorConfigOverwrite );
- mw.config.set( 'bsVisualEditorGuiMode', 'bn' );
- } else {
- tinymce.init( bsVisualEditorConfigStandard );
- mw.config.set( 'bsVisualEditorGuiMode', 'tm' );
- }
- if( bsVisualEditorConfigOverwrite ) {
- mw.config.set( 'bsVisualEditorGuiSwitchable', true );
- }
-});
-/**
- * Is the editor currently running?
- * @var bool True if the editor is running.
- */
-var VisualEditorMode = false;
-
-/**
- * Starts the editor, but only after toolbars are rendered.
- */
-function startEditor() {
- if (document.getElementById('toolbar') &&
document.getElementById('hw-toolbar')) {
- toggleEditorMode('wpTextbox1');
- }
- else {
- setTimeout("startEditor()", 100);
- }
-}
-
-/**
- * Actually displays the editor and removes the toolbars.
- */
-toggleEditorMode = function(sEditorID) {
- try {
- if(VisualEditorMode) {
- $(document).trigger('BSVisualEditorBeforeToggleEditor',
['MW']);
- tinymce.execCommand('mceRemoveControl', false,
sEditorID);
- $('#toolbar, #hw-toolbar').show();
- VisualEditorMode = false;
- $(document).trigger('BSVisualEditorToggleEditor',
['MW']);
- } else {
- $(document).trigger('BSVisualEditorBeforeToggleEditor',
['VisualEditor']);
- tinymce.execCommand('mceAddControl', false, sEditorID);
- $('#toolbar, #hw-toolbar').hide();
- VisualEditorMode = true;
- $(document).trigger('BSVisualEditorToggleEditor',
['VisualEditor']);
- }
- } catch(e) {
- //error handling
- }
-}
-
-/**
- * Switches betwenn full and reduced mode of the editor.
- */
-toggleGuiMode = function() {
- if( mw.config.get( 'bsVisualEditorGuiSwitchable' ) ) {
- tinymce.execCommand('mceRemoveControl', false, 'wpTextbox1');
- if(document.getElementById('toolbar'))
{document.getElementById('toolbar').style.display = "block";}
- if(document.getElementById('hw-toolbar'))
{document.getElementById('hw-toolbar').style.display = "block";}
- VisualEditorMode = false;
- if( mw.config.get( 'bsVisualEditorGuiMode' ) === 'bn') {
- tinymce.init( mw.config.get(
'bsVisualEditorConfigStandard' ) );
- mw.config.set( 'bsVisualEditorGuiMode', 'tm' );
- }
- else {
- tinymce.init( mw.config.get(
'bsVisualEditorConfigOverwrite' ) );
- mw.config.set( 'bsVisualEditorGuiMode', 'bn' );
- }
- tinymce.execCommand('mceAddControl', false, 'wpTextbox1');
- if(document.getElementById('toolbar'))
{document.getElementById('toolbar').style.display = "none";}
- if(document.getElementById('hw-toolbar'))
{document.getElementById('hw-toolbar').style.display = "none";}
- VisualEditorMode = true;
- }
- else {
- alert("no switch");
- }
-}
-
-BsVisualEditor = {
- //Init loadMask and loadMaskTask with minimal stub objects to avoid code
- //breaking in case of IE8 runtime error
- loadMask: {
- show: function() {},
- hide: function() {}
- },
-
- loadMaskTask:{
- cancel: function() {},
- delay: function( time, callback ) {}
- },
-
- init: function() {
- if (bsVisualEditorUse == true) {
- setTimeout("startEditor()", 100);
- }
-
- //TODO: User TinyMCE LoadMask:
http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setProgressState
- },
-
- /**
- * Starts the editor, but only after toolbars are rendered.
- */
- startEditor: function() {
-
- },
-
- /**
- * Actually displays the editor and removes the toolbars.
- */
- toggleEditorMode: function(sEditorID) {
-
- },
-
- /**
- * Switches betwenn full and reduced mode of the editor.
- */
- toggleGuiMode: function() {
-
- }
-}
-
-$(document).bind('BSVisualEditorBeforeArticleSave', function( event, plugin,
ajaxParams ) {
- tinymce.getInstanceById('wpTextbox1').setProgressState( true );
-});
-
-$(document).bind('BSVisualEditorAfterArticleSave', function( event, plugin,
success, response ) {
- tinymce.getInstanceById('wpTextbox1').setProgressState( false );
-});
-
-$(document).bind('BSVisualEditorBeforeWikiToHtml', function( event, textObject
) {
- //HINT:
http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setProgressState
- tinymce.getInstanceById('wpTextbox1').setProgressState( true );
-});
-
-$(document).bind('BSVisualEditorAfterWikiToHtml', function( event, textObject
) {
- tinymce.getInstanceById('wpTextbox1').setProgressState( false );
-});
-
-$(document).bind('BSVisualEditorBeforeHtmlToWiki', function( event, textObject
) {
- tinymce.getInstanceById('wpTextbox1').setProgressState( true );
-});
-
-$(document).bind('BSVisualEditorAfterHtmlToWiki', function( event, textObject
) {
- tinymce.getInstanceById('wpTextbox1').setProgressState( false );
-});
-
-$(document).ready(function(){
- BsVisualEditor.init();
-});
\ No newline at end of file
diff --git a/VisualEditor/resources/bluespice.visualEditor.js
b/VisualEditor/resources/bluespice.visualEditor.js
index ccbd843..0f44920 100644
--- a/VisualEditor/resources/bluespice.visualEditor.js
+++ b/VisualEditor/resources/bluespice.visualEditor.js
@@ -109,8 +109,15 @@
});
}
- if ( mw.config.get('bsVisualEditorUse') !== false
- && mw.user.options.get('MW::VisualEditor::Use') === true ) {
+ pageHasNOEDITOR = function() {
+ return mw.config.get( 'bsVisualEditor__NOEDITOR__', false );
+ }
+
+ userHasVEenabledByDefault = function() {
+ return mw.user.options.get( 'MW::VisualEditor::Use' ) === true;
+ }
+
+ if ( !pageHasNOEDITOR() && userHasVEenabledByDefault() ) {
VisualEditor.startEditors();
$(document).trigger('VisualEditor::instanceShow',
['wpTextbox1']);
}
--
To view, visit https://gerrit.wikimedia.org/r/365598
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied3d7a6fe52de20d3106117cd3a1133742570bd1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits