comparison cpack/dml/skin/framework/bootstrap.pl @ 0:718306e29690 tip

commiting public release
author Daniel Wolff
date Tue, 09 Feb 2016 21:05:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:718306e29690
1 /* Part of DML (Digital Music Laboratory)
2 Copyright 2014-2015 Samer Abdallah, University of London
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 :- module(bootstrap,
20 [ navbar//3
21 , navbar_menu//2
22 , navbar_item//1
23 ]).
24
25 /** <module> Enables use of Bootstrap CSS framework
26 */
27
28 :- use_module(library(http/html_write)).
29 :- use_module(library(http/html_head)).
30 :- use_module(library(htmlutils)).
31 :- use_module(library(dcg_core)).
32
33 :- set_prolog_flag(double_quote,string).
34
35 % http:location(bootstrap,"//maxcdn.bootstrapcdn.com/bootstrap/3.3.2",[]).
36 % http:location(bootstrap_examples,"//getbootstrap.com/examples",[]).
37
38 :- html_resource( bootstrap, [virtual(true), requires(web('css/bootstrap.min.1.css'))]).
39 :- html_resource( bootstrap_js, [virtual(true), requires(web('js/bootstrap.min.js'))]).
40 % :- html_resource( bootstrap("css/bootstrap-theme.min.css"), [requires(bootstrap)]).
41 % :- html_resource( bootstrap("css/bootstrap.min.css"), []).
42
43 % :- html_resource( bootstrap_examples("starter-template/starter-template.css"),
44 % [requires(bootstrap)]).
45 % :- html_resource( bootstrap_examples("navbar/navbar.css"),
46 % [requires(bootstrap)]).
47 % :- html_resource( bootstrap_examples("navbar-static-top/navbar-static-top.css"),
48 % [requires(bootstrap)]).
49 % :- html_resource( bootstrap_examples("navbar-fixed-top/navbar-fixed-top.css"),
50 % [requires(bootstrap)]).
51 % :- html_resource( bootstrap_examples("theme/theme.css"),
52 % [requires(bootstrap_theme)]).
53
54 % :- html_resource( bootstrap_theme, [virtual(true), requires(bootstrap("css/bootstrap-theme.min.css"))]).
55
56 % navbar_class_option('navbar-inverse').
57 % navbar_class_option('navbar-fixed-top').
58 % navbar_class_option('navbar-static-top').
59
60 % user:head(bootstrap(_,_),Head) --> !,
61 % html(head([ meta([name(viewport), content("width-device-width,initial-scale=1")])
62 % | Head ])).
63
64 % % use abstract paths here?ads
65 % user:body(bootstrap(Var,Nav),Body) --> !,
66 % html_requires(bootstrap("css/bootstrap.min.css")),
67 % bootstrap_body(Var,Nav,Body).
68
69 % bootstrap_body(1,Nav,Body) -->
70 % { setting(htmlutils:appname, AppName) },
71 % html_requires(bootstrap_examples("starter-template/starter-template.css")),
72 % html( body( div( class=container,
73 % \bootstrap_body(AppName,['navbar-static-top'],Nav,
74 % div(class="starter-template", Body))))).
75
76 % bootstrap_body(2,Nav,Body) -->
77 % { setting(htmlutils:appname, AppName) },
78 % html_requires(bootstrap_examples("navbar-fixed-top/navbar-fixed-top.css")),
79 % html(body(
80 % % div( class=container,
81 % \bootstrap_body(AppName,['navbar-default','navbar-fixed-top'],Nav,Body)
82 % % )
83 % )).
84 % % \bootstrap_body("swiPlayer",['navbar-inverse','navbar-fixed-top'],Nav,Body)))).
85
86 % bootstrap_body(3,Nav,Body) -->
87 % { setting(htmlutils:appname, AppName) },
88 % html_requires(bootstrap_examples("navbar-static-top/navbar-static-top.css")),
89 % % html_requires(bootstrap_examples("theme/theme.css")),
90 % html( body(role(document),
91 % [ \navbar(AppName,['navbar-inverse','navbar-static-top'],navbar_menu(left,Nav))
92 % , div([class=container,role=main], Body)
93 % , \script("//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js")
94 % , \script("//getbootstrap.com/dist/js/bootstrap.min.js")
95 % ])).
96
97 % bootstrap_body(AppName,NavbarClasses,Nav,Body) -->
98 % html( [ \navbar(AppName,NavbarClasses, navbar_menu(left,Nav))
99 % , div(class=container,Body)
100 % , \script("//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js")
101 % , \script("//getbootstrap.com/dist/js/bootstrap.min.js")
102 % ]).
103
104 navbar_item(link(Label,Location)) --> html(li(a([href(Location)], Label))).
105 navbar_item(divider) --> html(li(class=divider,[])).
106 navbar_item(header(Text)) --> html(li(class='dropdown-header',Text)).
107 navbar_item(menu(Label,Items)) -->
108 html(li(class(dropdown),
109 [ a([href='#', class='dropdown-toggle', 'data-toggle'=dropdown, role=button, aria-expanded=false],
110 [Label,span(class(caret1),'\u25BE')])
111 , ul([class='dropdown-menu', role=menu], \seqmap(navbar_item,Items))
112 ])).
113
114
115 button(Content,Classes) -->
116 html(button([type=button,class=[btn|Classes]], Content)).
117
118 button_link(Ref,Content) -->
119 html(a([role=button,class=[btn,'btn-default'],href=Ref],Content)).
120
121 :- meta_predicate navbar(:,+,//,?,?).
122 %% navbar( +Header:html_item, +Classes:list(html_class), +Menus:phrase(html))// is det.
123 navbar(_AppName,NavbarClasses,Menus) -->
124 html_requires(bootstrap),
125 html_requires(bootstrap_js),
126 html_requires(font_awesome),
127 html( div( [ class=[navbar | NavbarClasses], role=navigation],
128 div( class=container,
129 [ div( class='navbar-header',
130 [ \navbar_toggle
131 %, a([class='navbar-brand', href='.'], AppName)
132 ]
133 )
134 , div( class=[collapse,'navbar-collapse'], \Menus)
135 ]))).
136
137 %% navbar_menu(Just:oneof([left,right]), +Items:phrase(html))// is det.
138 navbar_menu(left,Items) --> html(ul(class=[nav,'navbar-nav'], \Items)).
139 navbar_menu(right,Items) --> html(ul(class=[nav,'navbar-nav','navbar-right'], \Items)).
140
141 navbar_toggle -->
142 html( button(
143 [ type=button
144 , class='navbar-toggle'
145 , 'data-toggle'=collapse
146 , 'data-target'='.navbar-collapse'
147 ],
148 [ span(class='sr-only',"Toggle navigation")
149 , i(class('fa fa-bars'),[]) %\rep(3,icon_bar)
150 ])).
151
152 icon_bar --> html(span(class='icon-bar',[])).
153
154 % user:style(bootstrap(1),'Bootstrap, variation 1').
155 % user:style(bootstrap(2),'Bootstrap, variation 2').
156 % user:style(bootstrap(3),'Bootstrap, variation 3').
157
158 side_nav(Items) -->
159 html(div(class='col-md-3',
160 div([ class=['bs-docs-sidebar','hidden-print','hidden-xs','hidden-sm'],
161 role=complementary ],
162 [ ul(class='nav bs-docs-sidenav', \Items)
163 , a([class='back-to-top',href='#top'],"Back to top")
164 ]))).