summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI-extensions/grid/editor/SelectEditor.js
Unidiff
Diffstat (limited to 'frontend/beta/js/YUI-extensions/grid/editor/SelectEditor.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/YUI-extensions/grid/editor/SelectEditor.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI-extensions/grid/editor/SelectEditor.js b/frontend/beta/js/YUI-extensions/grid/editor/SelectEditor.js
new file mode 100644
index 0000000..200b8e3
--- a/dev/null
+++ b/frontend/beta/js/YUI-extensions/grid/editor/SelectEditor.js
@@ -0,0 +1,37 @@
1/**
2 * @class YAHOO.ext.grid.SelectEditor
3 * @extends YAHOO.ext.grid.CellEditor
4Creates an editor out of an existing select field. You can create the select element through DOM in Javascript and pass it to the SelectEditor's constructor <b>or</b> an easier way is like this:
5<br><br>
6Define the select field in your document, giving it the ygrid-editor class.
7<pre><code>
8&lt;select id="light" class="ygrid-editor"&gt;
9 &lt;option value="Shade"&gt;Shade&lt;/option&gt;
10 &lt;option value="Mostly Shady"&gt;Mostly Shady&lt;/option&gt;
11 &lt;option value="Sun or Shade"&gt;Sun or Shade&lt;/option&gt;
12 &lt;option value="Mostly Sunny"&gt;Mostly Sunny&lt;/option&gt;
13 &lt;option value="Sunny"&gt;Sunny&lt;/option&gt;
14&lt;/select&gt;
15</code></pre>
16Create the SelectEditor object, passing in the id of your select field.
17<pre><code>
18var editor = new YAHOO.ext.grid.SelectEditor('light');
19</code></pre>
20For more information on using this editor, see <a href="http://www.jackslocum.com/yui/2006/09/10/adding-built-in-editing-support-to-the-yahoo-ui-extensions-grid/">this blog post</a>.
21* @constructor
22* Create a new SelectEditor
23* @param {HTMLElement/String} element
24 */
25YAHOO.ext.grid.SelectEditor = function(element){
26 element.hideFocus = true;
27 YAHOO.ext.grid.SelectEditor.superclass.constructor.call(this, element);
28 this.element.swallowEvent('click');
29};
30YAHOO.extendX(YAHOO.ext.grid.SelectEditor, YAHOO.ext.grid.CellEditor);
31
32YAHOO.ext.grid.SelectEditor.prototype.fitToCell = function(box){
33 if(YAHOO.ext.util.Browser.isGecko){
34 box.height -= 3;
35 }
36 this.element.setBox(box, true);
37};