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