forked from giterlizzi/dokuwiki-template-bootstrap3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
149 lines (101 loc) · 3.52 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
/*!
* 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';
if (typeof JSINFO.bootstrap3 === 'undefined') {
JSINFO.bootstrap3 = {};
}
function dw_mode(id) {
return ((JSINFO.bootstrap3.mode === id) ? true : false);
}
function dw_admin(page) {
return ((JSINFO.bootstrap3.admin === page) ? true : false);
}
function mediaSize(media) {
return jQuery(['#screen__mode .visible-', media, '-block'].join('')).is(':visible');
}
jQuery(window).resize(function() {
jQuery(document).trigger('bootstrap3:mobile-layout');
jQuery(document).trigger('bootstrap3:collapse-sections');
jQuery(document).trigger('bootstrap3:toc-resize');
});
// 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 $button = jQuery(this),
$containers = jQuery('body > div, header nav > div, article, footer > div');
if (jQuery('body > div.container').length) {
$containers
.removeClass('container')
.addClass('container-fluid');
$button.parent().addClass('active');
DokuCookie.setValue('fluidContainer', 1);
} else {
$containers
.removeClass('container-fluid')
.addClass('container');
$button.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:buttons');
jQuery(document).trigger('bootstrap3:tabs');
jQuery(document).trigger('bootstrap3:media-manager');
jQuery(document).trigger('bootstrap3:alerts')
});
}
// Admin mode
if (dw_mode('admin')) {
jQuery(document).trigger('bootstrap3:mode-admin');
}
// Search mode
if (dw_mode('search')) {
jQuery(document).trigger('bootstrap3:mode-search');
}
// Index mode
if (dw_mode('index')) {
jQuery(document).trigger('bootstrap3:mode-index');
jQuery(document).ajaxSuccess(function() {
jQuery(document).trigger('bootstrap3:mode-index');
});
jQuery('#index__tree').click(function(e) {
jQuery(document).trigger('bootstrap3:mode-index');
});
}
});