Get some buttons working in nm. Not quite done yet, only buttons with onclick function working

This commit is contained in:
Nathan Gray 2011-09-21 21:07:21 +00:00
parent 1f39e5c562
commit 7297e02f39
3 changed files with 28 additions and 7 deletions

View File

@ -200,7 +200,7 @@ var et2_baseWidget = et2_DOMWidget.extend(et2_IAligned, {
if (this.node)
{
$j(this.node).bind("click.et2_baseWidget", this, function(e) {
return e.data.click(this);
return e.data.click.call(e.data,e);
});
}
@ -232,10 +232,10 @@ var et2_baseWidget = et2_DOMWidget.extend(et2_IAligned, {
return this.getDOMNode(this);
},
click: function(_node) {
click: function(event) {
if (this.onclick)
{
return this.onclick.call(_node);
return this.onclick.call(this, event);
}
return true;

View File

@ -254,7 +254,14 @@ function et2_checkType(_val, _type, _attr, _cname)
{
// Parse JS code properly
_val = et2_js_pseudo_funcs(_val, _cname);
if(_val == "1") return function() {return true;};
// Check for remaining row data
if(_val.indexOf("$") >= 0 || _val.indexOf("@") >= 0)
{
// Still needs parsing
return _val;
}
return new Function(_val);
}
catch(e)

View File

@ -82,8 +82,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
return this.btn ? this.btn[0] : null;
},
// TODO: What's going on here? It doesn't get called, but something happens if you double click.
click: function() {
onclick: function(e) {
// Execute the JS code connected to the event handler
if (this.options.onclick)
{
@ -140,7 +139,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
*/
getDetachedAttributes: function(_attrs)
{
_attrs.push("value", "class", "image");
_attrs.push("value", "class", "image", "onclick");
},
getDetachedNodes: function()
@ -150,7 +149,9 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
setDetachedAttributes: function(_nodes, _values)
{
this.btn = _nodes[0];
this.btn = jQuery(_nodes[0]);
this.image = _nodes[1];
if (typeof _values["id"] != "undefined")
@ -165,6 +166,19 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
{
this.set_class(_values["class"]);
}
if (typeof _values["onclick"] == "string")
{
_values["onclick"] = new Function(_values["onclick"]);
}
if (typeof _values["onclick"] == "function")
{
this.options.onclick = _values["onclick"];
this.btn.bind("click.et2_baseWidget", this, function(e) {
return e.data.click.call(e.data,e);
});
}
}
});