{"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","webpack://mfModules.[name]/./src/mobile.talk.overlays/talkBoard.js"],"names":["mfExtend","require","View","Panel","util","makePanel","$child","panel","$el","append","AddTopicForm","options","call","this","extend","topicTitlePlaceHolder","mw","msg","topicContentPlaceHolder","className","events","input .wikitext-editor, input","change .wikitext-editor, input","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","Overlay","PageGateway","makeAddTopicForm","toast","Icon","TalkSectionAddOverlay","editorApi","api","pageGateway","click .confirm-save","title","currentPageTitle","eventBus","_saveHit","defaults","cancelMsg","editingMsg","waitMsg","waitIcon","name","additionalClassNames","toHtmlString","template","get","templatePartials","contentHeader","saveHeader","topicForm","bind","showHidden","$confirm","find","$ta","hide","empty","confirmMessage","window","confirm","clearTimeout","timer","setTimeout","prop","onSaveClick","isOnTalkPage","save","then","status","emit","invalidatePage","show","error","editMsg","details","heading","d","Deferred","removeClass","postWithToken","action","section","sectiontitle","summary","text","reject","user","popup","autosign","Page","Button","TalkSectionOverlay","focus textarea","click .save-button","header","content","saveButton","block","progressive","label","config","undefined","reply","info","$saveButton","hideSpinner","_enableComments","renderFromApi","$commentBox","isAnon","remove","$textarea","self","getPage","pageData","page","getSection","id","render","onFocusTextarea","enableSaveButton","showSpinner","appendtext","redirect","data","response","indexOf","code","_ref","m","talkBoard","overlay","deprecate","define","sections","board","explanation","length","line"],"mappings":"gMAAA,IACCA,EAAWC,EAAS,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wCAkBV,OAhBAoJ,EAAQ,IAAInK,GACXiB,UAAW,gBAENV,QACLL,EAAKsB,UAAW,8BAA+BwF,KAAMoD,GAErDlK,EAAKsB,UAAW,iCAAkCjB,OACjD2J,EAAS1H,IAAK,SAAWqE,GACxB,OAAO3G,EAAKsB,UAAW,QAASjB,OAC/BL,EAAKsB,UAAW,OACdC,KAAM,OAAQ,UAAYoF,EAAQoC,IAClCjC,KAAMH,EAAQyD,YAKbH","file":"mobile.talk.overlays.js","sourcesContent":["const\n\tmfExtend = require( '../mobile.startup/mfExtend' ),\n\tView = require( '../mobile.startup/View' ),\n\tPanel = require( '../mobile.startup/Panel' ),\n\tutil = require( '../mobile.startup/util' );\n\n/**\n * Create a panel with a child\n * @param {jQuery.Object} $child\n * @return {Panel}\n */\nfunction makePanel( $child ) {\n\tconst panel = new Panel();\n\tpanel.$el.append( $child );\n\treturn panel;\n}\n\n/**\n * Form for adding a talk section\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 * @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\tOverlay = require( '../mobile.startup/Overlay' ),\n\tPageGateway = require( '../mobile.startup/PageGateway' ),\n\tutil = require( '../mobile.startup/util' ),\n\tmakeAddTopicForm = require( './makeAddTopicForm' ),\n\ttoast = require( '../mobile.startup/toast' ),\n\tIcon = require( '../mobile.startup/Icon' );\n\n/**\n * Overlay for adding a talk section\n * @class TalkSectionAddOverlay\n * @extends Overlay\n * @uses Toast\n *\n * @param {Object} options Configuration options\n * @param {Object} options.title Title of the talk page being modified\n * @param {Object} options.currentPageTitle Title of the page before the overlay appears\n * @param {OO.EventEmitter} options.eventBus Object used to emit talk-added-wo-overlay\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\tevents: {\n\t\t\t\t'click .confirm-save': 'onSaveClick'\n\t\t\t}\n\t\t} )\n\t);\n\tthis.title = options.title;\n\tthis.currentPageTitle = options.currentPageTitle;\n\tthis.eventBus = options.eventBus;\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\t/**\n\t * @memberof TalkSectionAddOverlay\n\t * @instance\n\t * @mixes Overlay#defaults\n\t * @property {Object} defaults Default options hash.\n\t * @property {string} defaults.cancelMsg Caption for cancel button on edit form.\n\t * @property {string} defaults.topicTitlePlaceHolder Placeholder text to prompt user to add\n\t * a talk page topic subject.\n\t * @property {string} defaults.topicContentPlaceHolder Placeholder text to prompt user\n\t *  to add content to talk page content.\n\t * @property {string} defaults.editingMsg Label for button which\n\t *  submits a new talk page topic.\n\t */\n\tdefaults: util.extend( {}, Overlay.prototype.defaults, {\n\t\tcancelMsg: mw.msg( 'mobile-frontend-editor-cancel' ),\n\t\teditingMsg: mw.msg( 'mobile-frontend-talk-add-overlay-submit' ),\n\t\twaitMsg: mw.msg( 'mobile-frontend-talk-topic-wait' ),\n\t\t// icons.spinner can't be used, .loading has a fixed height, which breaks overlay-header\n\t\twaitIcon: new Icon( {\n\t\t\tname: 'spinner',\n\t\t\tadditionalClassNames: 'savespinner loading'\n\t\t} ).toHtmlString()\n\t} ),\n\t/**\n\t * @inheritdoc\n\t * @memberof TalkSectionAddOverlay\n\t * @instance\n\t */\n\ttemplate: mw.template.get( 'mobile.talk.overlays', 'SectionAddOverlay.hogan' ),\n\t/**\n\t * @inheritdoc\n\t * @memberof TalkSectionAddOverlay\n\t * @instance\n\t */\n\ttemplatePartials: util.extend( {}, Overlay.prototype.templatePartials, {\n\t\tcontentHeader: mw.template.get( 'mobile.talk.overlays', 'SectionAddOverlay/contentHeader.hogan' ),\n\t\tsaveHeader: mw.template.get( 'mobile.editor.overlay', 'saveHeader.hogan' )\n\t} ),\n\t/**\n\t * @inheritdoc\n\t * @memberof TalkSectionAddOverlay\n\t * @instance\n\t */\n\tpostRender: function () {\n\t\tlet topicForm;\n\t\tOverlay.prototype.postRender.call( this );\n\t\ttopicForm = 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.confirm-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\thide: function () {\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\tif ( this._saveHit || empty || window.confirm( confirmMessage ) ) {\n\t\t\treturn Overlay.prototype.hide.apply( this, arguments );\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t},\n\t/**\n\t * Handles an input into a textarea and enables or disables the submit button\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\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 * @memberof TalkSectionAddOverlay\n\t * @instance\n\t */\n\tonSaveClick: function () {\n\t\tvar isOnTalkPage = this.title === this.currentPageTitle;\n\n\t\tthis.showHidden( '.saving-header' );\n\t\tthis.save().then( function ( status ) {\n\t\t\tif ( status === 'ok' ) {\n\t\t\t\tif ( isOnTalkPage ) {\n\t\t\t\t\tthis.eventBus.emit( 'talk-added-wo-overlay' );\n\t\t\t\t} else {\n\t\t\t\t\tthis.pageGateway.invalidatePage( this.title );\n\t\t\t\t\ttoast.show( mw.msg( 'mobile-frontend-talk-topic-feedback' ) );\n\t\t\t\t\tthis.eventBus.emit( 'talk-discussion-added' );\n\t\t\t\t\tthis.hide();\n\t\t\t\t}\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\tdefault:\n\t\t\t\t\teditMsg = mw.msg( 'mobile-frontend-talk-topic-error' );\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\ttoast.show( 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 * @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\tmfExtend = require( '../mobile.startup/mfExtend' ),\n\tPageGateway = require( '../mobile.startup/PageGateway' ),\n\tOverlay = require( '../mobile.startup/Overlay' ),\n\tutil = require( '../mobile.startup/util' ),\n\tpopup = require( '../mobile.startup/toast' ),\n\tautosign = require( './autosign' ),\n\tPage = require( '../mobile.startup/Page' ),\n\tButton = require( '../mobile.startup/Button' );\n\n/**\n * Overlay for showing talk page section\n * @class TalkSectionOverlay\n * @extends Overlay\n * @uses PageGateway\n * @uses Page\n * @uses Button\n * @uses Toast\n * @param {Object} options\n */\nfunction TalkSectionOverlay( options ) {\n\tthis.editorApi = options.api;\n\tthis.pageGateway = new PageGateway( options.api );\n\tOverlay.call( this,\n\t\tutil.extend( true, options, {\n\t\t\tclassName: 'talk-overlay overlay',\n\t\t\tevents: {\n\t\t\t\t'focus textarea': 'onFocusTextarea',\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\theader: mw.template.get( 'mobile.talk.overlays', 'Section/header.hogan' ),\n\t\tcontent: mw.template.get( 'mobile.talk.overlays', 'Section/content.hogan' )\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 {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\tadditionalClassNames: 'save-button',\n\t\t\tprogressive: true,\n\t\t\tlabel: mw.config.get( 'wgEditSubmitButtonLabelPublish' ) ?\n\t\t\t\tmw.msg( 'mobile-frontend-editor-publish' ) : mw.msg( 'mobile-frontend-editor-save' )\n\t\t} ).options,\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 * Fetches the talk topics of the page specified in options.title\n\t * if options.section is not defined.\n\t * @inheritdoc\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t */\n\tpostRender: function () {\n\t\tOverlay.prototype.postRender.apply( this );\n\t\tthis.$saveButton = this.$el.find( '.save-button' );\n\t\tif ( !this.options.section ) {\n\t\t\tthis.renderFromApi( this.options );\n\t\t} else {\n\t\t\tthis.hideSpinner();\n\t\t\tthis._enableComments();\n\t\t}\n\t},\n\t/**\n\t * Enables comments on the current rendered talk topic\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 * Loads the discussion from api and add it to the Overlay\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t * @param {Object} options Render options\n\t */\n\trenderFromApi: function ( options ) {\n\t\tvar self = this;\n\n\t\tthis.pageGateway.getPage( options.title ).then( function ( pageData ) {\n\t\t\tvar page = new Page( pageData );\n\t\t\toptions.section = page.getSection( options.id );\n\t\t\tself.render( options );\n\t\t\tself.hideSpinner();\n\t\t} );\n\t},\n\t/**\n\t * Handler for focus of textarea\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t */\n\tonFocusTextarea: function () {\n\t\tthis.$textarea.removeClass( 'error' );\n\t},\n\t/**\n\t * Handle a click on the save button\n\t * @memberof TalkSectionOverlay\n\t * @instance\n\t */\n\tonSaveClick: function () {\n\t\tvar val = this.$textarea.val(),\n\t\t\tself = this;\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\tpopup.show( mw.msg( 'mobile-frontend-talk-reply-success' ) );\n\t\t\t\t// invalidate the cache\n\t\t\t\tself.pageGateway.invalidatePage( self.options.title );\n\n\t\t\t\tself.renderFromApi( self.options );\n\n\t\t\t\tenableSaveButton();\n\t\t\t}, function ( data, response ) {\n\t\t\t\t// FIXME: Code sharing with EditorOverlay?\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\tpopup.show( msg, 'toast error' );\n\n\t\t\t\tenableSaveButton();\n\t\t\t} );\n\t\t} else {\n\t\t\tthis.$textarea.addClass( 'error' );\n\t\t}\n\t}\n} );\n\nmodule.exports = TalkSectionOverlay;\n","/**\n * Autosign a block of text if necessary\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 * @deprecated\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 ( subject, body ) {\n\t\t\t// if the body has content, autosign it!\n\t\t\tif ( body ) {\n\t\t\t\tbody = autosign( body );\n\t\t\t}\n\t\t\t// propagate up the autosigned content\n\t\t\tonTextInput.call( this, subject, body );\n\t\t} : undefined\n\t} );\n\treturn form;\n}\n\nmodule.exports = makeAddTopicForm;\n","var m = require( './../mobile.startup/moduleLoaderSingleton' ),\n\ttalkBoard = require( './talkBoard' ),\n\toverlay = require( '../mobile.startup/talk/overlay' ),\n\tPageGateway = require( '../mobile.startup/PageGateway' ),\n\tTalkSectionAddOverlay = require( './TalkSectionAddOverlay' ),\n\tTalkSectionOverlay = require( './TalkSectionOverlay' );\n\n/**\n * Backwards compatible method for obtaining a TalkOverlay\n * used by Minerva until it updates itself.\n * @deprecated\n * @param {Object} options\n * @return {Overlay}\n */\nfunction talkOverlay( options ) {\n\treturn overlay( options.title, new PageGateway( options.api ) );\n}\n\nm.deprecate( 'mobile.talk.overlays/talkOverlay', talkOverlay,\n\t'Use `mobile.startup` (talk.overlay)' );\nm.define( 'mobile.talk.overlays/talkBoard', talkBoard );\nm.define( 'mobile.talk.overlays/TalkSectionAddOverlay', TalkSectionAddOverlay );\nm.define( 'mobile.talk.overlays/TalkSectionOverlay', TalkSectionOverlay ); // resource-modules-disable-line\n","var util = require( '../mobile.startup/util' ),\n\tView = require( '../mobile.startup/View' );\n\n/**\n * A board of talk topics\n * @param {Section[]} sections\n * @return {View}\n */\nfunction talkBoard( sections ) {\n\tvar board,\n\t\texplanation = sections.length > 0 ?\n\t\t\tmw.msg( 'mobile-frontend-talk-explained' ) :\n\t\t\tmw.msg( 'mobile-frontend-talk-explained-empty' );\n\n\tboard = new View( {\n\t\tclassName: 'talk-board'\n\t} );\n\tboard.append( [\n\t\tutil.parseHTML( '<p class=\"content-header\">' ).text( explanation ),\n\t\t// FIXME: Substitute with a TopicTitleList (T173534)\n\t\tutil.parseHTML( '<ul class=\"topic-title-list\">' ).append(\n\t\t\tsections.map( function ( section ) {\n\t\t\t\treturn util.parseHTML( '<li>' ).append(\n\t\t\t\t\tutil.parseHTML( '<a>' )\n\t\t\t\t\t\t.attr( 'href', '#/talk/' + section.id )\n\t\t\t\t\t\t.text( section.line )\n\t\t\t\t);\n\t\t\t} )\n\t\t)\n\t] );\n\treturn board;\n}\n\nmodule.exports = talkBoard;\n"],"sourceRoot":""}