private void AndOrClick(jQueryEvent e) { e.PreventDefault(); jQueryObject andor = J(e.Target).ToggleClass("or"); andor.Text(Q.Text("Controls.FilterPanel." + (andor.HasClass("or") ? "Or" : "And"))); }
private void UpdateRendering() { _list.Empty(); _itemTemplate.RenderTemplate(_todoList.Items).AppendTo(_list); _clearButton.SwitchClass("hidden", _todoList.CompletedCount == 0); _activeCount.Text(_todoList.ActiveCount + " item(s) left"); }
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); }
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 override void LoadValue(Dictionary <string, object> item) { // Get currency symbol string currencySymbolString = getCurrencySymbol((EntityReference)((EntityBuiltInAttributes)((object)item)).TransactionCurrencyId); currencySymbol.Text(currencySymbolString + " "); Money value = (Money)item[_args.Column.Field]; defaultValue = ""; if (value != null) { defaultValue = NumberEx.Format(value.Value, numberFormatInfo); } input.Value(defaultValue); input[0].SetAttribute("defaultValue", defaultValue); input.Select(); }
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)); }
private void linkFn(TestTextScope scope, jQueryObject element, object attrs) { element.Attribute("class", "text " + string.Format("text{0}", scope.Text.Name)); element.MouseDown((e) => { scope.Model.Selection.SelectedText = scope.Text; scope.Apply(); }); var scale = scope.Model.Scale; Action reApplyTextBind = () => { scope.TextStyle = new { }; scope.TextStyle.position = "absolute"; scope.TextStyle.left = scope.Text.Left * scale.X; scope.TextStyle.top = scope.Text.Top * scale.Y; scope.TextStyle.boxShadow = "rgb(51, 51, 51) 4px 4px 2px"; scope.TextStyle.borderRadius = "15px"; element.Text(scope.Text.Text); ClientHelpers.PurgeCSS("text" + scope.Text.Name + "::before"); foreach (var gameLayoutScenarioEffect in scope.Model.Selection.SelectedScenario.Effects) { foreach (var textGuid in gameLayoutScenarioEffect.TextGuids) { if (textGuid == scope.Text.Guid) { foreach (var gameEffectModel in scope.Model.Game.Effects) { if (gameEffectModel.Guid == gameLayoutScenarioEffect.EffectGuid) { var effect = gameEffectModel; switch (effect.Type) { case EffectType.Highlight: var color = effect.GetString("color"); var radius = effect.GetNumber("radius"); var rotate = effect.GetNumber("rotate"); var offsetX = effect.GetNumber("offsetx"); var offsetY = effect.GetNumber("offsety"); var opacity = effect.GetNumber("opacity"); var beforeStyle = new JsDictionary<string, string>(); beforeStyle["display"] = "block"; beforeStyle["position"] = "relative"; beforeStyle["z-index"] = "-1"; beforeStyle["width"] = "100%"; beforeStyle["height"] = "100%"; beforeStyle["left"] = (-radius + offsetX) + "px"; beforeStyle["top"] = (-radius + offsetY) + "px"; beforeStyle["padding"] = (radius) + "px"; beforeStyle["border-radius"] = "5px"; beforeStyle["box-shadow"] = "rgb(44, 44, 44) 3px 3px 2px"; var hexcolor = ClientHelpers.HexToRGB(color); beforeStyle["content"] = "\"\""; beforeStyle["background-color"] = string.Format("rgba({0}, {1}, {2}, {3})", hexcolor.R, hexcolor.G, hexcolor.B, opacity); beforeStyle["border"] = "2px solid black"; ClientHelpers.ChangeCSS("text" + scope.Text.Name + "::before", beforeStyle); break; case EffectType.Rotate: break; case EffectType.Bend: break; case EffectType.StyleProperty: break; case EffectType.Animated: break; } } } } } } }; scope.Watch("model.scale", () => { scale = scope.Model.Scale; element.Draggable(new DraggableOptions() { Cursor = "crosshair", Grid = new[] { scale.X, scale.Y }, OnDrag = (ev, ele) => { scope.Text.Left = (ele.Position.Left / scale.X); scope.Text.Top = (ele.Position.Top / scale.Y); scope.Apply(); } }); reApplyTextBind(); }); scope.Watch("text", reApplyTextBind, true); scope.Watch("model.selection.selectedEffect", reApplyTextBind, true); scope.Watch("model.selection.selectedScenario.effects", reApplyTextBind, true); }
private void linkFn(EffectTestTextScope scope, jQueryObject element, object attrs) { GameTextModel text = null; text = scope.Model.TextTest.Text; element.Attribute("class", "text " + string.Format("text{0}", text.Name)); var scale = scope.Model.Scale; Action reApplyTextBind = () => { /* JsDictionary<string, string> beforeStyle = new JsDictionary<string, string>(); if (false) { beforeStyle["display"] = "block"; beforeStyle["position"] = "relative"; beforeStyle["z-index"] = "-1"; beforeStyle["width"] = "100%"; beforeStyle["height"] = "100%"; beforeStyle["left"] = "-50px"; beforeStyle["top"] = "-50px"; beforeStyle["padding"] = "50px"; beforeStyle["border-radius"] = "15px"; beforeStyle["box-shadow"] = "rgb(51, 51, 51) 4px 4px 2px"; beforeStyle["content"] = "\"\""; beforeStyle["background"] = "rgba(112, 12, 58, 0.231373)"; } ChangeCSS("text" + text.Name + "::before", beforeStyle);*/ scope.TextStyle = new {}; var l = text.Left; var t = text.Top; var sl = scale.X; var st = scale.Y; scope.TextStyle.position = "absolute"; scope.TextStyle.left = l*sl; scope.TextStyle.top = t*st; scope.TextStyle.boxShadow = "rgb(51, 51, 51) 4px 4px 2px"; scope.TextStyle.borderRadius = "15px"; element.Text(scope.Text.Text); }; scope.Watch("model.selection.selectedEffect", () => { ClientHelpers.PurgeCSS("text" + text.Name + "::before"); var effect = scope.Model.Selection.SelectedEffect; if (effect == null) return; switch (effect.Type) { case EffectType.Highlight: var color = effect.GetString("color"); var radius = effect.GetNumber("radius"); var rotate = effect.GetNumber("rotate"); var offsetX = effect.GetNumber("offsetx"); var offsetY = effect.GetNumber("offsety"); var opacity = effect.GetNumber("opacity"); var beforeStyle =new JsDictionary<string, string>(); beforeStyle["display"] = "block"; beforeStyle["position"] = "relative"; beforeStyle["z-index"] = "-1"; beforeStyle["width"] = "100%"; beforeStyle["height"] = "100%"; beforeStyle["left"] = (-radius + offsetX) + "px"; beforeStyle["top"] = (-radius + offsetY) + "px"; beforeStyle["padding"] = (radius) + "px"; beforeStyle["border-radius"] = "5px"; beforeStyle["box-shadow"] ="rgb(44, 44, 44) 3px 3px 2px"; var hexcolor = ClientHelpers.HexToRGB(color); beforeStyle["content"] = "\"\""; beforeStyle["background-color"] =string.Format("rgba({0}, {1}, {2}, {3})",hexcolor.R, hexcolor.G, hexcolor.B, opacity); beforeStyle["border"] = "2px solid black"; ClientHelpers. ChangeCSS("text" + text.Name + "::before",beforeStyle); break; case EffectType.Rotate: break; case EffectType.Bend: break; case EffectType.StyleProperty: break; case EffectType.Animated: break; } }, true); scope.Watch("text", reApplyTextBind, true); }
static ModalForm() { jQuery.OnDocumentReady(delegate() { jQueryObject name = jQuery.Select("#name"); jQueryObject email = jQuery.Select("#email"); jQueryObject password = jQuery.Select("#password"); jQueryObject allFields = jQuery.FromObject(new jQuery[] { }).Add(name).Add(email).Add(password); jQueryObject tips = jQuery.Select(".validateTips"); Action <string> updateTips = new Action <string>(delegate(string t) { tips.Text(t) .AddClass("ui-state-highlight"); Window.SetTimeout(new Action(delegate() { tips.RemoveClass("ui-state-highlight"); //, 1500 ); }), 500); }); Func <jQueryObject, string, int, int, bool> checkLength = new Func <jQueryObject, string, int, int, bool>( delegate(jQueryObject o, string n, int min, int max) { if (o.GetValue().Length > max || o.GetValue().Length < min) { o.AddClass("ui-state-error"); updateTips("Length of " + n + " must be between " + min + " and " + max + "."); return(false); } else { return(true); } }); Func <jQueryObject, RegularExpression, string, bool> checkRegexp = new Func <jQueryObject, RegularExpression, string, bool>( delegate(jQueryObject o, RegularExpression regexp, string n) { if (!(regexp.Test(o.GetValue()))) { o.AddClass("ui-state-error"); updateTips(n); return(false); } else { return(true); } }); jQuery.Select("#dialog-form") .Plugin <DialogObject>() .Dialog(new DialogOptions( DialogOption.AutoOpen, false, DialogOption.Height, 300, DialogOption.Width, 350, DialogOption.Modal, true, DialogOption.Buttons, new DialogOptions( "Create an account", new Action(delegate() { bool bValid = true; allFields.RemoveClass("ui-state-error"); bValid = bValid && checkLength(name, "username", 3, 16); bValid = bValid && checkLength(email, "email", 6, 80); bValid = bValid && checkLength(password, "password", 5, 16); bValid = bValid && checkRegexp(name, new RegularExpression("^[a-z]([0-9a-z_])+$"), "Username may consist of a-z, 0-9, underscores, begin with a letter."); // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/ bValid = bValid && checkRegexp(email, new RegularExpression(@"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$"), "eg. [email protected]"); bValid = bValid && checkRegexp(password, new RegularExpression("^([0-9a-zA-Z])+$"), "Password field only allow : a-z 0-9"); if (bValid) { jQuery.Select("#users tbody") .Append("<tr>" + "<td>" + name.GetValue() + "</td>" + "<td>" + email.GetValue() + "</td>" + "<td>" + password.GetValue() + "</td>" + "</tr>"); jQuery.This.Plugin <DialogObject>() .Dialog(DialogMethod.Close); } }), "Cancel", new Action(delegate() { jQuery.This.Plugin <DialogObject>() .Dialog(DialogMethod.Close); })), DialogEvents.Close, new Action(delegate() { allFields.Value("").RemoveClass("ui-state-error"); }))); jQuery.Select("#create-user") .Plugin <ButtonObject>() .Button() .Click(new jQueryEventHandler(delegate(jQueryEvent e) { jQuery.Select("#dialog-form").Plugin <DialogObject>().Dialog(DialogMethod.Open); })); }); }