Beispiel #1
0
        static void ShouldSupportTypeWhenSourcePropertyTypeIsObjectAnd_Target_Is_HTML_Element(Assert assert)
        {
            var source = new A();
            var target = new jQuery(Document.CreateElement("input"));

            target.Attr("type", "hidden");

            var bindingInfo = new HTMLBindingInfo
            {
                BindingMode = BindingMode.TwoWay,
                SourcePath  = nameof(source.ObjectProperty),
                Source      = source,
                Target      = target,
                TargetPath  = "value"
            };

            bindingInfo.Connect();

            var value = 56;

            source.ObjectProperty = value;

            assert.AreEqual("56", target.Val());

            target.Val("76");

            target.Trigger(EventType.Change);

            assert.AreEqual(typeof(int).FullName, source.ObjectProperty.GetType().FullName);

            assert.AreEqual("76", source.ObjectProperty.ToString());
        }
        static private void OnClickMainMenu(MouseEvent e)
        {
            e.PreventDefault();
            jQuery target    = new jQuery(e.Target);
            string popupName = target.Attr("data-popup");

            PopupManager.Instance.OpenPopupBelow(popupName, (HTMLElement)target.Get(0));
        }
Beispiel #3
0
        public PageManager(jQuery page)
        {
            Element = page;

            if (page.HasClass("page") == false || page.Attr("data-pageid") == "")
            {
                throw new System.Exception($"Given element is not an actual page");
            }

            if (page.Length > 1)
            {
                throw new System.Exception($"Too many pages selected at once, is pageid repeated across pages?");
            }
        }
Beispiel #4
0
        public void RefreshTabHeader(jQuery tabElement)
        {
            jQuery pages  = tabElement.Children(".page");
            jQuery header = tabElement.Children("header");

            header.Remove("a");
            pages.Each((pid, page) =>
            {
                var jpage = new jQuery(page);
                header.Append($"<a href='' data-pageid='{jpage.Attr("data-pageid")}'>{jpage.Attr("data-page-title")}</a>");
            });

            jQuery active = tabElement.Children(".page.active");

            if (active.Length == 0)
            {
                active = pages.First();
            }
            ShowTab(tabElement, active);
        }
        internal static bool TargetCanUpdateSource(jQuery element)
        {
            if (element.Get(0).TagName == "INPUT")
            {
                var type = element.Attr("type");
                if (type == null)
                {
                    return(false);
                }

                type = type.ToUpperCase();

                if (type == "HIDDEN" ||
                    type == "TEXT" ||
                    type == "TEXTAREA")
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #6
0
        public static jQuery SetClass(this jQuery query, string newClassName)
        {
            query.Attr("class", newClassName);

            return(query);
        }
Beispiel #7
0
        /// <summary>
        /// Add the ui column player container
        /// </summary>
        /// <param name="playerObject"></param>
        public static void AddPlayerContainer(Player playerObject, int playerCount)
        {
            // Get main container
            var scoreboard = jQuery.Select("#" + DiceView.PlayerContainerId);

            // Max 6 item per real row
            var rowIndex = Convert.ToInt32(playerObject.Index / (DiceView.PlayerSlots / DiceView.MinColSizeLg));

            var playerRow = scoreboard.Find(string.Format("[PlayerRowAttribute={0}]", rowIndex));

            if (playerRow.Length <= 0)
            {
                playerRow = new jQuery("<div>")
                            .AddClass("row low-pad")
                            .Attr("PlayerRowAttribute", rowIndex);
                scoreboard.Append(playerRow);

                // correct row heights
                scoreboard.Find("[PlayerRowAttribute]")
                .RemoveClass("fill-height-" + rowIndex)
                .AddClass("fill-height-" + (rowIndex + 1));
            }

            // This is the column
            var playerContainer = new jQuery("<div>");

            playerContainer.Attr(DiceView.PlayerColumnAttribute, playerObject.Index)
            .AddClass("fill-height");
            // Panel with title and scoreboard
            var playerPanel = new jQuery("<div>");

            playerPanel
            .AddClass("panel panel-default low-pad")
            .Attr(DiceView.PlayerPanelAttribute, playerObject.Index)
            .Append(new jQuery("<div>").AddClass("panel-heading low-pad")
                    // Adding title
                    .Append(new jQuery("<h3>").AddClass("panel-title")
                            .Attr("id", DiceView.PlayerPanelTitleBaseId + playerObject.Index)
                            .Append(new jQuery("<span>").AddClass("player-name").Text(playerObject.Name))
                            .Append(new jQuery("<span>").AddClass("glyphicon glyphicon-edit pull-right player-icon")
                                    .On("click", null, playerObject.Index.ToString(), (Action <jQueryEvent>)Ui.ShowRename))))
            // Adding body (scoreboard)
            .Append(new jQuery("<div>").AddClass("panel-body low-pad")
                    .Append(new jQuery("<ul>").AddClass("list-group")
                            .Attr(DiceView.PlayerScoreBoardAttribute, playerObject.Index)))
            // Total in footer
            .Append(new jQuery("<div>").AddClass("panel-footer low-pad")
                    .Append(new jQuery("<h5>")
                            .AddClass("")
                            .Attr(DiceView.PlayerPanelFooterAttribute, playerObject.Index)
                            .Text("Total: 0")));
            // Adding to containers
            playerContainer.Append(playerPanel);
            playerRow.Append(playerContainer);
            // Force wrapping on a new line
            //if ((playerObject.Index + 1) % (DiceView.PlayerSlots / DiceView.MinColSizeLg) == 0)
            //{
            //    scoreboard.Append(new jQuery("<div>").AddClass("clearfix visible-lg-block"));
            //}
            // Break into logical rows on small devices
            if ((playerObject.Index + 1) % (DiceView.PlayerSlots / DiceView.MinColSizeMd) == 0)
            {
                playerRow.Append(new jQuery("<div>").AddClass("clearfix visible-md-block"));
            }
            if ((playerObject.Index + 1) % (DiceView.PlayerSlots / DiceView.MinColSizeSm) == 0)
            {
                playerRow.Append(new jQuery("<div>").AddClass("clearfix visible-sm-block"));
            }
            if ((playerObject.Index + 1) % (DiceView.PlayerSlots / DiceView.MinColSizeXs) == 0)
            {
                playerRow.Append(new jQuery("<div>").AddClass("clearfix visible-xs-block"));
            }
            // update columns classes
            Ui.SetColumnClass(playerCount);
        }
Beispiel #8
0
 public void ShowTab(jQuery tab, jQuery page)
 {
     CloseTabs(tab);
     page.AddClass("active");
     tab.Children("header").Children($"a[data-pageid='{page.Attr("data-pageid")}']").AddClass("active");
 }