Communication in both directions (Text control)
Code regrouping
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript 1.6.1
|
||||
(function() {
|
||||
var $el, WSF_BUTTON_CONTROL, WSF_CONTROL, controls, name, state, trigger_callback, type, typemap,
|
||||
var $el, WSF_BUTTON_CONTROL, WSF_CONTROL, WSF_TEXT_CONTROL, controls, name, state, trigger_callback, type, typemap, _ref,
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
@@ -8,18 +8,19 @@
|
||||
return $.ajax({
|
||||
data: {
|
||||
control_name: control_name,
|
||||
event: event
|
||||
event: event,
|
||||
states: JSON.stringify(states)
|
||||
},
|
||||
cache: false
|
||||
}).done(function(new_states) {
|
||||
var name, state, states, _ref;
|
||||
var name, state, _ref;
|
||||
window.states = new_states;
|
||||
for (name in new_states) {
|
||||
state = new_states[name];
|
||||
if ((_ref = controls[name]) != null) {
|
||||
_ref.update(state);
|
||||
}
|
||||
}
|
||||
states = new_states;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -70,12 +71,43 @@
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
WSF_TEXT_CONTROL = (function(_super) {
|
||||
|
||||
__extends(WSF_TEXT_CONTROL, _super);
|
||||
|
||||
function WSF_TEXT_CONTROL() {
|
||||
return WSF_TEXT_CONTROL.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
WSF_TEXT_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
self = this;
|
||||
return this.$el.change(function() {
|
||||
return self.change();
|
||||
});
|
||||
};
|
||||
|
||||
WSF_TEXT_CONTROL.prototype.change = function() {
|
||||
window.states[this.control_name]['text'] = this.$el.val();
|
||||
return trigger_callback(this.control_name, 'change');
|
||||
};
|
||||
|
||||
WSF_TEXT_CONTROL.prototype.update = function(state) {
|
||||
return this.$el.val(state.text);
|
||||
};
|
||||
|
||||
return WSF_TEXT_CONTROL;
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
typemap = {
|
||||
"WSF_BUTTON_CONTROL": WSF_BUTTON_CONTROL
|
||||
"WSF_BUTTON_CONTROL": WSF_BUTTON_CONTROL,
|
||||
"WSF_TEXT_CONTROL": WSF_TEXT_CONTROL
|
||||
};
|
||||
|
||||
for (name in states) {
|
||||
state = states[name];
|
||||
_ref = window.states;
|
||||
for (name in _ref) {
|
||||
state = _ref[name];
|
||||
$el = $('[data-name=' + name + ']');
|
||||
type = $el.data('type');
|
||||
if ((type != null) && (typemap[type] != null)) {
|
||||
|
||||
Reference in New Issue
Block a user