-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtabs.php
212 lines (173 loc) · 6.92 KB
/
tabs.php
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
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Theme tester tool
*
* @package tool_themetester
* @copyright 2012 Simon Coggins
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir . '/adminlib.php');
$strheading = 'Theme Tester: Tab bars';
$url = new moodle_url('/admin/tool/themetester/tabs.php');
// Start setting up the page.
$params = array();
$PAGE->set_context(context_system::instance());
$PAGE->set_url($url);
$PAGE->set_title($strheading);
$PAGE->set_heading($strheading);
admin_externalpage_setup('toolthemetester');
echo $OUTPUT->header();
echo html_writer::link(new moodle_url('index.php'), '« Back to index');
echo $OUTPUT->heading($strheading);
echo $OUTPUT->box_start();
echo $OUTPUT->container_start();
$tabs = array();
$row = array();
$inactive = array();
$activated = array();
echo $OUTPUT->box('Standard, single row tab bar');
$url = new moodle_url('index.php');
$row[] = new tabobject('tab1',
$url->out(),
'Selected Tab',
'This is the hover text for tab1'
);
$row[] = new tabobject('tab2',
$url->out(),
'Another tab',
'This is the hover text for tab2'
);
$row[] = new tabobject('tab3',
$url->out(),
'Yet Another tab',
'This is the hover text for tab3'
);
$row[] = new tabobject('tab4',
$url->out(),
'More tabs',
'This is the hover text for tab4'
);
$row[] = new tabobject('tab5',
$url->out(),
'Even more tabs',
'This is the hover text for tab5'
);
$currenttab = 'tab1';
$tabs[] = $row;
print_tabs($tabs, $currenttab, $inactive, $activated);
$loremipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eu accumsan nulla. Cras elementum tincidunt dictum. Phasellus varius, est non ornare mattis, leo velit congue libero, vitae suscipit ipsum urna sed orci. Pellentesque venenatis pulvinar lobortis. Vestibulum iaculis commodo eros quis volutpat. Morbi vitae dapibus ante. Nullam convallis interdum ipsum, venenatis consequat eros faucibus sed. Pellentesque non tellus vel eros ullamcorper sollicitudin ut in lectus. Sed aliquet gravida porta';
echo html_writer::tag('div', 'This is a div tag directly under the tab bar. Make sure the padding is correct. ' . $loremipsum);
echo $OUTPUT->box('Same as above, but with a couple of disabled tabs');
print_tabs($tabs, $currenttab, array('tab4', 'tab5'), $activated);
echo $OUTPUT->box('Same as above, but with a couple of extra activated tabs');
print_tabs($tabs, $currenttab, $inactive, array('tab4', 'tab5'));
echo $OUTPUT->box('You can set a flag on the tab object to keep the active tab as a link, though this doesn\'t affect additional selected tabs, just the current tab.');
$row = array();
$url = new moodle_url('index.php');
$row[] = new tabobject('tab1',
$url->out(),
'Selected Tab',
'This is the hover text for tab1',
true
);
$row[] = new tabobject('tab2',
$url->out(),
'Another tab',
'This is the hover text for tab2',
true
);
$row[] = new tabobject('tab3',
$url->out(),
'Yet Another tab',
'This is the hover text for tab3',
true
);
$row[] = new tabobject('tab4',
$url->out(),
'Activated tab',
'This is the hover text for tab4',
true
);
$row[] = new tabobject('tab5',
$url->out(),
'Another activated tab',
'This is the hover text for tab5',
true
);
$tabs2 = array($row);
print_tabs($tabs2, $currenttab, $inactive, array('tab4', 'tab5'));
echo $OUTPUT->box('Extra rows can be used to hold further subcategories.');
$row1 = array(
new tabobject('row1a', $url->out(), 'Activated Row 1 Tab A'),
new tabobject('row1b', $url->out(), 'Row 1 Tab B'),
new tabobject('row1c', $url->out(), 'Disabled Row 1 Tab C'),
);
$row2 = array(
new tabobject('row2a', $url->out(), 'Row 2 Tab A'),
new tabobject('row2b', $url->out(), 'Selected Row 2 Tab B'),
new tabobject('row2c', $url->out(), 'Row 2 Tab C'),
);
$tabs = array();
$tabs[] = $row1;
$tabs[] = $row2;
$currenttab = 'row2b';
$inactive = array('row1c');
$activated = array('row1a');
print_tabs($tabs, $currenttab, $inactive, $activated);
echo $OUTPUT->box('Extra rows can be used to hold further subcategories. You can nest as many levels of tabs as you like but for Totara please stick to a maximum of two levels, any more will be confusing anyway. Note that while each row is specified independently in the code, the HTML that is rendered nests the list items hierarchically, so the activated tabs on each row contains the list items for the level below.');
$row1 = array(
new tabobject('row1a', $url->out(), 'Activated Row 1 Tab A'),
new tabobject('row1b', $url->out(), 'Row 1 Tab B'),
new tabobject('row1c', $url->out(), 'Disabled Row 1 Tab C'),
);
$row2 = array(
new tabobject('row2a', $url->out(), 'Row 2 Tab A'),
new tabobject('row2b', $url->out(), 'Selected Row 2 Tab B'),
new tabobject('row2c', $url->out(), 'Row 2 Tab C'),
);
$tabs = array();
$tabs[] = $row1;
$tabs[] = $row2;
$currenttab = 'row2b';
$inactive = array('row1c');
$activated = array('row1a');
print_tabs($tabs, $currenttab, $inactive, $activated);
echo html_writer::tag('div', 'This is a div tag directly under a two row tab bar. Make sure the padding is correct. ' . $loremipsum);
echo $OUTPUT->box('Sometimes the tab bars can get very full, especially when translated into other languages. We need to ensure they are at least readable when the tabs are too wide for the page.');
$longtext = 'This is a really long title. This is a really long title. This is a really long title.';
$row1 = array(
new tabobject('row1a', $url->out(), 'Row 1 Tab A. ' . $longtext),
new tabobject('row1b', $url->out(), 'Row 1 Tab B. ' . $longtext),
new tabobject('row1c', $url->out(), 'Row 1 Tab C. ' . $longtext),
);
$row2 = array(
new tabobject('row2a', $url->out(), 'Row 2 Tab A. ' . $longtext),
new tabobject('row2b', $url->out(), 'Row 2 Tab B. ' . $longtext),
new tabobject('row2c', $url->out(), 'Row 2 Tab C. ' . $longtext),
);
$tabs = array();
$tabs[] = $row1;
$tabs[] = $row2;
$currenttab = 'row2b';
$inactive = array('row1c');
$activated = array('row1a');
print_tabs($tabs, $currenttab, $inactive, $activated);
echo html_writer::tag('div', 'This is a div tag directly under an overflowing two row tab bar. Make sure the padding is correct. ' . $loremipsum);
echo $OUTPUT->container_end();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();