From 2b690432db6913125e908a79041c34ed9c1fe396 Mon Sep 17 00:00:00 2001 From: BlockBuilder57 Date: Mon, 21 May 2018 20:01:15 -0500 Subject: [PATCH] Add positions to sections and comment out test section Now you can just put elements wherever you feel like. Also, that test section is good but it being in by default is a bit unwieldy. --- plugins/settingsapi.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/settingsapi.js b/plugins/settingsapi.js index b38f039..0a3bf12 100644 --- a/plugins/settingsapi.js +++ b/plugins/settingsapi.js @@ -24,7 +24,7 @@ exports = { ourSections: [], _callbacks: {}, _panels: {}, - addSection: function(name,label,color=null,callback){ + addSection: function(name,label,color=null,callback,pos){ let data = {}; data.section = name || `SAPI_${Math.floor(Math.random()*10000)}`; @@ -33,16 +33,16 @@ exports = { data.element = $api.util.findConstructor('FormSection', 'FormSection').FormSection; $settingsapi.ourSections.push(data); - $settingsapi.sections.splice($settingsapi.sections.length-4,0,data); + $settingsapi.sections.splice(pos ? pos : $settingsapi.sections.length-4,0,data); $settingsapi._callbacks[name] = callback; }, - addDivider: function(){ + addDivider: function(pos){ $settingsapi.ourSections.push({section:"DIVIDER"}); - $settingsapi.sections.splice($settingsapi.sections.length-4,0,{section:"DIVIDER"}); + $settingsapi.sections.splice(pos ? pos : $settingsapi.sections.length-4,0,{section:"DIVIDER"}); }, - addHeader: function(label){ + addHeader: function(label, pos){ $settingsapi.ourSections.push({section:"HEADER",label:label}); - $settingsapi.sections.splice($settingsapi.sections.length-4,0,{section:"HEADER",label:label}); + $settingsapi.sections.splice(pos ? pos : $settingsapi.sections.length-4,0,{section:"HEADER",label:label}); }, exportSections: function(){ let out = ""; @@ -184,7 +184,7 @@ exports = { } //Example settings tab - $settingsapi.addDivider(); + /*$settingsapi.addDivider(); $settingsapi.addHeader("Element Testing"); $settingsapi.addSection("TESTING","Element Test Page",null,function(pnl){ let em = $settingsapi.elements; @@ -204,7 +204,7 @@ exports = { em.createH2("Horizontal Panel!").appendTo(h); em.createButton("Boop Beep").appendTo(h); - }); + });*/ function setupSettings(e){ for(let i in $settingsapi._panels){ @@ -229,4 +229,4 @@ exports = { $api.events.hook("USER_SETTINGS_MODAL_SET_SECTION",setupSettings); $api.events.hook("USER_SETTINGS_MODAL_INIT",e=>setTimeout(_=>setupSettings(e),200)); } -} \ No newline at end of file +}