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.js | 37 |
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 | ||
4 | Creates 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> | ||
6 | Define the select field in your document, giving it the ygrid-editor class. | ||
7 | <pre><code> | ||
8 | <select id="light" class="ygrid-editor"> | ||
9 | <option value="Shade">Shade</option> | ||
10 | <option value="Mostly Shady">Mostly Shady</option> | ||
11 | <option value="Sun or Shade">Sun or Shade</option> | ||
12 | <option value="Mostly Sunny">Mostly Sunny</option> | ||
13 | <option value="Sunny">Sunny</option> | ||
14 | </select> | ||
15 | </code></pre> | ||
16 | Create the SelectEditor object, passing in the id of your select field. | ||
17 | <pre><code> | ||
18 | var editor = new YAHOO.ext.grid.SelectEditor('light'); | ||
19 | </code></pre> | ||
20 | For 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 | */ | ||
25 | YAHOO.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 | }; | ||
30 | YAHOO.extendX(YAHOO.ext.grid.SelectEditor, YAHOO.ext.grid.CellEditor); | ||
31 | |||
32 | YAHOO.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 | }; | ||