json-object-editor
Version:
JOE the Json Object Editor | Platform Edition
1 lines • 401 kB
JavaScript
$c.isMobile()?document.getElementsByTagName("html")[0].className+=" touch joesmall-size":document.getElementsByTagName("html")[0].className+=" no-touch joelarge-size",window._joeEditingHash=!1;var _webworkers=!1,_joeworker;window.Worker&&(_webworkers=!0);var joe_web_dir="//"+location.hostname+":"+(location.port||("https:"==location.protocol?443:80))+"/JsonObjectEditor/",__gotoJoeSection;function __require(file,callback){var head=document.getElementsByTagName("head")[0],script=document.createElement("script");script.src=file,script.type="text/javascript",script.onload=callback,script.onreadystatechange=function(){"complete"==this.readyState&&callback()},head.appendChild(script)}function JsonObjectEditor(specs){var self=this,htmlRef=document.getElementsByTagName("html")[0];self.initialDocumentTitle=document.title,$c.TEMPLATE_VARS.push({variable:"/textarea",value:"</textarea>"},{variable:"textarea",value:"<textarea>"},{variable:"SERVER",value:"//"+$c.SERVER});var initialized=!1,colCount=1,listMode=!1,gridMode=!1,tableMode=!1,tableSpecs,multiEdit=!1;this.VERSION="1.0.1",window._joes=window._joes||[],this.joe_index=window._joes.length,window._joes.length||(window._joe=this),this.Error={log:[],add:function(message,error,data){var payload={caller:arguments.callee.caller,callerargs:arguments.callee.caller.arguments,message:message,error:error,stack:new Error(error).stack,data:data,timestamp:(new Date).toISOString(),_id:cuid()};self.Error.log.push(payload),logit("[error]: "+message)},show:function(){self.show(self.Error.log,{schema:{title:"${message}",idprop:"_id",listView:{title:"<joe-title>${message}</joe-title><joe-subtitle>${timestamp}</joe-subtitle>",listWindowTitle:"Errors"},fields:["error:code","message","stack:code",{name:"data",type:"content",run:function(data,obj){return"<div><pre>"+tryEval(data)+"</pre></div>"}},"callerargs:code","timestamp:guid","_id"]}})}},window._joes.push(this),this.Cache={static:{},list:[],lookup:{},clear:function(){self.Cache.lookup={},self.Cache.list=[]},remove:function(id){},get:function(id,specs){var cacheitem=self.Cache.lookup[id];if(cacheitem&&"function"==typeof cacheitem.value&&"callback"==cacheitem.type)return cacheitem.value(cacheitem.data,cacheitem.id);if(!cacheitem){var obj=self.search(id)[0]||!1;return!!obj&&(self.Cache.add(obj,{id:id}),obj)}return cacheitem.value},callback:function(id){var cacheitem=self.Cache.lookup[id];if("function"==typeof cacheitem.value)return cacheitem.value(cacheitem.data,cacheitem.id);logit("cache item is not a function")},add:function(value,specs){specs=specs||{};var obj=$.extend({id:specs.id||cuid(),value:value,parent:self.joe_index},specs);return self.Cache.list.push(obj.id),self.Cache.lookup[obj.id]=obj,obj}},this.Cache.set=this.Cache.add,this.history=[];var defaults={localStorage:!1,container:"body",joeprofile:{lockedFields:["joeUpdated"],hiddenFields:[]},profiles:{},fields:{},schemas:{rendering:{title:"HTML Rendering",callback:function(){alert("yo")}}},compact:!1,useControlEnter:!0,useEscapeKey:!1,autoInit:!1,autosave:1e4,dynamicDisplay:$(window).height()<800&&$c.isMobile()?12:20,sans:!1,listSubMenu:!0,documentTitle:!1,style:{inset:!0,cards:!1},speechRecognition:!1},goingBackFromID,goingBackQuery;for(var s in this.specs=$.extend({},defaults,specs||{}),this.specs.localStorage&&"undefined"==typeof Storage&&(alert("no local storage"),this.specs.LocalStorage=!1),this.Indexes={_add:function(idprop,dataitem){self.Indexes[idprop]=self.Indexes[idprop]||{},self.Indexes[idprop][dataitem[idprop]]=dataitem},_usage:0},this.Printer={init:function(){document.querySelector("print-joe")||document.body.appendChild(document.createElement("print-joe"))},print:function(){self.Printer.init();var cln=document.getElementsByTagName("joe-panel-content")[0].cloneNode(!0);document.querySelector("print-joe").innerHTML="",document.querySelector("print-joe").appendChild(cln);var panelContent=document.querySelector("print-joe joe-panel-content");panelContent.className="joe-panel-content";var activeNodes=document.querySelectorAll("print-joe joe-panel-content .joe-content-section.active");if(activeNodes.length){panelContent.innerHTML="";for(var i=0;i<activeNodes.length;i++)panelContent.appendChild(activeNodes[i])}window.print(),document.querySelector("print-joe").innerHTML=""}},this.Data={},this.Render={schema_icon:function(schema,classes){var icon=self.schemas[schema]&&self.schemas[schema].menuicon||"";return icon&&(icon=`<joe-icon class="${classes||""}">${icon}</joe-icon>`),icon},ref_chip:function(things,specs){specs="string"==typeof specs?{cssclass:specs}:specs||{};const items=Array.isArray(things)?things:things?.tags||[];if(!items.length)return"";const labelProp=specs.labelProp||"name",tooltipProp=!1===specs.tooltipProp?null:specs.tooltipProp||"info";let html=`<joe-chips class="${specs.cssclass||""}">`;return items.forEach(ref=>{const obj="object"==typeof ref?ref:$J.get(ref);if(!obj)return;const label=obj[labelProp]||"",title=tooltipProp&&obj[tooltipProp]?` title="${obj[tooltipProp]}"`:"";let style="";if(specs.useStatusColor&&obj.status){const statusObj=_joe.Cache.get(obj.status);statusObj?.color&&(style=` style="border-left:4px solid ${statusObj.color}"`)}else obj.color&&(style=` style="background:${obj.color}"`);html+=`<joe-chip data-id="${obj._id}"${title}${style}>${label}</joe-chip>`}),html+="</joe-chips>",html}},this.container=$(this.specs.container),this.fields=this.specs.fields,this.Fields={reset:function(propname){var field=self.Fields.get(propname);self.current.object[propname]=field.reset,self.Fields.rerender(propname)},onPanelShow:function(cur){cur=cur||_jco();var currentFields=self.current.fields;logit("current fields",currentFields),currentFields.map(f=>{f.onPanelShow&&f.onPanelShow(cur)})}},this.schemas=this.specs.schemas,_joe.schemas)_joe.schemas[s].__schemaname=_joe.schemas[s].name=s,_joe.schemas[s]._id=cuid();function createTitleObject(specs){specs=specs||{};var titleObj=$.extend({},self.current.object),list=specs.list||self.current.list;if(list){var lcount=list.length;self.current.subset&&(lcount=list.where(self.current.subset.filter).length),titleObj._listCount=lcount||"0",titleObj._subsetName=self.current.subset&&self.current.subset.name+" "||""}self.current.title=specs.title||self.getCascadingProp("title")||self.current.schema&&"new "+self.current.schema.__schemaname||"Json Object Editor",self.current.subtitle=specs.subtitle||self.getCascadingProp("subtitle");var title=fillTemplate(self.propAsFuncOrValue(self.current.title),titleObj),subtitle=fillTemplate(self.propAsFuncOrValue(self.current.subtitle),titleObj);return titleObj.docTitle=title,titleObj.subTitle=subtitle,titleObj}function renderSubmenuButtons(buttons){var content,html="";if(buttons=self.propAsFuncOrValue(buttons||listMode&&self.getCascadingProp("headerListMenu")||!listMode&&self.getCascadingProp("headerMenu"))){var h=self.renderMenuButtons(buttons,"joe-submenu-button");h&&(content=!0),html+=h}return{html:html,content:content}}function renderSectionAnchors(){var anchorhtml='<joe-submenu-section-anchors><joe-panel-button class="sections-toggle" onclick="'+getSelfStr+'.Sections.toggle(this);">'+self.SVG.icon.sections+" <joe-button-label>"+(self.current.sections&&self.current.sections.count()||"")+" sections</joe-button-label></joe-panel-button>";anchorhtml+='<div class="joe-submenu-section" onclick="_joe.Sections.gotoTop('+self.joe_index+')">^ top</div>';var section,scount=0,template='<joe-submenu-section class="joe-submenu-section f${renderTo}" data-section="${name}" data-panel="${renderTo}" '+('onclick="getJoe('+self.joe_index+").gotoSection('${id}');\"")+" "+('ondblclick="getJoe('+self.joe_index+").gotoSection('${id}',{focus:'${id}'});\"")+">${${anchor}||${name}}</joe-submenu-section>";for(var secname in self.current.sections)(section=_getSection(secname)).hidden||(anchorhtml+=fillTemplate(template,section),scount++);return{count:scount,code:anchorhtml+="<div class='clear'></div></joe-submenu-section-anchors>"}}this.current={},this.current.clear=function(){self.current.list=null,self.current.subsets=null,self.current.subset=null,self.current.filters={},self.current.fields=[],self.current.schema=null,self.current.object=null,self.current.reset={},self.current.cache={},self.current.title=null,self.current.keyword="",1==_joes.length&&(document.title=self.initialDocumentTitle)},this.defaultProfile=this.specs.defaultProfile||this.specs.joeprofile,this.current.profile=this.defaultProfile,this.ace_editors={},this.Render.stripeColor=function(opt,colorfunc){var color=self.propAsFuncOrValue(colorfunc||opt.stripecolor,opt,null,_jco()),title="";return color&&$c.isObject(color)&&(title=' title="'+color.title+'" ',color=color.color),"<joe-stripe-color "+title+(color&&'style="background-color:'+color+';"'||"")+"></joe-stripe-color>"},this.Render.bgColor=function(opt,colorfunc){var color=self.propAsFuncOrValue(colorfunc||opt.bgcolor,opt,null,_jco());return color&&$c.isObject(color)&&(color=color.color),"<joe-bg-color "+(color&&'style="background-color:'+color+';"'||"")+"></joe-bg-color>"},this.Render.itemCheckbox=function(listItem,schema,specs){specs=specs||{};var checkbox=self.propAsFuncOrValue(self.getCascadingProp("checkbox",schema),listItem),idprop=specs.idprop||self.getIDProp();if(checkbox){var cbox_prop=checkbox,cbox_percentage=null,cbox_title="";"object"==$.type(checkbox)&&(cbox_prop=checkbox.prop,cbox_title=checkbox.title||cbox_prop,cbox_percentage=self.propAsFuncOrValue(checkbox.percentage,listItem));var cb_label=self.propAsFuncOrValue(checkbox.label,listItem);checkbox='<joe-checkbox title="'+cbox_title+'" class="'+([!0,"true"].contains(listItem[cbox_prop])?"checked":"")+'"onclick="_joe.checkItem(\''+listItem[idprop]+"','"+cbox_prop+"',null,this)\">"+(!1!==cbox_percentage&&checkbox.hasOwnProperty("percentage")?"<joe-checkbox-percentage>"+Math.round(100*cbox_percentage)+"%</joe-checkbox-percentage>":"")+(cb_label&&"<joe-checkbox-label>"+cb_label+"</joe-checkbox-label>"||"")+"</joe-checkbox>"}else checkbox="";return checkbox},this.init=function(callback){if(initialized)return!1;beginLogGroup("JOE init"),self.current.clear();var respond_timeout,html=self.renderFramework(self.renderEditorHeader()+self.renderEditorContent()+self.renderEditorFooter());self.container.append(html),self.overlay=$(".joe-overlay[data-joeindex="+self.joe_index+"]"),self.panel=self.overlay.find(".joe-overlay-panel"),self.initKeyHandlers(),self.Speech.init(),self.readHashLink(),window.addEventListener("hashchange",function(newH,oldH){if(!($GET("!")||location.hash)||0!=self.joe_index||!specs.useHashlink)return!1;window._joeEditingHash||self.readHashLink()},!1),$(window).on("resize",function(){self.resizeOk()&&(clearTimeout(respond_timeout),respond_timeout=setTimeout(self.respond,200))}),self.initButtons(),initialized=!0,self.respond(),endLogGroup(),self.Components.init(),callback&&callback()},this.initButtons=function(){$(document).on("click","joe-button",function(e){e.preventDefault();var actionName=$(this).attr("action");if(actionName){var currentObject=_joe.current?_joe.current.object:null,currentSchema=_joe.current&&_joe.current.schema,currentSchemaMethods=currentSchema?currentSchema.methods:null;JOE.async&&"function"==typeof JOE.async[actionName]?JOE.async[actionName](currentObject,e):currentSchemaMethods&&"function"==typeof currentSchemaMethods[actionName]?currentSchemaMethods[actionName](currentObject,e):console.warn("No method found for joe-button action:",actionName)}else console.warn("No action defined for joe-button")})},this.resizeOk=function(){return!$c.isMobile()||"INPUT"!=document.activeElement.tagName},this.initKeyHandlers=function(){self.specs.useBackButton&&(window.onkeydown=function(e){var code=e.keyCode,isInputElement=-1!=["input","select","textarea"].indexOf(e.target.tagName.toLowerCase()),isEditable=e.target.isContentEditable||$(e.target).closest("joe-ai-chatbox").length;if(8==code)return isInputElement||isEditable?void 0:(self.goBack(),!1);if(-1==[37,39,38,40,13,16,17,27].indexOf(code)){if(e.altKey)switch(code){case 70:self.quickFind(),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault();break;case 78:self.quickAdd(),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault();break;case 80:self.Printer.print(),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}else if(listMode){$(document.activeElement)&&$(document.activeElement)[0]!=$(".joe-submenu-search-field")[0]&&(self.overlay.find(".joe-submenu-search-field").focus(),$(".joe-panel-content-option.keyboard-selected").removeClass("keyboard-selected"))}else if((e.ctrlKey||e.metaKey)&&83===code)self.container.find(".joe-button.joe-quicksave-button").length&&(self.updateObject(null,null,!0),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault())}else{if($(".joe-text-autocomplete.active").length){var sel=".joe-text-autocomplete-option.visible.keyboard-selected",keyboardSelected=$(sel)[0],keyboardSelectedIndex=$(sel).length?$(sel).index():-1;switch(code){case 38:--keyboardSelectedIndex>-1&&keyboardSelectOption(".joe-text-autocomplete-option.visible");break;case 40:++keyboardSelectedIndex<$(".joe-text-autocomplete-option.visible").length&&keyboardSelectOption(".joe-text-autocomplete-option.visible");break;case 13:-1!=keyboardSelectedIndex&&keyboardSelected.click()}}if(listMode)if(e.altKey){if(self.current.subsets){var subindex=self.current.subsets.indexOf(self.current.subset)+1;switch(code){case 38:$("joe-subset-option").eq(subindex-1).click();break;case 40:$("joe-subset-option").eq(subindex+1).click()}}}else{keyboardSelectedIndex=$(".joe-panel-content-option.keyboard-selected").length?$(".joe-panel-content-option.keyboard-selected").index():-1;switch(code){case 38:--keyboardSelectedIndex>-1&&keyboardSelectOption(".joe-panel-content-option",top);break;case 40:++keyboardSelectedIndex<currentListItems.length&&keyboardSelectOption(".joe-panel-content-option",top);break;case 13:-1!=keyboardSelectedIndex&&$(".joe-panel-content-option.keyboard-selected").find(".joe-panel-content-option-content").click()}}else if(e.altKey)switch(code){case 219:case 221:var sside=219==code?"left":"right";self.current.sidebars[sside].content&&!self.current.sidebars[sside].hidden&&self.toggleSidebar(sside)}else if(e.ctrlKey)switch(code){case 37:self.previous();break;case 39:self.next()}else if(13==code){var ae=$(document.activeElement);if(ae&&ae.is("input")){var fieldobj=ae.parents(".joe-object-field");if(fieldobj.length)try{fieldobj.find(".joe-plus-button").click()}catch(e){self.Error.add("adding new row to objectlist",e)}}}function keyboardSelectOption(selector,top){$(selector+".keyboard-selected").toggleClass("keyboard-selected");var el=$(selector).eq(keyboardSelectedIndex);el.addClass("keyboard-selected"),self.overlay.find(".joe-submenu-search-field").blur(),el[0].scrollIntoView(top)}}})},this.getMode=function(){return listMode&&self.current.list?"list":self.current.object?"details":!!self.current.list&&"list"},this.renderFramework=function(content){return'<joe-overlay class="joe-overlay sans cols-'+colCount+" style-variant1 "+(self.specs.compact?" compact ":"")+(self.specs.sans?" sans ":"")+'" data-joeindex="'+this.joe_index+'"><joe-panel class="joe-overlay-panel">'+(content||"")+'</joe-panel><div class="joe-mini-panel"></div></joe-overlay>'},this.populateFramework=function(data,setts){self.current.cache={},self.overlay.removeClass("multi-edit");var joePopulateBenchmarker=new Benchmarker;self.current.reset=self.current.reset||{},beginLogGroup("JOE population");var specs=setts||{};self.current.specs=setts,self.current.data=data,self.current.userSpecs=$.extend({},setts),gridMode="grid"==self.current.specs.viewMode,tableMode="table"==self.current.specs.viewMode,self.current.specs.noHistory||self.history.push({specs:self.current.userSpecs,data:self.current.data});var currentSubsets,schema=setts.schema||"",profile=setts.profile||null,callback=setts.callback||null,datatype=setts.datatype||"",title=setts.title||"";(self.current.callback=callback||null,"string"==$.type(data)&&"string"!=datatype&&self.getDataset(data,{boolean:!0})&&(!specs.schema&&self.schemas[data]&&(schema=data),data=self.getDataset(data)),specs.schema=this.setSchema(schema),colCount=self.current.specs.colCount||specs.schema&&specs.schema.colCount||1,"small-size"==self.sizeClass&&(colCount=1),specs.preformat=specs.schema&&specs.schema.preformat||specs.preformat||function(d){return d},data=specs.preformat(data),"object"!=$.type(data)&&"object"!=datatype||(specs.object=data,specs.menu=specs.menu||specs.schema&&specs.schema.menu||self.specs.menu||specs.multiedit&&__defaultMultiButtons||__defaultObjectButtons,specs.mode="object",self.current.object=data),self.toggleMultiEditMode(specs,data),listMode=!1,"array"==$.type(data)||"array"==datatype)&&(listMode=!0,specs.list=data,specs.menu=specs.listMenu||specs.schema&&specs.schema.listMenu||__defaultButtons,specs.mode="list",self.current.list=data,"function"==typeof(currentSubsets=setts.subsets||specs.schema&&specs.schema.subsets||null)&&(currentSubsets=currentSubsets()),self.current.specs.subset&¤tSubsets&¤tSubsets.where({$or:[{name:specs.subset},{id:specs.subset},{group_start:specs.subset}]}).length?self.current.subset=currentSubsets.where({$or:[{name:specs.subset},{id:specs.subset},{group_start:specs.subset}]})[0]||!1:"All"==self.current.specs.subset?self.current.subset={name:"All",filter:{}}:self.current.subset=currentSubsets&¤tSubsets.where({default:!0})[0]||null,self.current.subsets=currentSubsets,self.current.sorter=setts.sorter||self.current.subset&&self.current.subset.sorter||specs.schema&&specs.schema.sorter||"name","string"==$.type(self.current.sorter)&&(self.current.sorter=[self.current.sorter]));"list"==specs.mode?self.current.submenu=self.current.specs.listsubmenu||self.current.specs.submenu||specs.schema&&specs.schema.listSubMenu||self.specs.listSubMenu:self.current.submenu=self.current.specs.submenu||specs.schema&&specs.schema.subMenu||self.specs.subMenu,"none"==self.current.submenu&&(self.current.submenu=null),"string"==$.type(data)&&"rendering"==datatype?(specs.rendering=data,specs.menu=[__replaceBtn__],specs.mode="rendering",self.current.rendering=specs.rendering):"string"!=$.type(data)&&"string"!=datatype||(specs.text=data,specs.menu=__defaultButtons,specs.mode="text",self.current.text=specs.text),specs.listWindowTitle=specs.list&&(specs._listMenuTitle||specs._listWindowTitle||self.getCascadingProp("listWindowTitle")||getProperty("specs.list.windowTitle")||specs.schema&&(specs.schema._listMenuTitle||specs.schema._listWindowTitle))||!1,specs.title=specs.listWindowTitle||title||specs.schema&&(specs.schema.title||specs.schema._title)||"Viewing "+(self.current.schema&&self.current.schema.__schemaname||"string"==typeof self.current.userSpecs.schema&&self.current.userSpecs.schema||specs.mode).capitalize(),specs.profile=profile&&self.specs.profiles[profile]||self.specs.joeprofile,self.current.profile=specs.profile,self.cleanUp(),tableSpecs=self.current.schema&&(self.current.schema.table||self.current.schema.tableView)?$.extend({cols:["name",self.getIDProp()]},self.current.schema&&(self.current.schema.table||self.current.schema.tableView)||{}):null;var contentBM=new Benchmarker;beginLogGroup("Content");var content=self.renderEditorContent(specs);endLogGroup(),_bmResponse(contentBM,"JOE [Content]");var chromeBM=new Benchmarker,html=self.renderEditorHeader(specs)+self.renderEditorSubmenu(specs)+content+self.renderEditorFooter(specs)+self.renderMessageContainer();return _bmResponse(chromeBM,"JOE [overlay-chrome]"),self.overlay.find(".joe-overlay-panel").html(html),!self.current.specs.noHistory&&self.history.length&&$.extend(self.history[self.history.length-1],{_joeHistoryTitle:self.overlay.find(".joe-panel-title").html()}),self.updateHashLink(),_bmResponse(joePopulateBenchmarker,"----Joe Populated"),endLogGroup(),html},this.toggleMultiEditMode=function(specs,data){multiEdit=self.current.userSpecs&&self.current.userSpecs.multiedit||!1},this.Header={},this.toggleHelpMenu=function(show,target){},this.listUnsavedChanges=function(){},this.Header.Render=this.renderEditorHeader=function(specs){var BM=new Benchmarker,titleObj=createTitleObject(specs=specs||{}),title=titleObj.docTitle||self.current.schema&&"new "+self.current.schema.__schemaname;titleObj.subTitle;if(self.specs.documentTitle){var doctitle=!0===self.specs.documentTitle?self.current.title:self.propAsFuncOrValue(self.specs.documentTitle,self.current.title);document.title=fillTemplate(self.propAsFuncOrValue(doctitle),titleObj)}var close_action=specs.close_action||'onclick="getJoe('+self.joe_index+').closeButtonAction()"',reload_action=specs.reload_action||'onclick="getJoe('+self.joe_index+').reload()"';!function(){var html="";specs.minimode||(html+='<div class="jif-panel-header-button joe-panel-help" onclick="_joe.toggleHelpMenu()" title="help">'+self.SVG.icon.help+"</div>")}();var unsaved_icon=function(){var html="";return specs.minimode?"":html+='<div class="jif-panel-header-button joe-panel-unsaved" onclick="_joe.updateObject(this,null,true);" title="unsaved changes">'+self.SVG.icon.unsaved+"</div>"}(),reload_button=(specs.speech_action||self.joe_index,specs.minimode?"":'<div class="jif-panel-header-button joe-panel-reload" title="reload" '+reload_action+'><span class="jif-reload"></span></div>'),mic_button=!self.specs.speechRecognition||specs.minimode?"":'<div class="jif-panel-header-button joe-panel-speech" title="speech" id="speech-button-'+self.joe_index+'">M</div>',close_button='<div class="jif-panel-header-button joe-panel-close" title="close" '+close_action+">"+self.SVG.icon.close+"</div>",schema_button=!specs.minimode&&self.current.schema&&self.current.schema.menuicon&&'<joe-schema-icon class="clickable" title="'+self.current.schema.__schemaname+'" onclick="goJoe(\''+self.current.schema.__schemaname+"')\">"+self.current.schema.menuicon+"</joe-schema-icon>"||"",back_button=!specs.minimode&&function(){var html="";return self.history.length>1&&(html+='<div class="jif-header-back-btn jif-panel-header-button standard-button" onclick="window.history.back()" title="back">'+self.SVG.icon.left+"</div>"),html}()||"",left_buttons=[back_button,schema_button],right_buttons=[close_button,mic_button,reload_button,unsaved_icon],html="<joe-panel-header >"+(specs.schema&&specs.schema.subsets&&self.renderSubsetselector(specs.schema)||specs.subsets&&self.renderSubsetselector(specs)||"")+left_buttons.join(" ")+'<div class="joe-vcenter joe-panel-title-holder"><span class="joe-panel-title">'+(("<div>"+title+"</div>").toDomElement().innerText||title||"Json Object Editor")+'</span></div><joe-panel-header-buttons class="right-side">'+right_buttons.join(" ")+'<div class="clear"></div></joe-panel-header-buttons><div class="clear"></div></joe-panel-header>';return _bmResponse(BM,"[Header] rendered"),html},this.closeButtonAction=function(prechecked){if(this.checkChanges()){self.history=[],self.panel.addClass("centerscreen-collapse"),self.hide(500),self.current.clear(),$(self.container).trigger({type:"hideJoe",index:self.joe_index}),self.updateHashLink();var closeAction=self.getCascadingProp("onPanelHide");closeAction&&closeAction(self.getState()),self.Autosave.deactivate()}},this.goBack=function(obj){if(this.checkChanges()){if(self.current.object){var gobackItem=self.current.object[self.getIDProp()];gobackItem&&(goingBackFromID=gobackItem)}self.history.pop();var joespecs=self.history.pop();if(joespecs){if(obj&&$c.isArray(joespecs.data)){var objid=obj[self.getIDProp()];if(objid){var query={};query[self.getIDProp()]=objid;var found=joespecs.data.where(query);found.length&&$.extend(found[0],obj)}}joespecs.keyword&&(goingBackQuery=joespecs.keyword);var specs=$.extend({},joespecs.specs);specs.filters=joespecs.filters,self.show(joespecs.data,specs)}else self.closeButtonAction(!0)}},this.cleanUp=function(){self.current.fields=[],self.shiftSelecting=!1,self.allSelected=!1,self.current.userSpecs&&self.current.userSpecs.multiedit?self.overlay.addClass("multi-edit"):self.overlay.removeClass("multi-edit")},this.renderEditorSubmenu=function(specs){beginLogGroup("Submenu");var BM=new Benchmarker,sectionAnchors=renderSectionAnchors(),submenuButtons=renderSubmenuButtons();if(!(self.current.submenu||sectionAnchors.count||listMode||self.getCascadingProp("headerMenu")))return"";var subSpecs={search:!0,itemcount:!0,filters:$c.getProperty(self.current,"userSpecs.filters")||$c.getProperty(self.current,"schema.filters")||$c.getProperty(self.current,"schema.subsets")||!1,numCols:self.current.schema.columns||0},userSubmenu="object"!=$.type(self.current.submenu)?{}:self.current.submenu;if($.extend(subSpecs,userSubmenu),"list"==specs.mode)var filters_obj=self.Filter.getCached(),submenu='<div class="joe-panel-submenu">'+self.Aggregator.renderToggleButton()+self.renderViewModeButtons(subSpecs)+self.renderColumnCountSelector(subSpecs.numCols)+self.renderSorter()+(subSpecs.filters&&self.renderSubmenuFilters(subSpecs.filter)||"")+(subSpecs.search&&self.renderSubmenuSearch(subSpecs.search)||"")+(subSpecs.itemcount&&self.renderSubmenuItemcount(subSpecs.itemcount)||"")+submenuButtons.html+"</div><div class='joe-filters-holder'>"+function(){var act,sh='<div><joe-menu-label title="select one subset at a time"><b>Subsets</b></joe-menu-label>',starting=[];self.current.schema&&self.current.schema.hideAllSubset||starting.push({name:"All",filter:{}});var group=null;return starting.concat(_joe.current.subsets||[]).map(function(opt){if(opt.group_start)group=opt.group_start,sh+=renderOptionGroupStart(opt,"joe-subset-option");else if(opt.group_end)sh+="</joe-option-group>",group=null;else{var idval=opt.id||opt.name||"";if(!opt.condition||self.propAsFuncOrValue(opt.condition)){"active"==(act=self.current.subset&&self.current.subset.name==opt.name||!self.current.subset&&"All"==opt.name?"active":"")&&group&&(sh=sh.replace('<joe-option-group id="'+group+'-group" class="collapsed','<joe-option-group id="'+group+'-group" class="'));let optCount=self.current.list.where(opt.filter).length;sh+=`<joe-subset-option data-subset="${idval}" class="joe-subset-option ${act} " \n onclick="getJoe(${self.joe_index}).selectSubset('${(opt.id||opt.name||"").toString().replace(/\'/g,"\\'")}');">`+renderOptBorderColor(opt)+renderOptBGColor(opt)+renderOptStripeColor(opt)+'<span style="position:relative;">'+opt.name+"</span>"+`<option-count>${optCount}</option-count></joe-subset-option>`}}}),sh+="</div>",_bmResponse(BM,"subsets rendered"),sh}()+(filters_obj&&function(){_bmResponse(BM,"filters start");var fh='<div><joe-menu-label title="select multiple filters at once"><b>Filters</b></joe-menu-label>',filters=self.current.schema.filters;filters=self.propAsFuncOrValue(filters);var group=null;return(filters||[]).map(function(opt){if(opt.group_start)group=opt.group_start,fh+=renderOptionGroupStart(opt,"joe-filter-option");else if(opt.group_end)fh+="</joe-option-group>",group=null;else{var idval=opt.id||opt.name||"";if(!opt.condition||self.propAsFuncOrValue(opt.condition)){act="",self.current.filters&&self.current.filters[idval]?act="active":opt.hasOwnProperty("default")&&(act=self.propAsFuncOrValue(opt.default)?"active":"",self.toggleFilter(opt.name)),"active"==act&&group&&(fh=fh.replace('<joe-option-group id="'+group+'-group" class="collapsed">','<joe-option-group id="'+group+'-group" class="">'));let optCount=self.current.list.where(opt.filter).length;fh+='<joe-filter-option data-filter="'+idval+'" class="joe-filter-option '+act+'" onclick="getJoe('+self.joe_index+").toggleFilter('"+idval+"',this);\">"+renderOptBorderColor(opt)+renderOptBGColor(opt)+renderOptStripeColor(opt)+'<span class ="joe-option-checkbox"></span><span style="position:relative;">'+opt.name+"</span>"+`<option-count>${optCount}</option-count></joe-filter-option>`}}}),fh+='<joe-subset-option class="joe-subset-option clear-filters" onclick="'+getSelfStr+'.clearFilters()">clear filters</joe-subset-option>',fh+="</div>",_bmResponse(BM,"filters rendered"),fh}()||"")+"</div>"+self.Aggregator.renderAggregatorHolder(!1);else submenu='<div class="joe-panel-submenu">'+renderSidebarToggle("left")+renderSidebarToggle("right")+submenuButtons.html+(sectionAnchors.count&§ionAnchors.code||"")+"</div>";function renderOptStripeColor(opt){var color=self.propAsFuncOrValue(opt.stripecolor||opt.stripeColor,null,null,opt),title="";return color&&$c.isObject(color.title)&&(title=' title="'+color.title+'" ',color=color.color),"<joe-stripe-color "+title+(color&&'style="background-color:'+color+';"'||"")+"></joe-stripe-color>"}function renderOptBGColor(opt){var color=self.propAsFuncOrValue(opt.bgcolor||opt.bgColor,null,null,opt);return color&&$c.isObject(color.title)&&(color=color.color),"<joe-bg-color "+(color&&'style="background-color:'+color+';"'||"")+"></joe-bg-color>"}function renderOptBorderColor(opt){var color=self.propAsFuncOrValue(opt.bordercolor||opt.borderColor,null,null,opt);return color&&$c.isObject(color.title)&&(color=color.color),"<joe-border-color "+(color&&'style="border:1px solid '+color+';"'||"")+"></joe-border-color>"}function renderOptionGroupStart(opt,childDom){var collapsed=self.propAsFuncOrValue(opt.collapsed)?"collapsed":"";if(opt.hasOwnProperty("filter")){var act,onclick,dataname,optdisplay=opt.display||opt.name||opt.group_start||"",optname=opt.id||opt.name||opt.group_start||"",cbox="";"joe-filter-option"==childDom?(dataname=' data-filter="'+optname+'" ',cbox='<span class ="joe-option-checkbox"></span>',act=self.current.filters&&self.current.filters[optname]?"active":"",onclick="getJoe("+self.joe_index+").toggleFilter('"+optname+"',this);_joe.Utils.stopPropagation();"):(dataname=' data-subset="'+optname+'" ',act=self.current.subset&&self.current.subset.name==optname||!self.current.subset&&"All"==opt.name?"active":"",onclick="getJoe("+self.joe_index+").selectSubset('"+optname.toString().replace(/\'/g,"\\'")+"');");var optiondiv="<"+childDom+" "+dataname+' class="'+childDom+" joe-group-option "+act+' " onclick='+onclick+">"+renderOptBorderColor(opt)+renderOptBGColor(opt)+renderOptStripeColor(opt)+cbox+'<span style="position:relative;">'+optdisplay+"</span></"+childDom+">";return'<joe-option-group id="'+opt.group_start+'-group" class="'+collapsed+' "><joe-menu-label onclick="$(this).parent().toggleClass(\'collapsed\');">'+optiondiv+"</joe-menu-label>"}return'<joe-option-group id="'+opt.group_start+'-group" class="'+collapsed+'"><joe-menu-label onclick="$(this).parent().toggleClass(\'collapsed\');">'+(opt.display||opt.name||opt.group_start)+"</joe-menu-label>"}return endLogGroup(),_bmResponse(BM,"[Submenu] rendered"),submenu},self.gotoSection=function(section,specs){specs=$.extend({},specs||{});if(section){var force_activation,i=specs.index||self.joe_index,sectionDom=$(".joe-overlay[data-joeindex="+i+"]").find(".joe-content-section[data-section='"+section+"']"),activated=sectionDom[0].hasClass("active");specs.hasOwnProperty("activate")&&(force_activation=specs.activate);var submenuDom=$(specs.dblclickdom)||self.overlay.find('joe-submenu-section[data-section="'+section+'"]');if(specs.focus){var tabbedmode,parent_dom=sectionDom.parents(".joe-content-sidebar,joe-panel-content");specs.hasOwnProperty("activate")?(submenuDom.toggleClass("active",force_activation),sectionDom.toggleClass("active",force_activation)):(submenuDom.toggleClass("active",!activated),sectionDom.toggleClass("active",!activated)),tabbedmode=submenuDom.parent().children(".active[data-panel="+submenuDom.data("panel")+"]").length>0,parent_dom.toggleClass("joe-tabbed-content",tabbedmode)}if(force_activation||!activated){sectionDom.removeClass("collapsed")[0].scrollIntoView();var sidebar=sectionDom.parents(".joe-content-sidebar");if(sidebar&&sidebar.length){var s=sidebar.data("side");self.toggleSidebar(s,!0),sectionDom.siblings(".joe-content-section").addClass("collapsed")}else"small-size"==self.sizeClass&&(self.toggleSidebar("left",!1),self.toggleSidebar("right",!1));$("joe-submenu-section-anchors.expanded").removeClass("expanded")}else $("joe-submenu-section-anchors.expanded").addClass("expanded")}},self.Sections={renderAchors:renderSectionAnchors,goto:self.gotoSection,gotoTop:function(index){var ajoe=getJoe(index);$(".joe-overlay[data-joeindex="+index+"]").find(".joe-panel-content").scrollTop(0),ajoe.panel.hasClass("small-size")&&(ajoe.toggleSidebar("right",!1),ajoe.toggleSidebar("left",!1)),$("joe-submenu-section-anchors.expanded").removeClass("expanded")}},self.Sections.toggleAll=function(expand){document.querySelectorAll(".joe-content-section").map(e=>{e.classList.toggle("collapsed",!expand)})},self.Sections.collapseAll=function(){document.querySelectorAll(".joe-content-section").map(e=>{e.classList.toggle("collapsed",!0)})},self.Sections.expandAll=function(){document.querySelectorAll(".joe-content-section").map(e=>{e.classList.toggle("collapsed",!1)})},self.Sections.toggleSome=function(sections,expand){sections.map(sect=>{document.querySelectorAll('.joe-content-section[data-section="'+sect+'"]').map(e=>{e.classList.toggle("collapsed",!expand)})})},self.Sections.unFocusAll=function(){self.overlay.find("joe-submenu-section").removeClass("active")},self.Sections.activate=function(sections){},self.Sections.setTabbedMode=function(show){self.overlay.find(".joe-content-sidebar,joe-panel-content").toggleClass("joe-tabbed-content",show)},self.Sections.toggle=function(dom){dom&&$(dom).parents("joe-submenu-section-anchors").toggleClass("expanded")},self.Sections.showAll=function(){self.Sections.toggleAll(!0)},this.Subset={getCached:function(list){list=list||self.current.list;var cache_query=self.current.schema.name+":"+self.current.subset.name,subcache=self.Cache.get(cache_query);return subcache||(subcache=list.where(self.current.subset.filter),self.Cache.set(subcache,{id:cache_query})),subcache}},this.Filter={refilter:function(){$c.isEmpty(self.current.filters)||self.filterListFromSubmenu(null,!0)},getCached:function(list){var BM=new Benchmarker;if(!self.current.schema||!self.current.schema.filters)return _bmResponse(BM,"filters gotten"),!1;list=list||self.current.list;var cache_query=self.current.schema.name+":filters",filtercache=self.Cache.get(cache_query);return filtercache||(filtercache=self.propAsFuncOrValue(self.current.schema.filters,self.current.list),self.Cache.set(filtercache,{id:cache_query})),_bmResponse(BM,"filters gotten"),filtercache}},this.renderSubmenuFilters=function(s){if(!(s||self.current.subsets||self.current.schema&&self.propAsFuncOrValue(self.current.schema.filters)))return"";var action=' onclick="getJoe('+self.joe_index+').toggleFiltersMenu();" ',active=self.current.subset?"active":"",count=$c.itemCount(self.current.filters);return"<div class='jif-panel-submenu-button joe-filters-toggle ' "+action+" title='show filters'>"+(active||count?'<joe-count-indicator class="'+active+(count?" count ":"")+'">'+(count||"")+"</joe-count-indicator>":"")+"</div>"};var leftMenuShowing=!1,rightMenuShowing=!1;this.toggleFiltersMenu=function(){leftMenuShowing=!leftMenuShowing,self.panel.toggleClass("show-filters",leftMenuShowing)},this.toggleAggregatorMenu=function(){rightMenuShowing=!rightMenuShowing,self.panel.toggleClass("show-aggregator",rightMenuShowing)},this.Filter.Options={datasetProperty:function(dataset,property,specs){var filters=[],groupname="string"==typeof(specs=specs||{}).group?specs.group:property;dataset=self.getDataset(self.propAsFuncOrValue(dataset)).sortBy(specs.sortby||"name");return specs.query&&(dataset=dataset.where(specs.query)),dataset.length?(specs.group&&filters.push({group_start:groupname,collapsed:specs.collapsed}),dataset.map(item=>{let props={name:item.name,filter:{}};props.filter[property]=item._id,filters.push(props)}),specs.group&&filters.push({group_end:groupname}),filters):[]},getDatasetPropertyValues:function(dataset,property,specs){var filters=[],groupname="string"==typeof(specs=specs||{}).group?specs.group:property;dataset=self.getDataset(self.propAsFuncOrValue(dataset)).sortBy(specs.sortby||"name");if(specs.query&&(dataset=dataset.where(specs.query)),!dataset.length)return[];specs.group&&filters.push({group_start:groupname,collapsed:specs.collapsed});var filterValues=specs.values||[];return dataset.map(item=>{item.hasOwnProperty(property)&&filterValues.push(item[property])}),(filterValues=Array.from(new Set(filterValues))).map(v=>{let filterObj={name:v,filter:{}};filterObj.filter[property]=v,filters.push(filterObj)}),specs.group&&filters.push({group_end:groupname}),filters},status:function(specs){specs=specs||{};"object"==$.type(schemaname)&&(specs=schemaname);var stat,schemaname=specs.schemaname||self.current.schema&&self.current.schema.name||"",stats=[],groupname="string"==typeof specs.group?specs.group:"tags";if(specs.group&&stats.push({group_start:groupname,collapsed:specs.collapsed}),self.Data.status.sortBy(specs.sortby||"index").where({datasets:{$in:[schemaname]}}).map(function(status){var sName=status.name;(stat={name:sName,id:status._id,filter:{status:status._id},title:self.propAsFuncOrValue(specs.title)||status.name})[specs.color||"bgcolor"]=status.color,stats.push(stat)}),specs.none){let noName="no status",noFil={$or:[{status:{$in:[null,""]}},{status:{$exists:!1}}]};stats.push({name:noName,filter:noFil})}return specs.group&&stats.push({group_end:groupname}),stats},tags:function(specs){var schemaname=(specs=specs||{}).schemaname||self.current.schema&&self.current.schema.name,filters=(schemaname=specs.schemaname||self.current.schema&&self.current.schema.name||"",[]),groupname="string"==typeof specs.group?specs.group:"tags";if(specs.group&&filters.push({group_start:groupname,collapsed:specs.collapsed}),_joe.Data.tag.sortBy(specs.sortby||"name").filter(function(tag){let fi={tags:{$in:[tag._id]}};if(-1!=tag.datasets.indexOf(schemaname)){let sName=tag.name;filters.push({name:sName,id:tag._id,filter:fi})}}),specs.untagged||specs.none){let noName="untagged",noFil={$or:[{tags:{$size:0}},{tags:{$exists:!1}}]};filters.push({name:noName,filter:noFil})}return specs.group&&filters.push({group_end:groupname}),filters}},this.Filter.generateQuery=this.generateFiltersQuery=function(){var filterinfo,filterobj,query={};for(var f in self.current.filters)if(!(filterinfo=(self.propAsFuncOrValue(self.current.schema.filters)||[]).where({name:f})[0]||self.current.filters[f]||{}).schema||!self.current.schema||!self.current.schema.__schemaname||filterinfo.schema==(self.current.schema.__Schemaname||self.current.schema.__schemaname))for(var ff in filterobj=filterinfo.filter)if(query[ff])switch($.type(filterobj[ff])){case"number":case"string":case"object":"string"==$.type(query[ff])||"number"==$.type(query[ff])?query[ff]={$in:[query[ff],filterobj[ff]]}:"object"==$.type(query[ff])&&query[ff].hasOwnProperty("$in")&&(query[ff].$in=query[ff].$in.concat(filterobj[ff].$in||[filterobj[ff]]))}else query[ff]=filterobj[ff];else delete self.current.filters[filterinfo.name];return logit(query),query},self.Search={schema:{title:"Search Results",name:"search",listTitle:function(item){return"<joe-full-right><joe-subtext>updated</joe-subtext><joe-subtitle>"+self.Utils.toDateString(item.joeUpdated)+"</joe-subtitle></joe-full-right>"+(_joe.schemas[item.itemtype].menuicon&&'<joe-icon class="icon-40 icon-grey fleft">'+_joe.schemas[item.itemtype].menuicon+"</joe-icon>"||"")+"<joe-subtext>${itemtype}</joe-subtext><joe-title>${name}</joe-title><joe-subtitle>${info}</joe-subtitle><joe-subtext>${_id}</joe-subtext>"},listmenu:[],sorter:["name",{name:"updated",value:"!joeUpdated"},"itemtype"],filters:function(){var f=[];return __appCollections.concat().sort().map(function(s){f.push({name:s,filter:{itemtype:s}})}),f},listAction:function(item){return"goJoeItem('"+item._id+"','"+item.itemtype+"')"}}},this.renderSubmenuSearch=function(s){return'<div class=\'joe-submenu-search \'><input class="joe-submenu-search-field" onkeyup="_joe.filterListFromSubmenu(this.value);" placeholder="search list" value="'+(self.current.keyword||$GET("keyword")||"")+'"/></div>'},this.searchTimeout;var searchTimeoutTime=$c.isMobile()?750:500,currentListItems,renderFieldTo;function renderSubmenuSelectors(specs){specs=$.extend({options:[],content:"",action:"nothing",buttonTemplate:"<div class='selection-label'>${label}</div>${name}",label:"label",cssclass:""},specs||{});var selectionTemplate="<div data-colcount='${name}' onclick='getJoe("+self.joe_index+")."+specs.action+"(${name});' class='jif-panel-button selector-button-${name} joe-selector-button '>"+specs.buttonTemplate+"</div>",onclick_action="onclick='$(this).parent().toggleClass(\"expanded\")'";return"<div class='joe-submenu-selector' >"+(specs.content||"<div class='joe-selector-button selector-label' "+onclick_action+">"+specs.label+"</div><div class='joe-selector-button selector-close joe-close-button' "+onclick_action+"> </div><joe-submenu-selector-options>"+fillTemplate(selectionTemplate,specs.options)+"</joe-submenu-selector-options>")+"</div>"}function renderEditorStyles(){return(self.specs.style&&self.specs.style.inset?"joe-style-inset ":"")+(self.specs.style&&self.specs.style.cards?"joe-style-cards ":"")}function renderSidebarToggle(side){return self.current.sidebars[side].hidden?"":'<div class="jif-panel-submenu-button joe-sidebar-button joe-sidebar_'+side+'-button" title="toggle" onclick="getJoe('+self.joe_index+").toggleSidebar('"+side+"')\">"+self.SVG.icon["sidebar-"+side]+"</div>"}function cleanDeleted(list,schema){var query={};return query[self.getCascadingProp("deleted")||"_deleted"]={$in:[!1,"false",void 0]},list.where(query)}this.filterListFromSubmenu=function(keyword,now){function searchFilter(keyword,frominput){var searchBM=new Benchmarker;if(self.current.keyword!=keyword){keyword=keyword||$(".joe-submenu-search-field").val()||"",frominput||keyword||!self.current.keyword||(keyword=self.current.keyword,$(".joe-submenu-search-field").val(keyword));var testable,value=keyword.toLowerCase(),keywords=value.replace(/,/g," ").split(" "),filters=self.generateFiltersQuery();_joe.history[_joe.history.length-1].keyword=value,_joe.history[_joe.history.length-1].filters=self.current.filters;var id,idprop=self.getIDProp(),listables=self.current.list;self.current.subset&&(listables=self.Subset.getCached()),listables=cleanDeleted(listables);var searchables=self.current.schema&&self.current.schema.searchables;_bmResponse(searchBM,"search where"),self.current.filteredList=currentListItems=listables.where(filters).filter(function(i){if(!keyword)return!0;if(id=i[idprop],testable="",searchables){searchables.map(function(s){testable+=i[s]+" "}),testable=testable.toLowerCase()+id;for(var k=0,tot=keywords.length;k<tot;k++)if(-1==testable.indexOf(keywords[k]))return!1}else{tableMode?testable=self.renderTableItem(i,!0):gridMode||(testable=self.renderListItem(i,!0)),testable=testable.toLowerCase()+id;for(k=0,tot=keywords.length;k<tot;k++)if(-1==testable.indexOf(keywords[k]))return!1}return!0}),_bmResponse(searchBM,"search '"+keyword+"' filtered "+currentListItems.length+"/"+self.current.list.length+" items ["+listables.length+"]"),self.overlay.find(".joe-submenu-itemcount").html(currentListItems.length+" item"+(currentListItems.length>1?"s":"")),self.panel.find(".joe-panel-content").html(self.renderListItems(currentListItems,0,self.specs.dynamicDisplay))}self.current.keyword=keyword,self.current.search_schema;var titleObj=createTitleObject();titleObj.subTitle?self.panel.find(".joe-panel-title").addClass("subtitled").html(titleObj.docTitle+"<joe-subtext>"+titleObj.subTitle+"</joe-subtext>"):self.panel.find(".joe-panel-title").addClass("subtitled").html(titleObj.docTitle),self.panel.find(".joe-filters-toggle").replaceWith(self.renderSubmenuFilters()),self.Aggregator.update()}clearTimeout(self.searchTimeout),self.overlay.removeClass(".multi-edit"),now?searchFilter(keyword):self.searchTimeout=setTimeout(function(){searchFilter(keyword,!0)},searchTimeoutTime)},this.renderSubmenuItemcount=function(s){return"<div class='joe-submenu-itemcount'>items</div>"},this.nothing=function(nothing){alert(value)},this.renderViewModeButtons=function(subspecs){var gridspecs=self.current.schema&&(self.current.schema.grid||self.current.schema.gridView),tablespecs=tableSpecs;if(!gridspecs&&!tablespecs)return"";var modes=[{name:"list"}];gridspecs&&modes.push({name:"grid"}),tablespecs&&modes.push({name:"table"});var modeTemplate="<div data-view='${name}' onclick='getJoe("+self.joe_index+").setViewMode(\"${name}\");' class='jif-panel-button joe-viewmode-button ${name}-button joe-selector-button'> </div>",onclick_action="onclick='$(this).parent().toggleClass(\"expanded\")'";return"<div class='joe-submenu-selector joe-viewmode-selector opts-"+modes.length+"' ><div class='joe-selector-button selector-label' "+onclick_action+">view</div><div class='joe-selector-button selector-close joe-close-button' "+onclick_action+"> </div><joe-submenu-selector-options>"+fillTemplate(modeTemplate,modes)+"</joe-submenu-selector-options></div>"},this.setViewMode=function(mode){self.reload(!0,{viewMode:mode})},this.renderColumnCountSelector=function(subspecs){if(!subspecs)return"";var modes=[{name:"1"},{name:"2"},{name:"3"},{name:"4"},{name:"5"}];"number"==typeof eval(subspecs)&&(modes=modes.slice(0,eval(subspecs)));var h=renderSubmenuSelectors({options:modes,label:"cols",value:colCount,action:"setColumnCount"});return h},this.setColumnCount=function(mode){self.overlay[0].className=self.overlay[0].className.replace(/cols-[0-9]/,"cols-"+mode),mode&&(colCount=mode);var multi=!!(mode&&mode>1);self.overlay.toggleClass("multi-col",multi)},this.Sorter={},this.Sorter.render=this.renderSorter=function(subspecs){var sorter=self.current.subset&&self.current.subset.sorter||self.current.schema&&self.current.schema.sorter||"name";if("string"==$.type(sorter)&&(sorter=sorter.split(",")),-1!=sorter.indexOf("name")||-1!=sorter.indexOf("!name")||sorter.where({field:"name"}).length||sorter.push("name"),1==sorter.length)return"";return'<label for="joe-'+self.joe_index+'-sorter" class="joe-list-sorter" ><svg onclick="getJoe('+self.joe_index+').Sorter.reverse();" class="joe-list-sorter-icon" title="reverse sort" xmlns="http://www.w3.org/2000/svg" viewBox="-20 6 40 40"><path d="M-4 16L-9.5 21.5 -8 23 -5 20 -5 28 -3 28 -3 20 0 23 1.5 21.5 -4 16zM3 16L3 18 5 18 5 16 3 16zM3 20L3 22 5 22 5 20 3 20zM3 24L3 32 0 29 -1.5 30.5 4 36 9.5 30.5 8 29 5 32 5 24 3 24zM-5 30L-5 32 -3 32 -3 30 -5 30zM-5 34L-5 36 -3 36 -3 34 -5 34z"/></svg><select title="sort" name="joe-'+self.joe_index+'-sorter" onchange="getJoe('+self.joe_index+').Sorter.resort(this.value);">'+sorter.map(function(so){var s=so,display=so;$c.isString(so)||(s=so.field||so.value,display=so.display||so.name||s),s=s.replace("!","");var valCheck=(self.current.sorter[0].field||self.current.sorter[0].value||self.current.sorter[0]).replace("!","");return"<option "+(s==valCheck?"selected":"")+' value="'+s+'">'+display+"</option>"}).join("")+"</select></label>"},this.Sorter.resort=function(sorter){self.reload(!0,{sorter:sorter})},this.Sorter.reverse=function(sorter){var curSorter=self.current.sorter;"array"==$.type(curSorter)&&(curSorter=[].concat(curSorter),"string"==$.type(curSorter[0])?0==curSorter[0].indexOf("!")?curSorter[0]=curSorter[0].substr(1):curSorter[0]="!"+curSorter[0]:"object"==$.type(curSorter[0])&&curSorter[0].value&&(0==curSorter[0].value.indexOf("!")?curSorter[0].value=curSorter[0].value.substr(1):curSorter[0].value="!"+curSorter[0].value),self.reload(!0,{sorter:curSorter}))},this.Submenu=this.Submenu||{},this.Aggregator={},this.Aggregator.renderToggleButton=function(){return s&&self.current.schema&&self.current.schema.hasOwnProperty("aggregator")?"<div class='jif-panel-submenu-button joe-aggregator-toggle ' "+(' onclick="getJoe('+self.joe_index+').toggleAggregatorMenu();" ')+" title='show aggregator'></div>":""},this.Aggregator.renderAggregatorHolder=function(contentOnly,content){if(!(s&&self.current.schema&&self.current.schema.hasOwnProperty("aggregator")))return"";var html=content=self.propAsFuncOrValue(self.current.schema.aggregator,self.current.filteredList||self.current.list);return contentOnly||(html="<div class='joe-aggregator-holder'>"+content+"</div>"),html},this.Aggregator.update=function(list){list=list||self.current.filteredList;var content=self.Aggregator.renderAggregatorHolder(!0),dom=document.querySelector('.joe-overlay[data-joeindex="0"]').getElementsByClassName("joe-aggregator-holder")[0];dom&&(dom.innerHTML=content)},this.renderEditorContent=function(specs){var content;self.current.sidebars={left:{collapsed:!1},right:{collapsed:!1}},specs||(specs={mode:"text",text:"No object or list selected"});var mode=specs.mode;switch(mode){case"text":content=self.renderTextContent(specs);break;case"rendering":content=self.renderHTMLContent(specs);break;case"list":content=self.renderListContent(specs);break;case"object":content=self.renderObjectContent(specs);break;default:content=content||""}var submenu="";specs.minimode||("list"==mode&&self.current.submenu||self.current.submenu||renderSectionAnchors().count||renderSubmenuButtons().content)&&(submenu=" with-submenu ");var scroll='onscroll="getJoe('+self.joe_index+').onListContentScroll(this);"',rightC=content.right||"",leftC=content.left||"",html='<joe-panel-content class="'+("joe-panel-content "+renderEditorStyles()+submenu)+'" '+(listMode&&scroll||"")+">"+(content.main||content)+"</joe-panel-content>"+self.renderSideBar("left",leftC,{css:submenu})+self.renderSideBar("right",rightC,{css:submenu});return self.current.sidebars.left.content=leftC,self.current.sidebars.right.content=rightC,html},this.renderSideBar=function(side,content,specs){side=side||"right";var addCss=(specs=specs||{}).css||"";return"<div class='joe-content-sidebar "+renderEditorStyles()+" joe-absolute "+side+"-side "+addCss+"' data-side='"+side+"'>"+(content||"")+__clearDiv__+"</div>"},this.toggleSidebar=function(side,h