Пример #1
0
        private void RowOperatorChange(jQueryObject row)
        {
            if (row.Length == 0)
            {
                return;
            }

            jQueryObject editorDiv = row.Children("div.v");

            editorDiv.Html("");

            IFiltering filtering = GetFilteringFor(row);

            if (filtering == null)
            {
                return;
            }

            var operatorSelect = row.Children("div.o").Find("input.op-select").GetWidget <OperatorSelect>();

            if (operatorSelect.Value.IsEmptyOrNull())
            {
                return;
            }

            var op = filtering.GetOperators().FirstOrDefault(x => x.Key == operatorSelect.Value);

            if (op == null)
            {
                return;
            }

            filtering.Operator = op;
            filtering.CreateEditor();
        }
Пример #2
0
        private void RowOperatorChange(jQueryObject row)
        {
            if (row.Length == 0)
            {
                return;
            }

            jQueryObject editorDiv = row.Children("div.v");

            editorDiv.Html("");

            IFilterHandler handler = GetFilterHandlerFor(row);

            if (handler == null)
            {
                return;
            }

            string op = row.Children("div.o").Children("select").GetValue();

            if (op == null || op == "")
            {
                return;
            }

            handler.CreateEditor(op);
        }
Пример #3
0
        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);
        }
Пример #4
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");
                    }
                }
            }
        }
Пример #5
0
        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");
                }
            }
        }
        /// <summary>Constructor.</summary>
        /// <param name="divHost">The control host DIV.</param>
        /// <param name="control">The logical IView control (null if not available).</param>
        /// <param name="htmlElement">The control content (supplied by the test class. This is the control that is under test).</param>
        /// <param name="displayMode">The sizing strategy to use for the control.</param>
        /// <param name="allViews">The Collection of all controls.</param>
        public ControlWrapperView(
            jQueryObject divHost, 
            IView control, 
            jQueryObject htmlElement, 
            ControlDisplayMode displayMode, 
            IEnumerable allViews) : base(divHost)
        {
            // Setup initial conditions.
            this.control = control;
            this.htmlElement = htmlElement;
            this.displayMode = displayMode;
            this.allViews = allViews;
            index = divHost.Children().Length; // Store the order position of the control in the host.
            events = Common.Events;

            // Create the wrapper DIV.
            divRoot = Html.CreateDiv();
            divRoot.CSS(Css.Position, Css.Absolute);
            divRoot.AppendTo(divHost);

            // Insert the content.
            htmlElement.CSS(Css.Position, Css.Absolute);
            htmlElement.AppendTo(divRoot);

            // Wire up events.
            events.ControlHostSizeChanged += OnHostResized;

            // Finish up.
            UpdateLayout();
        }
Пример #7
0
        private IFiltering GetFilteringFor(jQueryObject row)
        {
            var field = GetFieldFor(row);

            if (field == null)
            {
                return(null);
            }

            IFiltering filtering = (IFiltering)row.GetDataValue("Filtering");

            if (filtering != null)
            {
                return(filtering);
            }

            var filteringType = FilteringTypeRegistry.Get(field.FilteringType ?? "String");

            jQueryObject editorDiv = row.Children("div.v");

            filtering = (IFiltering)Activator.CreateInstance(filteringType);
            ReflectionOptionsSetter.Set(filtering, field.FilteringParams);
            filtering.Container = editorDiv;
            filtering.Field     = field;
            row.Data("Filtering", filtering);

            return(filtering);
        }
Пример #8
0
        /// <summary>
        /// Updats the HTML element with new HTML
        /// Also, loads the new JS object (module) to handle the behavior
        /// </summary>
        /// <param name="content">The element to be updated</param>
        /// <param name="value">The HTML with which to update it</param>
        private static void UpdateModule(jQueryObject content, string value)
        {
            Module module = null;

            // Find elements which have data-type attribute with any value
            // The attribute is applied to elements that can be updated
            jQueryObject dataTypes = content.Children("*[data-type]");

            // If updatable elements exist,
            if (dataTypes.Length > 0)
            {
                // Get the first element found
                Element element = dataTypes.First().GetElement(0);

                // Find the corresponding module
                module = Module.GetModule(element);

                // Now we have the module which should be unloaded and then updated
            }

            // Fade the element out and update with the new HTML
            content.FadeOut(250, delegate()
            {
                // Unload the module
                // BUGBUG: when can this be NULL
                if (null != module)
                {
                    module.Unload();
                }

                // Update the content
                content.Html(value);

                content.FadeIn(250);

                // Check if it has any child modules to be loaded
                dataTypes = content.Children("*[data-type]");

                if (dataTypes.Length > 0)
                {
                    // Load only the first
                    LoadModule(dataTypes.First().GetElement(0));

                    // BUGBUG: do we care about the rest?
                }
            });
        }
Пример #9
0
        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);
        }
Пример #10
0
        private void PopulateOperatorList(jQueryObject row)
        {
            row.Children("div.o").Html("");

            IFiltering filtering = GetFilteringFor(row);

            if (filtering == null)
            {
                return;
            }

            var hidden = row.Children("div.o").Html("<input/>").Children().Attribute("type", "hidden").AddClass("op-select");

            var operators = filtering.GetOperators();

            new OperatorSelect(hidden, operators).ChangeSelect2(OnRowOperatorChange);
        }
Пример #11
0
        private void OnRowFieldChange(jQueryEvent e)
        {
            jQueryObject row = J(e.Target).Closest("div.filter-line");

            RowFieldChange(row);
            jQueryObject opSelect = row.Children("div.o").Find("input.op-select");

            opSelect.Select2("focus");
        }
Пример #12
0
        private void OnRowOperatorChange(jQueryEvent e)
        {
            jQueryObject row = J(e.Target).Closest("div.filter-line");

            RowOperatorChange(row);
            jQueryObject firstInput = row.Children("div.v").Find(":input:visible").First();

            try { firstInput.Focus(); }
            catch { };
        }
Пример #13
0
        private void OnRowFieldChange(jQueryEvent e)
        {
            jQueryObject row = J(e.Target).Closest("div.row");

            RowFieldChange(row);
            jQueryObject opSelect = row.Children("div.o").Children("select").Focus();

            try { opSelect.Focus(); }
            catch { }
        }
Пример #14
0
        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();
        }
Пример #15
0
        private void RowFieldChange(jQueryObject row)
        {
            row.RemoveData("Filtering");

            var    select    = row.Children("div.f").Find("input.field-select").GetWidget <FieldSelect>();
            string fieldName = select.Value;

            bool isEmpty = (fieldName == null || fieldName == "");

            RemoveFiltering(row);
            PopulateOperatorList(row);
            RowOperatorChange(row);
            UpdateParens();
            UpdateButtons();
        }
Пример #16
0
 protected virtual void Populate()
 {
     UploadHelper.PopulateFileSymbols(fileSymbols, entities, true, options.UrlPrefix);
     fileSymbols.Children().Each((i, e) =>
     {
         var x = i;
         J("<a class='delete'></a>").AppendTo(J(e).Children(".filename"))
         .Click(ev =>
         {
             ev.PreventDefault();
             this.entities.RemoveAt(x);
             Populate();
         });
     });
 }
Пример #17
0
        private PropertyItem GetFieldFor(jQueryObject row)
        {
            if (row.Length == 0)
            {
                return(null);
            }

            var select = row.Children("div.f").Find("input.field-select").GetWidget <FieldSelect>();

            if (select.Value.IsEmptyOrNull())
            {
                return(null);
            }

            return(this.Store.FieldByName[select.Value]);
        }
Пример #18
0
        private FilterField GetFieldFor(jQueryObject row)
        {
            if (row.Length == 0)
            {
                return(null);
            }

            string fieldName = row.Children("div.f").Children("select").GetValue();

            if (fieldName == null || fieldName == "")
            {
                return(null);
            }

            FilterField field = fieldByName[fieldName];

            return(field);
        }
Пример #19
0
        private void BindSearchToEnterKey()
        {
            this.Element.Bind("keypress", delegate(jQueryEvent e)
            {
                if (e.Which != 13)
                {
                    return;
                }

                if (rowsDiv.Children().Length == 0)
                {
                    return;
                }

                Search();
            });
        }
Пример #20
0
        protected void UpdateRowsFromStore()
        {
            rowsDiv.Empty();

            foreach (var item in Store.Items)
            {
                AddEmptyRow(false);
                var row = rowsDiv.Children().Last();

                var divl = row.Children("div.l");
                divl.Children(".leftparen").ToggleClass("active", Q.IsTrue(item.LeftParen));
                divl.Children(".rightparen").ToggleClass("active", Q.IsTrue(item.RightParen));
                divl.Children(".andor").ToggleClass("or", Q.IsTrue(item.IsOr))
                .Text(Q.Text(Q.IsTrue(item.IsOr) ? "Controls.FilterPanel.Or" : "Controls.FilterPanel.And"));

                var fieldSelect = row.Children("div.f").Find("input.field-select").GetWidget <FieldSelect>();
                fieldSelect.Value = item.Field;
                RowFieldChange(row);

                var operatorSelect = row.Children("div.o").Find("input.op-select").GetWidget <OperatorSelect>();
                operatorSelect.Value = item.Operator;
                RowOperatorChange(row);

                var filtering = GetFilteringFor(row);
                if (filtering != null)
                {
                    filtering.Operator = item.Operator;
                    filtering.LoadState(item.State);
                }
            }

            if (ShowInitialLine && rowsDiv.Children().Length == 0)
            {
                AddEmptyRow(false);
            }

            UpdateParens();
        }
        private void linkFn(AcgSpacesScope scope, jQueryObject element, object attrs)
        {
            var updater = new Action(() =>
                                     {
                                         element.Children()
                                             .Each((ind, e) => { angular.Element(e).Scope<BaseScope>().Destroy(); });


                                         element.Empty();

                                         var content = @"<div>
    <div acg-draw-space ng-style='spaceStyle'>
        <div ng-repeat='card in space.pile.cards' acg-draw-card ng-style='cardStyle'>
        </div>
    </div> 
</div>";

                                         angular.ForEach(scope.Spaces,
                                             (space) =>
                                             {
                                                 var e = angular.Element(content);
                                                 var _scope = scope.New<AcgSpacesScope>();
                                                 _scope.Space = space;
                                                 var elk = myCompile(e.Contents())(_scope);

                                                 element.Append(elk);
                                             });
                                     });

            //scope["$watch"]("spaces",updater);

            myGameContentManagerService.Redraw += () =>
                                                  {
                                                      Console.WriteLine("updating board");
                                                      updater();
                                                      scope.Apply();
                                                  };

            updater();
        }
Пример #22
0
        private IFilterHandler GetFilterHandlerFor(jQueryObject row)
        {
            FilterField field = GetFieldFor(row);

            if (field == null)
            {
                return(null);
            }

            IFilterHandler handler      = (IFilterHandler)row.GetDataValue("FilterHandler");
            string         handlerField = row.GetDataValue("FilterHandlerField").As <string>();

            if (handler != null)
            {
                if (handlerField != field.Name)
                {
                    row.Data("FilterHandler", null);
                    handler = null;
                }
                else
                {
                    return(handler);
                }
            }

            Type handlerType = Type.GetType("Sinerji." + (field.Handler ?? "??") + "FilterHandler");

            if (handlerType == null)
            {
                throw new Exception(String.Format("FilterHandler type Sinerji.{0}FilterHandler is not defined!", field.Handler));
            }

            jQueryObject editorDiv = row.Children("div.v");

            handler = (IFilterHandler)Activator.CreateInstance(handlerType, editorDiv, field);

            return(handler);
        }
Пример #23
0
        public static void ExecuteOnceWhenShown(jQueryObject element, Action callback)
        {
            autoIncrement++;
            string eventClass = "ExecuteOnceWhenShown" + autoIncrement;

            bool executed = false;

            if (element.Is(":visible"))
            {
                callback();
            }
            else
            {
                jQueryObject uiTabs = element.Closest(".ui-tabs");
                if (uiTabs.Length > 0)
                {
                    uiTabs.Bind("tabsshow." + eventClass, delegate(jQueryEvent e)
                    {
                        if (element.Is(":visible"))
                        {
                            uiTabs.Unbind("tabsshow." + eventClass);

                            if (!executed)
                            {
                                executed = true;
                                element.Unbind("shown." + eventClass);
                                callback();
                            }
                        }
                    });
                }

                jQueryObject dialog;
                if (element.HasClass("ui-dialog"))
                {
                    dialog = element.Children(".ui-dialog-content");
                }
                else
                {
                    dialog = element.Closest(".ui-dialog-content");
                }

                if (dialog.Length > 0)
                {
                    dialog.Bind("dialogopen." + eventClass, delegate
                    {
                        dialog.Unbind("dialogopen." + eventClass);

                        if (element.Is(":visible") && !executed)
                        {
                            executed = true;
                            element.Unbind("shown." + eventClass);
                            callback();
                        }
                    });
                }

                element.Bind("shown." + eventClass, delegate
                {
                    if (element.Is(":visible"))
                    {
                        element.Unbind("shown." + eventClass);

                        if (!executed)
                        {
                            executed = true;
                            callback();
                        }
                    }
                });
            }
        }
Пример #24
0
 /// <summary>Retrieves the child at the specified index, otherwise Null.</summary>
 /// <param name="index">The index of the child (0-based).</param>
 /// <param name="parent">The parent to look within.</param>
 public static jQueryObject ChildAt(int index, jQueryObject parent)
 {
     jQueryObject element = parent.Children(string.Format(":nth-child({0})", index + 1));
     return element.Length == 0 ? null : element;
 }
Пример #25
0
        private void Search()
        {
            List <FilterLine> filterLines = new List <FilterLine>();
            string            filterText  = "";
            string            errorText   = null;
            jQueryObject      row         = null;

            this.rowsDiv.Children().Children("div.v").Children("span.error").Remove();

            bool inParens = false;

            for (int i = 0; i < rowsDiv.Children().Length; i++)
            {
                row = rowsDiv.Children().Eq(i);

                IFilterHandler handler = GetFilterHandlerFor(row);
                if (handler == null)
                {
                    continue;
                }

                FilterField field = GetFieldFor(row);

                string op = row.Children("div.o").Children("select").GetValue();
                if (op == null || op.Length == 0)
                {
                    errorText = Q.Text("Controls.FilterPanel.InvalidOperator");
                    break;
                }

                FilterLine lineEx = new FilterLine();
                lineEx.Field      = field.Name;
                lineEx.Title      = field.Title ?? field.Name;
                lineEx.Operator   = op;
                lineEx.IsOr       = row.Children("div.l").Children("a.andor").HasClass("or");
                lineEx.LeftParen  = row.Children("div.l").Children("a.leftparen").HasClass("active");
                lineEx.RightParen = row.Children("div.l").Children("a.rightparen").HasClass("active");

                handler.ToFilterLine(lineEx);

                if (lineEx.ValidationError != null)
                {
                    errorText = lineEx.ValidationError;
                    break;
                }

                FilterLine line = new FilterLine();
                line.Field    = lineEx.Field;
                line.Operator = lineEx.Operator;

                if (Script.IsValue(lineEx.Value))
                {
                    line.Value = lineEx.Value;
                }

                if (Script.IsValue(lineEx.Value2))
                {
                    line.Value2 = lineEx.Value2;
                }

                if (Script.IsValue(lineEx.Values) &&
                    lineEx.Values.Count > 0)
                {
                    line.Values = lineEx.Values;
                }

                if (lineEx.LeftParen)
                {
                    line.LeftParen = 1.As < bool > ();
                }

                if (lineEx.RightParen)
                {
                    line.RightParen = 1.As < bool > ();
                }

                if (lineEx.IsOr)
                {
                    line.IsOr = 1.As < bool > ();
                }

                filterLines.Add(line);

                if (inParens && (lineEx.RightParen || lineEx.LeftParen))
                {
                    filterText += ")";
                    inParens    = false;
                }

                if (filterText.Length > 0)
                {
                    filterText += " " + Q.Text("Controls.FilterPanel." + (lineEx.IsOr ? "Or" : "And")) + " ";
                }

                if (lineEx.LeftParen)
                {
                    filterText += "(";
                    inParens    = true;
                }

                filterText += lineEx.DisplayText;
            }

            // if an error occured, display it, otherwise set current filters
            if (errorText != null)
            {
                J("<span/>").AddClass("error").Text(errorText).AppendTo(row.Children("div.v"));
                row.Children("div.v").Find("input:first").Focus();
                return;
            }

            if (filterLines.Count == 0)
            {
                this.SetCurrentFilter(null, null);
            }
            else
            {
                this.SetCurrentFilter(filterLines, filterText);
            }
        }
Пример #26
0
    public static jQueryObject ScrollPagerPlugin(ScrollPagerPluginOptions customOptions)
    {
        ScrollPagerPluginOptions defaultOptions = new ScrollPagerPluginOptions();

        defaultOptions.pageSize      = 10;
        defaultOptions.currentPage   = 1;
        defaultOptions.holder        = ".listcontainer";
        defaultOptions.viewport      = "";
        defaultOptions.pageHeight    = 23;
        defaultOptions.onPageChanged = null;
        defaultOptions.container     = "#listcontainerdiv";

        ScrollPagerPluginOptions options = jQuery.ExtendObject <ScrollPagerPluginOptions>(new ScrollPagerPluginOptions(), defaultOptions, customOptions);

        return(jQuery.Current.Each(delegate(int i, Element element)
        {
            jQueryObject selector = jQuery.This;
            int pageCounter = 1;
            PositionInfo iPosition = new PositionInfo();
            MouseInfo iMouse = new MouseInfo();
            Number candidatePageIndex = 0;

            //this goes through every item in the
            selector
            .Children()
            .Each(delegate(int ic, Element elc)
            {
                if (ic < pageCounter * options.pageSize && ic >= (pageCounter - 1) * options.pageSize)
                {
                    jQuery.This.AddClass("page" + pageCounter);
                }
                else
                {
                    jQuery.This.AddClass("page" + (pageCounter + 1));
                    pageCounter++;
                }
            });

            //set and default the slider item height
            int contHeight = jQuery.Select(options.container).GetHeight();
            int sliderItemHeight = contHeight;

            //show/hide the appropriate regions
            selector.Children().Hide();
            jQuery.Select(".page" + options.currentPage).Show();

            //more than one page?
            if (pageCounter > 1)
            {
                //calculate the slider item height
                sliderItemHeight = (contHeight / pageCounter);

                //Build pager navigation
                string pageNav = "<UL class=scrollbar sizcache='4' sizset='13'>";
                for (i = 1; i <= pageCounter; i++)
                {
                    if (i == options.currentPage)
                    {
                        pageNav += "<LI class='currentPage pageItem' sizcache='4' sizset='13'><A class='sliderPage' href='#' rel='" + i + "'></A>";
                    }
                    else
                    {
                        pageNav += "<LI class='pageNav" + i + " pageItem' sizcache='4' sizset='14'><A class='sliderPage' href='#' rel='" + i + "'></A>";
                    }
                }

                //Create slider item
                string sliderItem = "<LI class='thumb' sizcache='4' sizset='13' style='top:" + (options.currentPage - 1) * sliderItemHeight + "; height:" + (sliderItemHeight - 3) + "'><A class='sliderThumb' href='#' rel='" + i + "'></A>";
                pageNav += sliderItem;
                pageNav += "</LI></UL>";

                if (options.holder == "")
                {
                    selector.After(pageNav);
                }
                else
                {
                    jQuery.Select(options.holder).Append(pageNav);
                }

                //Apply the slider item height
                jQuery.Select(".pageItem").Height(sliderItemHeight);
            }

            jQueryObject oTrack = jQuery.Select(".scrollbar");
            jQueryObject oThumb = jQuery.Select(".thumb");
            //jQueryObject oViewPort = jQuery.Select(options.viewport);
            Number maxPos = (oTrack.GetHeight() - oThumb.GetHeight());
            jQueryObject pageItemCollection = jQuery.Select(".pageItem a");

            Action <jQueryObject> selectPageItem = delegate(jQueryObject pageItem)
            {
                string clickedLink = pageItem.GetAttribute("rel");
                options.onPageChanged.Invoke(pageItem, new SelectedPageEventArgs(int.Parse(clickedLink)));

                options.currentPage = int.Parse(clickedLink);
                //remove current current (!) page
                jQuery.Select("li.currentPage").RemoveClass("currentPage");
                //Add current page highlighting
                pageItem.Parent("li").AddClass("currentPage");
                //hide and show relevant links
                selector.Children().Hide();
                selector.Find(".page" + clickedLink).Show();
            };

            //Action<jQueryObject> selectPageItem = delegate(jQueryObject pageItem)
            jQueryEventHandler selectPageItemHandler = delegate(jQueryEvent pageItemClickedEvent)
            {
                //grab the REL attribute
                jQueryObject pageItem = jQuery.FromElement(pageItemClickedEvent.CurrentTarget);
                selectPageItem(pageItem);
            };


            //pager navigation behaviour
            pageItemCollection.Live("click", selectPageItemHandler);

            jQueryEventHandler wheel = delegate(jQueryEvent oEvent)
            {
            };

            jQueryEventHandler drag = delegate(jQueryEvent oEvent)
            {
                Number candidatePos = Math.Max(0, (iPosition.Start + ((oEvent.PageY) - iMouse.Start)));
                iPosition.Now = (candidatePos > maxPos) ? maxPos : candidatePos;
                candidatePageIndex = Math.Round(iPosition.Now / oThumb.GetHeight());
                oThumb.CSS("top", iPosition.Now.ToString());;
            };

            jQueryEventHandler end = null;
            end = delegate(jQueryEvent oEvent)
            {
                jQuery.Document.Unbind("mousemove", drag);
                jQuery.Document.Unbind("mouseup", end);
                oThumb.Die("mouseup", end);
                selectPageItem(jQuery.FromElement(pageItemCollection[candidatePageIndex]));
            };

            jQueryEventHandler start = delegate(jQueryEvent oEvent)
            {
                iMouse.Start = oEvent.PageY;
                string oThumbDir = oThumb.GetCSS("top");
                iPosition.Start = (oThumbDir == "auto") ? 0 : int.Parse(oThumbDir);
                jQuery.Document.Bind("mousemove", drag);
                jQuery.Document.Bind("mouseup", end);
                oThumb.Live("mouseup", end);
            };

            Action setEvents = delegate()
            {
                oThumb.Live("mousedown", start);
                oTrack.Live("mouseup", drag);
                //if (options.scroll != null)
                //{
                //    oViewPort[0].AddEventListener("DOMMouseScroll", wheel, false);
                //    oViewPort[0].AddEventListener("mousewheel", wheel, false);
                //}
                //else if (options.scroll != null)
                //{
                //    oViewPort[0].OnMouseWheel = wheel;
                //}
            };

            setEvents.Invoke();
        }));
    }
Пример #27
0
 public PopupToolButton(jQueryObject div, PopupToolButtonOptions opt)
     : base(div, opt)
 {
     div.AddClass("s-PopupToolButton");
     J("<b/>").AppendTo(div.Children(".button-outer").Children("span"));
 }
Пример #28
0
        public static void ExecuteOnceWhenShown(jQueryObject element, Action callback)
        {
            autoIncrement++;
            string eventClass = "ExecuteOnceWhenShown" + autoIncrement;

            bool executed = false;

            if (element.Is(":visible"))
                callback();
            else
            {
                jQueryObject uiTabs = element.Closest(".ui-tabs");
                if (uiTabs.Length > 0)
                {
                    uiTabs.Bind("tabsshow." + eventClass, delegate(jQueryEvent e)
                    {
                        if (element.Is(":visible"))
                        {
                            uiTabs.Unbind("tabsshow." + eventClass);

                            if (!executed)
                            {
                                executed = true;
                                element.Unbind("shown." + eventClass);
                                callback();
                            }
                        }
                    });
                }

                jQueryObject dialog;
                if (element.HasClass("ui-dialog"))
                    dialog = element.Children(".ui-dialog-content");
                else
                    dialog = element.Closest(".ui-dialog-content");

                if (dialog.Length > 0)
                    dialog.Bind("dialogopen." + eventClass, delegate
                    {
                        dialog.Unbind("dialogopen." + eventClass);

                        if (element.Is(":visible") && !executed)
                        {
                            executed = true;
                            element.Unbind("shown." + eventClass);
                            callback();
                        }
                    });

                element.Bind("shown." + eventClass, delegate
                {
                    if (element.Is(":visible"))
                    {
                        element.Unbind("shown." + eventClass);

                        if (!executed)
                        {
                            executed = true;
                            callback();
                        }
                    }
                });
            }
        }
Пример #29
0
 public PopupToolButton(jQueryObject div, PopupToolButtonOptions opt)
     : base(div, opt)
 {
     div.AddClass("s-PopupToolButton");
     J("<b/>").AppendTo(div.Children(".button-outer").Children("span"));
 }
Пример #30
0
        public void Search()
        {
            this.rowsDiv.Children().Children("div.v").Children("span.error").Remove();

            var          filterLines = new List <FilterLine>();
            string       errorText   = null;
            jQueryObject row         = null;

            for (int i = 0; i < rowsDiv.Children().Length; i++)
            {
                try
                {
                    row = rowsDiv.Children().Eq(i);

                    var filtering = GetFilteringFor(row);
                    if (filtering == null)
                    {
                        continue;
                    }

                    var field = GetFieldFor(row);
                    var op    = row.Children("div.o").Find("input.op-select").GetWidget <OperatorSelect>().Value;

                    if (op == null || op.Length == 0)
                    {
                        throw new ArgumentOutOfRangeException("operator", Q.Text("Controls.FilterPanel.InvalidOperator"));
                    }

                    FilterLine line = new FilterLine();
                    line.Field      = field.Name;
                    line.Operator   = op;
                    line.IsOr       = row.Children("div.l").Children("a.andor").HasClass("or");
                    line.LeftParen  = row.Children("div.l").Children("a.leftparen").HasClass("active");
                    line.RightParen = row.Children("div.l").Children("a.rightparen").HasClass("active");
                    string displayText;
                    filtering.Operator = op;
                    line.Criteria      = filtering.GetCriteria(out displayText);
                    line.State         = filtering.SaveState();
                    line.DisplayText   = displayText;

                    filterLines.Add(line);
                }
                catch (ArgumentException ex)
                {
                    errorText = ex.Message;
                    break;
                }
            }

            // if an error occured, display it, otherwise set current filters
            if (errorText != null)
            {
                J("<span/>").AddClass("error").Text(errorText).AppendTo(row.Children("div.v"));
                row.Children("div.v").Find("input:first").Focus();
                return;
            }

            Store.Items.Clear();
            Store.Items.AddRange(filterLines);
            Store.RaiseChanged();
        }