{"version":3,"sources":["webpack://mfModules.[name]/./src/mobile.talk.overlays/AddTopicForm.js","webpack://mfModules.[name]/./src/mobile.talk.overlays/TalkSectionAddOverlay.js","webpack://mfModules.[name]/./src/mobile.talk.overlays/TalkSectionOverlay.js","webpack://mfModules.[name]/./src/mobile.talk.overlays/autosign.js","webpack://mfModules.[name]/./src/mobile.talk.overlays/makeAddTopicForm.js","webpack://mfModules.[name]/./src/mobile.talk.overlays/mobile.talk.overlays.js"],"names":["mfExtend","require","View","util","makePanel","$child","panel","className","$el","append","AddTopicForm","options","call","this","extend","topicTitlePlaceHolder","mw","msg","topicContentPlaceHolder","events","postRender","disabled","$subject","parseHTML","attr","class","type","value","subject","placeholder","$body","cols","rows","val","body","panels","addClass","html","licenseMsg","map","$messageBody","prototype","apply","arguments","onTextInput","trim","test","module","exports","headers","Overlay","PageGateway","makeAddTopicForm","TalkSectionAddOverlay","editorApi","api","pageGateway","onBeforeExit","bind","onSaveComplete","title","currentPageTitle","_saveHit","preRender","saveHeader","savingHeader","topicForm","showHidden","$confirm","find","$ta","exit","empty","confirmMessage","window","confirm","_loggedInput","track","clearTimeout","timer","setTimeout","prop","onSaveClick","save","then","status","error","editMsg","details","notify","heading","d","Deferred","removeClass","postWithToken","action","section","sectiontitle","summary","text","reject","user","icons","$spinner","spinner","header","autosign","Button","lazyImageLoader","TalkSectionOverlay","state","click","ev","target","tagName","indexOf","preventDefault","templatePartials","content","template","defaults","saveButton","block","additionalClassNames","progressive","label","saveButtonMessage","undefined","reply","info","onInputTextarea","$saveButton","loggedInput","cancel","line","back","loadImages","queryPlaceholders","prepend","hideSpinner","_enableComments","$commentBox","isAnon","remove","$textarea","self","showSpinner","id","appendtext","redirect","data","response","code","sub","bd","m","define"],"mappings":"gMAAA,IACCA,EAAWC,EAAS,oCACpBC,EAAOD,EAAS,gCAChBE,EAAOF,EAAS,gCAQjB,SAASG,EAAWC,GACnB,IAAMC,EAAQ,IAAIJ,EAAM,CAAEK,UAAW,UAErC,OADA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EnB,IAAItI,EAcHA,EAHAsI,EAASjE,OAPc,CACtB,WACA,UACA,eAKoB6B,QAASoC,EAASjE,MAAMkE,OAAU,EAEjDD,EAASjE,MAAM2C,KAEfjH,GAAGC,IAAK,gCAGfgI,EAAKN,cACL3H,GAAGyE,OAAQxE,EAAK,CAAES,KAAM,UA1CzBuH,EAAKd,YAAYlD,KAAM,YAAY,UAiDtClC,EAAOC,QAAU6D,G,uDCxPjB9D,EAAOC,QAJP,SAAmBmD,GAClB,MAAO,SAASrD,KAAMqD,GAASA,EAAOA,EAAO,U,iECR9C,IAAMzF,EAAeT,EAAS,8CAC7ByG,EAAWzG,EAAS,0CAgCrB8C,EAAOC,QAlBP,YAAkF,IAArDV,EAAqD,EAArDA,WAAYM,EAAyC,EAAzCA,YAAahB,EAA4B,EAA5BA,QAASM,EAAmB,EAAnBA,KAAMb,EAAa,EAAbA,SAepE,OAda,IAAIX,EAAc,CAC9B4B,aACAjB,WACAO,UACAM,OACAU,YAAaA,EAAc,SAAW6G,EAAKC,GAErCA,IACJA,EAAKhD,EAAUgD,IAGhB9G,EAAYhC,KAAMC,KAAM4I,EAAKC,SAC1B3B,M,qEC5BN,IAAI4B,EAAI1J,EAAS,iDAChBoD,EAAwBpD,EAAS,uDACjC4G,EAAqB5G,EAAS,oDAE/B0J,EAAEC,OAAQ,6CAA8CvG,GACxDsG,EAAEC,OAAQ,0CAA2C/C,K","file":"mobile.talk.overlays.js","sourcesContent":["const\n\tmfExtend = require( '../mobile.startup/mfExtend' ),\n\tView = require( '../mobile.startup/View' ),\n\tutil = require( '../mobile.startup/util' );\n\n/**\n * Create a panel with a child\n *\n * @param {jQuery.Object} $child\n * @return {Panel}\n */\nfunction makePanel( $child ) {\n\tconst panel = new View( { className: 'panel' } );\n\tpanel.$el.append( $child );\n\treturn panel;\n}\n\n/**\n * Form for adding a talk section\n *\n * @class AddTopicForm\n * @extends View\n *\n * @param {Object} options Configuration options\n * @param {string} options.licenseMsg license text (HTML strings accepted)\n * @param {Function} options.onTextInput callback for when text changes\n * @param {string} options.subject to prefill form with\n * @param {string} options.body to prefill form with\n * @param {boolean} options.disabled to mark the form inputs as disabled\n */\nfunction AddTopicForm( options ) {\n\tView.call( this,\n\t\tutil.extend( options, {\n\t\t\t// Template properties\n\t\t\ttopicTitlePlaceHolder: mw.msg( 'mobile-frontend-talk-add-overlay-subject-placeholder' ),\n\t\t\ttopicContentPlaceHolder: mw.msg( 'mobile-frontend-talk-add-overlay-content-placeholder' ),\n\n\t\t\t// Additional data\n\t\t\tclassName: 'add-topic-form',\n\t\t\tevents: {\n\t\t\t\t'input .wikitext-editor, input': 'onTextInput',\n\t\t\t\t'change .wikitext-editor, input': 'onTextInput'\n\t\t\t}\n\t\t} )\n\t);\n}\n\nmfExtend( AddTopicForm, View, {\n\t/**\n\t * @inheritdoc\n\t * @memberof AddTopicForm\n\t * @instance\n\t */\n\tpostRender: function () {\n\t\tconst options = this.options,\n\t\t\tdisabled = options.disabled,\n\t\t\t$subject = util.parseHTML( '<input>' ).attr( {\n\t\t\t\tclass: 'mw-ui-input',\n\t\t\t\ttype: 'text',\n\t\t\t\tdisabled,\n\t\t\t\tvalue: options.subject,\n\t\t\t\tplaceholder: options.topicTitlePlaceHolder\n\t\t\t} ),\n\t\t\t$body = util.parseHTML( '<textarea>' ).attr( {\n\t\t\t\tclass: 'wikitext-editor mw-ui-input',\n\t\t\t\tcols: 40,\n\t\t\t\trows: 10,\n\t\t\t\tdisabled,\n\t\t\t\tplaceholder: options.topicContentPlaceHolder\n\t\t\t} ).val( options.body ),\n\t\t\tpanels = [\n\t\t\t\tmakePanel( util.parseHTML( '<p>' ).addClass( 'license' ).html( options.licenseMsg ) ),\n\t\t\t\tmakePanel( $subject ),\n\t\t\t\tmakePanel( $body )\n\t\t\t];\n\n\t\tthis.$el.append(\n\t\t\tpanels.map( function ( panel ) {\n\t\t\t\treturn panel.$el;\n\t\t\t} )\n\t\t);\n\t\tthis.$subject = $subject;\n\t\tthis.$messageBody = $body;\n\t\tView.prototype.postRender.apply( this, arguments );\n\t},\n\t/**\n\t * Handles an input into a textarea and enables or disables the submit button\n\t *\n\t * @memberof AddTopicForm\n\t * @instance\n\t */\n\tonTextInput: function () {\n\t\tif ( this.options.onTextInput ) {\n\t\t\tthis.options.onTextInput( this.$subject.val().trim(), this.$messageBody.val().trim() );\n\t\t}\n\t}\n} );\n\nAddTopicForm.test = {\n\tmakePanel\n};\n\nmodule.exports = AddTopicForm;\n","var\n\tmfExtend = require( '../mobile.startup/mfExtend' ),\n\theaders = require( '../mobile.startup/headers' ),\n\tOverlay = require( '../mobile.startup/Overlay' ),\n\tPageGateway = require( '../mobile.startup/PageGateway' ),\n\tutil = require( '../mobile.startup/util' ),\n\tmakeAddTopicForm = require( './makeAddTopicForm' );\n\n/**\n * Overlay for adding a talk section\n *\n * @class TalkSectionAddOverlay\n * @extends Overlay\n *\n * @param {Object} options Configuration options\n * @param {mw.Api} options.api\n * @param {Object} options.title Title of the talk page being modified\n * @param {string} options.licenseMsg\n * @param {Object} options.currentPageTitle Title of the page before the overlay appears\n * @param {Function} [options.onSaveComplete] executed when a save has completed\n * and talk-discussion-added events\n */\nfunction TalkSectionAddOverlay( options ) {\n\tthis.editorApi = options.api;\n\tthis.pageGateway = new PageGateway( options.api );\n\tOverlay.call( this,\n\t\tutil.extend( options, {\n\t\t\tclassName: 'talk-overlay overlay',\n\t\t\tonBeforeExit: this.onBeforeExit.bind( this ),\n\t\t\tevents: {\n\t\t\t\t'click .save': 'onSaveClick'\n\t\t\t}\n\t\t} )\n\t);\n\tthis.onSaveComplete = options.onSaveComplete;\n\tthis.title = options.title;\n\tthis.currentPageTitle = options.currentPageTitle;\n\t// Variable to indicate, if the overlay will be closed by the save function\n\t// or by the user. If this is false and there is content in the input fields,\n\t// the user will be asked, if he want to abandon his changes before we close\n\t// the Overlay, otherwise the Overlay will be closed without any question.\n\tthis._saveHit = false;\n}\n\nmfExtend( TalkSectionAddOverlay, Overlay, {\n\tpreRender: function () {\n\t\tthis.options.headers = [\n\t\t\t// contentHeader\n\t\t\theaders.saveHeader(\n\t\t\t\tmw.msg( 'mobile-frontend-talk-add-overlay-submit' ),\n\t\t\t\t'initial-header save-header'\n\t\t\t),\n\t\t\theaders.savingHeader( mw.msg( 'mobile-frontend-talk-topic-wait' ) )\n\t\t];\n\t},\n\t/**\n\t * @inheritdoc\n\t * @memberof TalkSectionAddOverlay\n\t * @instance\n\t */\n\tpostRender: function () {\n\t\tOverlay.prototype.postRender.call( this );\n\t\tconst topicForm = makeAddTopicForm( {\n\t\t\tsubject: '',\n\t\t\tbody: '',\n\t\t\tdisabled: false,\n\t\t\tlicenseMsg: this.options.licenseMsg,\n\t\t\tonTextInput: this.onTextInput.bind( this )\n\t\t} );\n\t\tthis.showHidden( '.initial-header' );\n\t\tthis.$confirm = this.$el.find( 'button.save' );\n\t\tthis.$el.find( '.overlay-content' ).append( topicForm.$el );\n\t\tthis.$subject = topicForm.$el.find( 'input' );\n\t\tthis.$ta = topicForm.$el.find( '.wikitext-editor' );\n\t},\n\t/**\n\t * @inheritdoc\n\t * @memberof TalkSectionAddOverlay\n\t * @instance\n\t */\n\tonBeforeExit: function ( exit ) {\n\t\tvar empty,\n\t\t\tconfirmMessage = mw.msg( 'mobile-frontend-editor-cancel-confirm' );\n\n\t\tempty = ( !this.$subject.val() && !this.$ta.val() );\n\t\t// TODO: Replace with an OOUI dialog\n\t\t// eslint-disable-next-line no-alert\n\t\tif ( this._saveHit || empty || window.confirm( confirmMessage ) ) {\n\t\t\texit();\n\t\t}\n\t},\n\t/**\n\t * Handles an input into a textarea and enables or disables the submit button\n\t *\n\t * @memberof TalkSectionAddOverlay\n\t * @param {string} subject\n\t * @param {string} body\n\t * @instance\n\t */\n\tonTextInput: function ( subject, body ) {\n\t\tthis.subject = subject;\n\t\tthis.body = body;\n\n\t\tif ( !this._loggedInput ) {\n\t\t\tmw.track( 'webuiactions_log.click', 'talkpage.input-topic' );\n\t\t\tthis._loggedInput = true;\n\t\t}\n\n\t\tclearTimeout( this.timer );\n\t\tthis.timer = setTimeout( function () {\n\t\t\tif ( !body || !subject ) {\n\t\t\t\tthis.$confirm.prop( 'disabled', true );\n\t\t\t} else {\n\t\t\t\tthis.$confirm.prop( 'disabled', false );\n\t\t\t}\n\t\t}.bind( this ), 250 );\n\t},\n\t/**\n\t * Handles a click on the save button\n\t *\n\t * @memberof TalkSectionAddOverlay\n\t * @instance\n\t */\n\tonSaveClick: function () {\n\t\tmw.track( 'webuiactions_log.click', 'talkpage.publish-topic' );\n\t\tthis.showHidden( '.saving-header' );\n\t\tthis.save().then( function ( status ) {\n\t\t\tif ( status === 'ok' && this.options.onSaveComplete ) {\n\t\t\t\tthis.onSaveComplete();\n\t\t\t}\n\t\t}.bind( this ), function ( error ) {\n\t\t\tvar editMsg = mw.msg( 'mobile-frontend-talk-topic-error' );\n\n\t\t\tthis.$confirm.prop( 'disabled', false );\n\t\t\tswitch ( error.details ) {\n\t\t\t\tcase 'protectedpage':\n\t\t\t\t\teditMsg = mw.msg( 'mobile-frontend-talk-topic-error-protected' );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'noedit':\n\t\t\t\tcase 'blocked':\n\t\t\t\t\teditMsg = mw.msg( 'mobile-frontend-talk-topic-error-permission' );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'spamdetected':\n\t\t\t\t\teditMsg = mw.msg( 'mobile-frontend-talk-topic-error-spam' );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'badtoken':\n\t\t\t\t\teditMsg = mw.msg( 'mobile-frontend-talk-topic-error-badtoken' );\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tmw.notify( editMsg, { type: 'error' } );\n\t\t\tthis.showHidden( '.save-header, .save-panel' );\n\t\t}.bind( this ) );\n\t},\n\t/**\n\t * Save new talk section\n\t *\n\t * @memberof TalkSectionAddOverlay\n\t * @instance\n\t * @return {jQuery.Deferred} Object that either will be resolved with ok parameter\n\t * or rejected with type error.\n\t */\n\tsave: function () {\n\t\tvar heading = this.subject,\n\t\t\td = util.Deferred();\n\n\t\tthis.$ta.removeClass( 'error' );\n\t\tthis.$subject.removeClass( 'error' );\n\n\t\t// propagate, that we save an edit and want to close the Overlay without\n\t\t// any interruption (user questions e.g.)\n\t\tthis._saveHit = true;\n\n\t\tthis.$el.find( '.content' ).empty().addClass( 'loading' );\n\t\t// FIXME: while saving: a spinner would be nice\n\t\t// FIXME: This should be using a gateway e.g. TalkGateway, PageGateway or EditorGateway\n\t\treturn this.editorApi.postWithToken( 'csrf', {\n\t\t\taction: 'edit',\n\t\t\tsection: 'new',\n\t\t\tsectiontitle: heading,\n\t\t\ttitle: this.title,\n\t\t\tsummary: mw.msg( 'newsectionsummary', heading ),\n\t\t\ttext: this.body\n\t\t} ).then( function () {\n\t\t\treturn 'ok';\n\t\t}, function ( msg ) {\n\t\t\t// FIXME: Throw an Error\n\t\t\treturn d.reject( {\n\t\t\t\ttype: 'error',\n\t\t\t\tdetails: msg\n\t\t\t} );\n\t\t} );\n\t}\n} );\n\nmodule.exports = TalkSectionAddOverlay;\n","var\n\tuser = mw.user,\n\ticons = require( '../mobile.startup/icons' ),\n\t$spinner = icons.spinner().$el,\n\tmfExtend = require( '../mobile.startup/mfExtend' ),\n\tOverlay = require( '../mobile.startup/Overlay' ),\n\theader = require( '../mobile.startup/headers' ).header,\n\tutil = require( '../mobile.startup/util' ),\n\tautosign = require( './autosign' ),\n\tButton = require( '../mobile.startup/Button' ),\n\tlazyImageLoader = require( '../mobile.startup/lazyImages/lazyImageLoader' );\n\n/**\n * Callback executed when a save has successfully completed.\n *\n * @callback onSaveComplete\n */\n\n/**\n * Overlay for showing talk page section\n *\n * @class TalkSectionOverlay\n * @extends Overlay\n * @param {Object} options\n * @param {number} options.id Section ID\n * @param {Section} options.section\n * @param {mw.Api} options.api\n * @param {string} options.title\n * @param {string} options.licenseMsg\n * @param {onSaveComplete} [options.onSaveComplete]\n */\nfunction TalkSectionOverlay( options ) {\n\tconst onBeforeExit = this.onBeforeExit.bind( this );\n\n\tthis.editorApi = options.api;\n\tthis.state = {\n\t\t// current value of the textarea\n\t\ttext: ''\n\t};\n\tOverlay.call( this,\n\t\tutil.extend( true, options, {\n\t\t\tclassName: 'talk-overlay overlay',\n\t\t\tonBeforeExit,\n\t\t\tevents: {\n\t\t\t\tclick: function ( ev ) {\n\t\t\t\t\t// If a link has been clicked (that's not the save button)\n\t\t\t\t\t// check that it's okay to exit\n\t\t\t\t\tif ( ev.target.tagName === 'BUTTON' &&\n\t\t\t\t\t\tev.target.className.indexOf( 'save-button' ) === -1\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If the user says okay, do nothing, continuing as if normal link\n\t\t\t\t\t\tonBeforeExit( () => {}, function () {\n\t\t\t\t\t\t\t// if the user says no, prevent the default behaviour\n\t\t\t\t\t\t\tev.preventDefault();\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t'input textarea': 'onInputTextarea',\n\t\t\t\t'click .save-button': 'onSaveClick'\n\t\t\t}\n\t\t} )\n\t);\n}\n\nmfExtend( TalkSectionOverlay, Overlay, {\n\ttemplatePartials: util.extend( {}, Overlay.prototype.templatePartials, {\n\t\tcontent: util.template( `\n<div class=\"content talk-section mw-parser-output\">\n\t{{{section.text}}}\n\t<div class=\"comment\">\n\t\t<div class=\"list-header\">{{reply}}</div>\n\t\t<div class=\"comment-content\">\n\t\t\t<textarea class=\"wikitext-editor\" data-event-name=\"talkpage.focus-comment\"></textarea>\n\t\t\t<p class=\"license\">\n\t\t\t\t{{info}}\n\t\t\t\t{{{licenseMsg}}}\n\t\t\t</p>\n\t\t</div>\n\t</div>\n</div>\n\t\t` )\n\t} ),\n\t/**\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t * @mixes Overlay#defaults\n\t * @property {Object} defaults Default options hash.\n\t * @property {string} defaults.title Title.\n\t * @property {Section} defaults.section that is currently being viewed in overlay.\n\t * @property {string} defaults.reply Reply heading.\n\t * @property {Button} defaults.saveButton\n\t * @property {string} defaults.info Message that informs the user their talk reply will be\n\t * automatically signed.\n\t */\n\tdefaults: util.extend( {}, Overlay.prototype.defaults, {\n\t\tsaveButton: new Button( {\n\t\t\tblock: true,\n\t\t\ttagName: 'button',\n\t\t\tdisabled: true,\n\t\t\tadditionalClassNames: 'save-button',\n\t\t\tprogressive: true,\n\t\t\tlabel: util.saveButtonMessage()\n\t\t} ),\n\t\ttitle: undefined,\n\t\tsection: undefined,\n\t\treply: mw.msg( 'mobile-frontend-talk-reply' ),\n\t\tinfo: mw.msg( 'mobile-frontend-talk-reply-info' )\n\t} ),\n\t/**\n\t * A function to run before exiting the overlay\n\t *\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t * @param {Event} ev\n\t */\n\tonInputTextarea: function ( ev ) {\n\t\tvar value = ev.target.value;\n\t\tthis.state.text = value;\n\t\tif ( value ) {\n\t\t\tthis.$saveButton.prop( 'disabled', false );\n\t\t\tif ( !this.state.loggedInput ) {\n\t\t\t\tmw.track( 'webuiactions_log.click', 'talkpage.input-comment' );\n\t\t\t\tthis.state.loggedInput = true;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.$saveButton.prop( 'disabled', true );\n\t\t}\n\t},\n\t/**\n\t * A function to run before exiting the overlay\n\t *\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t * @param {Function} exit\n\t * @param {Function} cancel\n\t */\n\tonBeforeExit: function ( exit, cancel ) {\n\t\tvar confirmMessage = mw.msg( 'mobile-frontend-editor-cancel-confirm' );\n\n\t\t// eslint-disable-next-line no-alert\n\t\tif ( !this.state.text || window.confirm( confirmMessage ) ) {\n\t\t\texit();\n\t\t} else {\n\t\t\tcancel();\n\t\t}\n\t},\n\t/**\n\t * Accounts for the fact sections are loaded asynchronously and sets the headers\n\t * for the overlay\n\t *\n\t * @inheritdoc\n\t */\n\tpreRender: function () {\n\t\tvar options = this.options;\n\t\tthis.options.headers = [\n\t\t\theader(\n\t\t\t\toptions.section ? options.section.line : '',\n\t\t\t\t[],\n\t\t\t\ticons.back(),\n\t\t\t\t'initial-header'\n\t\t\t)\n\t\t];\n\t},\n\t/**\n\t * Fetches the talk topics of the page specified in options.title\n\t * if options.section is not defined.\n\t *\n\t * @inheritdoc\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t */\n\tpostRender: function () {\n\t\tlazyImageLoader.loadImages(\n\t\t\tlazyImageLoader.queryPlaceholders( this.$el[0] )\n\t\t);\n\t\tOverlay.prototype.postRender.apply( this );\n\t\tthis.$el.find( '.talk-section' ).prepend( $spinner );\n\t\tthis.$saveButton = this.options.saveButton.$el;\n\t\tthis.$el.find( '.comment-content' ).append( this.$saveButton );\n\t\tthis.hideSpinner();\n\t\tthis._enableComments();\n\t},\n\t/**\n\t * Enables comments on the current rendered talk topic\n\t *\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t * @private\n\t */\n\t_enableComments: function () {\n\t\tthis.$commentBox = this.$el.find( '.comment' );\n\t\tif ( user.isAnon() ) {\n\t\t\tthis.$commentBox.remove();\n\t\t} else {\n\t\t\tthis.$textarea = this.$commentBox.find( 'textarea' );\n\t\t}\n\t},\n\t/**\n\t * Handle a click on the save button\n\t *\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t */\n\tonSaveClick: function () {\n\t\tvar val = this.state.text,\n\t\t\tself = this;\n\n\t\tmw.track( 'webuiactions_log.click', 'talkpage.publish-comment' );\n\n\t\tfunction enableSaveButton() {\n\t\t\tself.$saveButton.prop( 'disabled', false );\n\t\t}\n\t\tif ( val ) {\n\t\t\t// show a spinner\n\t\t\tthis.showSpinner();\n\t\t\tthis.$saveButton.prop( 'disabled', true );\n\t\t\t// sign and add newline to front\n\t\t\tval = '\\n\\n' + autosign( val );\n\t\t\t// FIXME: This should be using a gateway\n\t\t\t// e.g. TalkGateway, PageGateway or EditorGateway\n\t\t\tthis.editorApi.postWithToken( 'csrf', {\n\t\t\t\taction: 'edit',\n\t\t\t\ttitle: this.options.title,\n\t\t\t\tsection: this.options.id,\n\t\t\t\tappendtext: val,\n\t\t\t\tredirect: true\n\t\t\t} ).then( function () {\n\t\t\t\tif ( self.options.onSaveComplete ) {\n\t\t\t\t\tself.options.onSaveComplete();\n\t\t\t\t}\n\t\t\t}, function ( data, response ) {\n\t\t\t\t// FIXME: Code sharing with SourceEditorOverlay?\n\t\t\t\tvar msg,\n\t\t\t\t\t// When save failed with one of these error codes, the returned\n\t\t\t\t\t// message in response.error.info will be forwarded to the user.\n\t\t\t\t\t// FIXME: This shouldn't be needed when info texts are all localized.\n\t\t\t\t\twhitelistedErrorInfo = [\n\t\t\t\t\t\t'readonly',\n\t\t\t\t\t\t'blocked',\n\t\t\t\t\t\t'autoblocked'\n\t\t\t\t\t];\n\n\t\t\t\tif (\n\t\t\t\t\tresponse.error &&\n\t\t\t\t\twhitelistedErrorInfo.indexOf( response.error.code ) > -1\n\t\t\t\t) {\n\t\t\t\t\tmsg = response.error.info;\n\t\t\t\t} else {\n\t\t\t\t\tmsg = mw.msg( 'mobile-frontend-editor-error' );\n\t\t\t\t}\n\n\t\t\t\tself.hideSpinner();\n\t\t\t\tmw.notify( msg, { type: 'error' } );\n\t\t\t\tenableSaveButton();\n\t\t\t} );\n\t\t}\n\t}\n} );\n\nmodule.exports = TalkSectionOverlay;\n","/**\n * Autosign a block of text if necessary\n *\n * @instance\n * @param {string} text\n * @return {string} text with an autosign (\"~~~~\") if necessary\n */\nfunction autosign( text ) {\n\treturn /~{3,5}/.test( text ) ? text : text + ' ~~~~';\n}\n\nmodule.exports = autosign;\n","const AddTopicForm = require( './AddTopicForm' ),\n\tautosign = require( './autosign' );\n\n/**\n * Backwards compatible method for obtaining a TalkOverlay\n * used by Minerva until it updates itself.\n *\n * @param {Object} options Configuration options\n * @param {string} options.licenseMsg license text (HTML strings accepted)\n * @param {Function} [options.onTextInput] callback for when text changes\n * @param {string} options.subject to prefill form with\n * @param {string} options.body to prefill form with\n * @param {boolean} options.disabled to mark the form inputs as disabled\n * @return {AddTopicForm}\n */\nfunction makeAddTopicForm( { licenseMsg, onTextInput, subject, body, disabled } ) {\n\tconst form = new AddTopicForm( {\n\t\tlicenseMsg,\n\t\tdisabled,\n\t\tsubject,\n\t\tbody,\n\t\tonTextInput: onTextInput ? function ( sub, bd ) {\n\t\t\t// if the body has content, autosign it!\n\t\t\tif ( bd ) {\n\t\t\t\tbd = autosign( bd );\n\t\t\t}\n\t\t\t// propagate up the autosigned content\n\t\t\tonTextInput.call( this, sub, bd );\n\t\t} : undefined\n\t} );\n\treturn form;\n}\n\nmodule.exports = makeAddTopicForm;\n","var m = require( './../mobile.startup/moduleLoaderSingleton' ),\n\tTalkSectionAddOverlay = require( './TalkSectionAddOverlay' ),\n\tTalkSectionOverlay = require( './TalkSectionOverlay' );\n\nm.define( 'mobile.talk.overlays/TalkSectionAddOverlay', TalkSectionAddOverlay );\nm.define( 'mobile.talk.overlays/TalkSectionOverlay', TalkSectionOverlay );\n"],"sourceRoot":""}