forked from giterlizzi/dokuwiki-template-bootstrap3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
198 lines (136 loc) · 5.79 KB
/
script.js
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
/*!
* DokuWiki Bootstrap3 Template: Hacks!
*
* Home http://dokuwiki.org/template:bootstrap3
* Author Giuseppe Di Terlizzi <[email protected]>
* License GPL 2 (http://www.gnu.org/licenses/gpl.html)
*/
jQuery(document).ready(function() {
//'use strict';
// Icons for DokuWiki Actions
var icons = [
// Mode Selector Icon
['denied', 'h1', 'fa fa-fw fa-ban text-danger'],
['show.notFound', 'h1', 'fa fa-fw fa-warning text-warning'],
['login', 'h1', 'fa fa-fw fa-sign-in text-muted'],
['register', 'h1', 'fa fa-fw fa-user-plus text-muted'],
['search', 'h1', 'fa fa-fw fa-search text-muted'],
['index', 'h1', 'fa fa-fw fa-sitemap text-muted'],
['recent', 'h1', 'fa fa-fw fa-list-alt text-muted'],
['media', 'h1', 'fa fa-fw fa-picture-o text-muted'],
['admin', 'h1', 'fa fa-fw fa-cogs text-muted'],
['profile', 'h1', 'fa fa-fw fa-user text-muted'],
['revisions', 'h1', 'fa fa-fw fa-clock-o text-muted'],
['backlink', 'h1', 'fa fa-fw fa-link text-muted'],
['diff', 'h1', 'fa fa-fw fa-list-alt text-muted'],
['preview', 'h1', 'fa fa-fw fa-eye text-muted'],
['conflict', 'h1', 'fa fa-fw fa-warning text-warning'],
['subscribe', 'h1', 'fa fa-fw fa-envelope text-warning'],
['unsubscribe', 'h1', 'fa fa-fw fa-envelope text-warning'],
['draft', 'h1', 'fa fa-fw fa-pencil-square-o text-muted'],
['showtag', 'h1', 'fa fa-fw fa-tags text-muted'],
['locked', 'h1', 'fa fa-fw fa-lock text-warning']
];
function dw_mode(id) {
return ((jQuery('.mode_' + id).length) ? true : false);
}
function checkSize() {
var $screen_mode = jQuery('#screen__mode'), // Responsive Check
$dw_aside = jQuery('.dw__sidebar'); // Sidebar (left and/or right) node
if ($screen_mode.find('.visible-xs').is(':visible')) {
$dw_aside.find('.content').addClass('panel panel-default');
$dw_aside.find('.toogle').addClass('panel-heading');
$dw_aside.find('.collapse').addClass('panel-body').removeClass('in');
} else {
$dw_aside.find('.content').removeClass('panel panel-default');
$dw_aside.find('.collapse').removeClass('panel-body').addClass('in');
}
}
function resizeToc() {
jQuery('#dw__toc .panel-body').css({
'height' : (jQuery(window).height() - 50 - jQuery('#dokuwiki__content').position().top) + 'px',
'overflow-y': 'scroll'
});
}
checkSize();
jQuery(window).resize(checkSize);
// Replace ALL input[type=submit|reset|button] (with no events) to button[type=submit|reset|button] for CSS styling
jQuery.fn.extend({
input2button: function() {
return this.each(function() {
var attrs = { 'type' : 'button' },
label = '',
node = jQuery(this);
if (typeof node.data('events') === 'undefined' && node.prop('tagName') == 'INPUT') {
jQuery(node[0].attributes).each(function(index, attribute) {
if (attribute.name == 'value') {
label = attribute.value;
} else {
attrs[attribute.name] = attribute.value;
}
});
var newNode = jQuery('<button/>', attrs).html(label);
node.replaceWith(newNode);
}
});
}
});
jQuery('.fluid-container').on('click', function() {
var $self = jQuery(this);
if (jQuery('#dokuwiki__site').hasClass('container')) {
jQuery('#dokuwiki__site, nav > div, article').removeClass('container').addClass('container-fluid');
$self.parent().addClass('active');
DokuCookie.setValue('fluidContainer', 1);
} else {
jQuery('#dokuwiki__site, nav > div, article').removeClass('container-fluid').addClass('container');
$self.parent().removeClass('active');
DokuCookie.setValue('fluidContainer', 0);
}
});
/* DOKUWIKI:include js/template.js */
// Init template
jQuery(document).trigger('bootstrap3:init');
// Init other components
jQuery(document).trigger('bootstrap3:components');
/* DOKUWIKI:include js/plugins.js */
// Init plugins
jQuery(document).trigger('bootstrap3:plugins');
// Re-initialize some components in media-manager
if (dw_mode('media') || jQuery('#media__manager')) {
jQuery(document).ajaxSuccess(function() {
jQuery(document).trigger('bootstrap3:init');
jQuery(document).trigger('bootstrap3:tabs');
});
}
// Index tree
if (dw_mode('index')) {
jQuery(document).ajaxSuccess(function() {
jQuery(document).trigger('bootstrap3:mode-index');
});
jQuery('#index__tree').click(function(e) {
jQuery(document).trigger('bootstrap3:mode-index');
});
}
// Configuration manager
if (dw_mode('admin')) {
var tpl_sections = {
// Section Insert before Icon
'Themes' : ['bootstrapTheme', 'fa-tint'],
'Sidebar' : ['sidebarPosition', 'fa-columns'],
'Navbar' : ['inverseNavbar', 'fa-navicon'],
'Semantic' : ['semantic', 'fa-share-alt'],
'Layout' : ['fluidContainer', 'fa-desktop'],
'Discussion' : ['showDiscussion', 'fa-comments'],
'Cookie Law' : ['showCookieLawBanner', 'fa-legal'],
'Others' : ['showPageInfo', 'fa-gears']
};
jQuery('label[for^=config___tpl____bootstrap3]').each(function() {
var $node = jQuery(this);
jQuery.each(tpl_sections, function(section, item){
if( $node.attr('for').match([item[0], '$'].join('')) ) {
$node.parents('tr').before(jQuery(['<tr><td><h4><i class="fa ', item[1], '"></i> ', section, '</h4></td><td></td></tr>'].join('')))
}
});
});
}
});