Redesign states and implement generated control_name
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Generated by CoffeeScript 1.6.1
|
||||
var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CODEVIEW_CONTROL, WSF_CONTROL, WSF_DROPDOWN_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_SLIDER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, show_alert, start_modal, start_modal_big, template, tmpl,
|
||||
var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CODEVIEW_CONTROL, WSF_CONTROL, WSF_DROPDOWN_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_NAVLIST_ITEM_CONTROL, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_SLIDER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, parseSuggestions, show_alert, start_modal, start_modal_big, template, tmpl,
|
||||
__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; };
|
||||
|
||||
@@ -101,6 +101,21 @@ Mini = {
|
||||
}
|
||||
};
|
||||
|
||||
parseSuggestions = function(data) {
|
||||
var a, d;
|
||||
for (a in data) {
|
||||
if (a === 'suggestions') {
|
||||
return data[a];
|
||||
} else {
|
||||
d = parseSuggestions(data[a]);
|
||||
if (d != null) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
loaded = {};
|
||||
|
||||
lazy_load = function(requirements, fn, that) {
|
||||
@@ -141,7 +156,7 @@ lazy_load = function(requirements, fn, that) {
|
||||
|
||||
build_control = function(control_name, state, control) {
|
||||
var $el, type, typeclass;
|
||||
$el = control.$el.find('[data-name=' + control_name + ']');
|
||||
$el = control.$el.find('[data-name=' + control_name + ']').first();
|
||||
type = $el.data('type');
|
||||
typeclass = null;
|
||||
try {
|
||||
@@ -293,21 +308,21 @@ WSF_CONTROL = (function() {
|
||||
};
|
||||
|
||||
WSF_CONTROL.prototype.process_update = function(new_states) {
|
||||
var control, _i, _len, _ref, _results;
|
||||
if (new_states[this.control_name] != null) {
|
||||
this.update(new_states[this.control_name]);
|
||||
}
|
||||
_ref = this.controls;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
control = _ref[_i];
|
||||
if (control != null) {
|
||||
_results.push(control.process_update(new_states));
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
var control, _i, _len, _ref;
|
||||
try {
|
||||
if (new_states[this.control_name] != null) {
|
||||
this.update(new_states[this.control_name]);
|
||||
_ref = this.controls;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
control = _ref[_i];
|
||||
if (control != null) {
|
||||
control.process_update(new_states[this.control_name]['controls']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
WSF_CONTROL.prototype.get_context_state = function() {
|
||||
@@ -317,6 +332,18 @@ WSF_CONTROL = (function() {
|
||||
return this.wrap(this.control_name, this.fullstate);
|
||||
};
|
||||
|
||||
WSF_CONTROL.prototype.get_full_control_name = function() {
|
||||
var val;
|
||||
if (this.parent_control != null) {
|
||||
val = this.parent_control.get_full_control_name();
|
||||
if (val !== "") {
|
||||
val = val + "-";
|
||||
}
|
||||
return val + this.control_name;
|
||||
}
|
||||
return this.control_name;
|
||||
};
|
||||
|
||||
WSF_CONTROL.prototype.wrap = function(cname, state) {
|
||||
var ctrs;
|
||||
ctrs = {};
|
||||
@@ -339,9 +366,20 @@ WSF_CONTROL = (function() {
|
||||
};
|
||||
|
||||
WSF_CONTROL.prototype.trigger_callback = function(control_name, event, event_parameter) {
|
||||
return this.run_trigger_callback(this.get_full_control_name(), event, event_parameter);
|
||||
};
|
||||
|
||||
WSF_CONTROL.prototype.get_page = function() {
|
||||
if (this.parent_control != null) {
|
||||
return this.parent_control.get_page();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
WSF_CONTROL.prototype.run_trigger_callback = function(control_name, event, event_parameter) {
|
||||
var self;
|
||||
if ((this.parent_control != null) && !this.isolation) {
|
||||
return this.parent_control.trigger_callback(control_name, event, event_parameter);
|
||||
return this.parent_control.run_trigger_callback(control_name, event, event_parameter);
|
||||
}
|
||||
self = this;
|
||||
return $.ajax({
|
||||
@@ -359,7 +397,7 @@ WSF_CONTROL = (function() {
|
||||
if (new_states.actions != null) {
|
||||
self.process_actions(new_states.actions);
|
||||
}
|
||||
return self.process_update(new_states);
|
||||
return self.get_page().process_update(new_states);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -416,6 +454,21 @@ WSF_PAGE_CONTROL = (function(_super) {
|
||||
this.load_subcontrols();
|
||||
}
|
||||
|
||||
WSF_PAGE_CONTROL.prototype.process_update = function(new_states) {
|
||||
var control, _i, _len, _ref;
|
||||
_ref = this.controls;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
control = _ref[_i];
|
||||
if (control != null) {
|
||||
control.process_update(new_states);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
WSF_PAGE_CONTROL.prototype.get_full_control_name = function() {
|
||||
return "";
|
||||
};
|
||||
|
||||
WSF_PAGE_CONTROL.prototype.wrap = function(cname, state) {
|
||||
return state;
|
||||
};
|
||||
@@ -534,6 +587,29 @@ WSF_INPUT_CONTROL = (function(_super) {
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
WSF_NAVLIST_ITEM_CONTROL = (function(_super) {
|
||||
|
||||
__extends(WSF_NAVLIST_ITEM_CONTROL, _super);
|
||||
|
||||
function WSF_NAVLIST_ITEM_CONTROL() {
|
||||
return WSF_NAVLIST_ITEM_CONTROL.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
WSF_NAVLIST_ITEM_CONTROL.prototype.update = function(state) {
|
||||
WSF_NAVLIST_ITEM_CONTROL.__super__.update.apply(this, arguments);
|
||||
if (state.active != null) {
|
||||
if (state.active) {
|
||||
return this.$el.addClass("active");
|
||||
} else {
|
||||
return this.$el.removeClass("active");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return WSF_NAVLIST_ITEM_CONTROL;
|
||||
|
||||
})(WSF_BUTTON_CONTROL);
|
||||
|
||||
WSF_TEXTAREA_CONTROL = (function(_super) {
|
||||
|
||||
__extends(WSF_TEXTAREA_CONTROL, _super);
|
||||
@@ -590,6 +666,7 @@ WSF_AUTOCOMPLETE_CONTROL = (function(_super) {
|
||||
var self;
|
||||
WSF_AUTOCOMPLETE_CONTROL.__super__.attach_events.apply(this, arguments);
|
||||
self = this;
|
||||
console.log(this.$el);
|
||||
this.$el.typeahead({
|
||||
name: this.control_name,
|
||||
template: this.state['template'],
|
||||
@@ -605,7 +682,7 @@ WSF_AUTOCOMPLETE_CONTROL = (function(_super) {
|
||||
});
|
||||
},
|
||||
filter: function(parsedResponse) {
|
||||
return parsedResponse[self.control_name]['suggestions'];
|
||||
return parseSuggestions(parsedResponse);
|
||||
},
|
||||
fn: function() {
|
||||
return self.trigger_callback(self.control_name, 'autocomplete');
|
||||
|
||||
Reference in New Issue
Block a user