[MediaWiki-commits] [Gerrit] Insert section name in edit summary - change (mediawiki...MobileFrontend)

2014-09-12 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Insert section name in edit summary
..


Insert section name in edit summary

To be consistent with desktop and app edits, add the section
name to the summary automatically when the user saves an edit.

Bug: 60134
Change-Id: Iebecb63f9c8766eaa06ea5b7c8d98c26931c4a57
---
M javascripts/modules/editor/EditorApi.js
M javascripts/modules/editor/EditorOverlay.js
2 files changed, 17 insertions(+), 4 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/javascripts/modules/editor/EditorApi.js 
b/javascripts/modules/editor/EditorApi.js
index aa7cb4c..e1eb1b4 100644
--- a/javascripts/modules/editor/EditorApi.js
+++ b/javascripts/modules/editor/EditorApi.js
@@ -173,7 +173,7 @@
},
 
getPreview: function( options ) {
-   var result = $.Deferred();
+   var result = $.Deferred(), sectionLine = '', self = 
this;
 
$.extend( options, {
action: 'parse',
@@ -184,12 +184,19 @@
// Output mobile HTML (bug 54243)
mobileformat: true,
title: this.title,
-   prop: 'text'
+   prop: ['text', 'sections']
} );
 
this.post( options ).done( function( resp ) {
if ( resp  resp.parse  resp.parse.text ) {
-   result.resolve( resp.parse.text['*'] );
+   // section 0 haven't a section name so 
skip
+   if ( self.sectionId !== 0 
+   resp.parse.sections 
+   resp.parse.sections[0].line !== 
undefined
+   ) {
+   sectionLine = 
resp.parse.sections[0].line;
+   }
+   result.resolve( resp.parse.text['*'], 
sectionLine );
} else {
result.reject();
}
diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index ff123bd..b303c3f 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -20,6 +20,7 @@
content: M.template.get( 
'modules/editor/EditorOverlay.hogan' )
},
editor: 'SourceEditor',
+   sectionLine: '',
 
initialize: function( options ) {
this.api = new EditorApi( {
@@ -134,7 +135,9 @@
if ( mw.config.get( 'wgIsMainPage' ) ) {
params.mainpage = 1; // Setting it to 0 will 
have the same effect
}
-   this.api.getPreview( params ).done( function( 
parsedText ) {
+   this.api.getPreview( params ).done( function( 
parsedText, parsedSectionLine ) {
+   // On desktop edit summaries strip tags. Mimic 
this behavior on mobile devices
+   self.sectionLine = $( 'div/' ).html( 
parsedSectionLine ).text();
new Section( {
el: self.$preview,
content: parsedText
@@ -225,6 +228,9 @@
var self = this,
options = { summary: this.$( '.summary' ).val() 
};
 
+   if ( self.sectionLine !== '' ) {
+   options.summary = '/* ' + self.sectionLine + ' 
*/' + options.summary;
+   }
this._super();
if ( this.confirmAborted ) {
return;

-- 
To view, visit https://gerrit.wikimedia.org/r/135311
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iebecb63f9c8766eaa06ea5b7c8d98c26931c4a57
Gerrit-PatchSet: 18
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow florian.schmidt.wel...@t-online.de
Gerrit-Reviewer: Awjrichards aricha...@wikimedia.org
Gerrit-Reviewer: Florianschmidtwelzow florian.schmidt.wel...@t-online.de
Gerrit-Reviewer: JGonera jgon...@wikimedia.org
Gerrit-Reviewer: Jdlrobson jrob...@wikimedia.org
Gerrit-Reviewer: Kaldari rkald...@wikimedia.org
Gerrit-Reviewer: Liangent liang...@gmail.com
Gerrit-Reviewer: MaxSem maxsem.w...@gmail.com
Gerrit-Reviewer: jenkins-bot 


[MediaWiki-commits] [Gerrit] Insert section name in edit summary - change (mediawiki...MobileFrontend)

2014-05-25 Thread Florianschmidtwelzow (Code Review)
Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135311

Change subject: Insert section name in edit summary
..

Insert section name in edit summary

I'm not sure, if this is the best solution :/

Bug: 60134
Change-Id: Iebecb63f9c8766eaa06ea5b7c8d98c26931c4a57
---
M javascripts/modules/editor/EditorOverlay.js
1 file changed, 14 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/11/135311/1

diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 6ffb1a8..ef11d35 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -124,7 +124,8 @@
},
 
_showPreview: function() {
-   var self = this, params = { text: this.$content.val() };
+   var self = this, params = { text: this.$content.val() },
+   summary = { raw: params.text };
 
// log save button click
this.log( 'save' );
@@ -157,6 +158,18 @@
self.$spinner.hide();
self.$preview.show();
} );
+   
+   // Bug 60134: set section name (choose from first line 
in text)
+   summary.raw = summary.raw.split( '\n' )[0];
+   
+   // Check if first line is a valid section name
+   if ( /^==.*==$/i.test(summary.raw) ) {
+   // remove equal signs and push to summary input 
field
+   this.$( '.summary' ).val( '/* ' + 
summary.raw.replace( /^=*=?|=*=$/g, '' ) + ' */ ' );
+   } else {
+   // clear summary input to clean our work (e.g. 
if user go back and edit first line to invalid)
+   this.$( '.summary' ).val( '' );
+   }
},
 
_hidePreview: function() {

-- 
To view, visit https://gerrit.wikimedia.org/r/135311
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iebecb63f9c8766eaa06ea5b7c8d98c26931c4a57
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow florian.schmidt.wel...@t-online.de

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits