public PhotoBrowsingUsingKeysControl(jQueryObject[] focusControls)
		{
			for (int i = 0; i < focusControls.Length; i++)
			{
				focusControls[i].Keydown(KeyDown);
			}
		}
        public LanguageSelection(jQueryObject select, string currentLanguage)
            : base(select)
        {
            currentLanguage = currentLanguage ?? "en";

            var self = this;
            this.Change(e =>
            {
                jQuery.Instance.cookie("LanguagePreference", select.GetValue(), new { path = Q.Config.ApplicationPath });
                Window.Location.Reload(true);
            });

            Q.GetLookupAsync<LanguageRow>("Administration.Language").Then(x =>
            {
                if (!x.Items.Any(z => z.LanguageId == currentLanguage))
                {
                    var idx = currentLanguage.LastIndexOf("-");
                    if (idx >= 0)
                    {
                        currentLanguage = currentLanguage.Substr(0, idx);
                        if (!x.Items.Any(z => z.LanguageId == currentLanguage))
                        {
                            currentLanguage = "en";
                        }
                    }
                    else
                        currentLanguage = "en";
                }

                foreach (var l in x.Items)
                    Q.AddOption(select, l.LanguageId, l.LanguageName);

                select.Value(currentLanguage);
            });
        }
예제 #3
0
        public static void InitFullHeightGridPage(jQueryObject gridDiv)
        {
            J("body")
                .AddClass("full-height-page");

            jQueryEventHandler layout = delegate
            {
                if (gridDiv.Parent().HasClass("page-content"))
                    gridDiv.CSS("height", "1px")
                        .CSS("overflow", "hidden");

                Q.LayoutFillHeight(gridDiv);
                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);
        }
 /// <summary>Constructor.</summary>
 /// <param name="container">The containing element.</param>
 public ListTreeView(jQueryObject container) : base(container)
 {
     ListCss.InsertCss();
     divInner = Html.AppendDiv(container);
     Css.AbsoluteFill(divInner);
     Css.SetOverflow(divInner, CssOverflow.Hidden);
 }
예제 #5
0
 public static void AddOption(jQueryObject select, string key, string text)
 {
     J("<option/>")
         .Value(key)
         .Text(text)
         .AppendTo(select);
 }
예제 #6
0
        public static void ExecuteEverytimeWhenShown(jQueryObject element, Action callback,
            bool callNowIfVisible)
        {
            autoIncrement++;
            string eventClass = "ExecuteEverytimeWhenShown" + autoIncrement;

            bool wasVisible = element.Is(":visible");

            if (wasVisible && callNowIfVisible)
                callback();

            jQueryEventHandler check = delegate(jQueryEvent e)
            {
                if (element.Is(":visible"))
                {
                    if (!wasVisible)
                    {
                        wasVisible = true;
                        callback();
                    }
                }
                else
                    wasVisible = false;
            };

            var uiTabs = element.Closest(".ui-tabs");
            if (uiTabs.Length > 0)
                uiTabs.Bind("tabsactivate." + eventClass, check);

            var dialog = element.Closest(".ui-dialog-content");
            if (dialog.Length > 0)
                dialog.Bind("dialogopen." + eventClass, check);

            element.Bind("shown." + eventClass, check);
        }
        private void LinkFn(CanvasPieceScope scope, jQueryObject element, dynamic attr)
        {
            element.Width(scope.Width);
            element.Height(scope.Height);
            element[0].Style.Display = scope.Inline ? "inline-block" : "block";
            var context = (CanvasRenderingContext2D)((CanvasElement)element[0]).GetContext(CanvasContextId.Render2D);

            Action updateAsset = () =>
                                 {
                                     context.Canvas.Width = context.Canvas.Width;

                                     context.Me().webkitImageSmoothingEnabled = false;
                                     context.Me().mozImageSmoothingEnabled = false;
                                     context.Me().imageSmoothingEnabled = false;

                                     var levelObjectAssetFrames = scope.Asset.Frames;
                                     if (levelObjectAssetFrames.Count == 0) return;
                                     levelObjectAssetFrames[0].DrawSimple(context, new Point(0, 0), scope.Width, scope.Height, false, false);
                                 };

            scope.Watch("asset", updateAsset);
            scope.Watch("asset.frames", updateAsset);
            scope.Watch("asset.width", updateAsset);
            scope.Watch("asset.height", updateAsset);

        }
예제 #8
0
        public static jQueryObject FindElementWithRelativeId(jQueryObject element, string relativeId)
        {
            var elementId = element.GetAttribute("id");

            if (elementId.IsEmptyOrNull())
                return J("#" + relativeId);

            var result = J(elementId + relativeId);
            if (result.Length > 0)
                return result;

            result = J(elementId + "_" + relativeId);
            if (result.Length > 0)
                return result;

            while (true)
            {
                var idx = elementId.LastIndexOf('_');
                if (idx <= 0)
                    return J("#" + relativeId);

                elementId = elementId.Substring(0, idx);

                result = J("#" + elementId + "_" + relativeId);
                if (result.Length > 0)
                    return result;
            }
        }
//        private DelayedAction timeout;

        public PartDownloader(PartDefinition definition, jQueryObject container, PartCallback onComplete, bool initializeOnComplete)
        {
            this.definition = definition;
            this.container = container;
            this.onComplete = onComplete;
            this.initializeOnComplete = initializeOnComplete;
        }
예제 #10
0
 public static void Show(jQueryObject element)
 {
     Script.SetTimeout(delegate()
     {
         element.Show();
     }, 0);
 }
예제 #11
0
파일: ScrollBar.cs 프로젝트: Aethon/odo
        public override void Arrange(AxisArrangement x, AxisArrangement y, Element hostElement)
        {
            base.Arrange(x, y, hostElement);

            if (_dom == null)
            {
                _dom = jQuery.FromHtml("<div class='ui-vertical-scrollbar' style='position: absolute;'></div>").AppendTo(hostElement);
                _near = jQuery.FromHtml("<div class='ui-scroll-up-button'></div>").AppendTo(_dom).MouseDown(LineNear);
                _track = jQuery.FromHtml("<div class='ui-scroll-vertical-track'></div>").AppendTo(_dom).MouseDown(Page);
                _thumb = jQuery.FromHtml("<div class='ui-scroll-vertical-thumb' style='position: relative'></div>").AppendTo(_track).MouseDown(Scrub);
                _far = jQuery.FromHtml("<div class='ui-scroll-down-button'></div>").AppendTo(_dom).MouseDown(LineFar);
            }

            int buttonLength = (y.Length > 2*x.Length) ? x.Length : (int)Math.Floor(y.Length/2);
            int trackHeight = y.Length - 2*buttonLength;

            _minThumbLength = Math.Min(buttonLength, trackHeight);
            _dom.CSS("width", x.Length + "px").CSS("height", y.Length + "px").CSS("top", y.Position + "px").CSS("left", x.Position + "px");
            _near.CSS("width", x.Length + "px").CSS("height", buttonLength + "px");
            _far.CSS("width", x.Length + "px").CSS("height", buttonLength + "px");
            _track.CSS("width", x.Length + "px").CSS("height", trackHeight + "px");
            _thumb.CSS("width", x.Length + "px");

            ScrollableAxisChanged();
        }
        /// <summary>Constructor.</summary>
        /// <param name="model">The logical model of the button</param>
        /// <param name="container">The HTML container of the button.</param>
        protected ButtonView(IButton model, jQueryObject container) : base(InitContainer(container))
        {
            // Setup initial conditions.
            if (Script.IsNullOrUndefined(model)) model = new ButtonBase();
            this.model = model;
            Focus.BrowserHighlighting = false;

            // Setup CSS.
            Css.InsertLink(Css.Urls.CoreButtons);
            Container.AddClass(ClassButton);
            Container.AddClass(Css.Classes.NoSelect);

            // Insert the content and mask containers.
            divContent = CreateContainer("buttonContent");

            // Create child controllers.
            eventController = new ButtonEventController(this);
            contentController = new ButtonContentController(this, divContent);

            // Wire up events.
            Model.LayoutInvalidated += OnLayoutInvalidated;
            Helper.ListenPropertyChanged(Model, OnModelPropertyChanged);
            eventController.PropertyChanged += OnEventControllerPropertyChanged;
            GotFocus += delegate { UpdateLayout(); };
            LostFocus += delegate { UpdateLayout(); };
            IsEnabledChanged += delegate { UpdateLayout(); };
            Container.Keydown(delegate(jQueryEvent e)
                                  {
                                      OnKeyPress(Int32.Parse(e.Which));
                                  });

            // Finish up.
            SyncCanFocus();
        }
        /// <summary>Constructor.</summary>
        public AddPackageView()
        {
            // Create buttons.
            addButton = CreateButton(StringLibrary.Add);
            cancelButton = CreateButton(StringLibrary.Cancel);

            // Load the HTML content.
            RetrieveHtml(ContentUrl, delegate
                                         {
                                             // Setup children.
                                             divInnerSlide = jQuery.Select(CssSelectors.AddPackageInnerSlide);
                                             offLeft = divInnerSlide.GetCSS(Css.Left);
                                             InitializeTextboxes();

                                             // Insert buttons.
                                             addButton.CreateView().Insert(CssSelectors.AddPackageBtnAdd, InsertMode.Replace);
                                             cancelButton.CreateView().Insert(CssSelectors.AddPackageBtnCancel, InsertMode.Replace);

                                             // Wire up events.
                                             Keyboard.Keydown += OnKeydown;

                                             // Finish up.
                                             isInitialized = true;
                                             UpdateState();
                                             SlideOn(null);
                                         });
        }
예제 #14
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]);
                }
            });
        }
        private void LinkFn(CanvasPieceLayoutScope scope, jQueryObject element, dynamic attr)
        {
            element.Width(scope.Width);
            element.Height(scope.Height);
  
            element[0].Style.Display = "inline-block";
            var context = (CanvasRenderingContext2D)((CanvasElement)element[0]).GetContext(CanvasContextId.Render2D);
            Action updatePieceLayout = () =>
            {
                context.Canvas.Width = context.Canvas.Width;

                context.Me().webkitImageSmoothingEnabled = false;
                context.Me().mozImageSmoothingEnabled = false;
                context.Me().imageSmoothingEnabled = false;

                context.FillStyle = "#FFFFFF";
                context.FillRect(0, 0, scope.Width, scope.Height);
                context.BeginPath();
                context.Rect(0, 0, scope.Width, scope.Height);
                context.Clip();
                context.ClosePath();
                if (scope.PieceLayout == null) return;

                var rect = scope.PieceLayout.GetRectangle(scope.ObjectData);

                context.Scale(scope.Width / ((double)rect.Width), scope.Height / ((double)rect.Height));
                context.Translate(-rect.X, -rect.Y);
                scope.PieceLayout.DrawUI(context, true, -1, scope.ObjectData);
            };

            scope.Watch("pieceLayout", updatePieceLayout);
            scope.Watch("pieceLayout.pieces", updatePieceLayout, true);
        }
예제 #16
0
 public static void LayoutFillHeight(jQueryObject element)
 {
     var h = LayoutFillHeightValue(element);
     string n = h + "px";
     if (element.GetCSS("height") != n)
         element.CSS("height", n);
 }
        /// <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();
        }
        public ThemeSelection(jQueryObject select)
            : base(select)
        {
            var self = this;

            this.Change(e =>
            {
                jQuery.Instance.cookie("ThemePreference", select.GetValue(), new { path = Q.Config.ApplicationPath });
                J("body").RemoveClass("skin-" + GetCurrentTheme());
                J("body").AddClass("skin-" + select.GetValue());
            });

            Q.AddOption(select, "blue", Q.Text("Site.Layout.ThemeBlue"));
            Q.AddOption(select, "blue-light", Q.Text("Site.Layout.ThemeBlueLight"));
            Q.AddOption(select, "purple", Q.Text("Site.Layout.ThemePurple"));
            Q.AddOption(select, "purple-light", Q.Text("Site.Layout.ThemePurpleLight"));
            Q.AddOption(select, "red", Q.Text("Site.Layout.ThemeRed"));
            Q.AddOption(select, "red-light", Q.Text("Site.Layout.ThemeRedLight"));
            Q.AddOption(select, "green", Q.Text("Site.Layout.ThemeGreen"));
            Q.AddOption(select, "green-light", Q.Text("Site.Layout.ThemeGreenLight"));
            Q.AddOption(select, "yellow", Q.Text("Site.Layout.ThemeYellow"));
            Q.AddOption(select, "yellow-light", Q.Text("Site.Layout.ThemeYellowLight"));
            Q.AddOption(select, "black", Q.Text("Site.Layout.ThemeBlack"));
            Q.AddOption(select, "black-light", Q.Text("Site.Layout.ThemeBlackLight"));

            select.Value(GetCurrentTheme());
        }
예제 #19
0
        public PhoneEditor(jQueryObject input)
            : base(input)
        {
            this.AddValidationRule(this.uniqueName, (e) =>
            {
                string value = this.Value.TrimToNull();
                if (value == null)
                    return null;

                return Validate(value, this.Multiple);
            });

            input.Bind("change", delegate(jQueryEvent e)
            {
                if (!e.HasOriginalEvent())
                    return;

                FormatValue();
            });

            input.Bind("blur", delegate(jQueryEvent e)
            {
                if (this.element.HasClass("valid"))
                {
                    FormatValue();
                }
            });
        }
예제 #20
0
 /// <summary>Constructor.</summary>
 /// <param name="container">The containing DIV.</param>
 public ShellView(jQueryObject container) : base(container)
 {
     // Create child views.
     sidebar = new SidebarView();
     controlHost = new ControlHostView();
     logContainer = new LogContainerView();
 }
예제 #21
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");
                }
            }
        }
        private void LinkFn(dynamic scope, jQueryObject element, dynamic attr)
        {
            scope.itemClick = new Action<dynamic>((item) => { scope.bind = item; });

            scope.currentClass = new Func<dynamic, dynamic>((item) => (item == scope.bind) ? "fancy-list-item fancy-list-item-selected" : "fancy-list-item ");
            scope.parentScope = scope["$parent"]["$parent"]["$parent"];
        }
예제 #23
0
        public XrmDateEditor(EditorArguments args)
            : base(args)
        {
            XrmDateEditor self = this;
            _container = jQuery.FromHtml("<div ><table class='inline-edit-container' cellspacing='0' cellpadding='0'><tr>" +
                "<td><INPUT type=text class='sparkle-input-inline' /></td>" +
                "<td class='lookup-button-td'><input type=button class='sparkle-imagestrip-inlineedit_calendar_icon' /></td></tr></table></div>");
            _container.AppendTo(_args.Container);

            _input = _container.Find(".sparkle-input-inline");
            _input.Bind("keydown.nav", delegate(jQueryEvent e)
            {
                if (!_calendarOpen && (e.Which == 38 || e.Which == 40) && e.CtrlKey) // Ctrl-Up/Down shows date picker
                {
                    _input.Plugin<DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
                    e.StopImmediatePropagation();
                }
                else if (_calendarOpen && e.Which == 13)
                {
                    e.PreventDefault();
                }

            });
            jQueryObject selectButton = _container.Find(".sparkle-imagestrip-inlineedit_calendar_icon");
            _input.Focus().Select();
            DatePickerOptions2 options2 = new DatePickerOptions2();
            options2.ShowOtherMonths = true;
            options2.ShowOn = ""; // Date Pickers in CRM do not show when they are focused - you click the button
            options2.FirstDay = OrganizationServiceProxy.OrganizationSettings != null ? OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value : 0;
            options2.BeforeShow = delegate()
            {
                this._calendarOpen = true;
            };

            options2.OnClose = delegate()
            {
                this._calendarOpen = false;
                _selectedValue = GetSelectedValue();
            };

            options2.OnSelect = delegate(string dateString, object instance)
            {
                // Select the date text field when selecting a date
                Focus();
            };

            if (OrganizationServiceProxy.UserSettings != null)
            {
                _dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
            }
            options2.DateFormat = _dateFormat;
            _input.Plugin<DatePickerPlugIn>().DatePicker(options2);

            // Wire up the date picker button
            selectButton.Click(delegate(jQueryEvent e){
                _input.Plugin<DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
                Focus();
            });
        }
예제 #24
0
 /// <summary>Adds a new element within an <li></li> item.</summary>
 /// <param name="element">The element to add (within the LI).</param>
 /// <returns>The LI element.</returns>
 public jQueryObject AddElement(jQueryObject element)
 {
     jQueryObject li = Html.CreateElement("li");
     li.Append(element);
     li.AppendTo(Container);
     FireSizeChanged();
     return li;
 }
예제 #25
0
 private static int GetBorderEdge(jQueryObject element, Edge edge)
 {
     if (Script.IsNullOrUndefined(element)) return 0;
     string value = element.GetCSS(string.Format("border-{0}-width", edge.ToString().ToLocaleLowerCase()));
     if (string.IsNullOrEmpty(value)) return 0;
     if (!value.EndsWith(Px)) return 0;
     return Int32.Parse(value);
 }
예제 #26
0
 public Pagination(jQueryObject parent, Action<int> changePageCallback, GetTotalPageDelegate getTotalPage, string floatDirection)
 {
     this.parent = parent;
     this.changePageCallback = changePageCallback;
     this.getTotalPage = getTotalPage;
     this.floatDirection = floatDirection;
     currentPage = 1;
 }
예제 #27
0
 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");
     }
 }
예제 #28
0
        public XrmDurationEditor(EditorArguments args)
            : base(args)
        {
            _args = args;
            _input = jQuery.FromHtml("<INPUT type=text class='editor-text' />");

            _input.AppendTo(_args.Container);
            Focus();
        }
예제 #29
0
 private void LoadPart(jQueryObject container)
 {
     Log.Info("Downloading part...");
     partDefinition.Initialize(container, delegate(Part value)
                                 {
                                     part = value as SamplePart;
                                     if (partDefinition.HasError) { Log.Error("Download callback (failed)"); } else { Log.Success("Download callback (succeeded) - " + part.InstanceId); }
                                 });
 }
예제 #30
0
 static ViewManager()
 {
     FileList = jQuery.Select("#filelist");
     Views.Add(FileList);
     SignIn = jQuery.Select("#signin");
     Views.Add(SignIn);
     Modal = jQuery.Select("#modal");
     Views.Add(Modal);
 }
예제 #31
0
파일: TaxGrid.cs 프로젝트: dfaruque/NERP
 public TaxGrid(jQueryObject container)
     : base(container)
 {
 }
예제 #32
0
        public override void Init(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context)
        {
            XrmLookupEditorButton footerButton = (XrmLookupEditorButton)allBindingsAccessor()["footerButton"];
            bool                showFooter     = (bool)allBindingsAccessor()["showFooter"];
            jQueryObject        container      = jQuery.FromElement(element);
            string              searchTerm     = "";
            jQueryObject        inputField     = container.Find(".sparkle-input-lookup-part");
            jQueryObject        selectButton   = container.Find(".sparkle-input-lookup-button-part");
            EntityReference     _value         = new EntityReference(null, null, null);
            AutoCompleteOptions options        = new AutoCompleteOptions();

            options.MinLength = 100000; // Don't enable type down - use search button (or return)
            options.Delay     = 0;
            options.Position  = new Dictionary <string, object>("collision", "fit");
            bool justSelected         = false;
            int  totalRecordsReturned = 0;
            Action <AutoCompleteItem, bool> setValue = delegate(AutoCompleteItem item, bool setFocus)
            {
                if (_value == null)
                {
                    _value = new EntityReference(null, null, null);
                }
                string value = item.Label;
                inputField.Value(value);
                searchTerm         = value;
                _value.Id          = ((Guid)item.Value);
                _value.Name        = item.Label;
                _value.LogicalName = (string)item.Data;
                justSelected       = true;
                TrySetObservable(valueAccessor, inputField, _value, setFocus);
            };

            // Set the value when selected
            options.Select = delegate(jQueryEvent e, AutoCompleteSelectEvent uiEvent)
            {
                // Note we assume that the binding has added an array of string items
                AutoCompleteItem item = (AutoCompleteItem)uiEvent.Item;
                string           data = ((string)item.Data);
                if (data == "footerlink" || data == null)
                {
                    footerButton.OnClick(item);
                    e.PreventDefault();
                    e.StopImmediatePropagation();
                    Script.Literal("return false;");
                }
                else
                {
                    setValue(item, true);
                    Script.Literal("return false;");
                }
            };

            options.Open = delegate(jQueryEvent e, jQueryObject o)
            {
                if (showFooter && totalRecordsReturned > 0)
                {
                    WidgetObject menu = (WidgetObject)Script.Literal("{0}.autocomplete({1})", inputField, "widget");
                    XrmLookupEditor.AddFooter(menu, totalRecordsReturned);
                }
            };

            options.Close = delegate(jQueryEvent e, jQueryObject o)
            {
                WidgetObject menu   = (WidgetObject)Script.Literal("{0}.autocomplete({1})", inputField, "widget");
                jQueryObject footer = menu.Next();
                if (footer.Length > 0 || footer.HasClass("sparkle-menu-footer"))
                {
                    footer.Hide();
                }
            };
            // Get the query command
            Action <string, Action <EntityCollection> > queryCommand = (Action <string, Action <EntityCollection> >)((object)allBindingsAccessor()["queryCommand"]);
            string nameAttribute     = ((string)allBindingsAccessor()["nameAttribute"]);
            string idAttribute       = ((string)allBindingsAccessor()["idAttribute"]);
            string typeCodeAttribute = ((string)allBindingsAccessor()["typeCodeAttribute"]);

            string[] columnAttributes = null;
            // If there multiple names, add them to the columnAttributes
            string[] columns = nameAttribute.Split(",");

            if (columns.Length > 1)
            {
                columnAttributes = columns;
                nameAttribute    = columnAttributes[0];
            }

            // wire up source to CRM search
            Action <AutoCompleteRequest, Action <AutoCompleteItem[]> > queryDelegate = delegate(AutoCompleteRequest request, Action <AutoCompleteItem[]> response)
            {
                Action <EntityCollection> queryCallBack = delegate(EntityCollection fetchResult)
                {
                    int  recordsFound          = fetchResult.Entities.Count;
                    bool noRecordsFound        = recordsFound == 0;
                    AutoCompleteItem[] results = new AutoCompleteItem[recordsFound + (footerButton != null ? 1 : 0) + (noRecordsFound ? 1 : 0)];

                    for (int i = 0; i < recordsFound; i++)
                    {
                        results[i]       = new AutoCompleteItem();
                        results[i].Label = (string)fetchResult.Entities[i].GetAttributeValue(nameAttribute);
                        results[i].Value = fetchResult.Entities[i].GetAttributeValue(idAttribute);
                        results[i].Data  = fetchResult.Entities[i].LogicalName;
                        GetExtraColumns(columnAttributes, fetchResult, results, i);

                        string typeCodeName = fetchResult.Entities[i].LogicalName;
                        // Get the type code from the name to find the icon
                        if (!string.IsNullOrEmpty(typeCodeAttribute))
                        {
                            typeCodeName = fetchResult.Entities[i].GetAttributeValue(typeCodeAttribute).ToString();
                        }

                        results[i].Image = MetadataCache.GetSmallIconUrl(typeCodeName);
                    }

                    if (fetchResult.TotalRecordCount > fetchResult.Entities.Count)
                    {
                        totalRecordsReturned = fetchResult.TotalRecordCount;
                    }
                    else
                    {
                        totalRecordsReturned = fetchResult.Entities.Count;
                    }
                    int itemsCount = recordsFound;
                    if (noRecordsFound)
                    {
                        AutoCompleteItem noRecordsItem = new AutoCompleteItem();
                        noRecordsItem.Label = SparkleResourceStrings.NoRecordsFound;
                        results[itemsCount] = noRecordsItem;
                        itemsCount++;
                    }
                    if (footerButton != null)
                    {
                        // Add the add new
                        AutoCompleteItem addNewLink = new AutoCompleteItem();
                        addNewLink.Label        = footerButton.Label;
                        addNewLink.Image        = footerButton.Image;
                        addNewLink.ColumnValues = null;
                        addNewLink.Data         = "footerlink";
                        results[itemsCount]     = addNewLink;
                    }
                    response(results);

                    // Disable it now so typing doesn't trigger a search
                    AutoCompleteOptions disableOption = new AutoCompleteOptions();
                    disableOption.MinLength = 100000;
                    inputField.Plugin <AutoCompleteObject>().AutoComplete(disableOption);
                };

                // Call the function with the correct 'this' context
                Script.Literal("{0}.call({1}.$parent,{2},{3})", queryCommand, context, request.Term, queryCallBack);
            };

            options.Source = queryDelegate;
            options.Focus  = delegate(jQueryEvent e, AutoCompleteFocusEvent uiEvent)
            {
                // Prevent the value being updated in the text box we scroll through the results
                Script.Literal("return false;");
            };
            inputField = inputField.Plugin <AutoCompleteObject>().AutoComplete(options);

            // Set render template
            ((RenderItemDelegate)Script.Literal("{0}.data('ui-autocomplete')", inputField))._renderItem = delegate(object ul, AutoCompleteItem item)
            {
                if (item.Data == null)
                {
                    return((object)jQuery.Select("<li class='ui-state-disabled'>" + item.Label + "</li>").AppendTo((jQueryObject)ul));
                }

                string html = "<a class='sparkle-menu-item'><span class='sparkle-menu-item-img'>";
                if (item.Image != null)
                {
                    html += @"<img src='" + item.Image + "'/>";
                }
                html += @"</span><span class='sparkle-menu-item-label'>" + item.Label + "</span><br>";

                if (item.ColumnValues != null && item.ColumnValues.Length > 0)
                {
                    foreach (string value in item.ColumnValues)
                    {
                        html += "<span class='sparkle-menu-item-moreinfo'>" + value + "</span>";
                    }
                }
                html += "</a>";
                return((object)jQuery.Select("<li>").Append(html).AppendTo((jQueryObject)ul));
            };

            // Add the click binding to show the drop down
            selectButton.Click(delegate(jQueryEvent e)
            {
                inputField.Value(searchTerm);
                AutoCompleteOptions enableOption = new AutoCompleteOptions();
                enableOption.MinLength           = 0;
                inputField.Focus();
                inputField.Plugin <AutoCompleteObject>().AutoComplete(enableOption);
                inputField.Plugin <AutoCompleteObject>().AutoComplete(AutoCompleteMethod.Search);
            });

            // handle the field changing
            inputField.FocusIn(delegate(jQueryEvent e)
            {
                searchTerm = "";
            });

            // handle the field changing
            inputField.Change(delegate(jQueryEvent e)
            {
                searchTerm        = inputField.GetValue();
                string inputValue = searchTerm;
                if (inputValue != _value.Name)
                {
                    // The name is different from the name of the lookup reference
                    // search to see if we can auto resolve it

                    TrySetObservable(valueAccessor, inputField, null, false);
                    AutoCompleteRequest lookup = new AutoCompleteRequest();
                    lookup.Term = inputValue;
                    Action <AutoCompleteItem[]> lookupResults = delegate(AutoCompleteItem[] results)
                    {
                        int selectableItems = 0;
                        // If there is only one, then auto-set
                        if (results != null)
                        {
                            foreach (AutoCompleteItem item in results)
                            {
                                if (isItemSelectable(item))
                                {
                                    selectableItems++;
                                }
                                if (selectableItems > 2)
                                {
                                    break;
                                }
                            }
                        }

                        if (selectableItems == 1)
                        {
                            // There is only a single value so set it now
                            setValue(results[0], false);
                        }
                        else
                        {
                            inputField.Value(String.Empty);
                        }
                    };

                    queryDelegate(lookup, lookupResults);
                }
            });

            Action disposeCallBack = delegate()
            {
                if ((bool)Script.Literal("$({0}).data('ui-autocomplete')!=undefined", inputField))
                {
                    Script.Literal("$({0}).autocomplete(\"destroy\")", inputField);
                }
            };

            //handle disposal (if KO removes by the template binding)
            Script.Literal("ko.utils.domNodeDisposal.addDisposeCallback({0}, {1})", element, (object)disposeCallBack);
            Knockout.BindingHandlers["validationCore"].Init(element, valueAccessor, allBindingsAccessor, null, null);

            // Bind return to searching
            inputField.Keydown(delegate(jQueryEvent e)
            {
                if (e.Which == 13 && !justSelected) // Return pressed - but we want to do a search not move to the next cell
                {
                    searchTerm = inputField.GetValue();
                    selectButton.Click();
                }
                else if (e.Which == 13)
                {
                    return;
                }
                switch (e.Which)
                {
                case 13:     // Return
                case 38:     // Up - don't navigate - but use the dropdown to select search results
                case 40:     // Down - don't navigate - but use the dropdown to select search results
                    e.PreventDefault();
                    e.StopPropagation();
                    break;
                }
                justSelected = false;
            });

            //Script.Literal("return { controlsDescendantBindings: true };");
        }
        public QuickSearchInput(jQueryObject input, QuickSearchInputOptions opt)
            : base(input, opt)
        {
            input.Attribute("title", Q.Text("Controls.QuickSearch.Hint"))
            .Attribute("placeholder", Q.Text("Controls.QuickSearch.Placeholder"));

            lastValue = Q.Trim(input.GetValue() ?? "");

            var self = this;

            this.element.Bind("keyup." + this.uniqueName, delegate
            {
                self.CheckIfValueChanged();
            });

            this.element.Bind("change." + this.uniqueName, delegate
            {
                self.CheckIfValueChanged();
            });

            J("<span><i></i></span>").AddClass("quick-search-icon")
            .InsertBefore(input);

            if (options.Fields != null && options.Fields.Count > 0)
            {
                var a = J("<a/>").AddClass("quick-search-field")
                        .Attribute("title", Q.Text("Controls.QuickSearch.FieldSelection"))
                        .InsertBefore(input);

                var menu = J("<ul></ul>").CSS("width", "120px");
                foreach (var item in options.Fields)
                {
                    var field = item;
                    J("<li><a/></li>").AppendTo(menu)
                    .Children().Attribute("href", "#")
                    .Text(item.Title ?? "")
                    .Click(delegate(jQueryEvent e) {
                        e.PreventDefault();
                        fieldChanged = self.field != field;
                        self.field   = field;
                        UpdateInputPlaceHolder();
                        CheckIfValueChanged();
                    });
                }

                new PopupMenuButton(a, new PopupMenuButtonOptions
                {
                    PositionMy = "right top",
                    PositionAt = "right bottom",
                    Menu       = menu
                });

                this.field = options.Fields[0];
                UpdateInputPlaceHolder();
            }

            this.element.Bind("execute-search." + this.uniqueName, e =>
            {
                if (Q.IsTrue(this.timer))
                {
                    Window.ClearTimeout(this.timer);
                }

                SearchNow(Q.Trim(this.element.GetValue() ?? ""));
            });
        }
예제 #34
0
 public static jQueryTemplate CreateTemplate(string templateName, jQueryObject template)
 {
     return(null);
 }
예제 #35
0
 public CountyGrid(jQueryObject container)
     : base(container)
 {
 }
예제 #36
0
        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;
            }

            UpdateReadOnly();
        }
예제 #37
0
 public static void Dialog(jQueryObject owner, jQueryObject dialog,
                           Func <string> hash)
 {
 }
 public DefaultValuesInNewGrid(jQueryObject container)
     : base(container)
 {
 }
예제 #39
0
        private Widget CreateField(jQueryObject container, PropertyItem item)
        {
            var fieldDiv = J("<div/>")
                           .AddClass("field")
                           .AddClass(item.Name)
                           .Data("PropertyItem", item)
                           .AppendTo(container);

            if (!String.IsNullOrEmpty(item.CssClass))
            {
                fieldDiv.AddClass(item.CssClass);
            }

            string editorId = options.IdPrefix + item.Name;

            string title       = DetermineText(item.Title, prefix => prefix + item.Name);
            string hint        = DetermineText(item.Hint, prefix => prefix + item.Name + "_Hint");
            string placeHolder = DetermineText(item.Placeholder, prefix => prefix + item.Name + "_Placeholder");

            var label = J("<label/>")
                        .AddClass("caption")
                        .Attribute("for", editorId)
                        .Attribute("title", hint ?? title ?? "")
                        .Html(title ?? "")
                        .AppendTo(fieldDiv);

            if (item.Required)
            {
                J("<sup>*</sup>")
                .Attribute("title", Texts.Controls.PropertyGrid.RequiredHint)
                .PrependTo(label);
            }

            var    editorType  = EditorTypeRegistry.Get(item.EditorType);
            var    elementAttr = editorType.GetCustomAttributes(typeof(ElementAttribute), true);
            string elementHtml = (elementAttr.Length > 0) ? elementAttr[0].As <ElementAttribute>().Html : "<input/>";

            var element = Widget.ElementFor(editorType)
                          .AddClass("editor")
                          .AddClass("flexify")
                          .Attribute("id", editorId)
                          .AppendTo(fieldDiv);

            if (element.Is(":input"))
            {
                element.Attribute("name", item.Name ?? "");
            }

            if (!placeHolder.IsEmptyOrNull())
            {
                element.Attribute("placeholder", placeHolder);
            }

            object editorParams = item.EditorParams;
            Type   optionsType  = null;
            var    optionsAttr  = editorType.GetCustomAttributes(typeof(OptionsTypeAttribute), true);

            if (optionsAttr != null && optionsAttr.Length > 0)
            {
                optionsType = optionsAttr[0].As <OptionsTypeAttribute>().OptionsType;
            }

            Widget editor;

            if (optionsType != null)
            {
                editorParams = jQuery.ExtendObject(Activator.CreateInstance(optionsType), item.EditorParams);

                editor = (Widget)(Activator.CreateInstance(editorType, element, editorParams));
            }
            else
            {
                editorParams = jQuery.ExtendObject(new object(), item.EditorParams);
                editor       = (Widget)(Activator.CreateInstance(editorType, element, editorParams));
            }

            editor.Initialize();

            if (editor is BooleanEditor)
            {
                label.RemoveAttr("for");
            }

            if (Script.IsValue(item.MaxLength))
            {
                SetMaxLength(editor, item.MaxLength.Value);
            }

            if (item.EditorParams != null)
            {
                ReflectionOptionsSetter.Set(editor, item.EditorParams);
            }

            J("<div/>")
            .AddClass("vx")
            .AppendTo(fieldDiv);

            J("<div/>")
            .AddClass("clear")
            .AppendTo(fieldDiv);

            return(editor);
        }
예제 #40
0
 public static AngularElement Element(jQueryObject document)
 {
     return(null);
 }
예제 #41
0
 public KategoriLookupEditor(jQueryObject hidden)
     : base(hidden, null)
 {
 }
예제 #42
0
 public static jQueryTemplate CreateTemplate(jQueryObject o)
 {
     return(null);
 }
예제 #43
0
 public FirmaLogoUploadEditor(jQueryObject div, ImageUploadEditorOptions opt)
     : base(div, opt)
 {
     this.toolbar.Element.AppendTo(this.element);
 }
예제 #44
0
 public GridEditorBase(jQueryObject container)
     : base(container)
 {
 }
예제 #45
0
 public SupplierGrid(jQueryObject container)
     : base(container)
 {
 }
 public EditorTypeEditor(jQueryObject select)
     : base(select, new SelectEditorOptions {
     EmptyOptionText = Q.Text("Controls.SelectEditor.EmptyItemText")
 })
 {
 }
 protected Widget(jQueryObject element, TOptions opt = null)
     : base(element, opt)
 {
 }
예제 #48
0
 private void RemoveFilterHandler(jQueryObject row)
 {
     row.Data("FilterHandler", null);
     row.Data("FilterHandlerField", null);
 }
예제 #49
0
        public static void PopulateFileSymbols(
            jQueryObject container,
            List <UploadedFile> items,
            bool displayOriginalName = false,
            string urlPrefix         = null)
        {
            items = items ?? new List <UploadedFile>();
            container.Html("");

            for (var index = 0; index < items.Count; index++)
            {
                var item = items[index];
                var li   = jQuery.FromHtml("<li/>")
                           .AddClass("file-item")
                           .Data("index", index);

                bool isImage = HasImageExtension(item.Filename);

                if (isImage)
                {
                    li.AddClass("file-image");
                }
                else
                {
                    li.AddClass("file-binary");
                }

                var editLink = "#" + index;

                var thumb = jQuery.FromHtml("<a/>")
                            .AddClass("thumb")
                            .AppendTo(li);

                string originalName = item.OriginalName ?? "";

                string fileName = item.Filename;
                if (urlPrefix != null && fileName != null && !fileName.StartsWith("temporary/"))
                {
                    fileName = urlPrefix + fileName;
                }

                thumb.Attribute("href", DbFileUrl(fileName));
                thumb.Attribute("target", "_blank");
                if (!originalName.IsEmptyOrNull())
                {
                    thumb.Attribute("title", (originalName));
                }

                if (isImage)
                {
                    thumb.CSS("backgroundImage", "url('" + DbFileUrl(ThumbFileName(item.Filename)) + "')");
                    ColorBox(thumb, new object());
                }

                if (displayOriginalName)
                {
                    jQuery.FromHtml("<div/>")
                    .AddClass("filename")
                    .Text(originalName)
                    .Attribute("title", originalName)
                    .AppendTo(li);
                }

                li.AppendTo(container);
            }
            ;
        }
예제 #50
0
 public CustomerEditor(jQueryObject container, LookupEditorOptions options)
     : base(container, options)
 {
 }
예제 #51
0
 public EmailGroupGrid(jQueryObject container)
     : base(container)
 {
     rowSelection = new GridRowSelectionMixin(this);
 }
예제 #52
0
 public ResponsiveGrid(jQueryObject container)
     : base(container)
 {
 }
예제 #53
0
 public EmailLogGrid(jQueryObject container)
     : base(container)
 {
 }
예제 #54
0
        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"));
                })
            });

            input.Bind("keyup." + this.uniqueName, e => {
                if (e.Which == 32 && !ReadOnly)
                {
                    this.ValueAsDate = JsDate.Now;
                }
                else
                {
                    DateEditor.DateInputKeyup(e);
                }
            });
            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 ?? 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(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;

            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;
            });
        }
예제 #55
0
 public EmployeeGrid(jQueryObject container)
     : base(container)
 {
 }
예제 #56
0
        private JsDictionary <string, int> CreateCategoryLinks(jQueryObject container, List <PropertyItem> items)
        {
            int idx       = 0;
            var itemIndex = new JsDictionary <string, int>();

            foreach (var x in items)
            {
                x.Category        = x.Category ?? options.DefaultCategory ?? "";
                itemIndex[x.Name] = idx++;
            }

            var self          = this;
            var categoryOrder = GetCategoryOrder(items);

            items.Sort((x, y) =>
            {
                var c = 0;

                if (x.Category != y.Category)
                {
                    var c1 = categoryOrder[x.Category];
                    var c2 = categoryOrder[y.Category];
                    if (c1 != null && c2 != null)
                    {
                        c = c1.Value - c2.Value;
                    }
                    else if (c1 != null)
                    {
                        c = -1;
                    }
                    else if (c2 != null)
                    {
                        c = 1;
                    }
                }

                if (c == 0)
                {
                    c = String.Compare(x.Category, y.Category);
                }

                if (c == 0)
                {
                    c = itemIndex[x.Name].CompareTo(itemIndex[y.Name]);
                }

                return(c);
            });

            var categoryIndexes = new JsDictionary <string, int>();

            for (int i = 0; i < items.Count; i++)
            {
                var item = items[i];

                if (!categoryIndexes.ContainsKey(item.Category))
                {
                    int index = categoryIndexes.Count + 1;
                    categoryIndexes[item.Category] = index;

                    if (index > 1)
                    {
                        J("<span/>")
                        .AddClass("separator")
                        .Text("|")
                        .PrependTo(container);
                    }

                    J("<a/>")
                    .AddClass("category-link")
                    .Text(DetermineText(item.Category, prefix => prefix + "Categories." + item.Category))
                    .Attribute("tabindex", "-1")
                    .Attribute("href", "#" + options.IdPrefix + "Category" + index.ToString())
                    .Click(CategoryLinkClick)
                    .PrependTo(container);
                }
            }

            J("<div/>")
            .AddClass("clear")
            .AppendTo(container);

            return(categoryIndexes);
        }
예제 #57
0
 public static jQueryTemplateInstance GetTemplateInstance(jQueryObject o)
 {
     return(null);
 }
예제 #58
0
 public static jQueryObject RenderTemplate(jQueryObject template, object data, object item)
 {
     return(null);
 }
예제 #59
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);
            }
        }
예제 #60
0
 public StringEditor(jQueryObject input)
     : base(input, new object())
 {
 }