Your IP : 18.118.164.105


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/mobileapp/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/mobileapp/designer.min.js

(function(){if(window.BX.app)return;var e=window.BX;if(e.browser.IsIE()&&e.browser.DetectIeVersion()<9){return false}e.Mobile={Events:{CONFIG_CHANGED:"onEditorConfigChanged",CONFIG_READY:"onEditorConfigReady",CONFIG_LOADED:"onEditorConfigLoad",CONFIG_LOADED_BEFORE:"onBeforeEditorConfigLoad",CONFIG_SAVED:"onEditorConfigSaved",APP_FILE_LIST_GOT:"onAppFileListGot",VIEWER_ELEMENT_SET_SIZE:"onViewerElementSetSize",VIEWER_ELEMENT_APPLY:"onApply",VIEWER_ELEMENT_REDRAW:"onRedraw",VIEWER_NEW_CONFIG_SET:"onViewerNewConfigSet",PROJECT_REMOVED:"onProjectRemoved",APP_SWITCHER_REMOVE:"delete",APP_SWITCHER_CHANGE:"change"},Tools:{extendProto:function(e,t){for(var i in t){e.prototype[i]=t[i]}},highlight:function(t,i,s,a){var r=a?a:.2;new e.fx({start:0,finish:30,step:.005,type:"accelerated",time:r,callback:function(e){t.style.backgroundColor="rgba("+i[0]+","+i[1]+","+i[2]+","+e/100+")"},callback_start:function(){},callback_complete:function(){if(typeof s!="undefined"&&s===false)return;new e.fx({start:30,finish:0,step:.005,type:"deccelerated",time:.8,callback:function(e){t.style.backgroundColor="rgba("+i[0]+","+i[1]+","+i[2]+","+e/100+")"},callback_start:function(){},callback_complete:function(){t.style.backgroundColor="ffffff"}}).start()}}).start()}},Designer:function(t){this.designerContainer=e(t.containerId);this.container=e.create("DIV",{attrs:{id:"app_params"}});this.previewContainer=e.create("DIV",{attrs:{id:"app_preview"}});this.projects={};this.apps=[];this.configs=[];this.saveTimeOutId=0;this.saveTimeOut=1e3;this.useAutoSave=true;this.editor=null;this.currentProject={};this.currentPlatform="";this.map={};this.createForm=false;this.availablePlatforms=t.platforms;this.currentPlatformTab=false;this.isDataSet=false;if(t.data){this.setData(t.data)}},Project:function(e){this.name=e.name;this.desc=e.desc;this.folder=e.folder;this.config={};this.files={};this.hasFiles=false;this.code=e.code},Editor:function(t,i,s,a){this.activeGroupId=false;this.previewContainer=s;this.saved=true;this.groups={};this.config={};this.controlList={};this.imager=a;this.map=t||{groupedParams:{},lang:{}};this.container=e.create("DIV",{props:{className:"designer-editor-wrap"}});i.appendChild(this.container);this.init()},Viewer:function(e,t){this.editor=e;this.map=e.map;this.container=t;this.config={}},ViewerElement:function(t,i){e.addCustomEvent(e.Mobile.Events.CONFIG_CHANGED,e.proxy(this.onParameterValueChanged,this));e.addCustomEvent(t.editor,e.Mobile.Events.CONFIG_READY,e.proxy(this.redrawElement,this));this.isEmpty=true;this.params=i||{};this.watched=[];this.elementStrokeColor="#999";this.cageStrokeColor="#C5CEF0";this.baseElement=null;this.canvasElement=null;this.valuesSet={};this.bindedParameters={};this.map=t.map;this.viewer=t;this.defaultValues=this.params.defaultValues||{};this.textShadowColor=false;this.text=this.params.text?this.params.text:"";this.textSize=this.params.textSize?this.params.textSize:10;this.type=this.params.type?this.params.type:"common";this.textPosition=this.params.textPosition?this.params.textPosition:{x:"center",y:"center"};if(this.params.element){this.setBaseElement(this.params.element)}if(this.params.bindedParams){for(var s in this.params.bindedParams){this.bindParameter(s,this.params.bindedParams[s])}}},Controls:{Base:function(t){this.langs=t.langs;this.params=t.params;this.id=t.id;this.picker=t.picker;this.imager=t.imageDialog;this.displayElement=null;this.value=null;this.startChoose=e.proxy(function(){if(typeof this["_startChoose"]=="function")this._startChoose()},this);if(typeof this["onCreate"]=="function")this.onCreate()},Select:function(t){e.Mobile.Controls.Select.superclass.constructor.apply(this,[t]);this._setValue=function(e){var t=false;for(var i in this.input.options){if(e==this.input.options[i].value){t=true;break}}if(t){this.input.value=e}else{this.input.options.selectedIndex=0}};this.setList=function(t){this.input.innerHTML="";var i=this.value=="";this.input.appendChild(e.create("OPTION",{html:e.message("MOBILEAPP_EMPTY_VALUE"),attrs:{value:""}}));for(var s in t){if(s==this.value){i=true}this.input.appendChild(e.create("OPTION",{html:s,attrs:{value:s,id:s}}))}if(!i){e.Mobile.Tools.highlight(this.displayElement.parentNode,[255,0,0],true)}this.setValue(i?this.value:"",!i,true)};this._getDisplayElement=function(){if(typeof this.params.list=="object"){var t=[e.create("OPTION",{html:e.message("MOBILEAPP_EMPTY_VALUE"),attrs:{value:""}})];for(var i=0;i<this.params.list.length;i++){t.push(e.create("OPTION",{html:this.getMessage(this.params.list[i]),attrs:{value:this.params.list[i],id:this.params.list[i]}}))}}else{e.addCustomEvent(e.Mobile.Events.CONFIG_READY,e.proxy(function(e){if(e.config[this.params.list]){this.setList(e.config[this.params.list])}else{this.setList({})}},this));e.addCustomEvent(e.Mobile.Events.CONFIG_CHANGED,e.proxy(function(e){if(e.id==this.params.list){this.setList(e.value)}},this))}this.displayElement=e.create("SPAN",{props:{className:"adm-select-wrap"},children:[this.input=e.create("SELECT",{props:{className:"adm-workarea adm-select designer-select"},attrs:{id:this.id},children:t,events:{change:e.proxy(function(){this.setValue(this.input.options.selectedIndex!=0?this.input.value:"",true,false)},this)}})]});return this.displayElement}},String:function(t){e.Mobile.Controls.String.superclass.constructor.apply(this,[t]);this._setValue=function(e){this.input.value=e};this._getDisplayElement=function(){this.displayElement=this.input=e.create("INPUT",{props:{className:"designer-simple-string"},attrs:{type:"text",id:this.id,placeholder:""},events:{change:e.proxy(function(){this.setValue(this.input.value,true,false)},this)}});if(typeof t.params.enabledIf!="undefined"){var i=t.params.enabledIf;var s=e.proxy(function(e){for(var t in i){if(!e.config[t]||i[t]!=e.config[t]){return false}}return true},this);e.addCustomEvent(e.Mobile.Events.CONFIG_READY,e.proxy(function(e){this.displayElement.disabled=!s(e)},this));e.addCustomEvent(e.Mobile.Events.CONFIG_CHANGED,e.proxy(function(t){var i=this.displayElement.disabled;this.displayElement.disabled=!s(this.editor);if(!this.displayElement.disabled&&i!=this.displayElement.disabled){e.Mobile.Tools.highlight(this.displayElement.parentNode,[97,140,80],true)}},this))}return this.displayElement}},Number:function(t){e.Mobile.Controls.Number.superclass.constructor.apply(this,[t]);this._setValue=function(e){this.input.value=e};this._getDisplayElement=function(){this.input=e.create("INPUT",{props:{className:"designer-simple-string"},attrs:{type:"number",id:this.id},events:{change:e.proxy(function(){if(this.params.limits){if(this.params.limits["min"]&&this.input.value<this.params.limits["min"]){this.input.value=this.params.limits["min"]}}this.setValue(this.input.value,true,false)},this)}});this.input.setAttribute("placeholder","0");this.displayElement=e.create("SPAN",{props:{className:"designer-input-wrap"},children:[this.input]});return this.displayElement}},Image:function(t){e.Mobile.Controls.Image.superclass.constructor.apply(this,[t]);this._setValue=function(t){if(typeof t==="object"){if(t.id){this.input.value=t.id}if(t.src){this.image.src=t.preview?t.preview:t.src;e.show(this.imageView)}else{e.hide(this.imageView)}}else{this.input.value=t?t:"";var i=this.imager.getSrcByID(t,true);this.image.src=this.imager.getSrcByID(t,true);if(t>0&&i){e.show(this.imageView)}else{e.hide(this.imageView)}}};this._getDisplayElement=function(){this.input=e.create("INPUT",{props:{className:"designer-simple-string"},attrs:{type:"text",id:this.id}});this.button=e.create("INPUT",{attrs:{type:"button",value:e.message("MOBILEAPP_SELECT_IMAGE")}});this.displayElement=e.create("DIV",{props:{className:"designer-image-wrap",id:this.id},events:{mouseover:function(){e.addClass(this,"designer-image-list-item-highlight")},mouseout:function(){e.removeClass(this,"designer-image-list-item-highlight")}},children:[this.imageView=e.create("DIV",{children:[e.create("DIV",{props:{className:"designer-imager-item-delete"},attrs:{"data-id":this.id},children:[e.create("SPAN",{attrs:{"data-id":this.id},props:{className:"designer-imager-item-delete-inner"}})],events:{click:e.proxy(function(){this.setValue("",true)},this)}}),e.create("DIV",{props:{className:"designer-image-preview"},children:[this.image=e.create("IMG",{attrs:{}})]})]}),this.button]});e.bind(this.button,"click",e.proxy(function(){this.imager.open(this)},this));return this.displayElement}},MultiImage:function(t){e.Mobile.Controls.MultiImage.superclass.constructor.apply(this,[t])},MultiValue:function(t){e.Mobile.Controls.MultiValue.superclass.constructor.apply(this,[t])},Boolean:function(t){e.Mobile.Controls.Boolean.superclass.constructor.apply(this,[t]);this._setValue=function(e){var t=this.input.options;for(var i=0;i<t.length;i++){if(t[i].value.toLowerCase()==e.toLowerCase()){this.input.selectedIndex=i;break}}};this._getDisplayElement=function(){var t=[];var i=["YES","NO"];var s=0;for(var a=0;a<i.length;a++){if(this.params.default&&this.params.default==i[a]){s=a}t.push(e.create("OPTION",{html:this.getMessage(i[a]),attrs:{value:i[a]}}))}this.displayElement=e.create("SPAN",{props:{className:"adm-select-wrap"},children:[this.input=e.create("SELECT",{attrs:{id:this.id},props:{className:"adm-workarea adm-select"},children:t,events:{change:e.proxy(function(){this.setValue(this.input.value,true,false)},this)}})]});this.input.selectedIndex=s;return this.displayElement}},Color:function(t){e.Mobile.Controls.Color.superclass.constructor.apply(this,[t]);this.colorBox=null}},ControlsFactory:{getControl:function(t){var i=null;switch(t.params.type){case"value_list":case"fill_list":i=new e.Mobile.Controls.Select(t);break;case"image":i=new e.Mobile.Controls.Image(t);break;case"value_set":i=new e.Mobile.Controls.MultiValue(t);break;case"image_set":i=new e.Mobile.Controls.MultiImage(t);break;case"color":i=new e.Mobile.Controls.Color(t);break;case"size":i=new e.Mobile.Controls.Number(t);break;case"boolean":i=new e.Mobile.Controls.Boolean(t);break;default:i=new e.Mobile.Controls.String(t);break}return i}}};e.Mobile.Designer.prototype={onEditorConfigChanged:function(){if(this.useAutoSave){clearTimeout(this.saveTimeOutId);this.saveTimeOutId=setTimeout(e.proxy(this.save,this),this.saveTimeOut)}},setData:function(t){this.map=t["map"];this.apps=t["apps"];this.configs=t["configs"];this.templates=t["templates"];for(var i=0;i<this.apps.length;i++){var s=this.apps[i]["code"];var a=this.apps[i]["platform"];var r=this.apps[i]["params"];if(!this.projects[s]){this.projects[s]=new e.Mobile.Project(this.apps[i])}this.projects[s].setConfig(a,r)}this.isDataSet=true},draw:function(){this.drawPanel();this.designerContainer.appendChild(this.container);this.designerContainer.appendChild(this.previewContainer);this.imager.init();this.editor=new e.Mobile.Editor(this.map,this.editorContainer,this.previewContainer,this.imager);if(this.apps.length!==0){this.editorContainer.style.display="inline-block";if(this.initedApp!=null&&this.appSwitcher[this.initedApp]){this.setCurrentProject(this.projects[this.initedApp])}else{this.setCurrentProject(this.projects[this.appSwitcher.activeApp])}}else{this.showEmptyScreen()}},init:function(){e.addCustomEvent(e.Mobile.Events.CONFIG_LOADED,e.proxy(this.onEditorConfigLoad,this));e.addCustomEvent(e.Mobile.Events.CONFIG_CHANGED,e.proxy(this.onEditorConfigChanged,this));e.addCustomEvent(e.Mobile.Events.CONFIG_SAVED,e.proxy(this.onEditorConfigSave,this));if(!this.isDataSet){this.executeRequest({command:"getInitData",onsuccess:e.proxy(function(e){this.setData(e);this.draw()},this),onfailure:function(e){}})}else{this.draw()}},setCurrentProject:function(e){if(!this.projects[e.code]){this.projects[e.code]=e;this.appSwitcher.add(e.code,e)}this.appSwitcher.setActiveApp(e.code);this.editor.setReady(false);this.editor.currentProject=e;this.currentProject=e;this.getFiles();this.imager.uploader.appCode=e.code;this.imager.setFileList(e.files);this.editor.setSaved(true);this.currentPlatform=false;var t=this.currentProject.config;this.currentPlatformTab=false;this.configList.innerHTML="";for(var i in t){var s=this.createPlatformTab(i);this.configList.appendChild(s);if(!this.currentPlatform){this.currentPlatform=i;this.currentPlatformTab=s}}this.editor.loadConfig(this.currentProject.getConfig(this.currentPlatform),this.currentPlatform);this.addConfigButton.style.visibility=this.getPlatformsToCreate().length==0?"hidden":"visible"},createPlatformTab:function(t){var i=this;return e.create("SPAN",{props:{className:"designer-config-tab"+(t==="global"?" global-config-tab":" ")+(this.currentPlatform==false?" designer-config-tab-selected":"")},attrs:{"data-platform":t},events:{click:function(){var t=this.getAttribute("data-platform");if(i.currentPlatform===t)return;if(i.editor.getSaved()===false)i.save();i.currentPlatform=t;e.addClass(this,"designer-config-tab-selected");if(i.currentPlatformTab!==false){e.removeClass(i.currentPlatformTab,"designer-config-tab-selected")}i.currentPlatformTab=this;i.editor.loadConfig(i.currentProject.getConfig(t),t)}},children:[e.create("SPAN",{html:e.message("MOBILEAPP_"+t.toUpperCase())}),t!=="global"?e.create("DIV",{attrs:{"data-platform":t},props:{className:"designer-config-tab-cross"},events:{mouseover:function(){e.addClass(this,"designer-config-tab-cross-hover")},mouseout:function(){e.removeClass(this,"designer-config-tab-cross-hover")},click:function(e){if(e.stopPropagation){e.stopPropagation()}else{e.cancelBubble=true}i.removePlatformConfig(e.target.getAttribute("data-platform"),e.target)}}}):null]})},drawPanel:function(){var t=this;this.configList=e.create("SPAN");this.saveButton=e.create("INPUT",{attrs:{value:e.message("MOBILEAPP_SAVE"),type:"button"},events:{click:e.proxy(this.save,this)},props:{className:"designer-save-button adm-btn-save"}});this.createButton=e.create("SPAN",{attrs:{},events:{click:e.proxy(function(){this.showCreateForm(this.createButton)},this)},props:{className:"designer-command-panel-item adm-filter-add-button designer-button-app-add"}});this.appSwitcher.create();e.addCustomEvent(this.appSwitcher,e.Mobile.Events.APP_SWITCHER_CHANGE,function(e){if(t.editor.getSaved()===false)t.save();t.setCurrentProject(t.projects[e])});e.addCustomEvent(this.appSwitcher,e.Mobile.Events.APP_SWITCHER_REMOVE,e.proxy(function(e){this.removeApp(e)},this));for(var i in this.projects){var s=this.projects[i];this.appSwitcher.add(i,s)}this.addButtonArea=e.create("SPAN",{props:{},children:[this.addConfigButton=e.create("SPAN",{html:e.message("MOBILEAPP_APP_PLATFORM"),props:{className:"designer-config-add-button"},events:{click:function(e){t.showCreateConfigForm(e.target)}}})]});this.addConfigButton.style.visibility=this.getPlatformsToCreate().length==0?"hidden":"visible";this.panel=e.create("DIV",{props:{className:"adm-filter-content designer-command-panel"},children:[this.createButton,this.appSwitcher.getDisplayElement(),this.configList,this.addButtonArea,this.connectButton=e.create("INPUT",{attrs:{type:"button",value:e.message("MOBILEAPP_CONNECT_TO_APP"),style:"float:right"},events:{click:function(i){var s=document.location.protocol+"//"+document.location.host+"/"+t.currentProject.folder;var a=e.create("DIV",{props:{className:"designer-connect-window-inner"}});var r=e.create("DIV",{html:e.message("MOBILEAPP_CONNECT_INSTRUCTION"),props:{className:"designer-connect-window-inner-instruction"}});var n=e.create("DIV",{html:s,props:{className:"designer-connect-window-inner-url"}});var o=e.create("DIV",{html:e.message("MOBILEAPP_CONNECT_INSTRUCTION_QR"),props:{className:"designer-connect-window-inner-instruction"}});var l=e.create("DIV",{props:{className:"designer-connect-window-inner-qr-container"}});a.appendChild(r);a.appendChild(n);a.appendChild(o);a.appendChild(l);new QRCode(l,{text:s,width:150,height:150});var h=new e.PopupWindow("qrcode"+Math.random(),null,{content:a,draggable:true,titleBar:e.message("MOBILEAPP_CONNECT_TO_APP_TITLE"),closeByEsc:true,contentColor:"white",overlay:{opacity:500},zIndex:1e4,buttons:[new e.PopupWindowButton({text:e.message("MOBILEAPP_CONNECT_BUTTON_CLOSE"),events:{click:e.proxy(function(){h.close()},this)}})]});h.show()}}})]});this.designerContainer.appendChild(this.panel);this.editorContainer=e.create("DIV");this.editorContainer.style.display="none";this.editorContainer.style.height="632px";this.editorContainer.appendChild(e.create("DIV",{props:{className:"designer-save-panel"},children:[this.configLabel=e.create("SPAN",{props:{className:"designer-label"}}),this.saveButton]}));if(this.useAutoSave)this.saveButton.style.visibility="hidden";this.container.appendChild(this.editorContainer)},getFiles:function(){if(this.currentProject.hasFiles){this.imager.setFileList(this.currentProject.files);e.onCustomEvent(e.Mobile.Events.APP_FILE_LIST_GOT,[this.currentProject.files])}else{this.executeRequest({data:{code:this.currentProject.code},command:"getFiles",onsuccess:e.proxy(function(t){this.currentProject.files=t.files;this.projects[this.currentProject.code].files=t.files;this.projects[this.currentProject.code].hasFiles=true;this.imager.setFileList(this.currentProject.files);e.onCustomEvent(e.Mobile.Events.APP_FILE_LIST_GOT,[t.files])},this),onfailure:function(e){}})}},showEmptyScreen:function(){this.emptyScreen=e.create("DIV",{props:{className:"designer-no-apps-message"},children:[e.create("DIV",{html:e.message("MOBILEAPP_NO_APPS")}),e.create("INPUT",{attrs:{value:e.message("MOBILEAPP_CREATE_APP"),type:"button"},events:{click:e.proxy(function(){this.showCreateForm()},this)}})]});this.designerContainer.appendChild(this.emptyScreen);e.addClass(this.designerContainer,"designer-prop-wrapper-empty")},closeEmptyScreen:function(){if(this.emptyScreen&&this.emptyScreen.parentNode!=null)this.designerContainer.removeChild(this.emptyScreen);e.removeClass(this.designerContainer,"designer-prop-wrapper-empty")},_createForm:{inited:false,hasErrors:false,fields:{},popupError:false,validatedFields:[],onChangeValidate:function(t){var i=t.target;var s=i.getAttribute("data-error");if(this.validate(i.value)){if(s==null||s=="N"){e.Mobile.Tools.highlight(i,[255,0,0],false);i.setAttribute("data-error","Y")}}else{i.setAttribute("data-error","N");i.style.backgroundColor="#ffffff"}this.saveButton.disabled=!this.isValid();e.PreventDefault(t)},validate:function(e){return/^[a-zA-Z0-9_]+$/.test(e)==false&&e.length>0},reset:function(){for(var t in this.fields){this.fields[t].value="";this.fields[t].setAttribute("data-error","N");e.Mobile.Tools.highlight(this.fields[t],[255,255,255]);if(t=="template")this.fields[t].value="NewMobileTemplate"}this.saveButton.disabled=true},isValid:function(){if(this.popupError)this.popupError.close();for(var e in this.fields){if(this.templateList.value!="new"&&e=="template")continue;if(this.fields[e].getAttribute("data-error")=="Y"||this.fields[e].value.length==0){return false}}return true},highlightAllErrors:function(){for(var t in this.fields){if(this.fields[t].getAttribute("data-error")=="Y"){e.Mobile.Tools.highlight(this.fields[t],[255,0,0],false,.8)}}},showError:function(t,i){if(this.popupError==false){this.popupError=new e.PopupWindow("DesignerCreateFormError",null,{content:e.create("DIV",{props:{className:"designer-create-form"},style:{width:"150px"},html:i}),autoHide:true,lightShadow:true,angle:{position:"left",offset:15},offsetTop:-37,closeByEsc:true,offsetLeft:210,zIndex:100500,bindOptions:{forceTop:true,forceLeft:true}})}if(this.fields[t]){e.Mobile.Tools.highlight(this.fields[t],[255,0,0],false);this.popupError.setBindElement(this.fields[t]);this.popupError.show()}},initCreateForm:function(t){this.designer=t;var i=[];i.push(e.create("DIV",{props:{className:"designer-form-title"},html:e.message("MOBILEAPP_CREATE_APP")}));i.push(e.create("HR"));i.push(e.create("DIV",{children:[e.create("DIV",{props:{className:"designer-create-form-field-wrap"},children:[e.create("DIV",{props:{className:"designer-create-form-input-wrap"},children:[this.fields.name=e.create("INPUT",{attrs:{placeholder:e.message("MOBILEAPP_APP_NAME")},events:{keyup:e.proxy(function(){this.saveButton.disabled=!this.isValid()},this)}})]})]}),e.create("DIV",{props:{className:"designer-create-form-field-wrap"},children:[e.create("DIV",{props:{className:"designer-create-form-input-wrap"},children:[this.fields.code=e.create("INPUT",{events:{keyup:e.proxy(this.onChangeValidate,this)},attrs:{placeholder:e.message("MOBILEAPP_LABEL_CODE")}})]})]}),e.create("DIV",{props:{className:"designer-create-form-field-wrap"},children:[e.create("DIV",{props:{className:"designer-create-form-input-wrap"},children:[this.fields.folder=e.create("INPUT",{attrs:{placeholder:e.message("MOBILEAPP_LABEL_APP_FOLDER")},events:{keyup:e.proxy(this.onChangeValidate,this)}})]})]})]}));i.push(e.create("DIV",{props:{className:"designer-form-subtitle"},html:e.message("MOBILEAPP_CREATE_APP_PUBLIC_OPTIONS_TITLE")}));i.push(e.create("HR"));i.push(e.create("SPAN",{props:{className:"adm-select-wrap"},children:[this.fields.appTemplateList=e.create("SELECT",{props:{className:"adm-workarea adm-select"},children:[e.create("OPTION",{html:e.message("MOBILEAPP_CREATE_APP_PUBLIC_TEMPLATE_SIMPLE"),attrs:{value:"simple"}}),e.create("OPTION",{html:e.message("MOBILEAPP_CREATE_APP_PUBLIC_TEMPLATE_API"),attrs:{value:"api"}})],events:{change:e.proxy(function(e){},this)}})]}));i.push(e.create("DIV",{props:{className:"designer-create-form-field-wrap"},children:[e.create("DIV",{props:{},children:[this.fields.useOffline=e.create("INPUT",{props:{className:"adm-designed-checkbox"},attrs:{type:"checkbox",id:"useOffline"}}),e.create("LABEL",{props:{className:"adm-designed-checkbox-label"},attrs:{"for":"useOffline"}}),e.create("LABEL",{html:e.message("MOBILEAPP_CREATE_OFFLINE"),attrs:{"for":"useOffline",style:"margin-left: 5px;"},events:{}})]})]}));this.templateList=e.create("SELECT",{props:{className:"adm-workarea adm-select"},style:{width:"212px"},events:{change:e.proxy(function(t){var i=t.target;if(i.options[i.selectedIndex].value!="new"){e.hide(this.templateFolderName)}else{e.show(this.templateFolderName)}this.saveButton.disabled=!this.isValid()},this)}});this.templateList.appendChild(e.create("OPTION",{html:e.message("MOBILEAPP_CREATE_NEW_TEMPLATE"),attrs:{value:"new"}}));this.templateList.appendChild(e.create("OPTION",{html:e.message("MOBILEAPP_WITHOUT_TEMPLATE"),attrs:{value:"without"}}));if(this.designer.templates.length>0){var s=e.create("OPTGROUP",{attrs:{label:e.message("MOBILEAPP_SELECT_TEMPLATE")}});this.templateList.appendChild(s);for(var a=0;a<this.designer.templates.length;a++){s.appendChild(e.create("OPTION",{html:this.designer.templates[a]["NAME"],attrs:{value:this.designer.templates[a]["ID"]}}))}}i.push(e.create("DIV",{props:{className:"designer-form-subtitle"},html:e.message("MOBILEAPP_APP_TEMPLATE")}));i.push(e.create("HR"));i.push(e.create("DIV",{props:{className:"designer-create-form-site-template-wrap"},children:[e.create("SPAN",{props:{className:"adm-select-wrap"},children:[this.templateList]}),this.templateFolderName=e.create("DIV",{props:{className:"designer-create-form-field-wrap"},style:{display:"block"},children:[e.create("DIV",{props:{className:"designer-create-form-input-wrap"},children:[this.fields.template=e.create("INPUT",{attrs:{placeholder:e.message("MOBILEAPP_NEW_TEMPLATE_NAME"),value:"NewMobileTemplate"},events:{keyup:e.proxy(this.onChangeValidate,this)}})]})]})]}));i.push(e.create("DIV",{props:{className:"popup-window-buttons"},children:[this.saveButton=e.create("input",{props:{className:"adm-btn-save"},attrs:{type:"button",disabled:true,value:e.message("MOBILEAPP_CREATE")},events:{click:e.proxy(function(){if(!this.isValid()){alert("Error!");return}var e={code:this.fields.code.value,platform:"global",name:this.fields.name.value,folder:this.fields.folder.value,appTemplateName:this.fields.appTemplateList.value,useOffline:this.fields.useOffline.checked?"Y":"N",createNew:"N",bindTemplate:"N"};if(this.templateList.value!="without"){if(this.templateList.value=="new"){if(this.fields.template.value.length>0){e["createNew"]="Y";e["bindTemplate"]="Y";e["template_id"]=this.fields.template.value}}else{e["bindTemplate"]="Y";e["template_id"]=this.templateList.value}}this.designer.createProject(e)},this)}}),e.create("input",{attrs:{type:"button",value:e.message("MOBILEAPP_CLOSE")},events:{click:e.proxy(function(){this.popup.close()},this)}})]}));var r=e.create("DIV",{props:{className:"designer-create-form adm-workarea"},children:i});if(!this.inited){this.inited=true;this.popup=new e.PopupWindow("DesignerCreateForm"+Math.random(),null,{content:r,closeByEsc:true,overlay:true,autoHide:false,zIndex:1e4});e.addCustomEvent(this.popup,"onPopupClose",e.proxy(function(){if(this.popupError)this.popupError.close()}))}else{this.popup.setContent(r)}}},showCreateForm:function(){this._createForm.initCreateForm(this);this._createForm.popup.show()},getPlatformsToCreate:function(){var e=[];var t=this.currentProject.config;if(t){for(var i=0;i<this.availablePlatforms.length;i++){if(!t[this.availablePlatforms[i]])e.push(this.availablePlatforms[i])}}return e},showCreateConfigForm:function(t){var i=[];var s=this.getPlatformsToCreate();var a=this;for(var r=0;r<s.length;r++){i.push(e.create("DIV",{html:e.message("MOBILEAPP_"+s[r].toUpperCase()),attrs:{"data-platform":s[r]},props:{className:"designer-app-switcher-list-item"},events:{click:function(e){var t=e.target;var i=t.getAttribute("data-platform");a.createPlatformConfig(i)}}}))}var n=e.create("DIV",{props:{className:"designer-popup-config-list"},children:i});if(!this.createConfigForm){this.createConfigForm=new e.PopupWindow("preview"+Math.random(),null,{content:"",lightShow:true,offsetTop:-5,autoHide:true,closeIcon:false,bindOptions:{forceTop:true},zIndex:2e3})}this.createConfigForm.setContent(n);this.createConfigForm.setBindElement(t);this.createConfigForm.show()},createPlatformConfig:function(t){var i=this.currentProject.code;this.executeRequest({command:"createPlatform",waitMessage:e.message("MOBILEAPP_APP_CREATE_CONFIG_WAIT"),data:{code:i,platform:t},onsuccess:e.proxy(function(e){if(e.status=="ok"){this.currentProject.setConfig(t,{});this.configList.appendChild(this.createPlatformTab(t));this.addConfigButton.style.visibility=this.getPlatformsToCreate().length==0?"hidden":"visible";this.createConfigForm.close()}else{alert("Error")}},this),onfailure:function(e){}})},createProject:function(t){this.executeRequest({command:"createApp",data:t,onsuccess:e.proxy(function(i){if(i.status=="ok"){this.currentProject=new e.Mobile.Project(t);this.currentProject.setConfig("global",i.config?i.config:{});this.editorContainer.style.display="inline-block";this.setCurrentProject(this.currentProject);this.closeEmptyScreen();this._createForm.popup.close();this._createForm.reset()}else if(i.status=="is_already_exists"){this._createForm.showError("code",e.message("MOBILEAPP_APP_IS_ALREADY_EXISTS"))}},this),onfailure:function(e){}})},removePlatformConfig:function(t,i){if(confirm(e.message("MOBILEAPP_REMOVE_CONFIG_ASK"))){var s=this.currentProject.code;this.executeRequest({command:"removePlatform",waitMessage:e.message("MOBILEAPP_APP_REMOVE_CONFIG_WAIT"),data:{code:s,platform:t},onsuccess:e.proxy(function(e){if(e.status=="ok"){i.parentNode.removeChild(i);delete this.currentProject.config[t];this.setCurrentProject(this.currentProject)}else{alert("Error")}},this),onfailure:function(e){}})}},removeApp:function(t){if(confirm(e.message("MOBILEAPP_REMOVE_APP_ASK"))){this.executeRequest({command:"removeApp",data:{code:t},onsuccess:e.proxy(function(e){if(e.status=="ok"){this.removeProject(t)}},this),onfailure:function(e){}})}},removeProject:function(t){delete this.projects[t];e.onCustomEvent(this,e.Mobile.Events.PROJECT_REMOVED,[t]);this.appSwitcher.remove(t);var i=Object.keys(this.projects);if(i.length==0){this.showEmptyScreen()}else{this.setCurrentProject(this.projects[i[0]])}},executeRequest:function(t){if(t.showWait!=false){if(t.waitMessage&&t.waitMessage.length>0){e.showWait(null,t.waitMessage)}else{e.showWait()}}var i=t.data||{};i["sessid"]=e.bitrix_sessid();e.ajax({url:"?action="+t.command,data:i,method:"POST",dataType:"json",onsuccess:function(i){e.closeWait();t.onsuccess(i)},onfailure:function(i){e.closeWait();t.onfailure(i)}})},save:function(){e.showWait(this.editor.container,e.message("MOBILEAPP_APP_SAVE_CONFIG_WAIT"));this.currentProject.setConfig(this.currentPlatform,this.editor.config);this.editor.setSaved(true);this.executeRequest({showWait:false,command:"save",method:"POST",onsuccess:function(){},onfailure:function(){},data:{code:this.currentProject.code,platform:this.currentPlatform,config:this.editor.config}})},onEditorConfigLoad:function(t){this.configLabel.innerHTML=e.message("MOBILEAPP_CONFIGNAME_"+t.platform.toUpperCase())},onEditorConfigSave:function(e){this.saveButton.disabled=e.status},imager:{init:function(){e.addCustomEvent("OnFileUploadRemove",e.proxy(this.onRemove,this));e.addCustomEvent("BFileDSelectFileDialogLoaded",e.proxy(function(e){this.uploader=e},this));this.projectId=false;this.files={};this.caller=null;this.popup=new e.PopupWindow("imageDialog",null,{content:e.create("DIV",{props:{className:"designer-create-form"}}),closeIcon:{right:"2px",top:"2px"},closeByEsc:true,width:500,overlay:true,zIndex:100001});var t=e("file-selectdialog-designer").parentNode;this.images=e.create("DIV",{props:{className:"designer-image-container"},attrs:{id:"images"}});this.popup.setContent(e.create("DIV",{style:{margin:"17px"},children:[this.images,e("file-selectdialog-designer")]}));e.addCustomEvent("OnFileUploadSuccess",e.proxy(this.fileUploadSuccess,this));e.onCustomEvent(t,"BFileDLoadFormController")},fileUploadSuccess:function(t){e.remove(e("wd-doc"+t.element_id));this.addImageToList(t.element_id,t.element_thumbnail);this.files["file_"+t.element_id]={src:t.element_url,preview:t.element_thumbnail};e.onCustomEvent("onImageUploaded",[{id:t.element_id,src:t.element_url,preview:t.element_thumbnail}])},addImageToList:function(t,i){var s=e.create("SPAN",{props:{className:"designer-image-list-item"},events:{mouseover:function(){e.addClass(this,"designer-image-list-item-highlight")},mouseout:function(){e.removeClass(this,"designer-image-list-item-highlight")}},attrs:{id:"image_container_"+t},children:[e.create("DIV",{props:{className:"designer-imager-item-delete"},attrs:{"data-id":t},children:[e.create("SPAN",{attrs:{"data-id":t},props:{className:"designer-imager-item-delete-inner"}})],events:{click:e.proxy(function(e){var t=e.target.getAttribute("data-id");this.uploader.remove(t)},this)}}),e.create("IMG",{attrs:{src:i,id:"img_"+t,"data-id":t},props:{className:"designer-imager-item-img"},events:{click:e.proxy(function(e){var t=e.target;this.onImageChosen({id:t.getAttribute("data-id")})},this)}})]});this.images.appendChild(s);this.images.style.display="block"},open:function(e){this.caller=e;this.popup.resizeOverlay();this.popup.show()},onRemove:function(t){var i=e("image_container_"+t);i.parentNode.removeChild(i);delete this.files["file_"+t];if(Object.keys(this.files).length==0){this.images.style.display="none"}},onImageChosen:function(e){if(this.caller&&this.caller["onImageChosen"]){this.caller.onImageChosen(e);this.caller=null}this.popup.close()},setFileList:function(e){this.images.innerHTML="";this.images.style.display="none";this.files=e;for(var t in e){this.addImageToList(e[t].id,e[t].preview?e[t].preview:e[t].src)}},getSrcByID:function(e,t){var i="";if(this.files["file_"+e]){i=t&&this.files["file_"+e]["preview"]?this.files["file_"+e]["preview"]:this.files["file_"+e]["src"]}return i}},appSwitcher:{inited:false,apps:{},activeApp:false,activeAppNode:false,add:function(t,i){var s=this;var a=e.create("SPAN",{props:{className:"designer-app-switcher-list-item-inner"},html:e.util.htmlspecialchars(i.name)+" ("+t+")"});var r=e.create("DIV",{props:{className:"designer-app-switcher-list-item"},attrs:{"data-app":t},children:[a,e.create("SPAN",{props:{className:"designer-app-switcher-item-del-link"},attrs:{"data-app":t},html:e.message("MOBILEAPP_REMOVE"),events:{click:e.proxy(function(t){
var i=this.getAttribute("data-app");s.onDelete(i);s.popupList.close();e.PreventDefault(t)},r)}}),e.create("SPAN",{props:{className:"designer-app-switcher-list-item-delimiter"}})],events:{click:e.proxy(function(){var e=this.getAttribute("data-app");s.onChange(e);s.popupList.close()},r)}});if(this.activeApp===false){this.activeValueNode.innerHTML=e.util.htmlspecialchars(i.name)+" ("+t+")";this.activeApp=t}this.apps[t]=i;this.apps[t]["node"]=r;this.apps[t]["value"]=a;this.appListContainer.appendChild(r)},remove:function(e){this.appListContainer.removeChild(this.apps[e]["node"]);delete this.apps[e]},create:function(){if(!this.popupList){this.appListContainer=e.create("DIV",{props:{className:""}});this.popupList=new e.PopupWindow("popupList",null,{content:this.appListContainer,closeByEsc:true,darkMode:false,autoHide:true,zIndex:1e4})}if(this.activeAppNode===false){this.activeValueNode=e.create("SPAN",{props:{className:"designer-app-switcher-inner"}});this.activeAppNode=e.create("SPAN",{props:{className:"designer-command-panel-item designer-app-switcher"},children:[this.activeValueNode,e.create("SPAN",{props:{className:"designer-app-switcher-angle"}})],events:{click:e.proxy(function(){if(Object.keys(this.apps).length>0)this.show()},this)}})}this.inited=true},getDisplayElement:function(){if(!this.inited)this.create();return this.activeAppNode},show:function(){this.popupList.setBindElement(this.activeAppNode);this.popupList.show()},setActiveApp:function(t){this.activeApp=t;this.activeValueNode.innerHTML=e.util.htmlspecialchars(this.apps[t].name)+" ("+t+")"},onChange:function(t){if(t==this.activeApp)return;this.setActiveApp(t);e.onCustomEvent(this,e.Mobile.Events.APP_SWITCHER_CHANGE,[this.activeApp])},onDelete:function(t){e.onCustomEvent(this,e.Mobile.Events.APP_SWITCHER_REMOVE,[t])}}};e.Mobile.Project.prototype={setConfig:function(e,t){this.config[e]=t},getConfig:function(e){return this.config[e]}};e.Mobile.Editor.prototype={loadConfig:function(t,i){this.config=typeof t!="object"||t==null?{}:e.clone(t);e.onCustomEvent(e.Mobile.Events.CONFIG_LOADED_BEFORE,[{platform:i,config:t}]);for(var s in this.controlList){this.controlList[s].setValue(typeof this.config[s]!="undefined"?this.config[s]:"")}e.onCustomEvent(e.Mobile.Events.CONFIG_LOADED,[{platform:i,config:t}]);if(!this.viewer){this.viewer=new e.Mobile.Viewer(this,this.previewContainer);this.viewer.setConfig(this.config);this.viewer.init()}else{this.viewer.setConfig(this.config)}this.setConfigReady(true)},setImageReady:function(e){this.imageReady=e;if(this.imageReady&&this.configReady)this.setReady(true)},setConfigReady:function(e){this.configReady=e;if(this.imageReady&&this.configReady)this.setReady(true)},setReady:function(t){if(!t){this.imageReady=false;this.configReady=false;this.ready=false}else{this.ready=true;e.onCustomEvent(this,e.Mobile.Events.CONFIG_READY,[this])}},sortByParent:function(e){var t={};for(var i in e){if(e[i]["type"]=="group")continue;var s=e[i]["parent"];if(s&&s.length>0){if(!t[s])t[s]={};t[s][i]=e[i]}else{if(!t["common_params"])t["common_params"]={};t["common_params"][i]=e[i]}}return t},init:function(){this.ready=false;this.imageReady=false;this.configReady=false;this.controlListImage={};this.picker=new window.BXColorPicker({id:"picker",name:"picker"});this.picker.Create();e.addCustomEvent(e.Mobile.Events.APP_FILE_LIST_GOT,e.proxy(function(e){this.setImageReady(true);var t=this.controlListImage;for(var i in t){if(t.hasOwnProperty(i)){var s=t[i].input.value;var a=e["file_"+t[i].input.value];if(s&&a){t[i].setValue(a,false,true)}}}},this));if(!this.map)return;this.initGroupTabs();for(var t=0;t<this.map.groups.length;t++){var i={tab:false,propCont:null};i=this.groups[this.map.groups[t]];var s=e.create("TABLE",{props:{className:"param-table"}});i.propCont.appendChild(s);var a=this.map.groupedParams[this.map.groups[t]];var r={};var n=this.sortByParent(a);for(var o in n){var l=n[o];var h=e.create("TR");s.appendChild(h);h.appendChild(e.create("TD",{attrs:{colspan:1},props:{className:"label-td subgroup-head"},html:this.getMessage(o)}));var c=l;var p=true;for(var d in c){if(!p){s.appendChild(s.appendChild(e.create("HR",{props:{className:"label-delimiter"}})))}p=false;var u=l[d];s.appendChild(this.getParamNameLine(d));this.controlList[d]=this.createControl(u,d);if(u.type=="image"){this.controlListImage[d]=this.controlList[d]}s.appendChild(this.getParamControlLine(this.controlList[d]))}}this.showGroup(this.activeGroupId)}},getParamNameLine:function(t){return e.create("TR",{children:[e.create("TD",{props:{className:"label-td"},children:[e.create("DIV",{html:this.getMessage(t)})]})]})},getParamControlLine:function(t){return e.create("TR",{children:[e.create("TD",{props:{className:"control-td"},children:[t.getDisplayElement()]})]})},initGroupTabs:function(){var t=this.map.groups;var i=e.create("DIV",{props:{className:"designer-tabs"}});this.container.appendChild(i);for(var s=0;s<t.length;s++){this.groups[t[s]]={tab:e.create("DIV",{attrs:{"data-gid":t[s]},props:{className:"designer-tab-wrap"},events:{click:e.proxy(function(){var e=arguments[0];var t=e.target.parentNode.getAttribute("data-gid");if(t)this.showGroup(t)},this)},children:[e.create("DIV",{props:{className:"designer-tab-back-shadow"}}),e.create("DIV",{props:{className:"designer-tab"},html:this.getMessage(t[s])})]}),propCont:e.create("DIV",{attrs:{id:t[s]+"_section"},props:{className:"designer-group-container"}})};i.appendChild(this.groups[t[s]].tab);if(s==0)this.activeGroupId=t[s]}},showGroup:function(t){if(this.groups[this.activeGroupId].propCont.parentNode){e.removeClass(this.groups[this.activeGroupId].tab,"designer-tab-active");this.container.removeChild(this.groups[this.activeGroupId].propCont)}this.activeGroupId=t;this.container.appendChild(this.groups[t].propCont);e.addClass(this.groups[t].tab,"designer-tab-active")},setSaved:function(t){this.saved=t;e.onCustomEvent(e.Mobile.Events.CONFIG_SAVED,[{status:t}])},getSaved:function(){return this.saved},createControl:function(t,i){var s=e.Mobile.ControlsFactory.getControl({id:i,params:t,langs:this.map.lang,picker:this.picker,imageDialog:this.imager});s.setOnChangeHandler(e.proxy(function(t,i){this.setSaved(false);if(i==""){delete this.config[t]}else{this.config[t]=i}e.onCustomEvent(e.Mobile.Events.CONFIG_CHANGED,[{id:t,value:i}])},this));s.editor=this;return s},jumpToControl:function(t,i){var s=t.split("/");if(s[0]!=this.viewer.editor.activeGroupId)this.viewer.editor.showGroup(s[0]);var a=this.viewer.editor.controlList[t];var r=e(s[0]+"_section");var n=e.pos(a.displayElement,true);var o=200;var l=this;var h=new e.fx({start:r.scrollTop,finish:n.top-o,type:"deccelerated",time:.3,step:.005,callback:function(e){r.scrollTop=e},callback_complete:function(){a.highlight(a.displayElement.parentNode,[199,219,125]);a.startChoose();if(i&&i.length>0){for(var e=0;e<i.length;e++){var t=l.viewer.editor.controlList[i[e]];t.highlight(t.displayElement.parentNode,[199,219,125])}}}});h.start()},openFileDialog:function(e){window.designerEditorFileChosen=function(t,i){e(i+"/"+t);window.designerEditorFileChosen=null};window.openFileDialog(false,{path:"/"+this.currentProject.folder})},getMessage:function(e){var t=e.toLowerCase().replace(new RegExp("/","g"),"_");if(this.map.lang[t])return this.map.lang[t];return e}};e.Mobile.Viewer.prototype={getListElement:function(){this.cells=[];var t=4;var i=0;for(var s=0;s<20;s++){if(i==0){var a=new e.Mobile.ViewerElement(this,{element:{position:{top:0,left:0},size:{width:320,height:25}},defaultValues:{fill_mode:"stretch"},bindedParams:{"table/sections_background_color":"color"}});var r=new e.Mobile.ViewerElement(this,{element:{position:{top:0,left:0},size:{width:40,height:25}},defaultValues:{textColor:"#dedede"},bindedParams:{"table/sections_text_color":"textColor","table/sections_text_shadow_color":"textShadowColor"}});r.setText("A");r.setTextSize(12);var n=e.create("DIV",{props:{className:""},style:{width:"320px",height:"25px",position:"relative"},children:[a.canvasElement,r.canvasElement]});this.cells.push(n)}var o=new e.Mobile.ViewerElement(this,{element:{position:{top:0,left:0},size:{width:320,height:50}},defaultValues:{fill_mode:"stretch",height:50},bindedParams:{"table/cell_background/color":"color","table/row_height":"height","table/cell_background/image":"image"}});var l=new e.Mobile.ViewerElement(this,{element:{position:{top:10,left:40},size:{width:50,height:20}},type:"cellText",text:"Title",textPosition:{y:"center",x:0},bindedParams:{"table/cell_text_color":"textColor","table/cell_text_shadow_color":"textShadowColor"}});l.type="cellText";var h=new e.Mobile.ViewerElement(this,{element:{position:{top:25,left:40},size:{width:50,height:20}},type:"detailText",textSize:8,textPosition:{y:"center",x:0},text:"Subtitle",bindedParams:{"table/cell_detail_text_color":"textColor"}});l.setText("Title");h.setText("Subtitle");h.setTextSize(8);var c=e.create("DIV",{props:{className:"preview_cell"},style:{width:"320px",height:"50px"},children:[o.canvasElement,h.canvasElement,l.canvasElement]});e.addCustomEvent(o,e.Mobile.Events.VIEWER_ELEMENT_SET_SIZE,e.proxy(function(e){if(e.height>=50){this.style.height=e.height+"px"}else{this.style.height="50px"}},c));this.cells.push(c);i++;if(i==t)i=0}return e.create("DIV",{style:{top:"44px",width:"320px",height:"448px",position:"absolute",overflowY:"auto",overflowX:"hidden"},children:this.cells})},createTableScreen:function(){return e.create("DIV",{props:{className:"preview_screen"},style:{overflow:"hidden"},children:[e.create("DIV",{children:[this.getTopBarElement().canvasElement,this.getTitleElement().canvasElement,this.getButtonElement().canvasElement]}),this.getListElement(),this.getToolBarElement().canvasElement]})},createMainScreen:function(){return e.create("DIV",{props:{className:"preview_screen"},children:[new e.Mobile.ViewerElement(this,{element:{className:"",size:{width:320,height:448},position:{top:44,left:0}},defaultValues:{fill_mode:"repeat"},bindedParams:{"controller_settings/main_background/color":"color","controller_settings/main_background/image":"image","controller_settings/main_background/fill_mode":"fill_mode"}}).baseElement,this.getTopBarElement().baseElement,this.getTitleElement().baseElement,this.getBackButtonElement().baseElement,this.getButtonElement().baseElement,this.getSlidingPanel().baseElement,this.getToolBarElement().baseElement]})},createLoadScreen:function(){return e.create("DIV",{props:{className:"preview_screen"},children:[new e.Mobile.ViewerElement(this,{element:{className:"",size:{width:320,height:448},position:{top:44,left:0}},defaultValues:{fill_mode:"repeat"},bindedParams:{"controller_settings/loading_background/color":"color","controller_settings/loading_background/image":"image","controller_settings/loading_background/fill_mode":"fill_mode"}}).baseElement,this.getTopBarElement().baseElement,this.getTitleElement().baseElement,this.getBackButtonElement().baseElement,this.getButtonElement().baseElement,this.getToolBarElement().baseElement]})},getButtonElement:function(){return new e.Mobile.ViewerElement(this,{element:{className:"preview_button preview_button_right",position:{top:0,left:0},size:{width:70,height:30}},text:"Button",defaultValues:{fill_mode:"stretch",textColor:"#ffffff"},bindedParams:{"buttons/type":"","buttons/text_color":"textColor","buttons/main_background_image":"image"}})},getBackButtonElement:function(){var t=new e.Mobile.ViewerElement(this,{element:{className:"preview_button preview_button_back",position:{top:0,left:0},size:{width:35,height:30}},text:"",defaultValues:{fill_mode:"stretch",textColor:"#ffffff"},bindedParams:{"buttons/type":"buttonTypes","buttons/default_back_button":"backType","buttons/text_color":"textColor","buttons/main_background_image":"image"}});t._customHandle=e.proxy(function(i,s){if(i=="buttonTypes"){var a=false;for(var r in s){if(r=="back"){if(t.valuesSet["backType"]=="back"){a=true;t.valuesSet["image"]=s[r];t.valuesSet["backImage"]=s[r];t.handleParameter("image",s[r]);break}}}}if(i=="backImage"&&t.valuesSet["backType"]=="back"){}if(i=="backType"){if(s=="default"){t.valuesSet["width"]=60;t.text="< "+e.message("MOBILEAPP_BACK");t.handleParameter("width",60)}else if(s=="back_text"){t.valuesSet["width"]=60;t.text=e.message("MOBILEAPP_BACK");t.handleParameter("width",60)}else{t.valuesSet["width"]=35;t.text="";t.handleParameter("width",35);if(typeof this.editor.config!="undefined"){if(this.editor.config["buttons/type"]&&this.editor.config["buttons/type"]["back"]){t.defaultValues["backImageId"]=this.editor.config["buttons/type"]["back"];this.handleParameter()}}}}},this);return t},getTitleElement:function(){return new e.Mobile.ViewerElement(this,{element:{position:{top:0,left:105},size:{width:110,height:44}},text:e.message("MOBILEAPP_TITLE"),textSize:12,defaultValues:{fill_mode:"stretch",textColor:"#dedede"},bindedParams:{"controller_settings/title_color":"textColor"}})},getSlidingPanel:function(){var t=[];var i=new e.Mobile.ViewerElement(this,{element:{className:"preview_sliding_bar",size:{width:320,height:44},position:{top:44,left:0}},bindedParams:{"sliding_panel/background/color":"color","sliding_panel/background/image":"image","sliding_panel/background/image_large":"image"}});t.push(i.canvasElement);var s=Math.round(i.canvasElement.width/3)-5;for(var a=0;a<2;a++){t.push(new e.Mobile.ViewerElement(this,{element:{className:"preview_button",position:{top:45,left:s*a},size:{width:s,height:30}},text:"Button",defaultValues:{textColor:"#ffffff"},bindedParams:{"sliding_panel/text_color":"textColor"}}).canvasElement)}return{baseElement:e.create("DIV",{style:{top:"44px",width:"320px",height:"44px",overflowX:"hidden"},children:t})}},getTopBarElement:function(){return new e.Mobile.ViewerElement(this,{element:{className:"preview_bar",size:{width:320,height:44},position:{top:0,left:0}},defaultValues:{fill_mode:"stretch"},bindedParams:{"controller_settings/navigation_bar_background/color":"color","controller_settings/navigation_bar_background/image":"image"}})},getToolBarElement:function(){return new e.Mobile.ViewerElement(this,{element:{className:"preview_bottom_bar",size:{width:320,height:44},position:{bottom:0}},bindedParams:{"controller_settings/toolbar_background/color":"color","controller_settings/toolbar_background/image":"image"}})},setConfig:function(t){this.config=t;e.onCustomEvent(this,e.Mobile.Events.VIEWER_NEW_CONFIG_SET,[t])},addScreen:function(t,i,s){this.screens[t]=s;this.screenList.push(t);this.screenView.appendChild(s);var a=e.create("OPTION",{html:i,attrs:{value:t,id:t}});this.selectScreens.appendChild(a)},jumpToScreen:function(t){var i=new e.fx({start:this.screenView.scrollTop,finish:this.screenList.indexOf(t)*536,type:"accelerated",time:.3,step:.005,callback:e.proxy(function(e){this.screenView.scrollTop=e},this),callback_complete:function(){}});i.start()},init:function(){this.screenView=e.create("DIV",{props:{className:"preview_view"}});this.viewerWrapper=e.create("DIV",{props:{className:"designer-editor-wrap preview_viewer_wrapper"}});this.viewerWrapper.appendChild(e.create("DIV",{props:{className:"preview_hint"},html:e.message("MOBILEAPP_PREVIEW_HINT")}));this.viewerWrapper.appendChild(this.screenView);this.container.appendChild(e.create("SPAN",{props:{className:"adm-select-wrap"},children:[this.selectScreens=e.create("SELECT",{props:{className:"adm-workarea adm-select"},events:{change:e.proxy(function(e){var t=e.target;this.jumpToScreen(t.value)},this)}})]}));this.container.appendChild(this.viewerWrapper);this.screens={};this.screenList=[];this.addScreen("main",e.message("MOBILEAPP_PREVIEW_MAIN"),this.createMainScreen());this.addScreen("load",e.message("MOBILEAPP_PREVIEW_LOAD"),this.createLoadScreen());this.addScreen("table",e.message("MOBILEAPP_PREVIEW_LISTS"),this.createTableScreen())}};e.Mobile.ViewerElement.prototype={setBaseElement:function(t){this.baseElement=this.canvasElement=e.create("CANVAS",{props:{className:"preview_element"+(t.className?" "+t.className:"")},style:{position:"absolute",top:t.position.top+"px",left:t.position.left+"px",bottom:t.position.bottom+"px",right:t.position.right+"px"},attrs:{width:t.size.width+"px",height:t.size.height+"px"},events:{click:e.proxy(function(){var e=["fill_mode"];var t={color:3,image:2,textColor:1,textShadowColor:0};var i="";var s="";var a=[];for(var r in this.bindedParameters){a.push(r);var n=this.bindedParameters[r];if(!jsUtils.in_array(n,e)){if(i){if(this.valuesSet[n]&&this.valuesSet[i]&&t[i]>t[n])continue;s=r;i=n}else{s=r;i=n}}}if(r){this.viewer.editor.jumpToControl(s,a)}},this)}})},setText:function(e){this.text=e},setTextSize:function(e){this.textSize=e},createNode:function(e){if(typeof this["_createNode"]==="function")this._createNode(e)},isBackgroundNeeded:function(){var e=jsUtils.in_array("image",this.watched);var t=jsUtils.in_array("color",this.watched);var i=this.valuesSet["color"];var s=this.valuesSet["image"];return!(!e&&!t||e&&t&&(i||s)||e&&s||t&&i)},bindParameter:function(e,t){this.bindedParameters[e]=t;var i=this.viewer.config[e]||this.defaultValues[t];if(i){this.handleParameter(t,i)}this.watched.push(t)},customHandle:function(e,t,i){if(typeof this["_customHandle"]=="function")this._customHandle(e,t,i)},handleParameter:function(t,i){this.valuesSet[t]=i;this.delayedParamData={param:t,value:i};clearTimeout(this.applyTimeout);this.applyTimeout=setTimeout(e.proxy(function(){this.apply();this.applyTimeout=0},this),200)},getParamValue:function(e){if(this.valuesSet[e])return this.valuesSet[e];if(this.defaultValues[e])return this.defaultValues[e];return false},apply:function(){e.onCustomEvent(this,e.Mobile.Events.VIEWER_ELEMENT_APPLY,[this.valuesSet]);var t=this.canvasElement;var i=t.getContext("2d");i.clearRect(0,0,t.width,t.height);this.setSize();if(!this.drawColor()){if(!this.drawImage())this.drawText()}this.customHandle();this.isEmpty=this.isBackgroundNeeded()||jsUtils.in_array("textColor",this.watched)&&!this.valuesSet["textColor"];if(this.isEmpty){this.drawEmpty()}},setSize:function(){var t=this.getParamValue("width");var i=this.getParamValue("height");if(t)this.canvasElement.width=parseInt(t);if(i){this.canvasElement.height=parseInt(i)}e.onCustomEvent(this,e.Mobile.Events.VIEWER_ELEMENT_SET_SIZE,[{width:t,height:i}])},drawText:function(){if(this.text.length>0){var e=this.canvasElement;var t=e.getContext("2d");var i=this.getParamValue("textColor");var s=this.getParamValue("textShadowColor");t.fillStyle=i?i:"#dedede";t.font="bold "+this.textSize+"pt Helvetica";if(s){t.shadowOffsetY=1;t.shadowOffsetX=1;t.shadowColor=s;t.shadowBlur=1}else{t.shadowOffsetY=0;t.shadowOffsetX=0;t.shadowBlur=0}var a=0;var r=0;if(this.textPosition.x){t.textAlign="center";a=this.textPosition.x=="center"?e.width/2:parseInt(this.textPosition.x)}if(this.textPosition.y){r=this.textPosition.y=="center"?(e.height+this.textSize)/2:parseInt(this.textPosition.y)}t.fillText(this.text,a,r);return true}return false},drawEmpty:function(){var e=this.canvasElement;var t=e.getContext("2d");var i=20;var s=Math.round(e.width-4/i);var a=Math.round(e.height-4/i);var r=i;var n=i;t.shadowOffsetY=0;t.shadowOffsetX=0;t.shadowBlur=0;t.strokeStyle=this.cageStrokeColor;t.beginPath();for(var o=0;o<s;o++){t.moveTo(r,2);t.lineTo(r,e.height-2);r=r+i}for(var l=0;l<a;l++){t.moveTo(2,n);t.lineTo(e.width-2,n);n=n+i}t.stroke();t.closePath();t.shadowOffsetY=0;t.shadowOffsetX=0;t.shadowBlur=0;t.strokeStyle=this.elementStrokeColor;t.beginPath();t.moveTo(2,2);t.lineTo(e.width-2,2);t.lineTo(e.width-2,e.height-2);t.lineTo(2,e.height-2);t.lineTo(2,2);t.stroke();t.closePath()},drawColor:function(){var e=this.getParamValue("color");if(e){var t=this.canvasElement;var i=t.getContext("2d");i.rect(0,0,this.canvasElement.width,this.canvasElement.height);i.fillStyle=e;i.fill();return true}return false},drawImage:function(){var t=this.canvasElement;var i=t.getContext("2d");var s=this.getParamValue("image");if(s){var a=new Image;i.clearRect(0,0,t.width,t.height);var r=this.viewer.editor.imager.getSrcByID(s);if(r=="")return;a.fillMode=this.getParamValue("fill_mode");e.bind(a,"load",function(){if(this.fillMode=="crop"){var e=a.naturalWidth/a.naturalHeight;var s=t.width/t.height-e;var r=s>0?t.width:Math.round(t.height*e);var n=s>0?Math.round(t.width/e):t.height;var o=n-t.height;var l=r-t.width;i.drawImage(a,-l/2,-o/2,r,n)}else if(this.fillMode=="stretch"){i.drawImage(a,0,0,t.width,t.height)}else{var h=i.createPattern(a,"repeat");i.rect(0,0,t.width,t.height);i.fillStyle=h;i.fill()}});e.bind(a,"load",e.proxy(function(){this.drawText()},this));a.src=r}},onParameterValueChanged:function(e){var t=e.id;var i=e.value;if(this.bindedParameters[t]){this.handleParameter(this.bindedParameters[t],i)}},redrawElement:function(){this.valuesSet={};this.canvasElement.getContext("2d").clearRect(0,0,this.canvasElement.width,this.canvasElement.height);e.onCustomEvent(this,e.Mobile.Events.VIEWER_ELEMENT_REDRAW,[this.defaultValues]);for(var t in this.bindedParameters){var i=this.viewer.config[t];if(i)this.valuesSet[this.bindedParameters[t]]=i}this.apply()},init:function(){this.createNode()}};e.Mobile.Controls.Base.prototype={setValue:function(e,t,i){this.value=e;if(typeof i=="undefined"||i==true){if(typeof this["_setValue"]=="function")this._setValue(e)}if(t||false)this.changeListener(this.id,e)},getInput:function(){if(typeof this["_getInput"]=="function")return this._getInput();return this.input},getDisplayElement:function(){if(this.displayElement)return this.displayElement;if(typeof this["_getDisplayElement"]=="function")return this._getDisplayElement();else console.error("Can't get display element",this)},setOnChangeHandler:function(e){this.changeListener=e},highlight:function(t,i){new e.fx({start:0,finish:30,step:.005,type:"accelerated",time:.2,callback:function(e){t.style.backgroundColor="rgba("+i[0]+","+i[1]+","+i[2]+","+e/100+")"},callback_start:function(){},callback_complete:function(){new e.fx({start:30,finish:0,step:.005,type:"deccelerated",time:.8,callback:function(e){t.style.backgroundColor="rgba("+i[0]+","+i[1]+","+i[2]+","+e/100+")"},callback_start:function(){},callback_complete:function(){t.style.backgroundColor="#ffffff"}}).start()}}).start()},getMessage:function(e){var t=e.toLowerCase().replace(new RegExp("/","g"),"_");if(this.langs[t])return this.langs[t];return e}};for(var t in e.Mobile.Controls){if(t.toString()!="Base")e.extend(e.Mobile.Controls[t],e.Mobile.Controls.Base)}e.Mobile.Tools.extendProto(e.Mobile.Controls.MultiImage,{onCreate:function(){this.values={};this.items={};e.addCustomEvent(e.Mobile.Events.APP_FILE_LIST_GOT,e.proxy(function(){this.setValue(this.values,false)},this))},_getDisplayElement:function(){this.displayElement=e.create("DIV",{children:[this.itemsNode=e.create("DIV",{props:{className:"designer-multi-image-container"},attrs:{id:this.id}}),this.button=e.create("INPUT",{events:{click:e.proxy(function(){this.imager.open(this)},this)},attrs:{type:"button",value:e.message("MOBILEAPP_ADD_IMAGE")}})]});return this.displayElement},_setValue:function(e){if(typeof e=="object")this.values=e;else this.values={};for(var t in this.items){if(!this.values[t]){this.items[t]["element"].parentNode.removeChild(this.items[t]["element"]);delete this.items[t]}}for(var i in this.values){this.addItem(i,this.values[i])}},getDefaultCode:function(){var e=1;var t="type";var i=t+e;var s=true;while(s){s=false;for(var a in this.values){if(a==i){i=t+ ++e;s=true;break}}}return i},addItem:function(t,i){if(t==false)t=this.getDefaultCode();if(!this.items[t]){this.items[t]={img:e.create("IMG",{props:{className:"designer-multi-img"},attrs:{src:this.imager.getSrcByID(i,true)}}),input:e.create("INPUT",{props:{className:"type-text"},attrs:{"data-code":t,value:t},events:{keyup:e.proxy(function(e){if(e.keyCode==13){if(this.save(e.target))e.target.blur()}},this),blur:function(e){var t=e.target;var i=t.getAttribute("data-code");var s=t.value;if(i!=s){t.value=i}},change:e.proxy(function(e){this.save(e.target)},this)}})};var s=this;this.items[t]["element"]=e.create("DIV",{props:{className:"designer-multi-image-item"},events:{mouseover:function(){e.addClass(this,"designer-multi-image-item-hover")},mouseout:function(){e.removeClass(this,"designer-multi-image-item-hover")}},children:[e.create("DIV",{props:{className:"designer-multi-image-item-left"},children:[this.items[t]["img"]]}),e.create("DIV",{props:{className:"designer-multi-image-item-right"},children:[this.items[t]["input"],e.create("DIV",{props:{className:"designer-multi-image-remove-button"},events:{click:e.proxy(function(){var e=this.input.getAttribute("data-code");delete s.values[e];s.setValue(s.values,true)},this.items[t])}})]})]});this.itemsNode.appendChild(this.items[t]["element"])}else{this.items[t]["img"].src=this.imager.getSrcByID(i,true);this.items[t]["input"].value=t}return this.items[t]},save:function(e){var t=e;var i=t.getAttribute("data-code");var s=this.values[i];var a=t.value;if(a==""){this.highlight(t,[255,0,0]);return false}else if(this.items[a]&&i!=this.items[a].input.getAttribute("data-code")){this.highlight(this.items[a].input,[255,0,0]);this.highlight(t,[255,0,0]);return false}if(i!=t.value){delete this.values[i];this.values[t.value]=s;this.items[t.value]=this.items[i];delete this.items[i];this.setValue(this.values,true);t.setAttribute("data-code",t.value);this.highlight(t,[34,139,34])}return true},onImageChosen:function(e){var t=this.getDefaultCode();this.values[t]=e.id;var i=this.addItem(t,e.id);this.setValue(this.values,true);i.input.focus();i.input.select()}});e.Mobile.Tools.extendProto(e.Mobile.Controls.MultiValue,{onCreate:function(){this.values={};this.fieldIndex=0;this.items={};this.displayElement=null;this.itemsNode=null;e.addCustomEvent(e.Mobile.Events.CONFIG_LOADED_BEFORE,e.proxy(function(){this.items={};this.itemsNode.innerHTML=""},this))},_getDisplayElement:function(){this.displayElement=e.create("DIV",{children:[this.itemsNode=e.create("DIV",{props:{className:"designer-multi-image-container"},attrs:{id:this.id}}),this.button=e.create("INPUT",{events:{click:e.proxy(function(){this.addItem(false,"")},this)},attrs:{type:"button",value:e.message("MOBILEAPP_ADD_FILE")}})]});return this.displayElement},_setValue:function(e){if(typeof e!="object"){e={}}for(var t in this.items){if(!this.values[t]){this.items[t]["element"].parentNode.removeChild(this.items[t]["element"]);delete this.items[t]}}for(var i in e){this.addItem(i,e[i])}},getDefaultCode:function(){var e="file_"+this.fieldIndex;this.fieldIndex++;return e},addItem:function(t,i){var s=this.getDefaultCode();if(!this.items[s]){var a=this;this.items[s]={input:e.create("INPUT",{props:{className:"type-text file-name"},attrs:{"data-code":s,value:t?t:"",placeholder:e.message("MOBILEAPP_SELECT_FILE_NAME")},events:{keyup:e.proxy(function(e){},this),blur:function(e){},change:e.proxy(function(e){this.save()},this)}}),inputValue:e.create("INPUT",{props:{className:"type-text file-path"},attrs:{"data-code":s,value:i?i:"",placeholder:e.message("MOBILEAPP_SELECT_FILE")},events:{change:e.proxy(function(){this.save()},this)}})};this.items[s]["element"]=e.create("DIV",{props:{className:"designer-multi-value-item"},events:{mouseover:function(){e.addClass(this,"designer-multi-image-item-hover")},mouseout:function(){e.removeClass(this,"designer-multi-image-item-hover")}},children:[e.create("DIV",{props:{className:"designer-multi-value-input-wrap"},children:[this.items[s]["input"]]}),e.create("DIV",{props:{className:"designer-chain-icon"}}),e.create("DIV",{props:{className:"designer-multi-value-input-wrap"},children:[this.items[s]["inputValue"],e.create("DIV",{props:{className:"designer-open-file-dialog-button"},events:{click:e.proxy(function(){a.editor.openFileDialog(e.proxy(function(e){this.items[s]["inputValue"].value=e;a.save()},this))},this)}}),e.create("DIV",{props:{className:"designer-multi-image-remove-button"},events:{click:e.proxy(function(){this.element.parentNode.removeChild(this.element);a.save()},this.items[s])}})]})]});this.itemsNode.appendChild(this.items[s]["element"])}else{this.items[s]["input"].value=s}this.items[s]["input"].focus();return this.items[s]},save:function(){var t=e.findChildren(this.itemsNode,{tagName:"INPUT",className:"file-name"},true);var i=e.findChildren(this.itemsNode,{tagName:"INPUT",className:"file-path"},true);var s={};for(var a in t){if(t[a].value!=""&&i[a].value!="")s[t[a].value]=i[a].value}this.setValue(s,true,false);return true}});e.Mobile.Tools.extendProto(e.Mobile.Controls.Image,{onImageChosen:function(e){this.setValue(e.id,true)}});e.Mobile.Tools.extendProto(e.Mobile.Controls.Color,{_setValue:function(t){this.input.value=t;this.colorBox.style.background=t;if(t=="")e.hide(this.deleteButton);else e.show(this.deleteButton)},_getDisplayElement:function(){this.input=e.create("INPUT",{props:{className:"designer-simple-string"},attrs:{type:"text",id:this.id,placeholder:"#FFFFFF"}});e.addClass(this.input,"color-input");this.colorBox=e.create("SPAN",{props:{className:"color-square"}});this.displayElement=e.create("SPAN",{attrs:{id:"wrap-"+this.id},props:{className:"designer-input-wrap"},children:[e.create("DIV",{props:{className:"designer-color-wrap"},children:[this.input,this.colorBox]}),this.deleteButton=e.create("SPAN",{props:{className:"designer-color-button-delete"},events:{click:e.proxy(function(){this.setValue("",true)},this)}})]});var t=e.proxy(function(t){var i=t.target;i.parentNode.appendChild(this.picker.pCont);this.picker.oPar.OnSelect=e.proxy(function(e){i.value=e;this.colorBox.style.background=e;this.setValue(e,true)},this);this.picker.Close();this.picker.Open(i)},this);e.bind(this.input,"click",t);e.bind(this.colorBox,"click",t);var i=e.proxy(function(e){var t=e.target;if(t.oldValue==t.value)return;t.oldValue=t.value;if(t.value==""){this.deleteButton.style.display="none"}else{if(this.input.value[0]!="#"){this.input.value="#"+this.input.value;return}this.deleteButton.style.display="inline-block"}this.colorBox.style.background=t.value;this.changeListener(this.id,t.value)},this);e.bind(this.input,"focus",function(e){var t=e.target;t.oldValue=t.value});e.bind(this.input,"blur",i);e.bind(this.input,"keyup",i);return this.displayElement}})})();
//# sourceMappingURL=designer.map.js