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