1 module deepmagic.dom.complex.context_menu;
2 
3 import deepmagic.dom;
4 
5 struct ContextMenuItem{
6 	string id = "";
7 	string value = "";
8 }
9 
10 struct ContextMenuDatastructure{
11 	ContextMenuItem[] items = null;
12 }
13 
14 class ContextMenuWidget : DivElement{
15 	ContextMenuDatastructure datastructure;
16 
17 	this(ContextMenuDatastructure datastructure){
18 		super();
19 		this ~= new Sass("tile-config");
20 		this ~= new Sass("dropdown");
21 		this.datastructure = datastructure;
22 		this ~= new MenuAnchor();
23 		this ~= new DropdownList(this.datastructure.items);
24 	}
25 
26 	class MenuAnchor : AElement{
27 		this(){
28 			super();
29 			this ~= new Sass("tile-menu");
30 			this.tag.attr["data-toggle"] = "dropdown";
31 			this.Href("");
32 			this ~= new Text("");
33 		}
34 	}
35 
36 	class DropdownList : UlElement{
37 		this(ContextMenuItem[] items){
38 			super();
39 			this ~= new Sass("dropdown-menu");
40 			this ~= new Sass("animated");
41 			this ~= new Sass("pull-right");
42 			this ~= new Sass("text-right");
43 			foreach(int i, ContextMenuItem item; items){
44 				this ~= new ListItem(item);
45 			}
46 		}
47 
48 		class ListItem : LiElement{
49 			this(ContextMenuItem item){
50 				super();
51 				this.Id = item.id;
52 				this ~= new ListAnchor(item);
53 			}
54 
55 			class ListAnchor : AElement{
56 				this(ContextMenuItem item){
57 					super();
58 					this.Href("");
59 					this ~= new Text(item.value);
60 				}
61 			}
62 		}
63 	}
64 }