comparison cpack/dml/skin/framework/pure.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(pure, []).
20
21 /** <module> Enables use of Pure CSS framework
22 */
23
24 % http://yui.github.io/skinbuilder/?mode=pureindex.html?opt=swi,457387,ffffff,1,1,20,1.5&h=0,-30,60&n=0,-30,75&l=0,-30,80&b=0,-30,90&mode=pure")
25 %
26 :- use_module(library(http/http_path)).
27 :- use_module(library(http/html_write)).
28 :- use_module(library(http/html_head)).
29 :- use_module(library(http/js_write)).
30 :- use_module(library(htmlutils)).
31
32 :- set_prolog_flag(double_quotes,string).
33
34 /*
35 YUI3 over HTTPS is just not going to work.
36 Google provide YUI2, but not YUI3.
37
38 */
39 http:location(yuix,"http://yui.yahooapis.com",[]).
40 http:location(pure,yuix('pure/0.5.0'),[]).
41 http:location(purecss,"//purecss.io/combo/1.16.5?",[]).
42
43 :- html_resource(purecss("css/layouts/side-menu.css"), [requires(pure("pure.min.css"))]).
44 :- html_resource(css("pure/pure-skin.css"), [requires(pure("pure-min.css"))]).
45
46 user:head(pure(_,_),Head) --> !,
47 html(head([ \style("//yui.yahooapis.com/pure/0.5.0/pure-min.css")
48 , \style("//yui.yahooapis.com/pure/0.5.0/grids-responsive-min.css")
49 , \style("/css/pure/pure-skin.css")
50 , meta([name(viewport), content("width-device-width,initial-scale=1")])
51 | Head ])).
52
53 activate_dropdowns(DivId,ULId) -->
54 {http_absolute_location(yuix('combo?'),ComboBase,[])},
55 html_requires(yuix('3.17.2/build/yui/yui-min.js')),
56 js_script({|javascript(ComboBase,DivId,ULId)||
57 YUI({ classNamePrefix: 'pure', combine: true, comboBase: ComboBase
58 }).use('gallery-sm-menu', function (Y) {
59 var horizontalMenu = new Y.Menu({
60 container : "#"+DivId,
61 sourceNode : "#"+ULId,
62 orientation : 'horizontal',
63 hideOnOutsideClick: false,
64 hideOnClick : false,
65 showdelay : 125,
66 });
67 horizontalMenu.render();
68 horizontalMenu.show();
69 });|}
70 ).
71
72 user:body(pure(1,Nav),Body) --> !,
73 { setting(htmlutils:appname, AppName) },
74 html(body([ div([id("layout"),class("pure-g")]
75 , [ div(class("pure-u-1-4"), \vmenu(AppName,Nav))
76 , div(class("content pure-u-3-4"), [
77 div(class(content),Body)
78 , div(class(footer),\hmenu(AppName,Nav))
79 ])
80 ])
81 ])).
82
83 user:body(pure(2,Nav),Body) --> !,
84 { setting(htmlutils:appname, AppName) },
85
86 use_font("Source Sans Pro",sourcepro),
87 % use_font("Open Sans",opensans),
88 % use_font("Quattrocento Sans",quattrocento),
89 % html_requires(purecss("css/main-grid.css&/css/main.css&/css/menus.css&/css/rainbow/baby-blue.css")),
90 html_requires(purecss("css/layouts/side-menu.css")),
91 html(body(div(id(layout),
92 [ a([href="#menu", id="menuLink", class="menu-link"],span([]))
93 , div(id(menu),\vmenu(AppName,Nav))
94 , div(id(main),
95 [ div(class(header), h1("Header"))
96 , div(class(content), [div(Body),div(class=footer,\hmenu(AppName,Nav))])
97 ])
98 , \script(purecss("js/ui.js"))
99 ]))).
100
101 button_link(Ref,Content) -->
102 html(a([class(['pure-button','pure-button-primary']),href(Ref)],Content)).
103
104 menu(Classes,Content) -->
105 html(div(class(['pure-menu', 'pure-menu-open'|Classes]), Content)).
106 % Add pure-menu-selected to active item
107 hmenu(Heading,Items) -->
108 menu(['pure-menu-horizontal'], [a([href='.',class="pure-menu-heading"],Heading), \Items]).
109
110 vmenu(Heading,Items) -->
111 menu([], [a([href='.',class="pure-menu-heading"],Heading), \Items]).
112
113 hmenu_with_dropdowns(Items) -->
114 % html_requires("//yui.yahooapis.com/3.17.2/build/yui/yui-min.js"),
115 html_requires(css("pure/pure-skin.css")),
116 {gensym(div,DivID), gensym(ul,ULID)},
117 html(div(id=DivID,ul(id=ULID,\Items))),
118 activate_dropdowns(DivID,ULID).