add UI.add and UI.remove methods.
also use json-ot from bower
This commit is contained in:
parent
ff0f7d15dc
commit
5bb77bd50c
@ -6,7 +6,7 @@ define([
|
|||||||
'/bower_components/textpatcher/TextPatcher.amd.js',
|
'/bower_components/textpatcher/TextPatcher.amd.js',
|
||||||
'json.sortify',
|
'json.sortify',
|
||||||
'/form/ula.js',
|
'/form/ula.js',
|
||||||
'/common/json-ot.js',
|
'/bower_components/chainpad-json-validator/json-ot.js',
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
'/customize/pad.js'
|
'/customize/pad.js'
|
||||||
], function (Config, Realtime, Crypto, TextPatcher, Sortify, Formula, JsonOT) {
|
], function (Config, Realtime, Crypto, TextPatcher, Sortify, Formula, JsonOT) {
|
||||||
@ -43,8 +43,29 @@ define([
|
|||||||
ids: [],
|
ids: [],
|
||||||
each: function (f) {
|
each: function (f) {
|
||||||
UI.ids.forEach(function (id, i, list) {
|
UI.ids.forEach(function (id, i, list) {
|
||||||
|
if (!UI[id]) { return; }
|
||||||
f(UI[id], i, list);
|
f(UI[id], i, list);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
add: function (id, ui) {
|
||||||
|
if (UI.ids.indexOf(id) === -1) {
|
||||||
|
UI.ids.push(id);
|
||||||
|
|
||||||
|
UI[id] = ui;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// it already exists
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
remove: function (id) {
|
||||||
|
delete UI[id];
|
||||||
|
var idx = UI.ids.indexOf(id);
|
||||||
|
if (idx > -1) {
|
||||||
|
UI.ids.splice(idx, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,9 +88,7 @@ define([
|
|||||||
// get its type
|
// get its type
|
||||||
.data('rt-ui-type', type);
|
.data('rt-ui-type', type);
|
||||||
|
|
||||||
UI.ids.push(id);
|
var component = {
|
||||||
|
|
||||||
var component = UI[id] = {
|
|
||||||
id: id,
|
id: id,
|
||||||
$: $this,
|
$: $this,
|
||||||
element: element,
|
element: element,
|
||||||
@ -78,6 +97,8 @@ define([
|
|||||||
name: $this.prop('name'),
|
name: $this.prop('name'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UI.add(id, component);
|
||||||
|
|
||||||
component.value = (function () {
|
component.value = (function () {
|
||||||
var checker = ['radio', 'checkbox'].indexOf(type) !== -1;
|
var checker = ['radio', 'checkbox'].indexOf(type) !== -1;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user