-
Notifications
You must be signed in to change notification settings - Fork 54
/
myflow.editors.js
62 lines (55 loc) · 1.55 KB
/
myflow.editors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(function($){
var myflow = $.myflow;
$.extend(true, myflow.editors, {
inputEditor : function(){
var _props,_k,_div,_src,_r;
this.init = function(props, k, div, src, r){
_props=props; _k=k; _div=div; _src=src; _r=r;
$('<input style="width:100%;"/>').val(props[_k].value).change(function(){
props[_k].value = $(this).val();
}).appendTo('#'+_div);
$('#'+_div).data('editor', this);
}
this.destroy = function(){
$('#'+_div+' input').each(function(){
_props[_k].value = $(this).val();
});
}
},
selectEditor : function(arg){
var _props,_k,_div,_src,_r;
this.init = function(props, k, div, src, r){
_props=props; _k=k; _div=div; _src=src; _r=r;
var sle = $('<select style="width:100%;"/>').val(props[_k].value).change(function(){
props[_k].value = $(this).val();
}).appendTo('#'+_div);
if(typeof arg === 'string'){
$.ajax({
type: "GET",
url: arg,
success: function(data){
var opts = eval(data);
if(opts && opts.length){
for(var idx=0; idx<opts.length; idx++){
sle.append('<option value="'+opts[idx].value+'">'+opts[idx].name+'</option>');
}
sle.val(_props[_k].value);
}
}
});
}else {
for(var idx=0; idx<arg.length; idx++){
sle.append('<option value="'+arg[idx].value+'">'+arg[idx].name+'</option>');
}
sle.val(_props[_k].value);
}
$('#'+_div).data('editor', this);
};
this.destroy = function(){
$('#'+_div+' input').each(function(){
_props[_k].value = $(this).val();
});
};
}
});
})(jQuery);