| 1 | define([ |
| 2 | "dojo/_base/declare", |
| 3 | "dojo/dom-class", |
| 4 | "./Container", |
| 5 | "dojo/has", |
| 6 | "dojo/has!dojo-bidi?dojox/mobile/bidi/FormLayout" |
| 7 | ], function(declare, domClass, Container, has, BidiFormLayout){ |
| 8 | |
| 9 | // module: |
| 10 | // dojox/mobile/FormLayout |
| 11 | |
| 12 | var FormLayout = declare(has("dojo-bidi") ? "dojox.mobile.NonBidiFormLayout" : "dojox.mobile.FormLayout", Container, { |
| 13 | // summary: |
| 14 | // A responsive container to create mobile forms. |
| 15 | // description: |
| 16 | // This container layouts form widgets according to the screen size. |
| 17 | // Each row of a form is made of a <label> and a <fieldset> that contains one or more form widgets. |
| 18 | // By default, if the width of the screen if greater than 500px, the <label> and the <fieldset> are positioned on the same line. |
| 19 | // Otherwise they are stacked vertically. You can force how a <label> and its <fieldset> are positioned using the |
| 20 | // 'columns' property. |
| 21 | // Form controls are: "dojox/mobile/Button", "dojox/mobile/CheckBox", "dojox/mobile/ComboBox", |
| 22 | // "dojox/mobile/RadioButton", "dojox/mobile/Slider", "dojox/mobile/TextBox", "dojox/mobile/SearchBox", |
| 23 | // "dojox/mobile/ExpandingTextArea", "dojox/mobile/ToggleButton". |
| 24 | // example: |
| 25 | // | <div data-dojo-type="dojox/mobile/FormLayout" data-dojo-props="columns:'two', rightAlign:true"> |
| 26 | // | <div> |
| 27 | // | <label>Name:</label> |
| 28 | // | <fieldset> |
| 29 | // | <input data-dojo-type="dojox/mobile/TextBox"> |
| 30 | // | </fieldset> |
| 31 | // | </div> |
| 32 | // | <div> |
| 33 | // | <label>Make a choice:</label> |
| 34 | // | <fieldset> |
| 35 | // | <input type="radio" id="rb1" data-dojo-type="dojox/mobile/RadioButton" name="mobileRadio" checked><label for="rb1">Small</label> |
| 36 | // | <input type="radio" id="rb2" data-dojo-type="dojox/mobile/RadioButton" name="mobileRadio" checked><label for="rb2">Medium</label> |
| 37 | // | <input type="radio" id="rb3" data-dojo-type="dojox/mobile/RadioButton" name="mobileRadio" checked><label for="rb3">Large</label> |
| 38 | // | </fieldset> |
| 39 | // | </div> |
| 40 | // | </div> |
| 41 | |
| 42 | |
| 43 | // columns: [const] "auto" | "single" | "two" |
| 44 | // This property controls how a <label> and its <fieldset> are positioned. The <label> can be on the same line |
| 45 | // than its <fieldset> (two columns) or on top of it (single column). |
| 46 | // If set to "auto", the number of columns depends on the width of the screen: Two columns |
| 47 | // if the width of the screen is larger than 500px, one column otherwise. The width of the screen is determined using CSS |
| 48 | // Media Queries. |
| 49 | // Setting this property to "single" or "two" allows to force the layout used whatever the width of the screen. |
| 50 | // Default value for this property is "auto". |
| 51 | // Note that changing the value of the property after the widget |
| 52 | // creation has no effect. |
| 53 | columns: "auto", |
| 54 | |
| 55 | // rightAlign: [const] Boolean |
| 56 | // This property controls the horizontal position of control(s) in a <fieldset>. It applies only |
| 57 | // to forms that have two columns (see 'columns' property). |
| 58 | // Default value for this property is false. |
| 59 | // Note that changing the value of the property after the widget |
| 60 | // creation has no effect. |
| 61 | rightAlign: false, |
| 62 | |
| 63 | /* internal properties */ |
| 64 | |
| 65 | // baseClass: String |
| 66 | // The name of the CSS class of this widget. |
| 67 | baseClass: "mblFormLayout", |
| 68 | |
| 69 | buildRendering: function(){ |
| 70 | this.inherited(arguments); |
| 71 | if(this.columns == "auto"){ |
| 72 | domClass.add(this.domNode, "mblFormLayoutAuto"); |
| 73 | }else if(this.columns == "single"){ |
| 74 | domClass.add(this.domNode, "mblFormLayoutSingleCol"); |
| 75 | }else if(this.columns == "two"){ |
| 76 | domClass.add(this.domNode, "mblFormLayoutTwoCol"); |
| 77 | } |
| 78 | if(this.rightAlign){ |
| 79 | domClass.add(this.domNode, "mblFormLayoutRightAlign"); |
| 80 | } |
| 81 | } |
| 82 | }); |
| 83 | return has("dojo-bidi") ? declare("dojox.mobile.FormLayout", [FormLayout, BidiFormLayout]) : FormLayout; |
| 84 | }); |