text: var resourceLocator={CONTENT_REPOSITORY:"CONTENT_REPOSITORY",LOCAL:"LOCAL",NONE:"NONE",FILE_SYSTEM:"FILE_SYSTEM",LOCATE_EVENT:"resource:locate",ALLOWED_FILE_RESOURCE_EXTENSIONS:["css","ttf","jpg","jpeg","gif","bmp","png","jar","jrxml","properties","jrtx","xml","agxml","docx","doc","ppt","pptx","xls","xlsx","ods","odt","odp","pdf","rtf","html"],initialize:function(e){var t=function(e){return _.isObject(e)?e:$(e)};this.resourceUri=t(e.resourceInput),this.browseButton=t(e.browseButton),this.filePath=t(e.fileUploadInput),this.fakeFilePath=t(e.fakeFileUploadInput),this.fakeFileInput=t(e.fakeFileUploadInputText),this.newResourceLink=t(e.newResourceLink);try{this._initFileSelector(e)}catch(i){}finally{this._initEvents(e)}return this},_initEvents:function(e){jQuery(document).on("click","#CONTENT_REPOSITORY, #FILE_SYSTEM, #NONE, #LOCAL",this._clickHandler),"fileResourceTreeDataProvider"===e.providerId&&(jQuery("#next").on("click",resourceLocator._nextClickHandler),jQuery("#filePath").on("change",resourceLocator._uploadChangeHandler))},_nextClickHandler:function(e){jQuery("#fileUpload").hasClass("error")&&e.preventDefault()},_uploadChangeHandler:function(e){jQuery("#fileUpload").removeClass("error");var t=!0,i=jQuery("#filePath")[0].value;if(i){var r=jQuery("#filePath")[0].value.match(/.*\.([^\.]+)$/);if(r){var s=r[1];_.indexOf(resourceLocator.ALLOWED_FILE_RESOURCE_EXTENSIONS,s)<0&&(t=!1)}else t=!1}else t=!1;if(!t){var o=resource.messages["resource.report.unsupportedFileType.error"]+" "+resourceLocator.ALLOWED_FILE_RESOURCE_EXTENSIONS.join(", ");jQuery("#fileUpload").addClass("error").find("span.warning").html(o)}},_clickHandler:function(e){resourceLocator._updateResourceSelectorState(e.target.id)},_updateResourceSelectorState:function(e){resource.switchButtonState(this.filePath,e===this.FILE_SYSTEM),resource.switchButtonState(this.fakeFilePath,e===this.FILE_SYSTEM),resource.switchButtonState(this.fakeFileInput,e===this.FILE_SYSTEM),resource.switchButtonState(this.browseButton,e===this.CONTENT_REPOSITORY),resource.switchDisableState(this.resourceUri,e!==this.CONTENT_REPOSITORY);var t=e===this.LOCAL?["disabled","launcher"]:["launcher","disabled"];this._switchElementClasses(this.newResourceLink,t)},_initFileSelector:function(e){this.fileSelector=new picker.FileSelector(_.extend({},e,{uriTextboxId:this.resourceUri,browseButtonId:this.browseButton,title:e.dialogTitle}))},remove:function(e){this.fileSelector.remove()},_switchElementClasses:function(e,t){e&&t&&e.removeClassName(t[0]).addClassName(t[1])}};define("resource.locate",["resource.base","jquery","components.pickers"],function(e){return function(){var t;return t||e.resourceLocator}}(this));var addFileResource={PAGE_ID:"addResourceFile",TYPE_ID:"fileType",PATH_ID:"filePath",LABEL_ID:"addFileInputResourceLabelID",RESOURCE_ID_ID:"addFileInputResourceID",DESCRIPTION_ID:"addFileInputDescription",FOLDER_URI_ID:"folderUri",SAVE_BUTTON_ID:"save",typeToExtMap:{accessGrantSchema:["xml"],css:["css"],font:["ttf"],img:["jpg","jpeg","gif","bmp","png"],jar:["jar"],jrxml:["jrxml"],olapMondrianSchema:["xml"],prop:["properties"],jrtx:["jrtx"],xml:["xml","agxml"],config:["config"],cer:["p12","pfx"],contentResource:["docx","doc","ppt","pptx","xls","xlsx","ods","odt","odp","pdf","rtf","html","txt","csv","json"],secureFile:["*"]},_canGenerateId:!0,initialize:function(e){this._form=$(this.PAGE_ID).select("form")[0],this._type=$(this.TYPE_ID),this._path=$(this.PATH_ID),this._label=$(this.LABEL_ID),this._resourceId=$(this.RESOURCE_ID_ID),this._description=$(this.DESCRIPTION_ID),this._folderUri=$(this.FOLDER_URI_ID),this._saveButton=$(this.SAVE_BUTTON_ID),this._isEditMode=e.isEditMode,this._type.validationEntry={validator:this._typeValidator.bind(this),element:this._type,onValid:function(){if(!this._manual){var e=this._getFileNameFromPath(this._path.getValue());this._label.value=e,this._resourceId.readOnly||(this._resourceId.value=resource.generateResourceId(this._label.getValue()))}}.bind(this)},this._path.validator=this._pathValidator.bind(this),this._label.validator=resource.labelValidator.bind(this),this._resourceId.validator=resource.resourceIdValidator.bind(this),this._description.validator=resource.descriptionValidator.bind(this),resourceLocator.initialize({resourceInput:"folderUri",browseButton:"browser_button",treeId:"addFileTreeRepoLocation",providerId:"repositoryExplorerTreeFoldersProvider",dialogTitle:resource.messages["resource.Add.Files.Title"]}),this._initEvents()},_initEvents:function(){this._saveButton.observe("click",function(e){this._isDataValid()||e.stop()}.bindAsEventListener(this)),this._type.observe("change",function(e){this._validateTypeAndPath()}.bindAsEventListener(this)),this._path.observe("change",function(e){this._validateTypeAndPath()}.bindAsEventListener(this)),this._form&&new Form.Observer(this._form,.3,function(){this._folderUri.getValue().blank()?buttonManager.disable("save"):buttonManager.enable("save")}.bindAsEventListener(this)),this._form.observe("keyup",function(e){var t=e.element(),i=[this._label,this._resourceId,this._description];i.include(t)&&(ValidationModule.validate(resource.getValidationEntries([t])),t==this._resourceId&&this._resourceId.getValue()!=resource.generateResourceId(this._label.getValue())&&(this._canGenerateId=!1),t==this._label&&!this._isEditMode&&this._canGenerateId&&(this._resourceId.setValue(resource.generateResourceId(this._label.getValue())),ValidationModule.validate(resource.getValidationEntries([this._resourceId])))),this._manual=!0}.bindAsEventListener(this)),this._form.observe("keydown",function(e){var t=matchAny(e.element(),["#"+this.DESCRIPTION_ID],!0);t||13==e.keyCode&&this._saveButton.focus()}.bindAsEventListener(this))},_isDataValid:function(){var e=[this._label,this._resourceId,this._description,this._path,this._type];return ValidationModule.validate(resource.getValidationEntries(e))},_validateTypeAndPath:function(){var e=[this._type,this._path];ValidationModule.validate(resource.getValidationEntries(e))},_typeValidator:function(e){var t=!0,i="",r={isValid:t,errorMessage:i},s=this._getExtension();if(s.blank())return r;if(this.typeToExtMap[e]&&this.typeToExtMap[e].include("*"))return r;var o=this._getTypesForExtension(s);return o.include(e)||(r.errorMessage=resource.messages.typeIsNotValid,r.isValid=!1),r},_pathValidator:function(e){var t=!0,i="";return!this._isEditMode&&e.blank()&&(i=resource.messages.pathIsEmpty,t=!1),{isValid:t,errorMessage:i}},_getTypesForExtension:function(e){var t=[];for(var i in this.typeToExtMap)this.typeToExtMap[i]&&this.typeToExtMap[i].include(e.toLowerCase())&&t.push(i);return t},_getExtension:function(){var e=this._path.getValue();if(e.blank())return"";var t=e.lastIndexOf(".");return-1==t?"":e.substr(t+1)},_getFileNameFromPath:function(e){var t=e.lastIndexOf("\\")>0?e.lastIndexOf("\\")+1:0;return e.substring(t,e.length)}};"undefined"==typeof require&&document.observe("dom:loaded",function(){addFileResource.initialize(localContext.initOptions)}),define("resource.add.files",["resource.locate","prototype","utils.common","core.events.bis"],function(e){return function(){var t;return t||e.addFileResource}}(this)),define("addResource/fileResource/addFileResourceMain",["require","!domReady","resource.add.files","underscore","jrs.configs","resource.base","utils.common"],function(e){"use strict";var t=e("!domReady"),i=e("resource.add.files"),r=e("underscore"),s=e("jrs.configs"),o=e("resource.base");e("utils.common"),t(function(){var e=s.addFileResource.localContext.initOptions;r.extend(window.localContext,s.addFileResource.localContext),r.extend(o.messages,s.addFileResource.resource.messages),i.initialize(e),isIPad()&&o.initSwipeScroll()})});