[Rt-commit] rt branch, lcore, updated. 4b095a011745bd72a22894e981528c063cf8b60d
clkao at bestpractical.com
clkao at bestpractical.com
Fri Sep 11 23:58:30 EDT 2009
The branch, lcore has been updated
via 4b095a011745bd72a22894e981528c063cf8b60d (commit)
via d1540a37d3dc0b98ce4ebba4724d9321518e145a (commit)
from 1243dab6a41eb663ad12d42b5f386d2e145713d1 (commit)
Summary of changes:
share/web/static/css/rulebuilder.css | 29 +++++++++++++++++------
share/web/static/js/rulebuilder.js | 40 +++++++++++++++++++--------------
2 files changed, 44 insertions(+), 25 deletions(-)
- Log -----------------------------------------------------------------
commit d1540a37d3dc0b98ce4ebba4724d9321518e145a
Author: Chia-liang Kao <clkao at bestpractical.com>
Date: Sat Sep 12 12:03:54 2009 +0900
reset states so serialization works properly.
diff --git a/share/web/static/js/rulebuilder.js b/share/web/static/js/rulebuilder.js
index f9f7e95..3177f76 100644
--- a/share/web/static/js/rulebuilder.js
+++ b/share/web/static/js/rulebuilder.js
@@ -376,6 +376,9 @@ RuleBuilder.Context.prototype.clear = function() {
jQuery('span.expression', this.element).remove();
jQuery('span.transform', this.element).hide();
jQuery('span.enter-value', this.element).hide();
+ this.self_eval = false;
+ this.expression = null;
+ this.func_name = null;
}
RuleBuilder.Context.prototype.serialize = function() {
commit 4b095a011745bd72a22894e981528c063cf8b60d
Author: Chia-liang Kao <clkao at bestpractical.com>
Date: Sat Sep 12 12:57:25 2009 +0900
- style tweaks.
- hotspring menu is now in the "! unmatched type" span.
- focus after transform.
diff --git a/share/web/static/css/rulebuilder.css b/share/web/static/css/rulebuilder.css
index f3665a5..cf09654 100644
--- a/share/web/static/css/rulebuilder.css
+++ b/share/web/static/css/rulebuilder.css
@@ -22,7 +22,7 @@ div.menu-item span.return-type {
div.top-context {
position: relative;
- left: 20em;
+ left: 1em;
}
div.context {
@@ -156,19 +156,32 @@ div.context span.expression {
padding-left: 1em;
}
-.context .unmatched {
- color: red;
- padding: 0.5em;
- margin-bottom: 0.5em;
- border: 1px solid red;
-
+.context .matched:before {
+ font-size: 1em;
+ font-weight: bold;
+ color: green;
+ content: "\2714";
+}
+.context .matched {
+ padding: 0.2em;
+ margin-bottom: 0.2em;
+ border: 1px solid green;
+ background: lightGreen;
}
+.context .unmatched {
+ color: red;
+ padding: 0.2em;
+ margin-bottom: 0.2em;
+ border: 1px solid red;
+ background: #e99;
+}
+
.context .unmatched:before {
font-size: 1em;
font-weight: bold;
color: #f00;
- content: "TYPE MISMATCH: ";
+ content: "! ";
}
.context .transform {
float: right;
diff --git a/share/web/static/js/rulebuilder.js b/share/web/static/js/rulebuilder.js
index 3177f76..cb24e6b 100644
--- a/share/web/static/js/rulebuilder.js
+++ b/share/web/static/js/rulebuilder.js
@@ -274,20 +274,14 @@ RuleBuilder.Context = function(expected_type, element, parent, rb) {
jQuery._span_({ 'class': 'return-type'})
.text(expected_type)
.appendTo(this.element);
- jQuery._span_({ 'class': 'launch-menu transform' })
- .text("â¨")
- .click(function(e) {
- that.transformMenu(this);
- return false;
- })
- .hide()
- .appendTo(this.element);
+
if (expected_type == 'Str' || expected_type == 'Num') { // self-evaluating
jQuery._span_({ 'class': 'enter-value' })
.text("Enter a value")
.click(function(e) {
jQuery(this).html('').unbind('click');
jQuery._input_({ 'type': 'text', class: 'enter-value'})
+ .change(function() { that.update_return_type(that.return_type_from_val(this.value)) } )
.appendTo(this).trigger('focus');
that.self_eval = true;
return true;
@@ -296,6 +290,10 @@ RuleBuilder.Context = function(expected_type, element, parent, rb) {
}
};
+RuleBuilder.Context.prototype.return_type_from_val = function(val) {
+ // XXX
+ return 'Str';
+}
RuleBuilder.Context.prototype.transform = function(func_name) {
if (this.parent) {
@@ -308,22 +306,24 @@ RuleBuilder.Context.prototype.transform = function(func_name) {
var tc = jQuery._div_({'class': 'context top-context'})
.prependTo(this.rb.ebuilder);
- rb.top_context = new RuleBuilder.Context(this.expected_type,
- tc.get(0), null, rb);
- rb.top_context.set_application(func_name, func);
- this.parent = rb.top_context;
+ var parent = new RuleBuilder.Context(this.expected_type,
+ tc.get(0), null, rb);
+ parent.set_application(func_name, func);
+ this.parent = rb.top_context = parent;
jQuery(this.element).unbind('click');
- var first_param = rb.top_context.children[0];
- rb.top_context.children[0] = this;
+ var first_param = parent.children[0];
+ var second_param = parent.children.length > 1 ? parent.children[1] : null;
+ parent.children[0] = this;
this.expected_type = first_param.expected_type;
jQuery('span.return-type:first', this.element)
.text(first_param.expected_type);
jQuery(first_param.element).replaceWith(this.element);
var that = this;
jQuery(this.element).click(function(e) { rb.focus(that); return false });
-
this.update_return_type(this.return_type);
+ if (second_param)
+ this.focus(second_param);
}
}
@@ -362,12 +362,15 @@ RuleBuilder.Context.prototype.transformMenu = function(el) {
}
RuleBuilder.Context.prototype.update_return_type = function(type) {
+ // XXX: this should query the server for 'is-a-type-of'
this.return_type = type;
+ var el = jQuery("span.return-type", this.element);
if (this.expected_type == type) {
- jQuery("span.return-type", this.element).removeClass("unmatched").addClass("matched");
+ el.removeClass("unmatched").addClass("matched");
}
else {
- jQuery("span.return-type", this.element).removeClass("matched").addClass("unmatched");
+ el.removeClass("matched").addClass("unmatched");
+ this.transformMenu(el);
}
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list