示例#1
0
        public static int LayoutFillHeightValue(jQueryObject element)
        {
            var h = 0;

            element.Parent()
            .Children()
            .Not(element)
            .Each((i, e) =>
            {
                var q = J(e);
                if (q.Is(":visible"))
                {
                    h += q.GetOuterHeight(true);
                }
            });

            h = element.Parent().GetHeight() - h;

            if (element.GetCSS("box-sizing") != "border-box")
            {
                h = h - (element.GetOuterHeight(true) - element.GetHeight());
            }

            return(h);
        }
示例#2
0
        public void HandleMouseEnter(EventData e, object item)
        {
            OnCellChangedEventData cell = (OnCellChangedEventData)(object)_grid.GetCellFromEvent(e);

            if (cell != null)
            {
                _mouseOut = false;
                Entity entityRow = (Entity)_grid.GetDataItem(cell.Row);
                if (entityRow != null)
                {
                    Script.Literal("{0}.getGridPosition()", _grid);
                    int viewPortRight = _grid.GetViewport().RightPx;
                    int viewPortLeft  = _grid.GetViewport().LeftPx;

                    jQueryObject node         = jQuery.Select((string)Script.Literal("{0}.getCellNode({1},{2})", _grid, cell.Row, cell.Cell));
                    int          buttonsWidth = _hoverButtons.GetWidth();
                    int          x            = node.Parent().GetWidth();
                    if (viewPortRight < x + buttonsWidth)
                    {
                        x = viewPortRight - buttonsWidth;
                    }
                    int y = 0;

                    node.Parent().Append(_hoverButtons);
                    _hoverButtons.CSS("left", x.ToString() + "px");
                    _hoverButtons.CSS("top", y.ToString() + "px");
                    _hoverButtons.CSS("display", "block");
                    _hoverButtons.Attribute("rowId", entityRow.Id.ToString());
                }
            }
        }
示例#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 (Window.Instance.As <dynamic>().Metronic != null)
            {
                Window.Instance.As <dynamic>().Metronic.addResizeHandler(layout);
            }
            else
            {
            }
            //jQuery.Window.Resize(layout);


            layout(null);
        }
示例#4
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);
        }
示例#5
0
        private void AcceptMatch(jQueryEvent e)
        {
            jQueryObject button  = jQuery.FromElement(e.CurrentTarget);
            string       offerId = button.Siblings("input").GetValue();

            jQueryObject parentRow = button.Parents(".offer");

            parentRow.Attribute("disabled", "disabled").AddClass("ui-state-disabled");

            jQuery.Post("/services/AcceptOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(new JsonObject("id", offerId)), (AjaxRequestCallback <object>) delegate(object data, string textStatus, jQueryXmlHttpRequest <object> request)
            {
                parentRow.Attribute("disabled", "").RemoveClass("ui-state-disabled");
                button.Parent().Children("a").FadeOut(EffectDuration.Slow);
                button.Parent().Children(".pending").FadeIn(EffectDuration.Fast);

                Utility.ProcessResponse((Dictionary)data);
            });
        }
示例#6
0
        public static void InitFullHeightGridPage(jQueryObject gridDiv)
        {
            J("body")
            .AddClass("full-height-page");

            gridDiv.AddClass("responsive-height");

            jQueryEventHandler layout = delegate
            {
                bool inPageContent = gridDiv.Parent().HasClass("page-content") ||
                                     gridDiv.Parent().Is("section.content");

                if (inPageContent)
                {
                    gridDiv.CSS("height", "1px")
                    .CSS("overflow", "hidden");
                }

                Q.LayoutFillHeight(gridDiv);

                if (inPageContent)
                {
                    gridDiv.CSS("overflow", "");
                }

                gridDiv.TriggerHandler("layout");
            };

            if (J("body").HasClass("has-layout-event"))
            {
                J("body").Bind("layout", layout);
            }
            else if (Window.Instance.As <dynamic>().Metronic != null)
            {
                Window.Instance.As <dynamic>().Metronic.addResizeHandler(layout);
            }
            else
            {
                jQuery.Window.Resize(layout);
            }

            layout(null);
        }
示例#7
0
        public static int LayoutFillHeightValue(jQueryObject element)
        {
            var h = 0; 
            element.Parent()
                .Children()
                .Not(element)
                    .Each((i, e) =>
                    {
                        var q = J(e);
                        if (q.Is(":visible"))
                            h += q.GetOuterHeight(true);
                    });

            h = element.Parent().GetHeight() - h;

            if (element.GetCSS("box-sizing") != "border-box")
                h = h - (element.GetOuterHeight(true) - element.GetHeight());

            return h;
        }
示例#8
0
 private void MakeDraggable(jQueryObject row)
 {
     row.Draggable(new DraggableOptions {
         Helper      = "clone",
         AppendTo    = row.Parent().GetElement(0),
         Scroll      = true,
         Containment = "parent",
         OnStart     = new jQueryUIEventHandler <DragStartEvent>(Delegate.ThisFix((Action <Element, jQueryEvent, DragStartEvent>)((d, evt, ui) => { jQuery.FromElement(d).AddClass(CurrentDraggingRowClass); }))),
         OnStop      = new jQueryUIEventHandler <DragStopEvent>(Delegate.ThisFix((Action <Element, jQueryEvent, DragStopEvent>)((d, evt, ui) => { jQuery.FromElement(d).RemoveClass(CurrentDraggingRowClass); })))
     });
 }
        private void LinkFn(IScope scope, jQueryObject element, dynamic attr)
        {
            var expression = (string)attr.specialNgRepeat;
            scope.Watch(expression, (cur) =>
                                    {
                                        var items = (List<object>)cur;
                                        var cloner = jQuery.FromElement(element[0]);

                                        var p = element.Parent();
                                        foreach (var item in items)
                                        {

                                            var e = angular.Element(cloner.Clone());
                                            var _scope = scope.New<dynamic>();
                                            _scope.item = item;
                                            var elk = compileService(e.Contents())(_scope);

                                            p.Append(elk);
                                             
                                        }
                                        cloner.Remove();
                                        });
        }
示例#10
0
        public string GetFetchXmlForQuery(string entityLogicalName, string queryName, string searchTerm, SearchTermOptions searchOptions)
        {
            FetchQuerySettings config;

            if (queryName == "QuickFind")
            {
                config = EntityLookup[entityLogicalName].QuickFindQuery;
            }
            else
            {
                config = EntityLookup[entityLogicalName].Views[queryName];
            }
            jQueryObject fetchElement = config.FetchXml.Clone().Find("fetch");

            fetchElement.Attribute("distinct", "true");
            fetchElement.Attribute("no-lock", "true");

            jQueryObject orderByElement = fetchElement.Find("order");

            orderByElement.Remove();

            // Add the search string and adjust any lookup columns
            jQueryObject conditions = fetchElement.Find("filter[isquickfindfields='1']");

            conditions.First().Children().Each(delegate(int index, Element element)
            {
                // Is this a lookup column?
                string logicalName = element.GetAttribute("attribute").ToString();
                if (LookupAttributes.ContainsKey(logicalName))
                {
                    element.SetAttribute("attribute", logicalName + "name");
                }
            });

            //See what field types can we use for query and remove those attributes we cannot query using this search term.
            if (Number.IsNaN(Int32.Parse(searchTerm)))
            {
                fetchElement.Find("condition[value='#QueryInt#']").Remove();
            }
            if (Number.IsNaN(Decimal.Parse(searchTerm)))
            {
                fetchElement.Find("condition[value='#QueryCurrency#']").Remove();
            }
            if (Number.IsNaN(Date.Parse(searchTerm).GetDate()))
            {
                fetchElement.Find("condition[value='#QueryDateTime#']").Remove();
            }
            if (Number.IsNaN(Double.Parse(searchTerm)))
            {
                fetchElement.Find("condition[value='#QueryFloat#']").Remove();
            }
            // Add the sort order placeholder
            string fetchXml = fetchElement.Parent().GetHtml();//.Replace("</entity>", "{3}</entity>");

            //Prepare search term based on options
            string textSearchTerm = searchTerm;

            if (searchOptions != null && (searchOptions & SearchTermOptions.PrefixWildcard) == SearchTermOptions.PrefixWildcard)
            {
                //Trimming, in case there are already wildcards with user input
                while (textSearchTerm.StartsWith("*") || textSearchTerm.StartsWith("%"))
                {
                    textSearchTerm = textSearchTerm.Substring(1, textSearchTerm.Length);
                }
                textSearchTerm = "%" + textSearchTerm;
            }
            if (searchOptions != null && (searchOptions & SearchTermOptions.SuffixWildcard) == SearchTermOptions.SuffixWildcard)
            {
                //Trimming, in case there are already wildcards
                while (textSearchTerm.EndsWith("*") || textSearchTerm.EndsWith("%"))
                {
                    textSearchTerm = textSearchTerm.Substring(0, textSearchTerm.Length - 1);
                }
                textSearchTerm = textSearchTerm + "%";
            }

            // Add the Query term
            fetchXml = fetchXml.Replace("#Query#", XmlHelper.Encode(textSearchTerm))
                       .Replace("#QueryInt#", Int32.Parse(searchTerm).ToString())
                       .Replace("#QueryCurrency#", Double.Parse(searchTerm).ToString())
                       .Replace("#QueryDateTime#", XmlHelper.Encode(Date.Parse(searchTerm).Format("MM/dd/yyyy")))
                       .Replace("#QueryFloat#", Double.Parse(searchTerm).ToString());

            return(fetchXml);
        }
示例#11
0
        private static void Arrange(jQueryObject element)
        {
#if DEBUG
            if (!element.Is("." + CssClassNameAdvancedLayout))
            {
                throw new Exception("Element not marked for advanced layout.");
            }
#endif
            // does element have its al state parsed?
            AdvancedLayoutState elementState = (AdvancedLayoutState)element.GetDataValue(DataNameLayoutState);
            if (elementState == null)
            {
                element.Data(DataNameLayoutState, elementState = ParseAdvancedLayout(element));
            }

            // grab parents
            jQueryObject parent = element.Parent();
            jQueryObject offsetParent = element.OffsetParent();
            if (offsetParent.Length == 0 || parent.Length == 0)
            {
                return;
            }

            bool parentIsOffsetParent = offsetParent[0] == parent[0];
#if DEBUG
            if (!parentIsOffsetParent && element.Is(":visible"))
            {
                throw new Exception("Parent must use position:absolute|fixed|relative;.");
            }
#endif
            if (!parentIsOffsetParent)
            {
                return;
            }

            // gather parent padding and client dimensions
            DimensionsAndPadding parentDimensions = null;
            parentDimensions = GetDimensionsAndPadding(parent);

            // detect parent's coordinates in offset-parent frame.
            float contentStartInOffsetSpaceX, contentStartInOffsetSpaceY;
            {
                if (parentIsOffsetParent)
                { // parent is offset parent. we know our local frame.
                    contentStartInOffsetSpaceX = 0;
                    contentStartInOffsetSpaceY = 0;
                }
                else
                { // experimental support for staticly positioned parent.

                    parent.Prepend(_frameDetector);

                    jQueryPosition parentContentFrameInDocumentSpace = _frameDetector.GetOffset();
                    jQueryPosition offsetParentFrameInDocumentSpace = offsetParent.GetOffset();
                    if (parentContentFrameInDocumentSpace != null && offsetParentFrameInDocumentSpace != null)
                    {
                        contentStartInOffsetSpaceX = parentContentFrameInDocumentSpace.Left - offsetParentFrameInDocumentSpace.Left - parentDimensions.PaddingLeft;
                        contentStartInOffsetSpaceY = parentContentFrameInDocumentSpace.Top - offsetParentFrameInDocumentSpace.Top - parentDimensions.PaddingTop;
                    }
                    else
                    {
                        jQueryPosition contentStartInOffsetSpace = _frameDetector.Position();
                        if (contentStartInOffsetSpace != null)
                        {
                            contentStartInOffsetSpaceX = contentStartInOffsetSpace.Left - parentDimensions.PaddingLeft;
                            contentStartInOffsetSpaceY = contentStartInOffsetSpace.Top - parentDimensions.PaddingTop;
                        }
                        else
                        {
                            contentStartInOffsetSpaceX = 0;
                            contentStartInOffsetSpaceY = 0;
                        }
                    }

                    _frameDetector.Remove();
                }

            }

            double topBoundary = contentStartInOffsetSpaceY + parentDimensions.PaddingTop + elementState.Margin.Top;
            double bottomBoundary = contentStartInOffsetSpaceY + parentDimensions.ClientHeight - parentDimensions.PaddingBottom - elementState.Margin.Bottom;
            double leftBoundary = contentStartInOffsetSpaceX + parentDimensions.PaddingLeft + elementState.Margin.Left;
            double rightBoundary = contentStartInOffsetSpaceX + parentDimensions.ClientWidth - parentDimensions.PaddingRight - elementState.Margin.Right;


            // determine where to position
            int top = 0;
            int left = 0;
            int width = 0;
            int height = 0;
            switch (elementState.VerticalAlignment)
            {
                case VerticalAlignment.Top:
                    height = Math.Round(elementState.Height - elementState.Padding.Top - elementState.Padding.Bottom);
                    top = Math.Round(topBoundary);
                    break;

                case VerticalAlignment.Center:
                    height = Math.Round(elementState.Height - elementState.Padding.Top - elementState.Padding.Bottom);
                    top = Math.Round(topBoundary * 0.5 + bottomBoundary * 0.5 - height * 0.5);
                    break;

                case VerticalAlignment.Bottom:
                    height = Math.Round(elementState.Height - elementState.Padding.Top - elementState.Padding.Bottom);
                    top = Math.Round(contentStartInOffsetSpaceY + parentDimensions.ClientHeight - parentDimensions.PaddingBottom - elementState.Margin.Bottom - elementState.Height);
                    break;

                case VerticalAlignment.Stretch:
                    height = Math.Round(bottomBoundary - topBoundary - elementState.Padding.Top - elementState.Padding.Bottom);
                    top = Math.Round(topBoundary);
                    break;

            }
            switch (elementState.HorizontalAlignment)
            {
                case HorizontalAlignment.Left:
                    width = Math.Round(elementState.Width - elementState.Padding.Left - elementState.Padding.Right);
                    left = Math.Round(leftBoundary);
                    break;

                case HorizontalAlignment.Center:
                    width = Math.Round(elementState.Width - elementState.Padding.Left - elementState.Padding.Right);
                    left = Math.Round(leftBoundary * 0.5 + rightBoundary * 0.5 - width * 0.5);
                    break;

                case HorizontalAlignment.Right:
                    width = Math.Round(elementState.Width - elementState.Padding.Left - elementState.Padding.Right);
                    left = Math.Round(contentStartInOffsetSpaceX + parentDimensions.ClientWidth - parentDimensions.PaddingRight - elementState.Margin.Right - elementState.Width);
                    break;

                case HorizontalAlignment.Stretch:
                    width = Math.Round(rightBoundary - leftBoundary - elementState.Padding.Left - elementState.Padding.Right);
                    left = Math.Round(leftBoundary);
                    break;
            }

            if (width <= 0)
            {
                width = 0;
            }
            if (height <= 0)
            {
                height = 0;
            }

            element.CSS(
                new Dictionary(
                    "position", "absolute",
                    "top", top,
                    "left", left,
                    "width", width,
                    "height", height,
                    "padding-top", elementState.Padding.Top,
                    "padding-right", elementState.Padding.Right,
                    "padding-bottom", elementState.Padding.Bottom,
                    "padding-left", elementState.Padding.Left
                )
            );
        }