diff options
author | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:10 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:18 +0400 |
commit | 1354d17270961fff662d40f90521223f8fd0d73b (patch) | |
tree | e9266be71587e47c800303446e968a6d3565e2cf /lib/dijit/form/DataList.js.uncompressed.js | |
parent | d04f8c826f5283765f52cf6b98b42a1ed8f2d6bc (diff) |
update dojo to 1.7.3
Diffstat (limited to 'lib/dijit/form/DataList.js.uncompressed.js')
-rw-r--r-- | lib/dijit/form/DataList.js.uncompressed.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/dijit/form/DataList.js.uncompressed.js b/lib/dijit/form/DataList.js.uncompressed.js new file mode 100644 index 000000000..acfb5167c --- /dev/null +++ b/lib/dijit/form/DataList.js.uncompressed.js @@ -0,0 +1,63 @@ +define("dijit/form/DataList", [ + "dojo/_base/declare", // declare + "dojo/dom", // dom.byId + "dojo/_base/lang", // lang.trim + "dojo/query", // query + "dojo/store/Memory", // dojo.store.Memory + "../registry" // registry.add registry.remove +], function(declare, dom, lang, query, MemoryStore, registry){ + + // module: + // dijit/form/DataList + // summary: + // Inefficient but small data store specialized for inlined data via OPTION tags + + function toItem(/*DOMNode*/ option){ + // summary: + // Convert <option> node to hash + return { + id: option.value, + value: option.value, + name: lang.trim(option.innerText || option.textContent || '') + }; + } + + return declare("dijit.form.DataList", MemoryStore, { + // summary: + // Inefficient but small data store specialized for inlined data via OPTION tags + // + // description: + // Provides a store for inlined data like: + // + // | <datalist> + // | <option value="AL">Alabama</option> + // | ... + + constructor: function(/*Object?*/ params, /*DomNode|String*/ srcNodeRef){ + // store pointer to original DOM tree + this.domNode = dom.byId(srcNodeRef); + + lang.mixin(this, params); + if(this.id){ + registry.add(this); // add to registry so it can be easily found by id + } + this.domNode.style.display = "none"; + + this.inherited(arguments, [{ + data: query("option", this.domNode).map(toItem) + }]); + }, + + destroy: function(){ + registry.remove(this.id); + }, + + fetchSelectedItem: function(){ + // summary: + // Get the option marked as selected, like `<option selected>`. + // Not part of dojo.data API. + var option = query("> option[selected]", this.domNode)[0] || query("> option", this.domNode)[0]; + return option && toItem(option); + } + }); +}); |