Example #1
0
 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);
 }
Example #2
0
        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");
                    }
                }
            }
        }
Example #3
0
        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 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));
        }
Example #5
0
 public BooleanEditor(jQueryObject input)
     : base(input, new object())
 {
     input.RemoveClass("flexify");
 }
Example #6
0
 /// <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;
 }
Example #7
0
        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);
                }));
            });
        }