public void DeleteItem(int row) { numRows--; rowData.RemoveAt(row); #if CLIENT if (isAttached && !rebuilding) { int newSelection = SelectedRowIndex; bool changeSelection = false; if (SelectedRowIndex == row) { if (numRows > 0) { if (newSelection == numRows) { newSelection = numRows - 1; } } else { newSelection = -1; } changeSelection = true; } jQueryObject q = jQuery.FromElement(GetValuesTBody().Rows[row]).Remove(), next = q.Next(); q.Remove(); for (; next.Size() > 0; next = next.Next()) { if (next.Is("." + EvenRowClass)) { next.RemoveClass(EvenRowClass); next.AddClass(OddRowClass); } else { next.RemoveClass(OddRowClass); next.AddClass(EvenRowClass); } } if (changeSelection) { selectedRowIndex = -1; // hack to make the next procedure sure the GUI must be updated SelectedRowIndex = newSelection; OnSelectionChanged(EventArgs.Empty); } return; } #endif if (selectedRowIndex >= row) { selectedRowIndex--; } rowTextsIfNotRendered.RemoveAt(row); rowClassesIfNotRendered.RemoveAt(row); }
public ImageUploadEditor(jQueryObject div, ImageUploadEditorOptions opt) : base(div, opt) { div.AddClass("s-ImageUploadEditor"); if (options.OriginalNameProperty.IsEmptyOrNull()) { div.AddClass("hide-original-name"); } var self = this; toolbar = new Toolbar(J("<div/>").AppendTo(this.Element), new ToolbarOptions { Buttons = GetToolButtons() }); var progress = J("<div><div></div></div>").AddClass("upload-progress") .PrependTo(toolbar.Element); var addFileButton = toolbar.FindButton("add-file-button"); uploadInput = UploadHelper.AddUploadInput(new UploadInputOptions { Container = addFileButton, InputName = this.uniqueName, Zone = this.element, Progress = progress, FileDone = (response, name, data) => { if (!UploadHelper.CheckImageConstraints(response, options)) { return; } var newEntity = new UploadedFile { OriginalName = name, Filename = response.TemporaryFile }; self.entity = newEntity; self.Populate(); self.UpdateInterface(); } }); fileSymbols = jQuery.FromHtml("<ul/>") .AppendTo(this.element); this.UpdateInterface(); }
public URLEditor(jQueryObject input) : base(input) { input.AddClass("url").Attribute("title", "URL 'http://www.site.com/sayfa' formatında girilmelidir."); input.Bind("blur." + this.uniqueName, delegate { var validator = input.Closest("form").GetDataValue("validator").As <jQueryValidator>(); if (validator == null) { return; } if (!input.HasClass("error")) { return; } var value = input.GetValue().TrimToNull(); if (value == null) { return; } value = "http://" + value; if (((dynamic)(jQueryValidator.Methods["url"])).apply(validator, new object[] { value, input[0] }) == true) { input.Value(value); validator.ValidateElement(input[0]); } }); }
public URLEditor(jQueryObject input) : base(input) { input.AddClass("url").Attribute("title", "URL 'http://www.site.com/sayfa' formatında girilmelidir."); input.Bind("blur." + this.uniqueName, delegate { var validator = input.Closest("form").GetDataValue("validator").As<jQueryValidator>(); if (validator == null) return; if (!input.HasClass("error")) return; var value = input.GetValue().TrimToNull(); if (value == null) return; value = "http://" + value; if (((dynamic)(jQueryValidator.Methods["url"])).apply(validator, new object[] { value, input[0] }) == true) { input.Value(value); validator.ValidateElement(input[0]); } }); }
public CheckTreeEditor(jQueryObject div, TOptions opt) : base(div, opt) { div.AddClass("s-CheckTreeEditor"); UpdateItems(); }
public FoldersWidget(jQueryObject parent, FolderJson[] folders, string folderPath) { string separator = Environment.ServerType == ServerType.AspNet ? "\\" : "/"; attachedObject = Template.Get("client", "folders-table", true).AppendTo(parent).Attribute("data-path", folderPath); ((List<FolderJson>)(object)folders).Sort(delegate(FolderJson a, FolderJson b) { return Utility.NaturalCompare(a.name, b.name); }); foreach (FolderJson folder in folders) { string subfolderPath = folderPath + separator + folder.name; jQueryObject row = Template.Get("client", "folders-trow", true).AppendTo(attachedObject.Children()); jQueryObject btn = jQuery.Select(".folders-btn", row).Click(FolderButtonClick).Attribute("data-path", subfolderPath).Text(folder.count == 0 ? folder.name : String.Format("{0} ({1})", folder.name, folder.count)).Attribute("data-count", folder.count.ToString()); jQueryObject expandBtn = jQuery.Select(".folders-expand-btn", row).Click(ExpandButtonClick); if (folder.subfolders != null && folder.subfolders.Length > 0) { expandBtn.Attribute("data-path", subfolderPath).Children().AddClass("icon-plus"); new FoldersWidget(jQuery.Select(".folders-tcell", row), folder.subfolders, subfolderPath); } } if (folderPath != "") { attachedObject.Hide(); if (Settings.UseAnimation) { attachedObject.AddClass("fade"); } } }
public EmailEditor(jQueryObject input, EmailEditorOptions opt) : base(input, opt) { RegisterValidationMethods(); input.AddClass("emailuser").RemoveClass("flexify"); var spanAt = J("<span/>") .Text("@") .AddClass("emailat") .InsertAfter(input); var domain = J("<input type=\"text\"/>") .AddClass("emaildomain") .AddClass("flexify") .InsertAfter(spanAt); domain.Bind("blur." + this.uniqueName, delegate { var validator = domain.Closest("form").GetDataValue("validator").As <jQueryValidator>(); if (validator != null) { validator.ValidateElement(input[0]); } }); if (!options.Domain.IsEmptyOrNull()) { domain.Value(options.Domain); } if (options.ReadOnlyDomain) { domain.Attribute("readonly", "readonly").AddClass("disabled").Attribute("tabindex", "-1"); } input.Bind("keypress." + this.uniqueName, delegate(jQueryEvent e) { if (e.Which == (int)'@') { e.PreventDefault(); if (!options.ReadOnlyDomain) { domain.Focus(); domain.Select(); } } }); domain.Bind("keypress." + this.uniqueName, delegate(jQueryEvent e) { if (e.Which == (int)'@') { e.PreventDefault(); } }); }
public DateEditor(jQueryObject input) : base(input, new object()) { input.AddClass("dateQ"); input.DatePicker(new DatePickerOptions { ShowOn = "button", BeforeShow = new Func <bool>(delegate { return(!input.HasClass("readonly")); }), YearRange = YearRange ?? "-100:+50" }); input.Bind("keyup." + this.uniqueName, e => { if (e.Which == 32 && !ReadOnly) { if (this.ValueAsDate != JsDate.Today) { this.ValueAsDate = JsDate.Today; this.element.Trigger("change"); } } else { DateInputKeyup(e); } }); input.Bind("change." + this.uniqueName, DateInputChange); input.AddValidationRule(this.uniqueName, e => { var value = this.Value; if (string.IsNullOrEmpty(value)) { return(null); } if (!string.IsNullOrEmpty(MinValue) && String.Compare(value, MinValue) < 0) { return(String.Format(Q.Text("Validation.MinDate"), Q.FormatDate(MinValue))); } if (!string.IsNullOrEmpty(MaxValue) && String.Compare(value, MaxValue) >= 0) { return(String.Format(Q.Text("Validation.MaxDate"), Q.FormatDate(MaxValue))); } return(null); }); SqlMinMax = true; }
protected ModuleBase(string template, string templateId, bool transition) { this.transition = Script.IsNullOrUndefined(transition) ? true : transition; attachedObject = Template.Get(template, templateId).AppendTo(jQuery.Select("body")).Hide(); if (this.transition && Settings.UseAnimation) { attachedObject.AddClass("fade"); } }
public CheckListEditor(jQueryObject div, CheckListEditorOptions opt) : base(div, opt) { div.AddClass("s-CheckListEditor"); this.list = J("<ul/>").AppendTo(div); UpdateItems(); }
public PropertyGrid(jQueryObject div, PropertyGridOptions opt) : base(div, opt) { if (!Script.IsValue(opt.Mode)) opt.Mode = PropertyGridMode.Insert; div.AddClass("s-PropertyGrid"); editors = new List<Widget>(); items = options.Items ?? new List<PropertyItem>(); var useTabs = Q.Any(items, x => !string.IsNullOrEmpty(x.Tab)); if (useTabs) { var ul = J("<ul class='nav nav-tabs property-tabs' role='tablist'></ul>") .AppendTo(this.element); var tc = J("<div class='tab-content property-panes'></div>") .AppendTo(this.element); int tabIndex = 0; int i = 0; while (i < items.Count) { var tab = items[i].Tab.TrimToEmpty(); var tabItems = new List<PropertyItem>(); var j = i; do { tabItems.Add(items[j]); } while (++j < items.Count && items[j].Tab.TrimToEmpty() == tab); i = j; var li = J("<li><a data-toggle='tab' role='tab'></a></li>").AppendTo(ul); if (tabIndex == 0) li.AddClass("active"); var tabID = this.UniqueName + "_Tab" + tabIndex; li.Children("a") .Attribute("href", "#" + tabID) .Text(DetermineText(tab, prefix => prefix + "Tabs." + tab)); var pane = J("<div class='tab-pane fade' role='tabpanel'>").AppendTo(tc); if (tabIndex == 0) pane.AddClass("in active"); pane.Attribute("id", tabID); CreateItems(pane, tabItems); tabIndex++; } } else CreateItems(this.element, items); UpdateInterface(); }
public ReportDesignPanel(jQueryObject element, ReportDesignPanelOptions options) : base(element, options) { element.AddClass("s-ReportDesignPanel"); this.ById("AddButton").Click(AddButtonClick); this.ById("EditButton").Click(EditButtonClick); this.Element.Find("a").Toggle(false);//Utils.HasRight("ReportDesign")); }
private jQueryObject AddEmptyRow(bool popupField) { jQueryObject emptyRow = FindEmptyRow(); if (emptyRow != null) { emptyRow.Find("input.field-select").Select2("focus"); if (popupField) { emptyRow.Find("input.field-select").Select2("open"); } return(emptyRow); } bool isLastRowOr = this.rowsDiv.Children().Last().Children("a.andor").HasClass("or"); jQueryObject row = J(RowTemplate).AppendTo(this.rowsDiv); jQueryObject parenDiv = row.Children("div.l").Hide(); parenDiv.Children("a.leftparen, a.rightparen").Click(LeftRightParenClick); jQueryObject andor = parenDiv.Children("a.andor").Attribute("title", Q.Text("Controls.FilterPanel.ChangeAndOr")); if (isLastRowOr) { andor.AddClass("or").Text(Q.Text("Controls.FilterPanel.Or")); } else { andor.Text(Q.Text("Controls.FilterPanel.And")); } andor.Click(AndOrClick); row.Children("a.delete").Attribute("title", Q.Text("Controls.FilterPanel.RemoveField")).Click(DeleteRowClick); var fieldSel = new FieldSelect(row.Children("div.f").Children("input"), this.Store.Fields); fieldSel.ChangeSelect2(OnRowFieldChange); UpdateParens(); UpdateButtons(); row.Find("input.field-select").Select2("focus"); if (popupField) { row.Find("input.field-select").Select2("open"); } return(row); }
static void UpdateCounterStatus(jQueryObject event_counter, int new_count) { // first update the status visually... if (!event_counter.HasClass("ui-state-hover")) { event_counter.AddClass("ui-state-hover") .Siblings().RemoveClass("ui-state-hover"); } // ...then update the numbers jQuery.Select("span.count", event_counter) .Text(new_count.ToString()); }
public ModalBase(string template, string templateId) { attachedObject = Template.Get(template, templateId).AppendTo(jQuery.Select("body")); if (Settings.UseAnimation) { attachedObject.AddClass("fade"); } Initialize(); attachedObject.Bind("shown", OnShown); }
public IntegerEditor(jQueryObject input, IntegerEditorOptions opt) : base(input, opt) { input.AddClass("decimalQ"); dynamic numericOptions = jQuery.ExtendObject(DecimalEditor.DefaultAutoNumericOptions(), new { vMin = options.MinValue, vMax = options.MaxValue }); ((dynamic)input).autoNumeric(numericOptions); }
public DateEditor(jQueryObject input) : base(input, new object()) { input.AddClass("dateQ"); input.DatePicker(new DatePickerOptions { ShowOn = "button", BeforeShow = new Func <bool>(delegate { return(!input.HasClass("readonly")); }) }); }
private void UpdateParens() { jQueryObject rows = rowsDiv.Children(); if (rows.Length == 0) { return; } rows.RemoveClass("paren-start"); rows.RemoveClass("paren-end"); rows.Children("div.l").CSS("display", rows.Length == 1 ? "none" : "block"); rows.First().Children("div.l").Children("a.rightparen, a.andor").CSS("visibility", "hidden"); for (int i = 1; i < rows.Length; i++) { jQueryObject row = rows.Eq(i); row.Children("div.l").CSS("display", "block") .Children("a.lefparen, a.andor").CSS("visibility", "visible"); } bool inParen = false; for (int i = 0; i < rows.Length; i++) { jQueryObject row = rows.Eq(i); jQueryObject divParen = row.Children("div.l"); jQueryObject lp = divParen.Children("a.leftparen"); jQueryObject rp = divParen.Children("a.rightparen"); if (rp.HasClass("active") && inParen) { inParen = false; if (i > 0) { rows.Eq(i - 1).AddClass("paren-end"); } } if (lp.HasClass("active")) { inParen = true; if (i > 0) { row.AddClass("paren-start"); } } } }
public IntegerEditor(jQueryObject input, IntegerEditorOptions opt) : base(input, opt) { input.AddClass("integerQ"); dynamic numericOptions = jQuery.ExtendObject(DecimalEditor.DefaultAutoNumericOptions(), new { vMin = options.MinValue ?? 0, vMax = options.MaxValue ?? 2147483647, aSep = (string)null }); ((dynamic)input).autoNumeric(numericOptions); }
public static jQueryObject SetReadOnly(jQueryObject elements, bool isReadOnly) { elements.Each(delegate(int index, Element el) { jQueryObject elx = jQuery.FromElement(el); string type = elx.GetAttribute("type"); if (elx.Is("select") || (type == "radio") || (type == "checkbox")) { if (isReadOnly) { elx.AddClass("readonly").Attribute("disabled", "disabled"); } else { elx.RemoveClass("readonly").RemoveAttr("disabled"); } } else { if (isReadOnly) { elx.AddClass("readonly").Attribute("readonly", "readonly"); } else { elx.RemoveClass("readonly").RemoveAttr("readonly"); } } return(true); }); return(elements); }
public DateTimeEditor(jQueryObject input, DateTimeEditorOptions opt) : base(input, opt) { input.AddClass("dateQ s-DateTimeEditor") .DatePicker(new DatePickerOptions { ShowOn = "button" }); input.Bind("keyup." + this.uniqueName, DateEditor.DateInputKeyup); input.Bind("change." + this.uniqueName, DateEditor.DateInputChange); time = J("<select/>") .AddClass("editor s-DateTimeEditor time") .InsertAfter(input.Next(".ui-datepicker-trigger")); foreach (var t in GetTimeOptions(fromHour: options.StartHour ?? 0, toHour: options.EndHour ?? 23, stepMins: options.IntervalMinutes ?? 30)) { Q.AddOption(time, t, t); } input.AddValidationRule(this.uniqueName, e => { var value = this.Value; if (string.IsNullOrEmpty(value)) { return(null); } if (!string.IsNullOrEmpty(MinValue) && String.Compare(value, MinValue) < 0) { return(String.Format(Q.Text("Validation.MinDate"), Q.FormatDate(Q.ParseISODateTime(MinValue)))); } if (!string.IsNullOrEmpty(MaxValue) && String.Compare(value, MaxValue) >= 0) { return(String.Format(Q.Text("Validation.MaxDate"), Q.FormatDate(Q.ParseISODateTime(MaxValue)))); } return(null); }); }
/// <summary>Constructor.</summary> public Textbox() { // Setup initial conditions. Container.AddClass(ClassTextbox); // Create INPUT. input = Html.CreateElement("input"); input.Attribute(Html.Type, "text"); input.AppendTo(Container); input.AddClass(ClassTextbox); // Set initial size. Height = 40; // Assign focus control to the input element. ChangeFocusElement(input); Focus.BrowserHighlighting = false; Focus.CanFocus = true; // Setup padding. padding = new Spacing().Sync(input, OnBeforePaddingSync); padding.Change(10, 5); // Create child objects. eventDelay = new DelayedAction(0.3, OnDelayElapsed); // Wire up events. Container.MouseDown(delegate { FocusOnClick(); }); input.Keyup(delegate(jQueryEvent e) { if (previousText != Text) FireTextChanged(); if (Int32.Parse(e.Which) == (int)Key.Enter) FireEnterPress(); }); input.MouseDown(delegate { OnInputMouseDown(); }); input.MouseUp(delegate { OnInputMouseUp(); }); Focus.GotFocus += OnGotFocus; Focus.LostFocus += OnLostFocus; IsEnabledChanged += delegate { SyncEnabled(); }; SizeChanged += delegate { UpdateLayout(); }; // Sync size and shape. SyncCornerRadius(); // Finish up. previousText = Text; FireSizeChanged(); }
public DateTimeEditor(jQueryObject input) : base(input) { input.AddClass("dateQ s-DateTimeEditor") .DatePicker(new DatePickerOptions { ShowOn = "button" }); time = J("<select/>") .AddClass("editor s-DateTimeEditor time") .InsertAfter(input.Next(".ui-datepicker-trigger")); foreach (var t in GetTimeOptions()) { Q.AddOption(time, t, t); } }
private jQueryObject AddEmptyRow() { jQueryObject emptyRow = FindEmptyRow(); if (emptyRow != null) { return(emptyRow); } bool isLastRowOr = this.rowsDiv.Children().Last().Children("a.andor").HasClass("or"); jQueryObject row = J(RowTemplate).AppendTo(this.rowsDiv); jQueryObject parenDiv = row.Children("div.l").Hide(); parenDiv.Children("a.leftparen, a.rightparen").Click(LeftRightParenClick); jQueryObject andor = parenDiv.Children("a.andor").Attribute("title", Q.Text("Controls.FilterPanel.ChangeAndOr")); if (isLastRowOr) { andor.AddClass("or").Text(Q.Text("Controls.FilterPanel.Or")); } else { andor.Text(Q.Text("Controls.FilterPanel.And")); } andor.Click(AndOrClick); row.Children("a.delete").Attribute("title", Q.Text("Controls.FilterPanel.RemoveField")).Click(DeleteRowClick); jQueryObject fieldSel = row.Children("div.f").Children("select"); fieldSel.Change(OnRowFieldChange); PopulateFieldList(fieldSel); UpdateParens(); UpdateButtons(); OnHeightChange(); fieldSel.Focus(); return(row); }
public static jQueryObject AddValidationRule(this jQueryObject element, string eventClass, Func <jQueryObject, string> rule) { if (element.Length == 0) { return(element); } if (rule == null) { throw new Exception("rule is null!"); } element.AddClass("customValidate") .Bind("customValidate." + eventClass, rule.As <jQueryEventHandler>()); return(element); }
public DateEditor(jQueryObject input) : base(input, new object()) { input.AddClass("dateQ"); input.DatePicker(new DatePickerOptions { ShowOn = "button", BeforeShow = new Func <bool>(delegate { return(!input.HasClass("readonly")); }) }); input.Bind("keyup." + this.uniqueName, DateInputKeyup); input.Bind("change." + this.uniqueName, DateInputChange); input.AddValidationRule(this.uniqueName, e => { var value = this.Value; if (string.IsNullOrEmpty(value)) { return(null); } if (!string.IsNullOrEmpty(MinValue) && String.Compare(value, MinValue) < 0) { return(String.Format(Q.Text("Validation.MinDate"), Q.FormatDate(Q.ParseISODateTime(MinValue)))); } if (!string.IsNullOrEmpty(MaxValue) && String.Compare(value, MaxValue) >= 0) { return(String.Format(Q.Text("Validation.MaxDate"), Q.FormatDate(Q.ParseISODateTime(MaxValue)))); } return(null); }); SqlMinMax = true; }
public static void InitFullHeightGridPage(jQueryObject gridDiv) { J("body") .AddClass("full-height-page"); gridDiv.AddClass("responsive-height"); jQueryEventHandler layout = delegate { bool inPageContent = gridDiv.Parent().HasClass("page-content") || gridDiv.Parent().Is("section.content"); if (inPageContent) { gridDiv.CSS("height", "1px") .CSS("overflow", "hidden"); } Q.LayoutFillHeight(gridDiv); if (inPageContent) { gridDiv.CSS("overflow", ""); } gridDiv.TriggerHandler("layout"); }; if (J("body").HasClass("has-layout-event")) { J("body").Bind("layout", layout); } else if (Window.Instance.As <dynamic>().Metronic != null) { Window.Instance.As <dynamic>().Metronic.addResizeHandler(layout); } else { jQuery.Window.Resize(layout); } layout(null); }
public void updatePager(PagingInfo pagingInfo) { NavigationState state = getNavState(); jQueryObject firstButton = _container.Find(".sparkle-grid-paging-first"); jQueryObject backButton = _container.Find(".sparkle-grid-paging-back"); jQueryObject nextButton = _container.Find(".sparkle-grid-paging-next"); jQueryObject label = _container.Find(".sparkle-grid-status-label"); jQueryObject pageInfo = _container.Find(".sparkle-grid-status-paging-page"); jQueryObject status = _container.Find(".sparkle-grid-status-label"); if (state.CanGotoFirst) { firstButton.RemoveClass("disabled"); } else { firstButton.AddClass("disabled"); } if (state.CanGotoPrev) { backButton.RemoveClass("disabled"); } else { backButton.AddClass("disabled"); } if (state.CanGotoNext) { nextButton.RemoveClass("disabled"); } else { nextButton.AddClass("disabled"); } status.Text(string.Format("{0} - {1} of {2} ({3} selected)", pagingInfo.FromRecord, pagingInfo.ToRecord, pagingInfo.TotalRows, _dataView.GetSelectedRows().Length.ToString())); pageInfo.Text(string.Format("Page {0}", pagingInfo.PageNum + 1)); }
public TimeEditor(jQueryObject input, TimeEditorOptions opt) : base(input, opt) { input.AddClass("editor s-TimeEditor hour"); if (!options.NoEmptyOption) { Q.AddOption(input, "", "--"); } for (var h = options.StartHour ?? 0; h <= (options.EndHour ?? 23); h++) { Q.AddOption(input, h.ToString(), h < 10 ? "0" + h : h.ToString()); } minutes = J("<select/>").AddClass("editor s-TimeEditor minute").InsertAfter(input); for (var m = 0; m <= 59; m += (options.IntervalMinutes ?? 5)) { Q.AddOption(minutes, m.ToString(), m < 10 ? "0" + m : m.ToString()); } }
public static void InitFullHeightGridPage(jQueryObject gridDiv) { J("body") .AddClass("full-height-page"); gridDiv.AddClass("responsive-height"); jQueryEventHandler layout = delegate { bool inPageContent = gridDiv.Parent().HasClass("page-content") || gridDiv.Parent().Is("section.content"); if (inPageContent) { gridDiv.CSS("height", "1px") .CSS("overflow", "hidden"); } Q.LayoutFillHeight(gridDiv); if (inPageContent) gridDiv.CSS("overflow", ""); gridDiv.TriggerHandler("layout"); }; if (J("body").HasClass("has-layout-event")) { J("body").Bind("layout", layout); } else if (Window.Instance.As<dynamic>().Metronic != null) Window.Instance.As<dynamic>().Metronic.addResizeHandler(layout); else { jQuery.Window.Resize(layout); } layout(null); }
public DecimalEditor(jQueryObject input, DecimalEditorOptions opt) : base(input, opt) { input.AddClass("decimalQ"); dynamic numericOptions = jQuery.ExtendObject(DefaultAutoNumericOptions(), new { vMin = options.MinValue, vMax = options.MaxValue }); if (options.Decimals.HasValue) { numericOptions.mDec = options.Decimals.Value; } if (options.PadDecimals.HasValue) { numericOptions.aPad = options.PadDecimals.Value; } ((dynamic)input).autoNumeric(numericOptions); }
public PopupMenuButton(jQueryObject div, PopupMenuButtonOptions opt) : base(div, opt) { var self = this; div.AddClass("s-PopupMenuButton"); div.Click((jQueryEvent e) => { e.PreventDefault(); e.StopPropagation(); if (options.OnPopup != null) { options.OnPopup(); } var menu = self.options.Menu; menu.Show().As <dynamic>().position(new { my = options.PositionMy ?? "left top", at = options.PositionAt ?? "left bottom", of = self.element }); var uq = self.uniqueName; jQuery.Document.One("click." + uq, x => { menu.Hide(); }); }); self.options.Menu.Hide().AppendTo(Document.Body).AddClass("s-PopupMenu") .As <dynamic>().menu(); }
/// <summary>Adds or removes a class from the given element.</summary> /// <param name="element">The element to add or remove from.</param> /// <param name="cssClass">The CSS class name.</param> /// <param name="add">Flag indicating whether the class should be added (true) or removed (false).</param> public static jQueryObject AddOrRemoveClass(jQueryObject element, string cssClass, bool add) { if (add) { element.AddClass(cssClass); } else { element.RemoveClass(cssClass); } return element; }
public PropertyGrid(jQueryObject div, PropertyGridOptions opt) : base(div, opt) { if (!Script.IsValue(opt.Mode)) { opt.Mode = PropertyGridMode.Insert; } items = options.Items ?? new List <PropertyItem>(); div.AddClass("s-PropertyGrid"); editors = new List <Widget>(); var categoryIndexes = new JsDictionary <string, int>(); var categoriesDiv = div; if (options.UseCategories) { var linkContainer = J("<div/>") .AddClass("category-links"); categoryIndexes = CreateCategoryLinks(linkContainer, items); if (categoryIndexes.Count > 1) { linkContainer.AppendTo(div); } else { linkContainer.Find("a.category-link").Unbind("click", CategoryLinkClick).Remove(); } categoriesDiv = J("<div/>") .AddClass("categories") .AppendTo(div); } var fieldContainer = categoriesDiv; string priorCategory = null; for (int i = 0; i < items.Count; i++) { var item = items[i]; if (options.UseCategories && priorCategory != item.Category) { var categoryDiv = CreateCategoryDiv(categoriesDiv, categoryIndexes, item.Category); if (priorCategory == null) { categoryDiv.AddClass("first-category"); } priorCategory = item.Category; fieldContainer = categoryDiv; } var editor = CreateField(fieldContainer, item); editors[i] = editor; } UpdateInterface(); }
public PopupToolButton(jQueryObject div, PopupToolButtonOptions opt) : base(div, opt) { div.AddClass("s-PopupToolButton"); J("<b/>").AppendTo(div.Children(".button-outer").Children("span")); }
public DateTimeEditor(jQueryObject input, DateTimeEditorOptions opt) : base(input, opt) { input.AddClass("dateQ s-DateTimeEditor") .DatePicker(new DatePickerOptions { ShowOn = "button", BeforeShow = new Func <bool>(delegate { return(!input.HasClass("readonly")); }), YearRange = options.YearRange ?? "-100:+50" }); input.Bind("keyup." + this.uniqueName, e => { if (e.Which == 32 && !ReadOnly) { if (this.ValueAsDate != JsDate.Now) { this.ValueAsDate = JsDate.Now; this.element.Trigger("change"); } } else { DateEditor.DateInputKeyup(e); } }); input.Bind("change." + this.uniqueName, DateEditor.DateInputChange); time = J("<select/>").AddClass("editor s-DateTimeEditor time"); var after = input.Next(".ui-datepicker-trigger"); if (after.Length > 0) { time.InsertAfter(after); } else { after = input.Prev(".ui-datepicker-trigger"); if (after.Length > 0) { time.InsertBefore(after); } else { time.InsertAfter(input); } } foreach (var t in GetTimeOptions(fromHour: options.StartHour ?? 0, toHour: options.EndHour ?? 23, stepMins: options.IntervalMinutes ?? 5)) { Q.AddOption(time, t, t); } input.AddValidationRule(this.uniqueName, e => { var value = this.Value; if (string.IsNullOrEmpty(value)) { return(null); } if (!string.IsNullOrEmpty(MinValue) && String.Compare(value, MinValue) < 0) { return(String.Format(Q.Text("Validation.MinDate"), Q.FormatDate(MinValue))); } if (!string.IsNullOrEmpty(MaxValue) && String.Compare(value, MaxValue) >= 0) { return(String.Format(Q.Text("Validation.MaxDate"), Q.FormatDate(MaxValue))); } return(null); }); SqlMinMax = true; J("<div class='inplace-button inplace-now'><b></b></div>") .Attribute("title", "set to now") .InsertAfter(time) .Click(e => { if (this.Element.HasClass("readonly")) { return; } this.ValueAsDate = JsDate.Now; }); time.On("change", e => input.TriggerHandler("change")); }
public PropertyGrid(jQueryObject div, PropertyGridOptions opt) : base(div, opt) { if (!Script.IsValue(opt.Mode)) { opt.Mode = PropertyGridMode.Insert; } items = options.Items ?? new List <PropertyItem>(); div.AddClass("s-PropertyGrid"); editors = new List <Widget>(); var categoryIndexes = new JsDictionary <string, int>(); var categoriesDiv = div; var useCategories = options.UseCategories && items.Any(x => !string.IsNullOrEmpty(x.Category)); if (options.UseCategories) { var linkContainer = J("<div/>") .AddClass("category-links"); categoryIndexes = CreateCategoryLinks(linkContainer, items); if (categoryIndexes.Count > 1) { linkContainer.AppendTo(div); } else { linkContainer.Find("a.category-link").Unbind("click", CategoryLinkClick).Remove(); } } categoriesDiv = J("<div/>") .AddClass("categories") .AppendTo(div); jQueryObject fieldContainer; if (useCategories) { fieldContainer = categoriesDiv; } else { fieldContainer = J("<div/>") .AddClass("category") .AppendTo(categoriesDiv); } string priorCategory = null; for (int i = 0; i < items.Count; i++) { var item = items[i]; var category = (item.Category ?? options.DefaultCategory ?? ""); if (useCategories && priorCategory != category) { var categoryDiv = CreateCategoryDiv(categoriesDiv, categoryIndexes, category, item.Collapsible != true ? (bool?)null : item.Collapsed ?? false); if (priorCategory == null) { categoryDiv.AddClass("first-category"); } priorCategory = category; fieldContainer = categoryDiv; } var editor = CreateField(fieldContainer, item); editors[i] = editor; } UpdateInterface(); }
public TemplateControl(object oTemplate) { // init static stuff if (!_bStaticConstructionFinished) { StaticConstructor(); } // continue instance setup.. this._strInstanceId = GenerateNewInstanceId(); string strTemplate; // grab template if (Script.IsNullOrUndefined(oTemplate)) { strTemplate = FindTemplate(this); #if DEBUG if (string.IsNullOrEmpty(strTemplate)) { throw new Exception(this.GetType().FullName + " is missing a Template member and no template was provided."); } #endif } else { if (oTemplate is string) { strTemplate = (string)oTemplate; } else { jQueryObject jqTemplate = jQuery.FromObject(oTemplate); strTemplate = "<" + jqTemplate[0].TagName + ">" + jqTemplate.GetHtml() + "</" + jqTemplate[0].TagName + ">"; } } _hash_oNamedChildControls = new Dictionary(); _hash_oNamedChildElements = new Dictionary(); jQueryObject jqHead = jQuery.Select("head"); // grab template if (Script.IsNullOrUndefined(strTemplate)) { strTemplate = (string)Type.GetField(this, "template"); } #if DEBUG if (string.IsNullOrEmpty(strTemplate)) { throw new Exception(this.GetType().FullName + " is missing a Template member."); } #endif // generate an absolute id for this control string newId = GenerateNewAutoId(); #if DEBUG // is there a conflict in the auto gen'd id? { int numOtherControlsWithId = jQuery.Select("#" + newId).Length; if (numOtherControlsWithId != 0) { throw new Exception("Auto generated id conflict."); } } #endif // parse template jQueryObject jqContent = jQuery.FromHtml(strTemplate.Replace("`", "\"")); // are there style tags? string strStyleRules = string.Empty; jqContent.Filter("style").Each(delegate(int i, Element e) { jQueryObject jqElement = jQuery.FromElement(e); strStyleRules += jqElement.GetHtml(); jqElement.Remove(); }); // proceed with non-style tags jqContent = jqContent.Not("style").Remove(); // remove attribute id if any #if DEBUG if (!string.IsNullOrEmpty(jqContent.GetAttribute("id"))) { throw new Exception("Global ID's not permitted. Element with ID \"" + jqContent.GetAttribute("id") + "\" found."); } #endif jqContent.RemoveAttr("id"); // store reference _jqRootElement = jqContent; // store reference from element back to this control _jqRootElement.Data(DataNameControl, this); // identify locally-named elements. this runs before parsing children because we don't want to add children's locally-named html elements. { jqContent.Find("*[" + AttributeNameLocalId + "]").Each( delegate(int i, Element e) { jQueryObject jqElement = jQuery.FromElement(e); if (!string.IsNullOrEmpty(jqElement.GetAttribute(AttributeNameControlClass))) { return; } string strLocalId = GetLocalId(jqElement); if (strLocalId == null) { return; } // store record of it this._hash_oNamedChildElements[strLocalId] = jqElement; // remove absolute id if any #if DEBUG if (!string.IsNullOrEmpty(jqElement.GetAttribute("id"))) { throw new Exception("Global ID's not permitted. Element with ID \"" + jqElement.GetAttribute("id") + "\" found."); } #endif jqElement.RemoveAttr("id"); }) ; } // rewrite image and image button paths { string baseUrl = BaseUrlImages; if (baseUrl.Length > 0) { jqContent.Find("img, input[type=image]").Each( delegate(int i, Element e) { jQueryObject jqe = jQuery.FromElement(e); string src = jqe.GetAttribute("src"); if (string.IsNullOrEmpty(src)) { string nullSrc = "http://null-image"; if (Window.Location.Protocol == "https:") { nullSrc = "https://null-image"; } jqe.Attribute("src", nullSrc); return; } if (src.StartsWith("http://") || src.StartsWith("https://")) { return; } jqe.Attribute("src", CombinePaths(baseUrl, src)); } ); } } // calculcate search namespace Type currentType = this.GetType(); string currentTopLevelNamespace = currentType .FullName .Substr(0, currentType.FullName.IndexOf('.')) ; // add class for identifying this as a template control _jqRootElement.AddClass(CssClassNameControl); // add class for identifying this as a newly added template control _jqRootElement.AddClass(CssClassNameControlUnadded); // recurse into child controls // todo: move this to *after* processing labels and images? jqContent.Find("div[" + AttributeNameControlClass + "]").Each( delegate(int index, Element element) { jQueryObject jqElement = jQuery.FromElement(element); string strChildTypeName = jqElement.GetAttribute(AttributeNameControlClass); string strChildTypeNameResolved = ResolveTypeName( strChildTypeName, currentTopLevelNamespace ) ; Type oChildType = Type.GetType(strChildTypeNameResolved); if (Script.IsNullOrUndefined(oChildType)) { #if DEBUG throw new Exception("Could not locate type \"" + (strChildTypeNameResolved ?? strChildTypeName) + "\""); #else return; #endif } TemplateControl childControl = Type.CreateInstance(oChildType, null) as TemplateControl; if (!(childControl is TemplateControl)) { // this check is still needed because of how the 'as' operator behaves in Script#. #if DEBUG throw new Exception("Control must derive from 'TemplateControl'."); #else return; #endif } // grab local id if any string strLocalId = GetLocalId(jqElement) ?? GenerateNewAutoId(); // store named control if (strLocalId != null) { this._hash_oNamedChildControls[strLocalId] = childControl; } // merge style and class attributes string strClass = jqElement.GetAttribute("class"); string strStyle = jqElement.GetAttribute("style"); if (!string.IsNullOrEmpty(strClass)) { string strClassFromTemplate = childControl.RootElement.GetAttribute("class") ?? string.Empty; childControl.RootElement.Attribute("class", strClassFromTemplate + " " + strClass); } if (!string.IsNullOrEmpty(strStyle)) { string strStyleFromTemplate = childControl.RootElement.GetAttribute("style") ?? string.Empty; childControl.RootElement.Attribute("style", strStyleFromTemplate + " " + strStyle); } // preserve other attributes for (int i = 0, m = jqElement[0].Attributes.Length; i < m; ++i) { ElementAttribute a = (ElementAttribute)Type.GetField(jqElement[0].Attributes, (string)(object)i); if (jQuery.Browser.Version == "7.0" && jQuery.Browser.MSIE && !a.Specified) { continue; } string attributeName = a.Name.ToLowerCase(); switch (attributeName) { case "id": case "xid": case "class": case "style": case "control": break; default: childControl.RootElement.Attribute(a.Name, a.Value); break; } } // replace the placeholder element with the new control. jqElement.RemoveAttr("id").After(childControl.RootElement).Remove(); // preserve local id & control type name if (strLocalId != null) { childControl.RootElement.Attribute("xid", strLocalId); } childControl.RootElement.Attribute("control", jqElement.GetAttribute(AttributeNameControlClass)); // any children content? jQueryObject jqChildContent = jqElement.Find(">*"); if (jqChildContent.Length > 0) { childControl.ProcessChildContent(jqChildContent); } } ); // rewrite radio input groups // todo: do this before processing child controls? { jQueryObject jqRadioInputs = _jqRootElement.Find("input[type=radio]"); Dictionary hash_rewrittenGroupNames = new Dictionary(); jqRadioInputs.Each(delegate(int index, Element element) { jQueryObject jqRadio = jQuery.FromElement(element); // rewrite name attribute { string strGroupName = jqRadio.GetAttribute("name"); if (string.IsNullOrEmpty(strGroupName)) { return; } // need a new name? string strNewGroupName; if (hash_rewrittenGroupNames.ContainsKey(strGroupName)) { strNewGroupName = (string)hash_rewrittenGroupNames[strGroupName]; } else { hash_rewrittenGroupNames[strGroupName] = strNewGroupName = GenerateNewAutoId(); } jqRadio.Attribute("name", strNewGroupName); } // make sure the element has an id, for label elements to use if (string.IsNullOrEmpty(jqRadio.GetAttribute("id"))) { jqRadio.Attribute("id", GenerateNewAutoId()); } }); this._hash_rewrittenGroupNames = hash_rewrittenGroupNames; } // rewrite label elements // todo: do this before processing child controls? { jQueryObject jqLabels = _jqRootElement.Find("label[for]"); jqLabels.Each(delegate(int index, Element element) { if (_bPresented) { } // workaround to delegate bug in Script# 0.7.0.0 jQueryObject jqLabelElement = jQuery.FromElement(element); string strForId = jqLabelElement.GetAttribute("for"); // is this element rewritten? jQueryObject jqTargetElement = TryGetElement(strForId); if (jqTargetElement == null) { return; } string strTargetElementNewId = jqTargetElement.GetAttribute("id"); // make sure the "for" element has an id if (string.IsNullOrEmpty(strTargetElementNewId)) { jqTargetElement.Attribute("id", strTargetElementNewId = GenerateNewAutoId()); } jqLabelElement.Attribute("for", strTargetElementNewId); return; }); } // fixup css rules & add to head if (strStyleRules.Length != 0) { ProcessCss(this, strStyleRules); } // auto fill members that point to elements/controls AutoFillMemberFields(); // any elements with advanced layout enabled? AdvancedLayout.AutoEnable(_jqRootElement); }
/// <summary>Adds a single class, or multiple classs from a space seperated list.</summary> /// <param name="target">The target element to add to.</param> /// <param name="classValue">The class attribute value to apply.</param> public static jQueryObject AddClasses(jQueryObject target, string classValue) { if (string.IsNullOrEmpty(classValue)) return target; foreach (string className in classValue.Split(" ")) { target.AddClass(className); } return target; }
private void InsertIcon() { // Setup initial conditions. if (icon != null) return; // Already inserted. // Create the icon. icon = Html.CreateElement(Html.Img); icon.AddClass(ClassTextbox); icon.AddClass(ClassIcon); Css.SetDisplay(icon, false); icon.AppendTo(Container); // Wire up events. icon.Load(delegate(jQueryEvent e) { PositionIcon(); Padding.UpdateLayout(); }); icon.MouseDown(delegate(jQueryEvent e) { FocusOnClick(); }); }
public MangaListItem(jQueryObject parent, MangaListItemJson data, int nextMangaId, Action loadFinishCallback) { attachedObject = Template.Get("client", "mangas-list-item", true).AppendTo(parent); jQuery.Select(".mangas-list-item-title", attachedObject).Text(data.title); jQuery.Select(".mangas-list-item-pages", attachedObject).Text(data.pages.ToString()); coverLoaded = false; coverRequestDelay = 500; this.nextMangaId = nextMangaId; this.data = data; callback = loadFinishCallback; double size = data.size; string unit; if (size > 1000) { size /= 1024; if (size > 1000) { size /= 1024; if (size > 1000) { size /= 1024; unit = Strings.Get("GigaBytes"); } else { unit = Strings.Get("MegaBytes"); } } else { unit = Strings.Get("KiloBytes"); } } else { unit = Strings.Get("Bytes"); } if (size < 10) { size = Math.Floor(size * 100) / 100; } else if (size < 100) { size = Math.Floor(size * 10) / 10; } else { size = Math.Floor(size); } jQuery.Select(".mangas-list-item-size", attachedObject).Text(size.ToString()); jQuery.Select(".mangas-list-item-size-unit", attachedObject).Text(unit); jQuery.Select(".mangas-list-item-details-btn", attachedObject).AddClass("disabled").Click(DetailsButtonClicked); jQuery.Select(".mangas-list-item-thumbnail-link", attachedObject).Click(CoverClicked); if (!Settings.UseAnimation) { TryLoadFromCache(); return; } attachedObject.AddClass("fade"); Window.SetTimeout( delegate { Utility.OnTransitionEnd( attachedObject.AddClass("in"), delegate { TryLoadFromCache(); }); }, 1); }