diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php index 5ff42bcd20..8e6b21530c 100644 --- a/ApiVisualEditor.php +++ b/ApiVisualEditor.php @@ -38,7 +38,7 @@ class ApiVisualEditor extends ApiBase { if ( $wikitext ) { /* Save Page */ - $flags = $params['minor'] ? EDIT_MINOR : EDIT_UPDATE; + $flags = $params['minor'] === 'true' ? EDIT_MINOR : EDIT_UPDATE; $wikiPage = WikiPage::factory( $page ); $status = $wikiPage->doEdit( @@ -46,7 +46,21 @@ class ApiVisualEditor extends ApiBase { $params['summary'], $flags ); - //$status->ok === true ? + + // Check status ? + // $status->ok === true ? + + // Add / Remove from watch list. + if( $params['watch'] === 'true' ) { + if ( $wgUser->isWatched( $page ) === false ) { + $wgUser->addWatch( $page ); + } + } else { + // Remove from watchlist? + if ( $wgUser->isWatched( $page ) === true ) { + $wgUser->removeWatch( $page ); + } + } /* Get page content */ // NOTE: possibly return content from revision object vs current rev ? @@ -94,6 +108,9 @@ class ApiVisualEditor extends ApiBase { 'minor' => array( ApiBase::PARAM_REQUIRED => false, ), + 'watch' => array( + ApiBase::PARAM_REQUIRED => false, + ), 'html' => array( ApiBase::PARAM_REQUIRED => false, ), diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index 5db4e4901c..d52efd1528 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -32,6 +32,11 @@ class VisualEditorHooks { } return true; } + public static function makeGlobalScriptVariables( &$vars ) { + global $wgUser, $wgTitle; + $vars['vePageWatched'] = $wgUser->isWatched( $wgTitle ) ? true : false; + return true; + } /** * */ diff --git a/VisualEditor.php b/VisualEditor.php index 7320bcca8b..9f05d5838b 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -84,7 +84,17 @@ $wgResourceModules += array( 'core/ve.Core.js', ), 'messages' => array( - '', + 'minoredit', + 'savearticle', + 'watchthis', + 'summary', + 'tooltip-save', + 'copyrightwarning', + 'copyrightpage', + 'edit', + 'accesskey-ca-edit', + 'tooltip-ca-edit' + ), 'styles' => 'core/ve.Core.css', 'dependencies' => array( @@ -243,6 +253,7 @@ $wgAPIModules['ve-parsoid'] = 'ApiVisualEditor'; $wgAutoloadClasses['VisualEditorHooks'] = $dir . 'VisualEditor.hooks.php'; $wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onPageDisplay'; $wgHooks['userCan'][] = 'VisualEditorHooks::namespaceProtection'; +$wgHooks['MakeGlobalVariablesScript'][] = 'VisualEditorHooks::makeGlobalScriptVariables'; // API for retrieving wikidom parse results $wgAutoloadClasses['ApiQueryParseTree'] = $dir . 'api/ApiQueryParseTree.php'; diff --git a/modules/core/ve.Core.css b/modules/core/ve.Core.css index 94076825e3..1f5329d263 100644 --- a/modules/core/ve.Core.css +++ b/modules/core/ve.Core.css @@ -14,7 +14,7 @@ vertical-align: top; padding: 0.25em; height: 22px; - margin-right: 0.125em; + margin-right: 0.25em; border: solid 1px transparent; } .ve-action-button:before { @@ -36,9 +36,9 @@ /* Save dialog styles */ #ve-saveDialog { - top: 0px; + top: -1px; right: 2.5em; - width: 35em; + width: 29em; } #ve-saveDialog > .ve-dialog-divider { @@ -51,18 +51,18 @@ clear: both; } -#ve-saveDialog > .ve-dialog-divider > .ve-dialog-left { +.ve-dialog-left { float: left; } -#ve-saveDialog > .ve-dialog-divider > input[type='text'] { +#ve-saveDialog input[type='text'] { width: 96%; font-size: 12px; padding: 4px; - margin-bottom: 10px; + margin: 10px 0px; } -#ve-saveDialog > .ve-dialog-divider > input[type='checkbox'] { +#ve-saveDialog input[type='checkbox'] { margin-right: 5px; } @@ -82,7 +82,7 @@ } /* inspector styles */ .es-inspector-savebutton { - padding-right: 24px; + padding-right: 26px; border:1px solid transparent; border-radius: 0.125em; -webkit-border-radius: 0.125em; @@ -90,7 +90,7 @@ -o-border-radius: 0.125em; /* need new button */ /* @embed */ - background-image: url(../ve2/ui/styles/images/save.png); + background-image: url(../ve2/ui/styles/images/close.png); background-position: center right; background-repeat: no-repeat; } diff --git a/modules/core/ve.Core.js b/modules/core/ve.Core.js index 26b46dc556..2561f96076 100644 --- a/modules/core/ve.Core.js +++ b/modules/core/ve.Core.js @@ -9,14 +9,12 @@ validNamespace = mw.config.get('wgCanonicalNamespace') === 'VisualEditor' ? true: false; this.mainEditor = null; - this.$content = $('#content'); - // modify / stash content styles - this.prepareContentStyles(); - // On VisualEditor namespace ? if ( validNamespace ) { + this.$content = $('#content'); this.setupTabs(); - + // modify / stash content styles + this.prepareContentStyles(); $('#ca-edit > span > a').click( function( e ){ // hijack the edit link e.preventDefault(); @@ -82,7 +80,7 @@ this.mainEditor = new ve.Surface( '#ve-editor', $html[0], options ); this.$editor.find('.es-panes') - .css('padding', this.contentPadding ); + .css('padding', this.contentStyles.padding ); // Save BTN this.$editor.find('.es-modes') @@ -99,8 +97,8 @@ .attr('class', 've-action-button ve-closeBtn') .click(function(){ // back to read mode - _this.cleanup(); _this.mainEditor = null; + _this.cleanup(); }) ); this.initSaveDialog(); @@ -117,10 +115,10 @@ mw.util.addPortletLink( 'p-views', '#', - 'Edit', //TODO: dig for i18n messages + mw.msg('edit'), 'ca-edit', - 'Edit button text', - null, + mw.msg('tooltip-ca-edit'), + mw.msg('accesskey-ca-edit'), '#ca-history' ); // Create 'View Source' link in sub menu from original. @@ -141,7 +139,7 @@ mw.util.addPortletLink( 'p-cactions', mw.util.wikiGetlink() + '?action=edit', - 'Edit Source', + 'Edit Source', // TODO: i18n 'ca-editsource' ); @@ -170,11 +168,11 @@ // Save _this.getParsoidWikitextAndSave( function( content ){ // cleanup - _this.$dialog.toggle(); - _this.cleanup(); + _this.$dialog.slideUp(); // load saved page _this.$content .find('#mw-content-text').html( content ); + _this.cleanup(); }); }; @@ -188,7 +186,7 @@ }).append( $('
') .attr('class', 'es-inspector-title') - .text('Save your changes') + .text( mw.msg('tooltip-save') ) ).append( $('
') .attr('class', 'es-inspector-button ve-saveBtn') @@ -201,9 +199,11 @@ .append( $('
') .text("Describe what you changed") + //.text( mw.msg('summary') ) ).append( $('') .attr({ + 'id': 'txtEditSummary', 'type':'text' }) ).append( @@ -221,8 +221,7 @@ ).append( $('