- auto iterated tab/widget unique ids if not set in session file

- docs, wip
This commit is contained in:
jean-emmanuel 2015-09-17 13:58:01 +02:00 • committed by bordun
parent a93e8dc9c8
commit 60967e0e89
8 changed files with 124 additions and 53 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,16 @@
__widgets__ = {}
__widgetsIds__ = {}
var iterator = {
tab: 0,
widget: 0
},
getIterator = function(type){
iterator[type] += 1
return iterator[type]
}
parsetabs = function(tabs,parent,sub){
if (!sub) {
var nav = $(document.createElement('div')).addClass('main navigation'),
@ -15,16 +28,18 @@ parsetabs = function(tabs,parent,sub){
}
for (i in tabs) {
var tabData = tabs[i];
tabData.id = tabData.id.replace(' ','_')
var id = parent?parent.attr('id')+tabData.id:tabData.id
label= tabData.label||tabData.id
var tabData = tabs[i]
tabData.id = tabData.id?tabData.id.replace(' ','_'):'tab_'+getIterator('tab')
var id = tabData.id,
label= tabData.label||id
navtabs.append('<li><a data-tab="#'+id+'"><span>'+label+'</span></a></li>');
var tabContent = $(document.createElement('div')).addClass('tab').attr('id',id);
var tabContent = $('<div></div>').addClass('tab').attr('id',id);
if (tabData.mode=='stack') tabContent.addClass('stack')
if (tabData.stack) tabContent.addClass('stack')
if (tabData.tabs) {
parsetabs(tabData.tabs,parent=tabContent,sub=true);
@ -37,14 +52,16 @@ parsetabs = function(tabs,parent,sub){
}
}
__widgets__ = {}
__widgetsIds__ = {}
parsewidgets = function(widgets,parent) {
for (i in widgets) {
var widgetData = widgets[i],
id = widgetData.id,
var widgetData = widgets[i]
widgetData.id = widgetData.id?widgetData.id.replace(' ','_'):'widget_'+getIterator('widget')
var id = widgetData.id,
label = widgetData.label || id,
type = widgetData.type || 'fader',
path = widgetData.path || '/' + id,
@ -53,12 +70,6 @@ parsewidgets = function(widgets,parent) {
widgetData.path = path
if (widgetData.color && widgetData.color=='accent') {
accentclass = 'accent'
} else if (widgetData.color) {
color = 'style="color:'+widgetData.color+'"'
}
var widgetContainer = $('\
<div class="widget '+type+'-container" widgetType="'+type+'" widgetId="'+id+'" path="'+path+'">\
<div class="label">'+label+'</div>\

View file

@ -6,7 +6,7 @@ createWidget.strip = function(widgetData) {
<div class="strip">\
</div>\
');
if (widgetData.mode=='horizontal') widget.addClass('horizontal')
if (widgetData.horizontal) widget.addClass('horizontal')
parsewidgets(widgetData.widgets,widget)
widget.getValue = function(){return}
widget.setValue = function(){return}
@ -86,8 +86,6 @@ createWidget.toggle = createWidget.button = function(widgetData) {
createWidget.switch = function(widgetData) {
widgetData.on = widgetData.on || 1
widgetData.off = widgetData.off || 0
var widget = $('\
<div class="switch">\
@ -402,9 +400,9 @@ createWidget.fader = function(widgetData,container){
pips = widget.find('.pips'),
input = widget.find('input'),
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
dimension = widgetData.mode=='horizontal'?'width':'height';
dimension = widgetData.horizontal?'width':'height';
if (widgetData.mode=='horizontal') container.addClass('horizontal')
if (widgetData.horizontal) container.addClass('horizontal')
handle.size = 0
fader.size = dimension=='height'?fader.height():fader.width()

View file

@ -321,7 +321,7 @@ a {
&.main {
padding-right:55rem;
right:0;
background: linear-gradient($color-border,$color-bg);
// background: linear-gradient($color-border,$color-bg);
}
ul {
@ -643,7 +643,8 @@ form {
&.horizontal {
flex-direction: row;
> .widget {
border-bottom: 0;
border-bottom-width: 0;
border-right-width:6rem;
}
}
height: 100%;
@ -652,10 +653,10 @@ form {
> .widget {
display: block;
border-left:0;
border-right:0;
border-left-width:0;
border-right-width:0;
&:not(:last-child) {
border-bottom:0;
border-bottom-width:0;
}
}

View file

@ -26,9 +26,7 @@ compileScss = function(){
});
}
}
if (args.indexOf('-c')!=-1) {
compileScss()
}
dialog.showErrorBox = function(title,err) {
console.log(title + ': ' + err)
@ -101,6 +99,11 @@ app.on('window-all-closed', function() {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
if (args.indexOf('-c')!=-1) {
compileScss()
}
// Create the browser window.
window = new BrowserWindow({
width: 810,
@ -128,9 +131,9 @@ app.on('ready', function() {
label: 'View',
submenu: [
{
label: 'Reload',
label: 'Restart',
accelerator: 'CmdOrCtrl+R',
click: function() { window.reload(); }
click: function() { window.reload(); }//restartApp
},
{
label: 'Toggle DevTools',
@ -141,10 +144,6 @@ app.on('ready', function() {
label: 'Toggle Fullscreen',
accelerator: 'F11',
click: function() { window.setFullScreen(!window.isFullScreen()); }
},
{
label:'Restart App',
click:restartApp
}
]
},