Esempio n. 1
0
		public static NavItem NavItem(string value, string text, jQueryEventHandler handler, bool disable, string iconClassName)
		{
			var i = new HtmlListItem ().As<NavItem>();
			i.SetAttribute ("value", value);

			if (disable)
				jQuery.FromElement (i).AddClass ("disabled");

			i.Handler = handler;

			i._icon = new CssIcon (iconClassName);
			i._anchor = new Anchor ();

			jQuery.FromElement (i._anchor).Append (i._icon);
			i._anchor.Text = text??value;

			jQuery.FromElement (i).Append (i._anchor);


			SetToAtomProperty (i, "get_text", (Func<string>)(() => i._anchor.Text));
			SetToAtomProperty (i, "set_text", (Action<string>)((v) => i._anchor.Text=v));

			SetToAtomProperty (i, "get_value", (Func<string>)(() => i.GetAttribute ("value").ToString () ?? "" ));
			SetToAtomProperty (i, "set_value", (Action<string>)((v) => i.SetAttribute ("value", v) ));

			SetToAtomProperty (i, "get_iconClass", (Func<string>)(() => i._icon.ClassName));
			SetToAtomProperty (i, "set_iconClass", (Action<string>)((v) => i._icon.ClassName = v));

			SetToAtomProperty (i, "is_disabled", (Func<bool>)(() =>
			             jQuery.FromElement (i).HasClass ("disabled")));

			SetToAtomProperty (i, "disable",(Action<bool>)((d) =>{
				if(d)jQuery.FromElement (i).AddClass ("disabled");
				else jQuery.FromElement (i).RemoveClass ("disabled");
			}));

			i.Clicked += ev=>{
				if( i.Disabled ) return;
				var h = i.Handler;
				if (h!=null) h(ev);
			};

			return i;

		}