Merge pull request #1 from BlockBuilder57/patch-1

Add positions to sections and comment out test section
This commit is contained in:
Cynthia Foxwell 2018-05-21 20:23:34 -06:00 committed by GitHub
commit 21075e78d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 9 deletions

View File

@ -24,7 +24,7 @@ exports = {
ourSections: [], ourSections: [],
_callbacks: {}, _callbacks: {},
_panels: {}, _panels: {},
addSection: function(name,label,color=null,callback){ addSection: function(name,label,color=null,callback,pos){
let data = {}; let data = {};
data.section = name || `SAPI_${Math.floor(Math.random()*10000)}`; data.section = name || `SAPI_${Math.floor(Math.random()*10000)}`;
@ -33,16 +33,16 @@ exports = {
data.element = $api.util.findConstructor('FormSection', 'FormSection').FormSection; data.element = $api.util.findConstructor('FormSection', 'FormSection').FormSection;
$settingsapi.ourSections.push(data); $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; $settingsapi._callbacks[name] = callback;
}, },
addDivider: function(){ addDivider: function(pos){
$settingsapi.ourSections.push({section:"DIVIDER"}); $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.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(){ exportSections: function(){
let out = ""; let out = "";
@ -184,7 +184,7 @@ exports = {
} }
//Example settings tab //Example settings tab
$settingsapi.addDivider(); /*$settingsapi.addDivider();
$settingsapi.addHeader("Element Testing"); $settingsapi.addHeader("Element Testing");
$settingsapi.addSection("TESTING","Element Test Page",null,function(pnl){ $settingsapi.addSection("TESTING","Element Test Page",null,function(pnl){
let em = $settingsapi.elements; let em = $settingsapi.elements;
@ -204,7 +204,7 @@ exports = {
em.createH2("Horizontal Panel!").appendTo(h); em.createH2("Horizontal Panel!").appendTo(h);
em.createButton("Boop Beep").appendTo(h); em.createButton("Boop Beep").appendTo(h);
}); });*/
function setupSettings(e){ function setupSettings(e){
for(let i in $settingsapi._panels){ 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_SET_SECTION",setupSettings);
$api.events.hook("USER_SETTINGS_MODAL_INIT",e=>setTimeout(_=>setupSettings(e),200)); $api.events.hook("USER_SETTINGS_MODAL_INIT",e=>setTimeout(_=>setupSettings(e),200));
} }
} }