mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 10:50:08 +00:00
general structure of the generic dialog done, still need testing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3ca6cc7835
commit
e3f08a460c
78
ui/ui.js
78
ui/ui.js
@ -446,33 +446,39 @@ var FIELD_TYPES = {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
text: null,
|
text: null,
|
||||||
default: '',
|
default: '',
|
||||||
html: '<div class="field">'+
|
html: '<div class="field checkbox">'+
|
||||||
'<span class="text"></span>'+
|
'<span class="text"></span>'+
|
||||||
'<input type="text" class="value">'+
|
'<input type="text" class="value">'+
|
||||||
'</div>',
|
'</div>',
|
||||||
setter: function(field){
|
test: function(val){
|
||||||
|
return typeof(val) == typeof('abc')
|
||||||
|
},
|
||||||
|
set: function(field){
|
||||||
$(field).find('.value').attr('value', this.default)
|
$(field).find('.value').attr('value', this.default)
|
||||||
},
|
},
|
||||||
getter: function(field){
|
get: function(field){
|
||||||
return $(field).find('.value').attr('value')
|
return $(field).find('.value').attr('value')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bool: {
|
bool: {
|
||||||
type: 'text',
|
type: 'bool',
|
||||||
text: null,
|
text: null,
|
||||||
default: false,
|
default: false,
|
||||||
html: '<div class="field">'+
|
html: '<div class="field string">'+
|
||||||
'<input type="checkbox" class="value">'+
|
'<input type="checkbox" class="value">'+
|
||||||
'<span class="text"></span>'+
|
'<span class="text"></span>'+
|
||||||
'</div>',
|
'</div>',
|
||||||
setter: function(field){
|
test: function(val){
|
||||||
if(this.default){
|
return val === true || val === false
|
||||||
|
},
|
||||||
|
set: function(field, value){
|
||||||
|
if(value){
|
||||||
$(field).find('.value').attr('checked', '')
|
$(field).find('.value').attr('checked', '')
|
||||||
} else {
|
} else {
|
||||||
$(field).find('.value').removeAttr('checked')
|
$(field).find('.value').removeAttr('checked')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getter: function(field){
|
get: function(field){
|
||||||
return $(field).find('.value').attr('value')
|
return $(field).find('.value').attr('value')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -512,6 +518,62 @@ var FIELD_TYPES = {
|
|||||||
//
|
//
|
||||||
// XXX find a better name...
|
// XXX find a better name...
|
||||||
function promptPlus(message, config, btn){
|
function promptPlus(message, config, btn){
|
||||||
|
var form = $('<div class="form"/>')
|
||||||
|
var data = {}
|
||||||
|
var res = $.Deferred()
|
||||||
|
|
||||||
|
// XXX handle message and btn...
|
||||||
|
// XXX
|
||||||
|
|
||||||
|
// build the form...
|
||||||
|
for(var t in config){
|
||||||
|
var did_handling = false
|
||||||
|
for(var f in FIELD_TYPES){
|
||||||
|
if(FIELD_TYPES[f].test(config[t])){
|
||||||
|
var field = FIELD_TYPES[f]
|
||||||
|
var html = $(field.html)
|
||||||
|
|
||||||
|
html.find('.text').text(t)
|
||||||
|
field.set(html, config[t])
|
||||||
|
|
||||||
|
html.on('resolve', function(){
|
||||||
|
data[t] = field.get(html)
|
||||||
|
})
|
||||||
|
|
||||||
|
form.append(html)
|
||||||
|
|
||||||
|
did_handling = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle unresolved fields...
|
||||||
|
if(!did_handling){
|
||||||
|
// XXX skipping field...
|
||||||
|
// XXX
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var root = $('.viewer')
|
||||||
|
|
||||||
|
showInOverlay(root, form)
|
||||||
|
.addClass('prompt dialog')
|
||||||
|
.on('accept', function(){
|
||||||
|
form.find('.field').each(function(_, e){
|
||||||
|
$(e).trigger('resolve')
|
||||||
|
})
|
||||||
|
|
||||||
|
// XXX test if all required stuff is filled...
|
||||||
|
res.resolve(data)
|
||||||
|
|
||||||
|
hideOverlay(root)
|
||||||
|
})
|
||||||
|
.on('close', function(){
|
||||||
|
res.reject()
|
||||||
|
hideOverlay(root)
|
||||||
|
})
|
||||||
|
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user