Exemple #1
0
        public virtual IDictionary <string, object> ToJson()
        {
            var options = new Dictionary <string, object>(Events);

            if (Filter.HasValue())
            {
                options["filter"] = SanitizeSelector(Filter);
            }

            if (Disabled.HasValue())
            {
                options["disabled"] = SanitizeSelector(Disabled);
            }

            if (Handler.HasValue())
            {
                options["handler"] = SanitizeSelector(Handler);
            }

            if (ContainerSelector.HasValue())
            {
                options["container"] = SanitizeSelector(ContainerSelector);
            }

            if (ConnectWith.HasValue())
            {
                options["connectWith"] = SanitizeSelector(ConnectWith);
            }

            if (HoldToDrag)
            {
                options["holdToDrag"] = true;
            }

            if (Axis != SortableAxis.None)
            {
                options["axis"] = Enum.GetName(typeof(SortableAxis), Axis).ToLowerInvariant();
            }

            if (Cursor.HasValue())
            {
                options["cursor"] = SanitizeSelector(Cursor);
            }

            if (CursorOffset.Left != int.MinValue || CursorOffset.Top != int.MinValue)
            {
                var topLeft = new Dictionary <string, int>();

                if (CursorOffset.Top != int.MinValue)
                {
                    topLeft.Add("top", CursorOffset.Top);
                }

                if (CursorOffset.Left != int.MinValue)
                {
                    topLeft.Add("left", CursorOffset.Left);
                }

                options.Add("cursorOffset", topLeft);
            }

            if (HintHandler.HasValue())
            {
                options["hint"] = HintHandler;
            }
            else if (Hint.HasValue())
            {
                options["hint"] = Hint;
            }

            if (PlaceholderHandler.HasValue())
            {
                options["placeholder"] = PlaceholderHandler;
            }
            else if (Placeholder.HasValue())
            {
                options["placeholder"] = Placeholder;
            }

            return(options);
        }