Skip to content

Commit 4a7e968

Browse files
committed
events rework
1 parent c23d6e8 commit 4a7e968

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

static/main.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ $(function(){
324324
opts[define]=file.defs[define];
325325
if (def.changed)
326326
d.addClass('bg-info')
327+
d.attr('define', define);
327328
d.find('label').eq(0).text(define.split('.')[0]).attr('title',def.line.trim())//.tooltip(def.line.length>24&&tooltip_large); //take 200ms
328329
var dis=d.find('.onoffswitch')
329330
var p=d.find('.mct-splitter');
@@ -368,49 +369,58 @@ $(function(){
368369
val.val(dv);
369370
sel.remove();
370371
}
371-
inp
372-
.on('change',function(){
373-
var dv=$(this).val();
374-
if (def.type=='string')
375-
dv='"'+dv+'"';
376-
processProp('value',dv);
377-
})
378-
}
379-
function processProp(name,val){
380-
lastChanged=define+name;
381-
saveProp('/set/'+file.file.name+'/'+define+'/'+name+'/'+val)
382-
.then(function(){
383-
setProp(define,name,val);
384-
});
372+
inp.attr('dtype', def.type)
385373
}
374+
386375
if ( !( def.changed && def.changed.disabled ) && !def.disabled && def.value != undefined)
387376
dis.remove(),p.remove();
388377
else{
389378
dis.find('input')
390379
.attr('checked',!getVal(def,'disabled'))
391-
.on('change',function(){
392-
processProp('disabled',!$(this).prop('checked'));
393-
})
394380
}
395381
if (def.condition){
396382
var title='( '+def.condition.join(') && (')+' )';
397383
d.find('.col-sm-6').attr('title',title)//.tooltip(tooltip_large);
398384
}
399-
var b=d.find('button');
400-
b.eq(1).on('click', function(){ window.opener("https://github.com/MarlinFirmware/Marlin/search?q=" + define + "&type=Issues&utf8=%E2%9C%93", "_blank"); })
385+
var b = d.find('button');
401386
if ( def.hint == undefined )
402387
b.eq(0).remove();
403-
else
404-
b.eq(0).on('click',function(){ loadHint(define) })
405-
})
388+
}) //define
389+
406390
sec.find('.card-header span.badge:eq(0)').text(cnt);
407391
updateChanged(sec);
408392
var btns=sec.find('.card-header button');
409393
btns.eq(1).on('click',function(){sec.find('.form-group').not('.bg-info').hide()})
410394
btns.eq(0).on('click',function(){sec.find('.form-group').show()})
411395
$('.config-files a[href$=Configuration]').tab('show');
396+
}) //section
397+
tab.tab.on('click', '.card-block button', function() {
398+
var btn = $(this), define = btn.parents('.form-group').attr('define');
399+
if (btn.hasClass('fa-info'))
400+
loadHint(define);
401+
if (btn.hasClass('fa-github'))
402+
window.opener("https://github.com/MarlinFirmware/Marlin/search?q=" + define + "&type=Issues&utf8=%E2%9C%93", "_blank");
412403
})
413-
})
404+
function processProp(define, name, val) {
405+
lastChanged = define + name;
406+
saveProp('/set/' + file.file.name + '/' + define + '/' + name + '/' + val)
407+
.then(function() {
408+
setProp(define, name, val);
409+
});
410+
}
411+
tab.tab.on('change', '.card-block select,.card-block input[type=text]', function() {
412+
var btn = $(this), define = btn.parents('.form-group').attr('define');
413+
var val = btn.val();
414+
if (btn.attr('dtype') == 'string')
415+
val = '"' + val + '"';
416+
processProp(define, 'value', val);
417+
})
418+
tab.tab.on('change', '.card-block .onoffswitch input', function() {
419+
var btn = $(this), define = btn.parents('.form-group').attr('define');
420+
processProp(define, 'disabled', !$(this).prop('checked'));
421+
})
422+
423+
}) //file
414424
$('body').scrollspy({ target: '#navbar-sections' })
415425
$('.config-files .nav-tabs a[data-toggle="tab"]').on('show.bs.tab', function (e) { //sync tab with nav
416426
var href=$(e.target).attr('href')
@@ -480,7 +490,7 @@ $(function(){
480490
})
481491
);
482492
});
483-
d.find('button').on('click',function(){ loadGcode(tag)});
493+
d.on('click', 'button', function(){ loadGcode(tag)});
484494
});
485495
})
486496
$.each(data.tags,function(name,d){ //TODO:put it into server

0 commit comments

Comments
 (0)