-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.app
1285 lines (1136 loc) · 39.4 KB
/
lib.app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module elib/elib-bootstrap/lib
imports elib/elib-bootstrap/icons
section default attribute sets
override attributes submit{ class="btn btn-default" }
attributes btnSuccess { class= "btn btn-success" }
attributes btnWarn{ class= "btn btn-warning" }
attributes btnDanger{ class= "btn btn-danger" }
attributes btnPrimary { class= "btn btn-primary" }
override attributes inputInt{ class="inputInt form-control" }
override attributes inputString{ class="inputString form-control" }
override attributes inputEmail{ class="inputEmail form-control" }
override attributes inputSecret{ class="inputSecret form-control" }
override attributes inputURL{ class="inputURL form-control " }
override attributes inputText{ class="inputTextarea inputText form-control" }
override attributes inputWikiText{ class="inputTextarea inputWikiText form-control" }
override attributes inputFloat{ class="inputFloat form-control" }
override attributes inputLong{ class="inputLong form-control" }
override attributes inputDate{ class="inputDate form-control" }
override attributes inputSelect{ class="select form-control" }
override attributes inputSelectMultiple{ class="select form-control" }
override attributes inputFile{ class="inputFile form-control" }
override attributes inputMultiFile{ class="inputFile form-control" }
override attributes inputSDF{ class="inputSDF form-control" }
section tooltips
// TODO: Migrate to Bootstrap 4
template tooltipsBS(){
postProcess("$(node).find('[title]').tooltip({placement: 'auto top', container: 'body'}); $('.tooltip.fade.in, .ui-tooltip-content').remove();")
}
section positioning
/** Pulls the content to the right. */
template pullRight() {
span[class="float-right", all attributes]{ elements }
}
/** Pulls the content to the left. */
template pullLeft() {
span[class="float-left", all attributes]{ elements }
}
section grid system
/** A grid container. */
template gridContainer() {
div[class="container", all attributes]{ elements }
}
/** A full-width grid container. */
template gridContainerFluid() {
div[class="container-fluid", all attributes]{ elements }
}
/** A grid row consisting of a single column. */
template gridRowCol(){
gridRowCol(12)[all attributes]{ elements }
}
/** A grid row consisting of a single column of the specified span. */
template gridRowCol(colSpan: Int){
gridRow[all attributes]{ gridCol(colSpan){ elements } }
}
/** A grid row. */
template gridRow(){
div[class="row", all attributes]{ elements }
}
/** A grid row with the specified class added. */
template gridRow(cls: String){
div[class="row " + cls, all attributes]{ elements }
}
/** Grid column spanning the specified number of columns on small viewports and bigger. */
template gridCol(colSpan: Int){
gridColSm(colSpan)[all attributes]{ elements }
}
/** Grid column spanning the specified number of columns starting at the specified offset on small viewports and bigger. */
template gridCol(colSpan: Int, offset: Int){
gridColSm(colSpan, offset)[all attributes]{ elements }
}
/** A grid column that spans the specified number of columns on small and large viewports respectively. */
template gridColAdapt(colSpanSm: Int, colSpanLg: Int){
div[class="col-sm-" + colSpanSm + " col-lg-" + colSpanLg , all attributes]{ elements }
}
/** A grid column that spans the specified number of columns on small and large viewports respectively,
offset by the specified number of columns on small and large viewports respectively. */
template gridColAdapt(colSpanSm: Int, offsetSm: Int, colSpanLg: Int, offsetLg: Int){
div[class="col-sm-" + colSpanSm + " col-lg-" + colSpanLg + " col-sm-offset-" + offsetSm + " col-lg-offset-" + offsetLg , all attributes]{ elements }
}
// NOTE: gridColPush() and gridColPull() have been removed. Use gridColOrder() instead.
/** Grid column for small viewports and bigger, spanning the specified number of columns,
using the specified order. */
template gridColOrder(colSpan: Int, order: Int){
div[class="col-sm-" + colSpan + " order-" + order, all attributes]{ elements }
}
/** Grid column for small viewports and bigger, spanning the specified number of columns,
ordering before all other columns. */
template gridColOrderFirst(colSpan: Int){
div[class="col-sm-" + colSpan + " order-first", all attributes]{ elements }
}
/** Grid column for small viewports and bigger, spanning the specified number of columns,
ordering after all other columns. */
template gridColOrderLast(colSpan: Int){
div[class="col-sm-" + colSpan + " order-last", all attributes]{ elements }
}
/** Grid column spanning the specified number of columns on all viewports. */
template gridColXs(colSpan: Int){
div[class="col-" + colSpan, all attributes]{ elements }
}
/** Grid column spanning the specified number of columns starting at the specified offset on all viewports. */
template gridColXs(colSpan: Int, offset: Int){
div[class="col-" + colSpan + " col-offset-" + offset , all attributes]{ elements }
}
/** Grid column spanning the specified number of columns on small viewports and bigger. */
template gridColSm(colSpan: Int){
div[class="col-sm-" + colSpan, all attributes]{ elements }
}
/** Grid column spanning the specified number of columns starting at the specified offset on small viewports and bigger. */
template gridColSm(colSpan: Int, offset: Int){
div[class="col-sm-" + colSpan + " col-sm-offset-" + offset, all attributes]{ elements }
}
/** Grid column spanning the specified number of columns on medium viewports and bigger. */
template gridColMd(colSpan: Int){
div[class="col-md-" + colSpan , all attributes]{ elements }
}
/** Grid column spanning the specified number of columns starting at the specified offset on medium viewports and bigger. */
template gridColMd(colSpan: Int, offset: Int){
div[class="col-md-" + colSpan + " col-md-offset-" + offset , all attributes]{ elements }
}
/** Grid column spanning the specified number of columns on large viewports and bigger. */
template gridColLg(colSpan: Int){
div[class="col-lg-" + colSpan , all attributes]{ elements }
}
/** Grid column spanning the specified number of columns starting at the specified offset on large viewports and bigger. */
template gridColLg(colSpan: Int, offset: Int){
div[class="col-lg-" + colSpan + " col-lg-offset-" + offset , all attributes]{ elements }
}
/** Grid column spanning the specified number of columns on extra large viewports and bigger. */
template gridColXl(colSpan: Int){
div[class="col-xl-" + colSpan , all attributes]{ elements }
}
/** Grid column spanning the specified number of columns starting at the specified offset on extra large viewports and bigger. */
template gridColXl(colSpan: Int, offset: Int){
div[class="col-xl-" + colSpan + " col-xl-offset-" + offset , all attributes]{ elements }
}
section footer
/** A footer. */
template footer() {
<footer class="footer" all attributes>
elements
</footer>
}
section navigation bar
/** Name of the application, to be overridden. */
template appname() { "<default>" }
template navbar() {
div[class="navbar navbar-inverse navbar-fixed-top", all attributes]{
gridContainer{
elements
}
}
}
template navbarResponsive(){
navbarResponsive(true)[all attributes]{ elements }
}
template navbarResponsive(fixed : Bool) {
div[class=if(fixed)"navbar navbar-inverse navbar-fixed-top" else "navbar navbar-inverse navbar-static-top", all attributes]{
gridContainer{
div[class="navbar-header"]{
navbarBrand
navCollapseButton
}
div[class="navbar-collapse collapse", style="height: 0px;"]{
elements
}
}
}
}
template navbarFluid() {
div[class="navbar navbar-inverse navbar-fixed-top", all attributes]{
div[class="navbar-inner"]{
gridContainer{
elements
}
}
}
}
template navbarStatic() {
div[class="navbar", all attributes]{
div[class="navbar-inner"]{
gridContainer{
elements
}
}
}
}
template navCollapse() {
div[class="nav-collapse"]{
elements
}
}
template navbarRight() {
div[class="navbar-right"]{
elements
}
}
template navItems() {
list[class="nav navbar-nav"]{
elements
}
}
template navItem() {
listitem{ elements }
}
template navCollapseButton() {
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
}
template brand() { navbarBrand() } // deprecated
/** Add a brand to the navbar. Use in a navbar() template. */
template navbarBrand() {
navigate root() [class="navbar-brand", all attributes]{ appname }
}
/** Add navigation items (navbarNavLinkItem()) to the navbar. Use in a navbar() template. */
template navbarNav() {
div[class="navbar-nav", all attributes]{ elements }
}
/** Adds a nav item link to a navbar. Use in the navbarNav() template. */
template navbarNavLinkItem(nav: String) {
navbarNavLinkItem(nav, false, false)[all attributes]{ elements }
}
/** Adds a nav item link to a navbar. Use in the navbarNav() template. */
template navbarNavLinkItem(nav: String, active: Bool, disabled: Bool) {
<a href=nav class="nav-item nav-link " + activeClass(active) + " " + disabledClass(disabled) if (disabled) { tabindex="-1" aria-disabled="true" } all attributes>elements</a>
}
/** Adds a dropdown button to a navbar. Use in the navbarNav() template. */
template navbarNavDropdownItem(title: String) {
dropdown[class="nav-item"]{
dropdownToggleLink(id, "nav-link") { output(title) }
dropdownMenu(id) {
elements
}
}
}
/** Adds a list of navigation items (navbarNavListItem()) to the navbar. Use in a navbar() template. */
template navbarNavList() {
list[class="navbar-nav", all attributes]{ elements }
}
/** Adds a nav list item to a navbar. Use in the navbarNavList() template. */
template navbarNavListItem() {
listitem[class="nav-item", all attributes]{ elements }
}
/** Adds a nav link to a navbar. Use in the navbarNavListItem() template. */
template navbarNavLink(nav: String, active: Bool, disabled: Bool) {
<a href=nav class="nav-link " + activeClass(active) + " " + disabledClass(disabled) if (disabled) { tabindex="-1" aria-disabled="true" } all attributes>elements</a>
}
section sections
template pageHeader() {
div[class="page-header", all attributes]{
header1{ elements }
}
}
template pageHeader2() {
div[class="page-header", all attributes]{
header2{ elements }
}
}
template pageHeader3() {
div[class="page-header", all attributes]{
header3{ elements }
}
}
template pageHeader4() {
div[class="page-header", all attributes]{
header4{ elements }
}
}
template small() {
<small all attributes>elements</small>
}
section tables
template tableBordered(){
table[class="table table-bordered table-striped table-condensed", all attributes]{
elements
}
}
template tableStriped(){
table[class="table table-striped table-condensed", all attributes]{
elements
}
}
template tableHovered(){
table[class="table table-hover", all attributes]{
elements
}
}
template theader() {
<thead all attributes>elements</thead>
}
template tbody() {
<tbody all attributes>elements</thead>
}
template tfooter() {
<tfoot all attributes>elements</tfoot>
}
template th(){
<th all attributes>elements</th>
}
section forms
// template span() { <span all attributes>elements</span> }
template inlForm() {
span[class="form-inline", role="form", all attributes]{
form[class="bla"]{
elements
}
}
}
template formEntry(l: String){
<label all attributes>output(l)</label> elements
}
template formEntry(l: String, help: String){
<label all attributes>output(l)</label>
elements
<span class="help-inline">output(help)</span>
}
template formActions(){
// div[class="form-group"]{
// div[class="col-sm-offset-2 col-sm-10"]{
// elements
// }
// }
formActions(2, 10)[all attributes]{ elements }
}
template formActions(labelOff: Int, elemCol: Int){
div[class="form-group", all attributes]{
div[class="col-sm-offset-" + labelOff + " col-sm-" + elemCol]{
elements
}
}
}
template formSearch(query: Ref<String>) {
form[class="form-search", all attributes]{
input(query)[class="input-medium search-query", placeholder="Search"]
elements
}
}
template navbarSearch(query: Ref<String>) {
form[class="navbar-search pull-left", all attributes]{
input(query)[class="search-query", placeholder="Search"]
elements
}
}
section horizontal forms
template horizontalForm(){
form[class="form-horizontal", role="form", all attributes] {
elements
}
}
template horizontalForm(title: String){
horizontalForm[all attributes]{
fieldset(title){
elements
}
}
}
template controlGroup(s: String){
controlGroup(s, 2, 10)[all attributes]{ elements }
}
template controlGroup(s: String, labelCol: Int, elemCol: Int){
div[class="row form-group ", all attributes]{
label(s)[class="control-label col-sm-" + labelCol]{
div[class="col-sm-" + elemCol]{
elements
}
}
}
}
template checkboxGroup( label : String ){
checkboxGroup(label, 2, 10)[all attributes]{ elements }
}
template checkboxGroup( label : String, labelCol: Int, elemCol: Int ){
div[class="checkbox", all attributes]{
<label class="col-sm-" + elemCol + " col-sm-offset-" + labelCol>
elements output(label)
</label>
}
}
template helpBlock(){
<span class="help-block" all attributes> elements </span>
}
template inputAppend() {
inputGroup[all attributes]{ elements }
}
template inputPrepend() {
inputGroup[all attributes]{ elements }
}
template inputPrependAppend() {
inputGroup[all attributes]{ elements }
}
template inputGroup() {
<span class="input-group" all attributes>
elements
</span>
}
template inputGroupButton(){
<span class="input-group-btn" all attributes> elements </span>
}
section breadcrumbs
template breadcrumbs(){
<ul class="breadcrumb" all attributes> elements </ul>
}
template breadcrumb() {
<li all attributes> elements </li>
}
template breadcrumbActive() {
<li class="active" all attributes> elements </li>
}
section pagers
template pager() {
<ul class="pager" all attributes>
elements
</ul>
}
template pagerPrevious(nav: String){
<li all attributes>navigate url(nav) { "Previous" }</li>
}
template pagerNext(nav: String){
<li all attributes>navigate url(nav) { "Next" }</li>
}
section buttons
template buttonToolbar() {
div[class="btn-toolbar", role="toolbar", all attributes]{
elements
}
}
template buttonGroup(){
div[class="btn-group", all attributes]{
elements
}
}
template buttonGroupSpan(){
span[class="btn-group", all attributes]{
elements
}
}
template buttonGroupVertical(){
div[class="btn-group btn-group-vertical", all attributes]{
elements
}
}
template buttonNavigate(nav: String) {
//navigate url(nav) [class="btn btn-default"]{ elements }
<a href=nav class="btn btn-default" all attributes>elements</a>
}
template button() {
div[class="btn btn-default", all attributes]{ elements }
}
template buttonMini(){
div[class="btn btn-default btn-xs", all attributes]{ elements }
}
template buttonSmall(){
div[class="btn btn-default btn-sm", all attributes]{ elements }
}
template buttonPrimary() {
div[class="btn btn-primary ", all attributes]{ elements }
}
template buttonPrimaryMini(){
div[class="btn btn-primary btn-xs", all attributes]{ elements }
}
template buttonPrimarySmall(){
div[class="btn btn-primary btn-sm", all attributes]{ elements }
}
section dropdowns
/** A dropdown link. The class is used to style the toggle,
the elements are put in the menu. */
template dropdownLink(title: String) {
dropdown() {
dropdownToggleLink(id, attribute("class")){ output(title) }
dropdownMenu(id){ elements }
}
}
/** A dropdown button. The class is used to style the toggle,
the elements are put in the menu. */
template dropdownButton(title: String) {
buttonGroup() {
dropdownToggleButton(id, attribute("class")){ output(title) }
dropdownMenu(id){ elements }
}
}
/** A split dropdown button. The class is used to style the button and toggle,
the elements are put in the menu. */
template dropdownSplitButton(title: String) {
buttonGroup() {
<button class="btn "+attribute("class")>output(title)</button>
dropdownToggleButton(attribute("class") + " dropdown-toggle-split"){ <span class="sr-only">"Toggle Dropdown"</span> }
dropdownMenu(id){ elements }
}
}
/** A dropdown menu. Use dropdownLinkMenu() or dropdownButtonMenu() for the content. */
template dropdown() {
div[class="dropdown", all attributes]{ elements }
}
/** A dropdown link with the specified title. Use inside dropdown() to toggle the dropdown and provide the menu. */
template dropdownLinkMenu(title: String) {
buttonGroup{
dropdownToggleLink(id, attribute("class")){ output(title) }
dropdownMenu(id){ elements }
}
}
/** A dropdown button with the specified title. Use inside dropdown() to toggle the dropdown and provide the menu. */
template dropdownButtonMenu(title: String) {
buttonGroup{
dropdownToggleButton(id, attribute("class")){ output(title) }
dropdownMenu(id){ elements }
}
}
/** A toggle link for a dropdown menu. Use inside dropdown() to toggle the dropdown. */
template dropdownToggleLink(idAttr: String){
dropdownToggleLink(idAttr, ""){ elements }
}
/** A toggle link for a dropdown menu, with the specified class. Use inside dropdown() to toggle the dropdown. */
template dropdownToggleLink(idAttr: String, cls: String){
// TODO: Support id for aria-labelledby
<a class="dropdown-toggle "+cls href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" id=idAttr>
elements
</a>
}
/** A toggle button for a dropdown menu. Use inside dropdown() to toggle the dropdown. */
template dropdownToggleButton(idAttr: String){
dropdownToggleButton(idAttr, ""){ elements }
}
/** A toggle button for a dropdown menu, with the specified class. Use inside dropdown() to toggle the dropdown. */
template dropdownToggleButton(idAttr: String, cls: String){
<button class="btn dropdown-toggle "+cls href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" id=idAttr>
elements
</button>
}
/** A dropdown menu. Use inside dropdown() to provide the menu. */
template dropdownMenu(idAttr: String){
div[class="dropdown-menu", aria-labelledby=idAttr, all attributes]{
elements
}
}
/** A dropdown menu floating right. Use inside dropdown() to provide the menu. */
template dropdownMenuRight(idAttr: String){
div[class="dropdown-menu float-right", aria-labelledby=idAttr, all attributes]{
elements
}
}
/** A link item in a dropdown menu. */
template dropdownMenuLinkItem(nav: String) {
dropdownMenuLinkItem(nav, false, false)[all attributes]{ elements }
}
/** A link item in a dropdown menu. */
template dropdownMenuLinkItem(nav: String, active: Bool, disabled: Bool) {
<a href=nav class="dropdown-item " + activeClass(active) + " " + disabledClass(disabled) if (disabled) { tabindex="-1" aria-disabled="true" } all attributes>elements</a>
}
/** A text item in a dropdown menu. */
template dropdownMenuTextItem() {
<span class="dropdown-item-text" all attributes>elements</span>
}
/** A header item in a dropdown menu. */
template dropdownMenuHeaderItem() {
<h6 class="dropdown-header" all attributes>elements</h6>
}
/** A divider item in a dropdown menu. */
template dropdownMenuDividerItem() {
<div class="dropdown-divider" all attributes></div>
}
template subMenu() {
dropdownMenuDividerItem
elements
}
// NOTE: dropdownToggle() has been renamed to dropdownToggleLink().
template dropdownToggle(idAttr: String) { dropdownToggleLink(idAttr) } // deprecated
// NOTE: dropdownMenuDivider() has been renamed to dropdownMenuDividerItem()
template dropdownMenuDivider() { dropdownMenuDividerItem() } // deprecated
// NOTE: dropdownButton() has been renamed to dropdownLinkMenu()
template dropdownButton(title: String) { dropdownLinkMenu(title) } // deprecated
// NOTE: dropdownMenuItem() has been removed. Use dropdownMenu*Item() or <p> or <form>.
template dropdownMenuItem() { dropdownMenuTextItem() } // deprecated
// NOTE: dropdownInNavbar() has been renamed to navbarNavDropdownItem()
template dropdownInNavbar(title: String) { navbarNavDropdownItem(title) } // deprecated
// NOTE: dropdownCaret() has been removed
template dropdownCaret() { } // deprecated
section miscellaneous
template well(){
div[class="well", all attributes]{ elements }
}
template wellSmall(){
div[class="well well-sm", all attributes]{ elements }
}
template wellLarge(){
div[class="well well-lg", all attributes]{ elements }
}
template blockquote() {
<blockquote all attributes> elements </blockquote>
}
section tabs
template tabsBSElem(elems: [tabId: String, tabLabelElem : TemplateElements, content: TemplateElements] ){
tabsBS{
if(elems.length > 8){
navbarNavDropdownItem("Items (" + elems.length+ ")" ){
for( e in elems ){
tabElems(e.tabId, false){
e.tabLabelElem
}
}
}
} else {
for(e in elems){
tabElems(e.tabId, false){
e.tabLabelElem
}
}
}
}
tabContent{ par{
for(e in elems){
tabPane(e.tabId){
e.content
}
}
} }
}
template tabsBSWithId(elems: [tabId: String, label : String, content: TemplateElements] ){
tabsBSElem([
for( e in elems ){
( e.tabId,
{ if(e.label == ""){ "-" } else{ output(e.label) } "" },
e.content
)
}
])
}
template tabsBS(elems: [label: String, content: TemplateElements] ){
tabsBSElem([
for( e in elems ){
( id + e.label,
{ if(e.label == ""){ "-" } else{ output(e.label) } "" },
e.content
)
}
])
}
template tabsBSNoURL(){
<ul id="tab" class="nav nav-tabs" all attributes>
elements
</ul>
}
template pillsBS(){
tabsPills( "nav-pills" )[all attributes]{
elements
}
}
template tabsBS() {
tabsPills("nav-tabs")[all attributes]{
elements
}
}
template tabsPills( tabClass : String){
<ul id="tab" class="nav " + tabClass all attributes>
elements
</ul>
includeHead(rendertemplate(setHashOnTabAndOpenFirstTab))
postProcess("autoTabFunction(node);")
}
template setHashOnTabAndOpenFirstTab(){
<script>
function hashChangeFunc(){
// show active tab on hash in url
if (window.location.hash !== ''){
var hashTarget = $('a[href="' + window.location.hash + '"]');
if(hashTarget.length){
if( hashTarget.attr('data-toggle') === 'tab' ){
hashTarget.tab('show');
}
// and open parent tabs in case the target element is nested in a tab
var parentPane = hashTarget.closest( '.tab-pane' );
if(parentPane.length){
$('.nav a[href=#'+ parentPane.attr('id') +']').tab('show');
}
var parentCollapse = hashTarget.closest( '.panel-collapse:not(.in)' ).collapse('show');
}
}
return false;
}
$(document).ready(function(){
var tabFromRequestUrl = window.location.hash !== '' ? $('a[href="' + window.location.hash + '"][data-toggle="tab"]') : [];
var initUrlHash = window.location.hash;
hashChangeFunc()
if( tabFromRequestUrl.length ){
//Prevent the browser to auto-scroll to the anchor of the tab
window.location.hash = "";
}
if ($._data( $(window)[0], 'events' ).hashchange == undefined){
$(window).on('hashchange', hashChangeFunc);
}
setTimeout( function(){
if(tabFromRequestUrl.length){
history.replaceState(null, null, initUrlHash);
}
}, 10 );
});
var autoTabFunction = function(node){
// remember the hash in the URL without jumping
$('a[data-toggle="tab"]:not(.bound)').addClass('bound').on('shown.bs.tab', function(e){
var newhash = '#' + $(e.target).attr('href').substr(1);
if(history.replaceState){
history.replaceState(null, null, newhash);
} else{
location.hash = newhash;
}
});
//When no tab is active, set the first one to active
$(node).find('.nav-tabs:not(.bound), .nav-pills:not(.bound)').addClass('bound').each(function(){
if( $(this).children().length > 0 && 1 > $(this).find('.active').length){
$(this).children().first().addClass('active');
}
});
$(node).find('.tab-content:not(.bound)').addClass('bound').each(function(){
if( $(this).children().length > 0 && 1 > $(this).children('.active').length){
$(this).children('.tab-pane').first().addClass('active');
}
});
}
</script>
}
template tabActive(label: String, idAttr: String) {
tab(label, idAttr, true)[all attributes]
}
template tabActive(label: String) {
tab(label, label, true)[all attributes]
}
template tab(label: String, idAttr: String) {
tab(label, idAttr, false)[all attributes]
}
template tab(label: String, idAttr: String, active: Bool) {
var nonEmptyLabel := if(label == "") "-" else label
tabElems(idAttr, active)[all attributes]{ output(nonEmptyLabel) }
}
template tabElems(idAttr: String, active: Bool) {
<li class=activeClass(active)> <a href=hrefHashId(idAttr, true) data-toggle="tab" all attributes> elements </a> </li>
// <script> $(function () { $('~(hrefHashId(id, true))').tab('show') }) </script>
}
template tabLink(idAttr : String){
<a href="javascript:$('a[href=~hrefHashId(idAttr, true)]').click();void(0)" all attributes> elements </a>
}
function hrefHashId(s : String, includeHash : Bool) : String {
return if(includeHash) "#" + /(\W|\s)+/.replaceAll("-",s) else /(\W|\s)+/.replaceAll("-",s);
}
function activeClass(active: Bool): String {
if(active) { return "active"; } else { return ""; }
}
function disabledClass(disabled: Bool): String {
if(disabled) { return "disabled"; } else { return ""; }
}
template tabBS(label: String) {
tab(label, label)[all attributes]{ elements }
}
template tabContent(){
div[class="tab-content", all attributes]{
elements
}
}
template tabPaneActive(idAttr: String){
tabPane(idAttr, true)[all attributes] { elements }
}
template tabPane(idAttr: String){
tabPane(idAttr, false)[all attributes] { elements }
}
template tabPane(idAttr: String, active: Bool){
div[class="tab-pane " + activeClass(active), id=hrefHashId(idAttr,false), all attributes]{
elements
}
}
section labels
template labelDefault(){ labelInternal("label-default")[all attributes]{ elements } }
template labelSuccess(){ labelInternal("label-success")[all attributes]{ elements } }
template labelPrimary(){ labelInternal("label-primary")[all attributes]{ elements } }
template labelWarning(){ labelInternal("label-warning")[all attributes]{ elements } }
template labelDanger(){ labelInternal("label-danger")[all attributes]{ elements } }
template labelInfo(){ labelInternal("label-info")[all attributes]{ elements } }
template labelInternal( labelClass : String ){
<span class=labelClass + " label" all attributes> elements </span>
}
section alerts
template alert(){
div[class="alert alert-dismissible", all attributes]{
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">rawoutput("×")</span>
</button>
elements
}
}
expand
Success
Info
Warning
Error
to alert
expandtemplate alert to Type{
template alertType() {
alert[class="alert-type", all attributes]{
elements
}
}
}
/*
template tabExperiment() {
<ul id="tab" class="nav nav-tabs">
<li><a href="#home" data-toggle="tab">"Home"</a></li>
<li><a href="#profile" data-toggle="tab">"Profile"</a></li>
<li><a href="#messages" data-toggle="tab">"Messages"</a></li>
<li><a href="#settings" data-toggle="tab">"Settings"</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="home">"home content"</div>
<div class="tab-pane" id="profile">"profile content"</div>
<div class="tab-pane" id="messages">"messages content"</div>
<div class="tab-pane" id="settings">"settings content"</div>
</div>
<script>
$(function () {
$('.tabs a:last').tab('show')
$('#home').tab('show')
$('#profile').tab('show')
$('#messages').tab('show')
$('#settings').tab('show')
})
</script>
}
*/
/*
template tabDefault(label: String) {
tab(label, true){ elements }
}
template tab(label: String, checked: Bool) {
var tname := getTemplate().getUniqueId()
div[class="tab"]{
if(checked) {
<input type="radio" id=tname name="tab-group-1" checked="true"></input>
} else {
<input type="radio" id=tname name="tab-group-1"></input>
}
<label for=tname>output(label)</label>
div[class="content"]{
elements
}
}
}
*/
section panels
expandtemplate panels to Cls{
template panelCls(){
panelNoBody("panel-cls")[all attributes]{ elements }
}
template panelCls( header : String ){
panelInternal( header, "panel-cls")[all attributes]{ elements }
}
template panelClsWithHeading( headerElem : TemplateElements ){
panelNoBody("panel-cls")[all attributes]{
panelHeading { headerElem }
panelBody { elements }
}
}
}
expand
Danger
Warning
Info
Primary
Success
to panels
template panel(){
panelNoBody("panel-default")[all attributes]{
elements
}
}
template panel( header : String ){
panelInternal( header, "panel-default")[all attributes]{ elements }
}
template panelWithHeading( headerElem : TemplateElements ){
panelNoBody("panel-default")[all attributes]{
panelHeading { headerElem }
panelBody { elements }
}
}
template panelNoBody( panelClass : String ){
div[class="panel " + panelClass, all attributes]{
elements
}
}
define panelHeading(){
div[class="panel-heading clearfix", all attributes]{
div[class="panel-title"]{