예제 #1
0
		void renderItemToHtmlNow(HtmlItem item, bool insertAtTop)
		{
			DOMElement newNode = Document.CreateElement("span");
			newNode.InnerHTML = ((HtmlItem)item).ToHtml();

			DOMElement messageList = isStreamRoom ? Parent.StreamList : MesssagesElement;

			if (messageList.HasChildNodes() && insertAtTop)
				messageList.InsertBefore(newNode, messageList.ChildNodes[0]);
			else
				messageList.AppendChild(newNode);

			((HtmlItem)item).InitialiseElements();
		}
예제 #2
0
		public Popup(Controller controller, string title, Room room, HtmlItem[] items)
		{
			Title = title;
			RoomGuid = room.Guid;
			Removed = false;
			RoomGuidForClickAction = room.Guid;
			//RoomGuidForClickAction = item.GetRoomGuidForChatClickAction();


			#region //Holder
			Holder = (DivElement)Document.CreateElement("div");
			Holder.ClassName = "ChatClientPopup";
			Holder.Style.Width = PopupArea.PopupWidth.ToString() + "px";
			Holder.Style.Height = PopupArea.PopupHeight.ToString() + "px";
			
			#region //HeaderDiv
			DOMElement header = (DOMElement)Document.CreateElement("div");
			header.ClassName = "ChatClientPopupHeader";
			header.Style.Overflow = "hidden";

			{
				#region //Close button
				DivElement div = (DivElement)Document.CreateElement("div");
				div.ClassName = "ChatClientPopupCloseLinkHolder";

				{
					AnchorElement link = (AnchorElement)Document.CreateElement("a");
					link.InnerHTML = "Close";
					link.Href = "";
					DomEvent.AddHandler(link, "click", new DomEventHandler(closeButtonClick));
					div.AppendChild(link);
				}
				header.AppendChild(div);
				#endregion
			}

			{
				#region //TitleDiv
				DivElement div = (DivElement)Document.CreateElement("div");
				div.ClassName = "ChatClientPopupTitle";
				div.InnerHTML = Title;
				header.AppendChild(div);
				#endregion
			}

			Holder.AppendChild(header);
			
			#endregion

			#region //ItemsDiv
			{
				if (items != null)
				{
					ItemsList = (DivElement)Document.CreateElement("div");
					ItemsList.ClassName = "ChatClientPopupItemsList";

					DomEvent.AddHandler(ItemsList, "click", new DomEventHandler(holderClick));
					DomEvent.AddHandler(ItemsList, "mouseover", new DomEventHandler(holderMouseOver));
					DomEvent.AddHandler(ItemsList, "mouseout", new DomEventHandler(holderMouseOut));

					bool hasMultipleRelevantItems = false;
					for (int i = 0; i < items.Length; i++)
					{
						HtmlItem item = (HtmlItem)items[i];

						#region // if the item is posted by the current user, we never want to show a popup
						if (item is IHasPostingUsr)
						{
							if (((IHasPostingUsr)item).PostingUsrK == controller.UsrK)
								continue;
						}
						#endregion

						if (HasRelevantItems)
						{
							hasMultipleRelevantItems = true;
							break;
						}

						HasRelevantItems = true;
					}
					if (HasRelevantItems)
					{
						for (int i = 0; i < items.Length; i++)
						{
							HtmlItem item = (HtmlItem)items[i];

							#region // if the item is posted by the current user, we never want to show a popup
							if (item is IHasPostingUsr)
							{
								if (((IHasPostingUsr)item).PostingUsrK == controller.UsrK)
									continue;
							}
							#endregion

							if (!hasMultipleRelevantItems)
								RoomGuidForClickAction = item.GetRoomGuidForChatClickAction();

							#region //bodge it so it displays correctly - remember to save all things we change
							int previousInstance = item.Instance;
							bool previousNewStatus = false;
							if (item is Newable)
							{
								previousNewStatus = ((Newable)item).IsInNewSection;
								((Newable)item).IsInNewSection = false;
							}
							item.Instance = 2;

							bool previousShowChatButton = false;
							if (!hasMultipleRelevantItems && item is Message) // we only hide the chat button if there's only one item shown. for multi-item popups we want to leave the chat buttons as they were.
							{
								previousShowChatButton = ((Message)item).ShowChatButton;
								((Message)item).ShowChatButton = false;
							}
							#endregion

							DOMElement itemNode = Document.CreateElement("span");
							itemNode.InnerHTML = item.ToHtml();

							if (ItemsList.HasChildNodes())
								ItemsList.InsertBefore(itemNode, ItemsList.ChildNodes[0]);
							else
								ItemsList.AppendChild(itemNode);

							#region //restore all the things we bodged

							item.Instance = previousInstance;

							if (item is Newable)
								((Newable)item).IsInNewSection = previousNewStatus;
							
							if (!hasMultipleRelevantItems && item is Message) // we only hide the chat button if there's only one item shown. for multi-item popups we want to leave the chat buttons as they were.
								((Message)item).ShowChatButton = previousShowChatButton;

							#endregion

						}
						Holder.AppendChild(ItemsList);
					}
				}
			}
			#endregion

			#endregion

			Id = Math.Random().ToString();
			jHolder = JQueryAPI.JQuery(Holder);
		}
예제 #3
0
		public bool AddItem(Item item, Dictionary itemTracker)
		{
			if (Guest && !item.FromGuestRefresh)
				return false;

			if (!Guest && !Pinned)
				return false;

			LatestItem = item.Guid;

			if (item is HtmlItem)
			{
				latestHtmlItem = (HtmlItem)item;

				if (!isStreamRoom)
				{
					if (item is Newable)
						needsNewStatusUpdate = true;

					if (item.ServerRequestIndex > 0)
					{
						if (item is Newable)
							((Newable)item).IsInNewSection = true;
					}
				}
				else
				{
					if (item is Newable)
						((Newable)item).IsInNewSection = false;
				}


				if (!onlyRenderItemsWhenSelected)
				{
					renderItemToHtmlNow((HtmlItem)item, true);
				}

				if (itemTracker != null)
				{
					if (itemTracker[Guid] == null)
						itemTracker[Guid] = new Array();

					HtmlItem[] roomTracker = (HtmlItem[])itemTracker[Guid];
					roomTracker[roomTracker.Length] = (HtmlItem)item;
				}

				if (hideMoreInfoOnNextReceivedItem && MoreInfoVisible)
					HideMoreInfo(false);
			}
			else if (item is TopPhoto)
			{
				hasTopPhoto = true;
				topPhoto = (TopPhoto)item;
				updateUI();
			}

			Items[Items.Length] = item;

			return true;
		}