internal static string SerializeForm(FormElement form) { DOMElement[] formElements = form.Elements; StringBuilder formBody = new StringBuilder(); int count = formElements.Length; for (int i = 0; i < count; i++) { DOMElement element = formElements[i]; string name = (string)Type.GetField(element, "name"); if (name == null || name.Length == 0) { continue; } string tagName = element.TagName.ToUpperCase(); if (tagName == "INPUT") { InputElement inputElement = (InputElement)element; string type = inputElement.Type; if ((type == "text") || (type == "password") || (type == "hidden") || (((type == "checkbox") || (type == "radio")) && (bool)Type.GetField(element, "checked"))) { formBody.Append(name.EncodeURIComponent()); formBody.Append("="); formBody.Append(inputElement.Value.EncodeURIComponent()); formBody.Append("&"); } } else if (tagName == "SELECT") { SelectElement selectElement = (SelectElement)element; int optionCount = selectElement.Options.Length; for (int j = 0; j < optionCount; j++) { OptionElement optionElement = (OptionElement)selectElement.Options[j]; if (optionElement.Selected) { formBody.Append(name.EncodeURIComponent()); formBody.Append("="); formBody.Append(optionElement.Value.EncodeURIComponent()); formBody.Append("&"); } } } else if (tagName == "TEXTAREA") { formBody.Append(name.EncodeURIComponent()); formBody.Append("="); formBody.Append(((string)Type.GetField(element, "value")).EncodeURIComponent()); formBody.Append("&"); } } return(formBody.ToString()); }
private void OnSelect(PilesElement piles, OptionElement option) { if (!piles.m_bIsVisable) { return; } piles.m_SpriteItem.spriteName = option.m_strName; option.m_RootObj.SetActive(false); }
public void NotifySelectedSetsSelected() { var option = new OptionElement(); option.NotifyValue(new ElementEventValue { Checked = true, }); Assert.True(option.Selected); }
public void OptionWithValueGetsSelected() { var select = new SelectElement { Value = "lolo" }; var option = new OptionElement { Value = "lolo" }; select.AppendChild(option); Assert.True(option.Selected); }
public void LoopSelectOptions() { var select = new SelectElement(); var option1 = new OptionElement(); var group = Element.Create("optgroup"); var option2 = new OptionElement(); group.AppendChild(option2); select.AppendChild(option1); select.AppendChild(group); Assert.Equal(new List <OptionElement> { option1, option2 }, select.Options); }
private int GetSelectedItem(out OptionElement el) { var index = Children(Parent).IndexOf(item => item.Element.HasAttribute("selected"), out el); if (Parent.Multiple || index >= 0) { return(index); } else { return(Children(Parent).IndexOf(item => !item.Disabled, out el)); } }
public void AddSelectedOptionInGroup() { var select = new SelectElement { Value = "lolo" }; var option = new OptionElement { Value = "lolo" }; var group = new OptionGroup(); select.AppendChild(group); group.AppendChild(option); Assert.True(option.Selected); }
private int GetSelectedItem(out OptionElement el) { throw new System.MyNotImplementException(); // HTML5 says the last selected one is it //var index = Children(Parent).LastIndexOf(item => // item.Element.HasAttribute("selected"), out el); //if (Parent.Multiple || index >= 0) //{ // return index; //} //else //{ // return Children(Parent).IndexOf(item => !item.Disabled, out el); //} }
private void OnDragEnd(MyUIDragDropItem item) { for (int i = 0; i < m_PilesList.Count; ++i) { //check drag over if (IsInRect(item.GetComponent <UIWidget>(), m_PilesList[i].m_RootObj.GetComponent <UIWidget>())) { OptionElement option = null; foreach (var elem in m_OptionList) { if (elem.m_RootObj == item.gameObject) { option = elem; break; } } OnSelect(m_PilesList[i], option); break; } } }
public void ResetWindow(Regularity2DWindowParam param) { ClearWindow(); for (int i = 0; i < param.m_PilesList.Count; ++i) { var data = param.m_PilesList[i]; PilesElement elem = new PilesElement(); elem.m_RootObj = GameObject.Instantiate(m_PilesTemplate); elem.m_RootObj.transform.parent = m_PilesRoot.transform; elem.m_bIsVisable = data.IsVisable; elem.m_SpriteItem = ComponentTool.FindChildComponent <UISprite>("Sprite_Option", elem.m_RootObj); elem.m_SpriteItem.spriteName = elem.m_bIsVisable ? data.Name : ""; elem.m_strName = data.Name; elem.m_RootObj.SetActive(true); elem.m_RootObj.transform.localScale = Vector3.one; m_PilesList.Add(elem); } for (int i = 0; i < param.m_OptionList.Count; ++i) { var data = param.m_OptionList[i]; OptionElement elem = new OptionElement(); elem.m_RootObj = GameObject.Instantiate(m_OptionTemplate); elem.m_RootObj.transform.parent = m_OptionRoot.transform; elem.m_SpriteItem = ComponentTool.FindChildComponent <UISprite>("Sprite_Option", elem.m_RootObj); elem.m_SpriteItem.spriteName = data; elem.m_RootObj.GetComponent <MyUIDragDropItem>().RegisterDragEndAction(OnDragEnd); elem.m_strName = data; elem.m_RootObj.SetActive(true); elem.m_RootObj.transform.localScale = Vector3.one; m_OptionList.Add(elem); } m_ResultCallBack = param.m_ResultCallBack; m_OptionRoot.repositionNow = true; m_PilesRoot.repositionNow = true; }
private void RowFieldChange(jQueryObject row) { jQueryObject select = row.Children("div.f").Children("select"); string fieldName = select.GetValue(); bool isEmpty = (fieldName == null || fieldName == ""); // if a field is selected and first option is "---please select---", remove it if (!isEmpty) { OptionElement firstOption = (OptionElement)select.Children("option").First()[0]; if (firstOption.Value == null || firstOption.Value == "") { J(firstOption).Remove(); } } jQueryObject opDiv = row.Children("div.o"); jQueryObject opSelect = opDiv.Children("select"); if (opSelect.Length == 0) { opSelect = J("<select/>").AppendTo(opDiv).Change(OnRowOperatorChange); } else { Q.ClearOptions(opSelect); } RemoveFilterHandler(row); PopulateOperatorList(opSelect); RowOperatorChange(row); UpdateParens(); UpdateButtons(); }
public void SelectValueChangeOnChildOptions() { var select = new SelectElement(); var opt1 = new OptionElement { Value = "a" }; var opt2 = new OptionElement { Value = "b" }; var group = new OptionGroup(); group.AppendChild(opt2); select.AppendChild(opt1); select.AppendChild(group); select.Value = "a"; Assert.True(opt1.Selected); Assert.False(opt2.Selected); select.Multiple = true; select.Value = "b"; Assert.True(opt1.Selected); Assert.True(opt2.Selected); }
private int GetSelectedItem(out OptionElement el) { // HTML5 says the last selected one is it var index = Children(Parent).LastIndexOf(item => item.Element.HasAttribute("selected"), out el); if (Parent.Multiple || index >= 0) { return index; } else { return Children(Parent).IndexOf(item => !item.Disabled, out el); } }
public void ResetWindow(Regularity2DWindowParam param) { ClearWindow(); for (int i = 0; i < param.m_PilesList.Count; ++i) { var data = param.m_PilesList[i]; PilesElement elem = new PilesElement(); elem.m_RootObj = GameObject.Instantiate(m_PilesTemplate); elem.m_RootObj.transform.parent = m_PilesRoot.transform; elem.m_bIsVisable = data.IsVisable; elem.m_SpriteItem = ComponentTool.FindChildComponent<UISprite>("Sprite_Option", elem.m_RootObj); elem.m_SpriteItem.spriteName = elem.m_bIsVisable ? data.Name : ""; elem.m_strName = data.Name; elem.m_RootObj.SetActive(true); elem.m_RootObj.transform.localScale = Vector3.one; m_PilesList.Add(elem); } for (int i = 0; i < param.m_OptionList.Count; ++i) { var data = param.m_OptionList[i]; OptionElement elem = new OptionElement(); elem.m_RootObj = GameObject.Instantiate(m_OptionTemplate); elem.m_RootObj.transform.parent = m_OptionRoot.transform; elem.m_SpriteItem = ComponentTool.FindChildComponent<UISprite>("Sprite_Option", elem.m_RootObj); elem.m_SpriteItem.spriteName = data; elem.m_RootObj.GetComponent<MyUIDragDropItem>().RegisterDragEndAction(OnDragEnd); elem.m_strName = data; elem.m_RootObj.SetActive(true); elem.m_RootObj.transform.localScale = Vector3.one; m_OptionList.Add(elem); } m_ResultCallBack = param.m_ResultCallBack; m_OptionRoot.repositionNow = true; m_PilesRoot.repositionNow = true; }
private void OnSelect(PilesElement piles,OptionElement option) { if (!piles.m_bIsVisable) { return; } piles.m_SpriteItem.spriteName = option.m_strName; option.m_RootObj.SetActive(false); }
public static new Element FromObj(object instance) { if (instance == null) { return(null); } try{ string tagUrn = (string)GetProperty(instance, "tagUrn"); string tagName = (string)GetProperty(instance, "tagName"); if (tagUrn == null || tagUrn == "") { switch (tagName.ToLower()) { case "!": return(CommentElement.FromObj(instance)); case "a": return(AElement.FromObj(instance)); case "area": return(AreaElement.FromObj(instance)); case "base": return(BaseElement.FromObj(instance)); case "basefont": return(BaseFontElement.FromObj(instance)); case "bgsound": return(BgsoundElement.FromObj(instance)); case "address": case "pre": case "center": case "listing": case "xmp": case "plaintext": case "blockquote": return(BlockElement.FromObj(instance)); case "body": return(BodyElement.FromObj(instance)); case "br": return(BrElement.FromObj(instance)); case "button": return(ButtonElement.FromObj(instance)); case "dd": return(DdElement.FromObj(instance)); case "div": return(DivElement.FromObj(instance)); case "dl": return(DlElement.FromObj(instance)); case "dt": return(DtElement.FromObj(instance)); case "embed": return(EmbedElement.FromObj(instance)); case "fieldset": return(FieldsetElement.FromObj(instance)); case "font": return(FontElement.FromObj(instance)); case "form": return(FormElement.FromObj(instance)); case "frame": return(FrameElement.FromObj(instance)); case "frameset": return(FramesetElement.FromObj(instance)); case "head": return(HeadElement.FromObj(instance)); case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": return(HnElement.FromObj(instance)); case "hr": return(HrElement.FromObj(instance)); case "html": return(HtmlElement.FromObj(instance)); case "iframe": return(IframeElement.FromObj(instance)); case "img": return(ImgElement.FromObj(instance)); case "input": return(InputElement.FromObj(instance)); case "isindex": return(IsindexElement.FromObj(instance)); case "legend": return(LegendElement.FromObj(instance)); case "label": return(LabelElement.FromObj(instance)); case "li": return(LiElement.FromObj(instance)); case "link": return(LinkElement.FromObj(instance)); case "map": return(MapElement.FromObj(instance)); case "marquee": return(MarqueeElement.FromObj(instance)); case "meta": return(MetaElement.FromObj(instance)); case "nextid": return(NextidElement.FromObj(instance)); case "noembed": case "noframes": case "nolayer": case "noscript": return(NoshowElement.FromObj(instance)); case "applet": case "object": return(ObjectElement.FromObj(instance)); case "ol": return(OlElement.FromObj(instance)); case "optgroup": case "option": return(OptionElement.FromObj(instance)); case "p": return(PElement.FromObj(instance)); case "param": return(ParamElement.FromObj(instance)); case "i": case "u": case "b": case "q": case "s": case "strong": case "del": case "strike": case "em": case "small": case "big": case "ruby": case "rp": case "sub": case "sup": case "acronym": case "bdo": case "cite": case "dfn": case "ins": case "code": case "kbd": case "samp": case "var": case "nobr": return(PhraseElement.FromObj(instance)); case "script": return(ScriptElement.FromObj(instance)); case "select": return(SelectElement.FromObj(instance)); case "span": return(SpanElement.FromObj(instance)); case "style": return(StyleElement.FromObj(instance)); case "caption": return(CaptionElement.FromObj(instance)); case "td": case "th": return(TableCellElement.FromObj(instance)); case "table": return(TableElement.FromObj(instance)); case "colgroup": case "col": return(ColElement.FromObj(instance)); case "tr": return(TrElement.FromObj(instance)); case "thead": case "tbody": case "tfoot": return(TableSectionElement.FromObj(instance)); case "textarea": return(TextAreaElement.FromObj(instance)); case "wbr": return(TextElement.FromObj(instance)); case "title": return(TitleElement.FromObj(instance)); case "dir": case "menu": case "ul": return(UlElement.FromObj(instance)); // optionbutton ? // spanflow ? // default: return UnknownElement.FromObj(instance); } } }catch { // IHTMLElement でない可能性 } return(new Element(instance)); }
//#>>delete public OptionElement create(string text, string value, bool defaultSelected, bool selected) { return(OptionElement.FromObj(this.Invoke("create", text, value, defaultSelected, selected))); }
private void FillSelect(SelectElement el, OptionElement[] options) { ClearSelect(el); for (int i = 0; i < options.Length; i++) { el.AppendChild(options[i]); } }
private void FillOptionArrayFromValues(Pair[] options, OptionElement[] array) { for (int i = 0; i < options.Length;i++ ) { Pair de = options[i]; OptionElement el = (OptionElement)Document.CreateElement("OPTION"); el.InnerHTML = de.key.Unescape().Replace("&", "&").Replace(" ", " "); el.Value = de.value; array[array.Length] = el; } }
private void CopyValuesFromSelectListToArray(SelectElement el, OptionElement[] options) { for (int i = 0; i < el.Options.Length; i++) { options[options.Length] = (OptionElement) el.Options[i]; } }
public extern static AngularOptionElement Angular(this OptionElement el);
internal static HtmlElement CreateFor(XElement element) { HtmlElement result = null; switch (element.Name.LocalName.ToLower()) { case "form": result = new FormElement(element); break; case "input": string type = element.GetAttribute("type") ?? ""; switch (type.ToLower()) { case "radio": result = new RadioInputElement(element); break; case "checkbox": result = new CheckboxInputElement(element); break; case "image": result = new ImageInputElement(element); break; case "submit": case "button": result = new ButtonInputElement(element); break; case "file": result = new FileUploadElement(element); break; case "email": result = new EmailInputElement(element); break; case "url": result = new UrlInputElement(element); break; case "datetime-local": case "date": case "month": case "week": case "time": result = new DateTimeInputElement(element); break; case "number": case "range": result = new NumberInputElement(element); break; case "color": result = new ColorInputElement(element); break; default: result = new InputElement(element); break; } break; case "textarea": result = new TextAreaElement(element); break; case "select": result = new SelectElement(element); break; case "option": result = new OptionElement(element); break; case "iframe": case "frame": var src = element.GetAttributeCI("src"); if (!string.IsNullOrWhiteSpace(src)) { result = new FrameElement(element); } else { result = default(HtmlElement); } break; case "a": result = new AnchorElement(element); break; case "label": result = new LabelElement(element); break; case "button": result = new ButtonInputElement(element); break; default: result = new HtmlElement(element); break; } return(result); }
private HtmlElement CreateFor(XElement element) { HtmlElement result; switch (element.Name.LocalName.ToLower()) { case "form": result = new FormElement(element); break; case "input": string type = element.GetAttribute("type") ?? ""; switch (type.ToLower()) { case "radio": result = new RadioInputElement(element); break; case "checkbox": result = new CheckboxInputElement(element); break; case "submit": case "image": case "button": string buttonType = element.GetAttribute("type"); result = new ButtonInputElement(element); break; case "file": result = new FileUploadElement(element); break; default: result = new InputElement(element); break; } break; case "textarea": result = new TextAreaElement(element); break; case "select": result = new SelectElement(element); break; case "option": result = new OptionElement(element); break; case "iframe": case "frame": result = new FrameElement(element); break; case "a": result = new AnchorElement(element); break; case "label": result = new LabelElement(element); break; case "button": result = new ButtonInputElement(element); break; default: result = new HtmlElement(element); break; } _allActiveElements.Add(result); return(result); }