Commit 2c0d6e8a authored by Xiaowu Zhang's avatar Xiaowu Zhang

Add requied functionality for listfield gadget

parent e3f8dfcf
......@@ -101,7 +101,7 @@
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*global window, rJS, Handlebars, document, RSVP */\n
/*global window, rJS, Handlebars, document, RSVP, loopEventListener*/\n
/*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window, rJS, Handlebars, document, RSVP) {\n
"use strict";\n
......@@ -132,7 +132,8 @@
// acquired method\n
//////////////////////////////////////////////\n
.declareAcquiredMethod("translateHtml", "translateHtml")\n
\n
.declareAcquiredMethod("notifyValid", "notifyValid")\n
.declareAcquiredMethod("notifyInvalid", "notifyInvalid")\n
.declareMethod(\'render\', function (options) {\n
var i,\n
template,\n
......@@ -164,9 +165,7 @@
})\n
.push(function (my_translated_html) {\n
// XXX: no fan...\n
var option_list,\n
i_len,\n
select_div,\n
var select_div,\n
div = document.createElement("div");\n
\n
div.innerHTML = my_translated_html;\n
......@@ -185,12 +184,40 @@
}\n
});\n
})\n
\n
.declareMethod(\'checkValidity\', function () {\n
var result;\n
result = this.element.querySelector(\'select\').checkValidity();\n
if (result) {\n
return this.notifyValid()\n
.push(function () {\n
return result;\n
});\n
}\n
return result;\n
})\n
.declareMethod(\'getContent\', function () {\n
var input = this.element.querySelector(\'select\'),\n
result = {};\n
result[input.getAttribute(\'name\')] = input.options[input.selectedIndex].value;\n
return result;\n
})\n
.declareService(function () {\n
////////////////////////////////////\n
// Inform when the field input is invalid\n
////////////////////////////////////\n
var field_gadget = this;\n
\n
function notifyInvalid(evt) {\n
return field_gadget.notifyInvalid(evt.target.validationMessage);\n
}\n
\n
// Listen to input change\n
return loopEventListener(\n
field_gadget.element.querySelector(\'select\'),\n
\'invalid\',\n
false,\n
notifyInvalid\n
);\n
});\n
\n
}(window, rJS, Handlebars, document, RSVP));
......@@ -316,7 +343,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>xiaowu</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -330,7 +357,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>940.21609.3247.37922</string> </value>
<value> <string>940.49457.43407.46148</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -348,7 +375,7 @@
</tuple>
<state>
<tuple>
<float>1421405407.17</float>
<float>1423135404.46</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment