1 |
87dbc3bf
|
Benjamin Luce
|
(function ($, Drupal) {
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
"use strict";
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
Drupal.behaviors.bootstrapSettingSummaries = {
|
10 |
|
|
attach: function (context) {
|
11 |
|
|
var $context = $(context);
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
$context.find('#edit-components').drupalSetSummary(function () {
|
15 |
|
|
var summary = [];
|
16 |
|
|
|
17 |
|
|
var breadcrumb = parseInt($context.find('select[name="bootstrap_breadcrumb"]').val(), 10);
|
18 |
|
|
if (breadcrumb) {
|
19 |
|
|
summary.push(Drupal.t('Breadcrumbs'));
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
var navbar = 'Navbar: ' + $context.find('select[name="bootstrap_navbar_position"] :selected').text();
|
23 |
|
|
if ($context.find('input[name="bootstrap_navbar_inverse"]').is(':checked')) {
|
24 |
|
|
navbar += ' (' + Drupal.t('Inverse') + ')';
|
25 |
|
|
}
|
26 |
|
|
summary.push(navbar);
|
27 |
|
|
return summary.join(', ');
|
28 |
|
|
});
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
$context.find('#edit-javascript').drupalSetSummary(function () {
|
32 |
|
|
var summary = [];
|
33 |
|
|
if ($context.find('input[name="bootstrap_anchors_fix"]').is(':checked')) {
|
34 |
|
|
summary.push(Drupal.t('Anchors'));
|
35 |
|
|
}
|
36 |
|
|
if ($context.find('input[name="bootstrap_popover_enabled"]').is(':checked')) {
|
37 |
|
|
summary.push(Drupal.t('Popovers'));
|
38 |
|
|
}
|
39 |
|
|
if ($context.find('input[name="bootstrap_tooltip_enabled"]').is(':checked')) {
|
40 |
|
|
summary.push(Drupal.t('Tooltips'));
|
41 |
|
|
}
|
42 |
|
|
return summary.join(', ');
|
43 |
|
|
});
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
$context.find('#edit-advanced').drupalSetSummary(function () {
|
47 |
|
|
var summary = [];
|
48 |
|
|
|
49 |
|
|
var bootstrapCDN = $context.find('select[name="bootstrap_cdn"]').val();
|
50 |
|
|
if (bootstrapCDN.length) {
|
51 |
|
|
bootstrapCDN = 'BootstrapCDN v' + bootstrapCDN;
|
52 |
|
|
|
53 |
|
|
if ($context.find('select[name="bootstrap_bootswatch"]').val().length) {
|
54 |
|
|
bootstrapCDN += ' (' + $context.find('select[name="bootstrap_bootswatch"] :selected').text() + ')';
|
55 |
|
|
}
|
56 |
|
|
summary.push(bootstrapCDN);
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
if ($context.find('input[name="bootstrap_rebuild_registry"]').is(':checked')) {
|
60 |
|
|
summary.push(Drupal.t('Rebuild Registry'));
|
61 |
|
|
}
|
62 |
|
|
return summary.join(', ');
|
63 |
|
|
});
|
64 |
|
|
}
|
65 |
|
|
};
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
Drupal.behaviors.bootstrapBootswatchPreview = {
|
71 |
|
|
attach: function (context) {
|
72 |
|
|
var $context = $(context);
|
73 |
|
|
var $preview = $context.find('#bootswatch-preview');
|
74 |
|
|
$preview.once('bootswatch', function () {
|
75 |
|
|
$.get("http://api.bootswatch.com/3/", function (data) {
|
76 |
|
|
var themes = data.themes;
|
77 |
|
|
for (var i = 0, len = themes.length; i < len; i++) {
|
78 |
|
|
$('<a/>').attr({
|
79 |
|
|
id: themes[i].name.toLowerCase(),
|
80 |
|
|
class: 'bootswatch-preview element-invisible',
|
81 |
|
|
href: themes[i].preview,
|
82 |
|
|
target: '_blank'
|
83 |
|
|
}).html(
|
84 |
|
|
$('<img/>').attr({
|
85 |
|
|
src: themes[i].thumbnail,
|
86 |
|
|
alt: themes[i].name
|
87 |
|
|
})
|
88 |
|
|
)
|
89 |
|
|
.appendTo($preview);
|
90 |
|
|
}
|
91 |
|
|
$preview.parent().find('select[name="bootstrap_bootswatch"]').bind('change', function () {
|
92 |
|
|
$preview.find('.bootswatch-preview').addClass('element-invisible');
|
93 |
|
|
if ($(this).val().length) {
|
94 |
|
|
$preview.find('#' + $(this).val()).removeClass('element-invisible');
|
95 |
|
|
}
|
96 |
|
|
}).change();
|
97 |
|
|
}, "json");
|
98 |
|
|
});
|
99 |
|
|
}
|
100 |
|
|
};
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
Drupal.behaviors.bootstrapNavbarPreview = {
|
106 |
|
|
attach: function (context) {
|
107 |
|
|
var $context = $(context);
|
108 |
|
|
var $preview = $context.find('#edit-navbar');
|
109 |
|
|
$preview.once('navbar', function () {
|
110 |
|
|
var $body = $context.find('body');
|
111 |
|
|
var $navbar = $context.find('#navbar.navbar');
|
112 |
|
|
$preview.find('select[name="bootstrap_navbar_position"]').bind('change', function () {
|
113 |
|
|
var $position = $(this).find(':selected').val();
|
114 |
|
|
$navbar.removeClass('navbar-fixed-bottom navbar-fixed-top navbar-static-top container');
|
115 |
|
|
if ($position.length) {
|
116 |
|
|
$navbar.addClass('navbar-'+ $position);
|
117 |
|
|
}
|
118 |
|
|
else {
|
119 |
|
|
$navbar.addClass('container');
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
$body.removeClass('navbar-is-fixed-top navbar-is-fixed-bottom navbar-is-static-top');
|
123 |
|
|
switch ($position) {
|
124 |
|
|
case 'fixed-top':
|
125 |
|
|
$body.addClass('navbar-is-fixed-top');
|
126 |
|
|
break;
|
127 |
|
|
|
128 |
|
|
case 'fixed-bottom':
|
129 |
|
|
$body.addClass('navbar-is-fixed-bottom');
|
130 |
|
|
break;
|
131 |
|
|
|
132 |
|
|
case 'static-top':
|
133 |
|
|
$body.addClass('navbar-is-static-top');
|
134 |
|
|
break;
|
135 |
|
|
}
|
136 |
|
|
});
|
137 |
|
|
$preview.find('input[name="bootstrap_navbar_inverse"]').bind('change', function () {
|
138 |
|
|
$navbar.toggleClass('navbar-inverse navbar-default');
|
139 |
|
|
});
|
140 |
|
|
});
|
141 |
|
|
}
|
142 |
|
|
};
|
143 |
|
|
|
144 |
|
|
})(jQuery, Drupal); |