webpackJsonp(["blob"],{"./blob/blob_file_dropzone.js":function(e,t,n){"use strict";(function(e){function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){n?(e.disable(),t.removeClass(l.b)):(e.enable(),t.addClass(l.b))}var r=n("../../../node_modules/dropzone/dist/dropzone.js"),a=n.n(r),l=(n("./lib/utils/url_utility.js"),n("./lib/utils/constants.js")),s=n("./lib/utils/csrf.js"),c=function t(n,r){o(this,t);var c=n.find(".dropzone"),u=n.find("#submit-all"),f=u.find(".js-loading-icon"),d=n.find(".dz-message");a.a.autoDiscover=!1;var p=c.dropzone({autoDiscover:!1,autoProcessQueue:!1,url:n.attr("action"),method:r,clickable:!0,uploadMultiple:!1,paramName:"file",maxFilesize:gon.max_file_size||10,parallelUploads:1,maxFiles:1,addRemoveLinks:!0,previewsContainer:".dropzone-previews",headers:s.a.headers,init:function(){this.on("addedfile",function(){i(u,f,!1),d.addClass(l.b),e(".dropzone-alerts").html("").hide()}),this.on("removedfile",function(){i(u,f,!1),d.removeClass(l.b)}),this.on("success",function(t,n){e("#modal-upload-blob").modal("hide"),window.gl.utils.visitUrl(n.filePath)}),this.on("maxfilesexceeded",function(e){d.addClass(l.b),this.removeFile(e)}),this.on("sending",function(e,t,o){o.append("branch_name",n.find(".js-branch-name").val()),o.append("create_merge_request",n.find(".js-create-merge-request").val()),o.append("commit_message",n.find(".js-commit-message").val())})},error:function(t,n){var o=e("<div/>").html(n).text();e(".dropzone-alerts").html('Error uploading file: "'+o+'"').show(),this.removeFile(t)}});u.on("click",function(e){return e.preventDefault(),e.stopPropagation(),0===p[0].dropzone.getQueuedFiles().length?(alert("Please select a file"),!1):(i(u,f,!0),p[0].dropzone.processQueue(),!1)})};t.a=c}).call(t,n("../../../node_modules/jquery/dist/jquery.js"))},"./blob/file_template_mediator.js":function(e,t,n){"use strict";(function(e){function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n("./flash.js"),r=n("./blob/template_selectors/type_selector.js"),a=n("./blob/template_selectors/ci_yaml_selector.js"),l=n("./blob/template_selectors/dockerfile_selector.js"),s=n("./blob/template_selectors/gitignore_selector.js"),c=n("./blob/template_selectors/license_selector.js"),u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),f=function(){function t(e){var n=e.editor,i=e.currentAction;o(this,t),this.editor=n,this.currentAction=i,this.initTemplateSelectors(),this.initTemplateTypeSelector(),this.initDomElements(),this.initDropdowns(),this.initPageEvents()}return u(t,[{key:"initTemplateSelectors",value:function(){var e=this;this.templateSelectors=[s.a,a.a,l.a,c.a].map(function(t){return new t({mediator:e})})}},{key:"initTemplateTypeSelector",value:function(){this.typeSelector=new r.a({mediator:this,dropdownData:this.templateSelectors.map(function(e){var t=e.config;return{name:t.name,key:t.key}})})}},{key:"initDomElements",value:function(){var t=e(".template-selectors-menu"),n=t.find(".template-selectors-undo-menu"),o=e(".file-editor");this.$templatesMenu=t,this.$undoMenu=n,this.$undoBtn=n.find("button"),this.$templateSelectors=t.find(".template-selector-dropdowns-wrap"),this.$filenameInput=o.find(".js-file-path-name-input"),this.$fileContent=o.find("#file-content"),this.$commitForm=o.find("form"),this.$navLinks=o.find(".nav-links")}},{key:"initDropdowns",value:function(){"create"===this.currentAction?this.typeSelector.show():this.hideTemplateSelectorMenu(),this.displayMatchedTemplateSelector()}},{key:"initPageEvents",value:function(){this.listenForFilenameInput(),this.prepFileContentForSubmit(),this.listenForPreviewMode()}},{key:"listenForFilenameInput",value:function(){var e=this;this.$filenameInput.on("keyup blur",function(){e.displayMatchedTemplateSelector()})}},{key:"prepFileContentForSubmit",value:function(){var e=this;this.$commitForm.submit(function(){e.$fileContent.val(e.editor.getValue())})}},{key:"listenForPreviewMode",value:function(){var e=this;this.$navLinks.on("click","a",function(t){var n=t.target.href.split("#"),o=n[1];"preview"===o?e.hideTemplateSelectorMenu():"editor"===o&&e.showTemplateSelectorMenu()})}},{key:"selectTemplateType",value:function(e,t){t&&t.preventDefault(),this.templateSelectors.forEach(function(t){t.config.key===e.key?t.show():t.hide()}),this.typeSelector.setToggleText(e.name),this.cacheToggleText()}},{key:"selectTemplateTypeOptions",value:function(e){this.selectTemplateType(e.selectedObj,e.e)}},{key:"selectTemplateFile",value:function(e,t,n){var o=this;e.renderLoading(),this.destroyUndoMenu(),this.fetchFileTemplate(e.config.endpoint,t,n).then(function(t){o.showUndoMenu(),o.setEditorContent(t),o.setFilename(e.config.name),e.renderLoaded()}).catch(function(e){return new i.a("An error occurred while fetching the template: "+e)})}},{key:"displayMatchedTemplateSelector",value:function(){var e=this,t=this.getFilename();this.templateSelectors.forEach(function(n){n.config.pattern.test(t)&&(e.typeSelector.show(),e.selectTemplateType(n.config),e.showTemplateSelectorMenu())})}},{key:"fetchFileTemplate",value:function(e,t,n){return new Promise(function(o){var i=function(e){return o(e)};n?e(t,n,i):e(t,i)})}},{key:"setEditorContent",value:function(e){if(e||""===e){var t=e.content||e;this.editor.setValue(t,1),this.editor.focus(),this.editor.navigateFileStart()}}},{key:"findTemplateSelectorByKey",value:function(e){return this.templateSelectors.find(function(t){return t.config.key===e})}},{key:"showUndoMenu",value:function(){var e=this;this.$undoMenu.removeClass("hidden"),this.$undoBtn.on("click",function(){e.restoreFromCache(),e.destroyUndoMenu()})}},{key:"destroyUndoMenu",value:function(){this.cacheFileContents(),this.cacheToggleText(),this.$undoMenu.addClass("hidden"),this.$undoBtn.off("click")}},{key:"hideTemplateSelectorMenu",value:function(){this.$templatesMenu.hide()}},{key:"showTemplateSelectorMenu",value:function(){this.$templatesMenu.show()}},{key:"cacheToggleText",value:function(){this.cachedToggleText=this.getTemplateSelectorToggleText()}},{key:"cacheFileContents",value:function(){this.cachedContent=this.editor.getValue(),this.cachedFilename=this.getFilename()}},{key:"restoreFromCache",value:function(){this.setEditorContent(this.cachedContent),this.setFilename(this.cachedFilename),this.setTemplateSelectorToggleText()}},{key:"getTemplateSelectorToggleText",value:function(){return this.$templateSelectors.find(".js-template-selector-wrap:visible .dropdown-toggle-text").text()}},{key:"setTemplateSelectorToggleText",value:function(){return this.$templateSelectors.find(".js-template-selector-wrap:visible .dropdown-toggle-text").text(this.cachedToggleText)}},{key:"getTypeSelectorToggleText",value:function(){return this.typeSelector.getToggleText()}},{key:"getFilename",value:function(){return this.$filenameInput.val()}},{key:"setFilename",value:function(e){this.$filenameInput.val(e)}},{key:"getSelected",value:function(){return this.templateSelectors.find(function(e){return e.selected})}}]),t}();t.a=f}).call(t,n("../../../node_modules/jquery/dist/jquery.js"))},"./blob/file_template_selector.js":function(e,t,n){"use strict";(function(e){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=function(){function t(e){n(this,t),this.mediator=e,this.$dropdown=null,this.$wrapper=null}return o(t,[{key:"init",value:function(){var t=this.config;this.$dropdown=e(t.dropdown),this.$wrapper=e(t.wrapper),this.$loadingIcon=this.$wrapper.find(".fa-chevron-down"),this.$dropdownToggleText=this.$wrapper.find(".dropdown-toggle-text"),this.initDropdown()}},{key:"show",value:function(){null===this.$dropdown&&this.init(),this.$wrapper.removeClass("hidden")}},{key:"hide",value:function(){null!==this.$dropdown&&this.$wrapper.addClass("hidden")}},{key:"getToggleText",value:function(){return this.$dropdownToggleText.text()}},{key:"setToggleText",value:function(e){this.$dropdownToggleText.text(e)}},{key:"renderLoading",value:function(){this.$loadingIcon.addClass("fa-spinner fa-spin").removeClass("fa-chevron-down")}},{key:"renderLoaded",value:function(){this.$loadingIcon.addClass("fa-chevron-down").removeClass("fa-spinner fa-spin")}},{key:"reportSelection",value:function(e){var t=e.query,n=e.e,o=e.data;return n.preventDefault(),this.mediator.selectTemplateFile(this,t,o)}},{key:"reportSelectionName",value:function(e){var t=e;t.query=e.selectedObj.name,this.reportSelection(t)}}]),t}();t.a=i}).call(t,n("../../../node_modules/jquery/dist/jquery.js"))},"./blob/template_selectors/ci_yaml_selector.js":function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n("./api.js"),l=n("./blob/file_template_selector.js"),s=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(e){function t(e){var n=e.mediator;o(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n));return r.config={key:"gitlab-ci-yaml",name:".gitlab-ci.yml",pattern:/(.gitlab-ci.yml)/,endpoint:a.a.gitlabCiYml,dropdown:".js-gitlab-ci-yml-selector",wrapper:".js-gitlab-ci-yml-selector-wrap"},r}return r(t,e),s(t,[{key:"initDropdown",value:function(){var e=this;this.$dropdown.glDropdown({data:this.$dropdown.data("data"),filterable:!0,selectable:!0,toggleLabel:function(e){return e.name},search:{fields:["name"]},clicked:function(t){return e.reportSelectionName(t)},text:function(e){return e.name}})}}]),t}(l.a);t.a=c},"./blob/template_selectors/dockerfile_selector.js":function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n("./api.js"),l=n("./blob/file_template_selector.js"),s=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(e){function t(e){var n=e.mediator;o(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n));return r.config={key:"dockerfile",name:"Dockerfile",pattern:/(Dockerfile)/,endpoint:a.a.dockerfileYml,dropdown:".js-dockerfile-selector",wrapper:".js-dockerfile-selector-wrap"},r}return r(t,e),s(t,[{key:"initDropdown",value:function(){var e=this;this.$dropdown.glDropdown({data:this.$dropdown.data("data"),filterable:!0,selectable:!0,toggleLabel:function(e){return e.name},search:{fields:["name"]},clicked:function(t){return e.reportSelectionName(t)},text:function(e){return e.name}})}}]),t}(l.a);t.a=c},"./blob/template_selectors/gitignore_selector.js":function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n("./api.js"),l=n("./blob/file_template_selector.js"),s=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(e){function t(e){var n=e.mediator;o(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n));return r.config={key:"gitignore",name:".gitignore",pattern:/(.gitignore)/,endpoint:a.a.gitignoreText,dropdown:".js-gitignore-selector",wrapper:".js-gitignore-selector-wrap"},r}return r(t,e),s(t,[{key:"initDropdown",value:function(){var e=this;this.$dropdown.glDropdown({data:this.$dropdown.data("data"),filterable:!0,selectable:!0,toggleLabel:function(e){return e.name},search:{fields:["name"]},clicked:function(t){return e.reportSelectionName(t)},text:function(e){return e.name}})}}]),t}(l.a);t.a=c},"./blob/template_selectors/license_selector.js":function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n("./api.js"),l=n("./blob/file_template_selector.js"),s=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(e){function t(e){var n=e.mediator;o(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n));return r.config={key:"license",name:"LICENSE",pattern:/^(.+\/)?(licen[sc]e|copying)($|\.)/i,endpoint:a.a.licenseText,dropdown:".js-license-selector",wrapper:".js-license-selector-wrap"},r}return r(t,e),s(t,[{key:"initDropdown",value:function(){var e=this;this.$dropdown.glDropdown({data:this.$dropdown.data("data"),filterable:!0,selectable:!0,toggleLabel:function(e){return e.name},search:{fields:["name"]},clicked:function(t){var n=t.e,o=t.$el,i=t.selectedObj,r={project:e.$dropdown.data("project"),fullname:e.$dropdown.data("fullname")};e.reportSelection({query:i.id,el:o,e:n,data:r})},text:function(e){return e.name}})}}]),t}(l.a);t.a=c},"./blob/template_selectors/type_selector.js":function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n("./blob/file_template_selector.js"),l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),s=function(e){function t(e){var n=e.mediator,r=e.dropdownData;o(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n));return a.mediator=n,a.config={dropdown:".js-template-type-selector",wrapper:".js-template-type-selector-wrap",dropdownData:r},a}return r(t,e),l(t,[{key:"initDropdown",value:function(){var e=this;this.$dropdown.glDropdown({data:this.config.dropdownData,filterable:!1,selectable:!0,toggleLabel:function(e){return e.name},clicked:function(t){return e.mediator.selectTemplateTypeOptions(t)},text:function(e){return e.name}})}}]),t}(a.a);t.a=s},"./blob_edit/blob_bundle.js":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){var t=n("./blob_edit/edit_blob.js"),o=n("./blob/blob_file_dropzone.js");e(function(){var n=e(".js-edit-blob-form"),i=e(".js-upload-blob-form"),r=e(".js-delete-blob-form");if(n.length){var a=n.data("relative-url-root"),l=n.data("assets-prefix"),s=n.data("blob-language"),c=e(".js-file-title").data("current-action");new t.a(""+a+l,s,c),new NewCommitForm(n)}if(i.length){var u=i.data("method");new o.a(i,u),new NewCommitForm(i),window.gl.utils.disableButtonIfEmptyField(i.find(".js-commit-message"),".btn-upload-file")}r.length&&new NewCommitForm(r)})}.call(t,n("../../../node_modules/jquery/dist/jquery.js"))},"./blob_edit/edit_blob.js":function(e,t,n){"use strict";(function(e){function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n("./blob/file_template_mediator.js"),r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),a=function(){function t(e,n,i){o(this,t),this.configureAceEditor(n,e),this.initModePanesAndLinks(),this.initSoftWrap(),this.initFileSelectors(i)}return r(t,[{key:"configureAceEditor",value:function(e,t){ace.config.set("modePath",t+"/ace"),ace.config.loadModule("ace/ext/searchbox"),this.editor=ace.edit("editor"),this.editor.$blockScrolling=1/0,this.editor.focus(),e&&this.editor.getSession().setMode("ace/mode/"+e)}},{key:"initFileSelectors",value:function(e){this.fileTemplateMediator=new i.a({currentAction:e,editor:this.editor})}},{key:"initModePanesAndLinks",value:function(){var t=this;this.$editModePanes=e(".js-edit-mode-pane"),this.$editModeLinks=e(".js-edit-mode a"),this.$editModeLinks.on("click",function(e){return t.editModeLinkClickHandler(e)})}},{key:"editModeLinkClickHandler",value:function(t){t.preventDefault();var n=e(t.target),o=n.attr("href"),i=this.$editModePanes.filter(o);return this.$editModeLinks.parent().removeClass("active hover"),n.parent().addClass("active hover"),this.$editModePanes.hide(),i.fadeIn(200),"#preview"===o?(this.$toggleButton.hide(),e.post(n.data("preview-url"),{content:this.editor.getValue()},function(e){return i.empty().append(e),i.renderGFM()})):(this.$toggleButton.show(),this.editor.focus())}},{key:"initSoftWrap",value:function(){var t=this;this.isSoftWrapped=!1,this.$toggleButton=e(".soft-wrap-toggle"),this.$toggleButton.on("click",function(){return t.toggleSoftWrap()})}},{key:"toggleSoftWrap",value:function(){this.isSoftWrapped=!this.isSoftWrapped,this.$toggleButton.toggleClass("soft-wrap-active",this.isSoftWrapped),this.editor.getSession().setUseWrapMode(this.isSoftWrapped)}}]),t}();t.a=a}).call(t,n("../../../node_modules/jquery/dist/jquery.js"))},"./lib/utils/constants.js":function(e,t,n){"use strict";n.d(t,"a",function(){return o}),n.d(t,"b",function(){return i});var o=1024,i="hidden"}},["./blob_edit/blob_bundle.js"]); //# sourceMappingURL=blob.6517a7b1816669c70165.bundle.js.map