Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 113 lines (97 sloc) 2.727 kb
11158ee @akoprow Adding basic demo for Sortable.
authored
1 import jQueryUI
2
76efc37 @akoprow Introducing 2-level hierarchy for demo pages.
authored
3 //type demo_page = { string name, ( -> xhtml) show }
4 //type demo = { string name, list(demo_page) pages }
733cd93 draggable added
derdiedasjojo authored
5 module Draggable {
6 demo =
7 { name: "Draggable"
8 , pages:
039ce64 update für opa 0.9.4
derdiedasjojo authored
9 [ {name: "drag" , show: on_update_demo }
733cd93 draggable added
derdiedasjojo authored
10 ]
11 }
12
13
14
15 client function on_update_demo(){
16 function mk_draggable(_) {
17 jQueryUI.Draggable.mk_draggable(#draggable)
18 //return js_void;
19 }
20
21 <div id=draggable style="background:#cccccc" onready={mk_draggable}>bla</div>
22
23 }
76efc37 @akoprow Introducing 2-level hierarchy for demo pages.
authored
24
733cd93 draggable added
derdiedasjojo authored
25 }
11158ee @akoprow Adding basic demo for Sortable.
authored
26 module Sortable {
27
76efc37 @akoprow Introducing 2-level hierarchy for demo pages.
authored
28 demo =
29 { name: "Sortable"
30 , pages:
4c9cb63 @akoprow Slightly beefing up visuals of Sortable-default demo.
authored
31 [ {name: "Default functionality", show: default_functionality }
255bdfd @ogunden Add on_update and associated demo.
ogunden authored
32 ,{name: "on_update" , show: on_update_demo }
76efc37 @akoprow Introducing 2-level hierarchy for demo pages.
authored
33 ]
34 }
35
4c9cb63 @akoprow Slightly beefing up visuals of Sortable-default demo.
authored
36 client function default_functionality() {
11158ee @akoprow Adding basic demo for Sortable.
authored
37 function mk_entry(i) {
4c9cb63 @akoprow Slightly beefing up visuals of Sortable-default demo.
authored
38 <li><div class="alert alert-info">Item #{i}</></>
11158ee @akoprow Adding basic demo for Sortable.
authored
39 }
40 function mk_sortable(_) {
41 jQueryUI.Sortable.mk_sortable(#sortable)
42 jQueryUI.Sortable.disable_selection(#sortable)
43 }
255bdfd @ogunden Add on_update and associated demo.
ogunden authored
44 <div>
45 <ul id=sortable onready={mk_sortable}>
46 {List.init(mk_entry, 7)}
47 </ul>
48 </div>
49 }
50
51 client function on_update_demo() {
52 function mk_entry(i) {
53 <li id={i}><div class="alert alert-info">Item #{i}</></>
54 }
55 function on_update() {
56 children = Dom.split(Dom.select_children(#sortable))
57 l = List.map( function(d) { Dom.get_id(d) }, children)
58 #sorting = "sorting is: " ^ String.concat(", ", l)
59 }
60 function mk_sortable(_) {
61 jQueryUI.Sortable.mk_sortable(#sortable)
62 jQueryUI.Sortable.disable_selection(#sortable)
63 jQueryUI.Sortable.on_update(#sortable, on_update)
64 }
65 <div>
66 <span id=sorting/>
67 <ul id=sortable onready={mk_sortable}>
68 {List.init(mk_entry, 7)}
69 </ul>
70 </div>
11158ee @akoprow Adding basic demo for Sortable.
authored
71 }
72
73 }
74
039ce64 update für opa 0.9.4
derdiedasjojo authored
75 demos = [Sortable.demo, Draggable.demo]
11158ee @akoprow Adding basic demo for Sortable.
authored
76
76efc37 @akoprow Introducing 2-level hierarchy for demo pages.
authored
77 function mk_demo(demo) {
78 function show_demo(gen)(_event) {
79 #demo = gen()
80 }
81 function mk_page(page) {
f5ce475 @akoprow Forgotten main file rename.
authored
82 <li><a onclick={show_demo(page.show)} data-toggle=tab>{page.name}</></>
76efc37 @akoprow Introducing 2-level hierarchy for demo pages.
authored
83 }
11158ee @akoprow Adding basic demo for Sortable.
authored
84 function show(_) {
76efc37 @akoprow Introducing 2-level hierarchy for demo pages.
authored
85 #submenu =
86 <ul class="nav nav-tabs nav-stacked">
87 {List.map(mk_page, demo.pages)}
88 </>
11158ee @akoprow Adding basic demo for Sortable.
authored
89 }
f5ce475 @akoprow Forgotten main file rename.
authored
90 <li><a onclick={show} data-toggle=tab>{demo.name}</></>
11158ee @akoprow Adding basic demo for Sortable.
authored
91 }
92
93 function page() {
94 <div class=container>
95 <div class=row>
96 <div class=span2>
f5ce475 @akoprow Forgotten main file rename.
authored
97 <ul id=menu class="nav nav-tabs nav-stacked">
11158ee @akoprow Adding basic demo for Sortable.
authored
98 {List.map(mk_demo, demos)}
99 </>
100 </>
76efc37 @akoprow Introducing 2-level hierarchy for demo pages.
authored
101 <div class=span2 id=submenu />
102 <div class=span8 id=demo />
11158ee @akoprow Adding basic demo for Sortable.
authored
103 </>
104 </>
105 }
106
107 Server.start(Server.http,
108 [ {resources: @static_resource_directory("resources")}
039ce64 update für opa 0.9.4
derdiedasjojo authored
109 , {register:{css: ["resources/bootstrap.css", "resources/style.css", "resources/bootstrap.js"]}}
11158ee @akoprow Adding basic demo for Sortable.
authored
110 , {title: "JQuery-UI in Opa", ~page}
111 ]
112 )
Something went wrong with that request. Please try again.