| author | Tomas Zeman <tomas@functionals.cz> |
| Tue, 24 Nov 2020 11:17:26 +0100 | |
| changeset 31 | 5c4364d6e726 |
| parent 12 | e7512f9dc903 |
| permissions | -rw-r--r-- |
|
31
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
1 |
/* |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
2 |
* Copyright 2018-2020 Tomas Zeman <tomas@functionals.cz> |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
3 |
* |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
5 |
* you may not use this file except in compliance with the License. |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
6 |
* You may obtain a copy of the License at |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
7 |
* |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
9 |
* |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
13 |
* See the License for the specific language governing permissions and |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
14 |
* limitations under the License. |
|
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
15 |
*/ |
| 5 | 16 |
package sqwl.cms.layout |
17 |
||
| 6 | 18 |
import scalatags.Text.TypedTag |
| 5 | 19 |
import scalatags.Text.all._ |
|
12
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
20 |
import sqwl.cms._ |
| 5 | 21 |
|
22 |
object Navbar extends config {
|
|
23 |
||
24 |
def apply(cnt: iContent, st: ViewState): TypedTag[String] = {
|
|
25 |
||
|
12
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
26 |
def activeCls(c: iCategory): String = {
|
|
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
27 |
st match {
|
|
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
28 |
case ViewCategory(v) if v == c => "active" |
|
31
5c4364d6e726
SQWL#2003 Studie -> Projekt
Tomas Zeman <tomas@functionals.cz>
parents:
12
diff
changeset
|
29 |
case ViewArticle(v) if v.category contains c => "active" |
|
12
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
30 |
case _ => "" |
|
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
31 |
} |
|
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
32 |
} |
|
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
33 |
|
| 5 | 34 |
val navSections = ul(cls:="nav navbar-nav navbar-section", width:="100%", |
35 |
cnt.categories map(c => |
|
|
12
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
36 |
li(cls:=s"text-center ${activeCls(c)}",
|
|
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
37 |
a(href:=s"/${http.prefix}/${c.pathSegment}", c.name))
|
| 5 | 38 |
) |
39 |
) |
|
40 |
||
| 6 | 41 |
header(cls:="navbar navbar-default navbar-fixed-top", |
| 5 | 42 |
div(cls:="navbar-inner", |
43 |
div(cls:="container", |
|
44 |
div(cls:="navbar-header", |
|
| 6 | 45 |
button(`type`:="button", cls:="navbar-toggle collapsed", |
46 |
attr("data-toggle"):="collapse",
|
|
| 5 | 47 |
attr("data-target"):="#navbar1",
|
48 |
span(cls:="sr-only", "Navigation"), |
|
49 |
span(cls:="icon-bar"), |
|
50 |
span(cls:="icon-bar"), |
|
51 |
span(cls:="icon-bar") |
|
52 |
), |
|
|
12
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
53 |
a(href:=s"/${http.prefix}", cls:="navbar-brand",
|
|
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
54 |
paddingTop:=4, paddingBottom:=4, |
| 7 | 55 |
img(src:=s"/${http.prefix}/public/${cnt.icon._1}",
|
56 |
alt:=cnt.appTitleShort, width:=40, height:=40)), |
|
|
12
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
57 |
a(href:=s"/${http.prefix}", cls:="navbar-brand visible-xs",
|
| 7 | 58 |
span(cnt.appTitleShort)), |
|
12
e7512f9dc903
Layout: categories, articles, primary view
Tomas Zeman <tzeman@volny.cz>
parents:
8
diff
changeset
|
59 |
a(href:=s"/${http.prefix}", cls:="navbar-brand hidden-xs",
|
| 7 | 60 |
span(cnt.appTitle)) |
| 6 | 61 |
) |
62 |
//tag("nav")(cls:="hidden-xs", navMenu)
|
|
| 5 | 63 |
) |
64 |
), |
|
| 6 | 65 |
div(cls:="collapse navbar-collapse", id:="navbar1", |
66 |
div(cls:="container", navSections)) |
|
| 5 | 67 |
) |
68 |
} |
|
69 |
||
70 |
} |
|
| 6 | 71 |