- added popup and configuration panel api
- remove all href attributes to prevent dragging showing urls
This commit is contained in:
parent
e5b7f63f08
commit
2d673310dd
7 changed files with 190 additions and 56 deletions
|
|
@ -19,7 +19,7 @@ ipc.on('load',function(preset){
|
|||
|
||||
ipc.on('listSessions',function(data){
|
||||
for (i in data) {
|
||||
$('#lobby .list').append('<li><a class="btn" data-session="'+i+'">'+data[i]+'<span>x</span></a></li>')
|
||||
$('#lobby .list').append('<li><a class="btn" data-session="'+i+'">'+data[i]+'<span>'+icon('remove')+'</span></a></li>')
|
||||
}
|
||||
$('#lobby .list').append('<a class="btn" data-session="browse">...</a>')
|
||||
$('#lobby a').click(function(){
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ init = function(callback) {
|
|||
// Tabs...
|
||||
$('.tablist a').click(function(){
|
||||
|
||||
var id = $(this).attr('href');
|
||||
var id = $(this).data('tab');
|
||||
$(id).siblings('.on').removeClass('on');
|
||||
$(id).addClass('on');
|
||||
$(this).parents('ul').find('.on').removeClass('on');
|
||||
|
|
@ -103,10 +103,11 @@ init = function(callback) {
|
|||
},
|
||||
{
|
||||
label:'Config',
|
||||
icon:'gears'
|
||||
icon:'gears',
|
||||
click:configPanel
|
||||
},
|
||||
{
|
||||
html:'<div class="inspector">\
|
||||
html:'<div class="inspector btn">\
|
||||
Inspector\
|
||||
<div class="result"><em>Click on a widges\'s title to inspect</em></div>\
|
||||
</div>',
|
||||
|
|
@ -117,7 +118,7 @@ init = function(callback) {
|
|||
|
||||
$('#open-toggle').click(function(){
|
||||
$('#open-toggle, #sidepanel, #container').toggleClass('sidepanel-open');
|
||||
}).click()
|
||||
})
|
||||
|
||||
$('.title').click(function(){
|
||||
if (!$('#sidepanel').hasClass('sidepanel-open')){return}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ parsetabs = function(tabs,parent,sub){
|
|||
var title = tabData.title||tabId
|
||||
|
||||
var id = parent?parent.attr('id')+tabId:tabId
|
||||
$navtabs.append('<li><a href="#'+id+'"><span>'+title+'</span></a></li>');
|
||||
$navtabs.append('<li><a data-tab="#'+id+'"><span>'+title+'</span></a></li>');
|
||||
|
||||
var $tabContent = $(document.createElement('div')).addClass('tab').attr('id',id);
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ createMenu = function(template) {
|
|||
html
|
||||
|
||||
if (!item.html) {
|
||||
html = $('<a href="" class="'+classname+' btn">'+label+'</a>')
|
||||
html = $('<a class="'+classname+' btn">'+label+'</a>')
|
||||
} else {
|
||||
html = $(item.html)
|
||||
}
|
||||
|
|
@ -88,3 +88,80 @@ createMenu = function(template) {
|
|||
return menu
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
createPopup = function(title,content) {
|
||||
var popup = $('\
|
||||
<div class="popup">\
|
||||
<div class="popup-wrapper">\
|
||||
<div class="popup-title">'+title+'<span class="closer">'+icon('remove')+'</span></div>\
|
||||
<div class="popup-content"></div>\
|
||||
</div>\
|
||||
</div>'),
|
||||
closer = popup.find('.popup-title .closer')
|
||||
|
||||
closer.click(function(){
|
||||
popup.close()
|
||||
})
|
||||
|
||||
|
||||
popup.close = function(){
|
||||
$(document).unbind('keydown.popup')
|
||||
popup.remove()
|
||||
}
|
||||
|
||||
popup.find('.popup-content').append(content)
|
||||
$('body').append(popup)
|
||||
|
||||
$(document).on('keydown.popup', function(){
|
||||
popup.close()
|
||||
})
|
||||
|
||||
|
||||
return popup
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var remote = require('remote');
|
||||
configPanel = function(){
|
||||
var readConfig = remote.getGlobal('readConfig')
|
||||
var writeConfig = remote.getGlobal('writeConfig')
|
||||
var config = readConfig()
|
||||
|
||||
var form = $('<form></form>')
|
||||
|
||||
for (i in config) {
|
||||
var html = $('\
|
||||
<label for="'+i+'">'+i+'</label>\
|
||||
<p class="info">'+config[i].info+'</p>\
|
||||
<input name="'+i+'" value="'+config[i].value+'"/>')
|
||||
form.append(html)
|
||||
}
|
||||
|
||||
var submit = $('<a class="btn submit">'+icon('save')+' Save configuration</a>')
|
||||
|
||||
form.append(submit)
|
||||
|
||||
popup = createPopup(icon('gear')+' Configuration panel',form)
|
||||
|
||||
submit.click(function(e){
|
||||
e.preventDefault()
|
||||
var data = form.serializeArray(),
|
||||
newconfig = {}
|
||||
|
||||
for (i in data) {
|
||||
newconfig[data[i].name] = data[i].value
|
||||
}
|
||||
|
||||
writeConfig(newconfig)
|
||||
|
||||
popup.close();
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue