localtower 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +38 -0
- data/Rakefile +33 -0
- data/app/controllers/localtower/application_controller.rb +5 -0
- data/app/controllers/localtower/pages_controller.rb +55 -0
- data/app/helpers/localtower/application_helper.rb +19 -0
- data/app/views/layouts/localtower/application.html.erb +94 -0
- data/app/views/localtower/pages/dashboard.html.erb +55 -0
- data/app/views/localtower/pages/migrations.html.erb +99 -0
- data/app/views/localtower/pages/models.html.erb +78 -0
- data/app/views/localtower/pages/relations.html.erb +53 -0
- data/config/routes.rb +16 -0
- data/lib/localtower.rb +19 -0
- data/lib/localtower/engine.rb +9 -0
- data/lib/localtower/generators/migration.rb +275 -0
- data/lib/localtower/generators/model.rb +36 -0
- data/lib/localtower/generators/relation.rb +55 -0
- data/lib/localtower/tools.rb +173 -0
- data/lib/localtower/version.rb +3 -0
- data/lib/tasks/localtower_tasks.rake +4 -0
- data/public/css/app.css +29 -0
- data/public/js/app.js +106 -0
- data/public/light-bootstrap-dashboard-master/assets/css/animate.min.css +6 -0
- data/public/light-bootstrap-dashboard-master/assets/css/bootstrap.min.css +5 -0
- data/public/light-bootstrap-dashboard-master/assets/css/demo.css +61 -0
- data/public/light-bootstrap-dashboard-master/assets/css/light-bootstrap-dashboard.css +2815 -0
- data/public/light-bootstrap-dashboard-master/assets/css/pe-icon-7-stroke.css +632 -0
- data/public/light-bootstrap-dashboard-master/assets/fonts/Pe-icon-7-stroke.eot +0 -0
- data/public/light-bootstrap-dashboard-master/assets/fonts/Pe-icon-7-stroke.svg +212 -0
- data/public/light-bootstrap-dashboard-master/assets/fonts/Pe-icon-7-stroke.ttf +0 -0
- data/public/light-bootstrap-dashboard-master/assets/fonts/Pe-icon-7-stroke.woff +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/default-avatar.png +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/face-0.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/face-1.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/face-2.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/face-3.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/face-4.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/face-5.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/face-6.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/face-7.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/faces/tim_vector.jpe +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/favicon.ico +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/loading-bubbles.svg +14 -0
- data/public/light-bootstrap-dashboard-master/assets/img/mask.png +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/new_logo.png +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/sidebar-1.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/sidebar-2.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/sidebar-3.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/sidebar-4.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/sidebar-5.jpg +0 -0
- data/public/light-bootstrap-dashboard-master/assets/img/tim_80x80.png +0 -0
- data/public/light-bootstrap-dashboard-master/assets/js/bootstrap-checkbox-radio-switch.js +502 -0
- data/public/light-bootstrap-dashboard-master/assets/js/bootstrap-notify.js +404 -0
- data/public/light-bootstrap-dashboard-master/assets/js/bootstrap-select.js +438 -0
- data/public/light-bootstrap-dashboard-master/assets/js/bootstrap.min.js +7 -0
- data/public/light-bootstrap-dashboard-master/assets/js/chartist.min.js +9 -0
- data/public/light-bootstrap-dashboard-master/assets/js/demo.js +152 -0
- data/public/light-bootstrap-dashboard-master/assets/js/jquery-1.10.2.js +9789 -0
- data/public/light-bootstrap-dashboard-master/assets/js/light-bootstrap-dashboard.js +182 -0
- data/spec/dummy/Gemfile +33 -0
- data/spec/dummy/Gemfile.lock +186 -0
- data/spec/dummy/README.md +24 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +9 -0
- data/spec/dummy/bin/rake +9 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/spring +17 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +30 -0
- data/spec/dummy/config/boot.rb +3 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +18 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +86 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/coverage/assets/0.10.0/application.css +799 -0
- data/spec/dummy/coverage/assets/0.10.0/application.js +1707 -0
- data/spec/dummy/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/spec/dummy/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/loading.gif +0 -0
- data/spec/dummy/coverage/assets/0.10.0/magnify.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/dummy/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/dummy/coverage/index.html +294 -0
- data/spec/dummy/custom_plan.rb +11 -0
- data/spec/dummy/db/schema.rb +4 -0
- data/spec/dummy/lib/playground.rb +0 -0
- data/spec/dummy/log/development.log +22924 -0
- data/spec/dummy/log/localtower.log +11352 -0
- data/spec/dummy/log/test.log +9166 -0
- data/spec/dummy/tmp/restart.txt +0 -0
- data/spec/dummy/zeus.json +22 -0
- data/spec/factories/migration.rb +140 -0
- data/spec/factories/model.rb +36 -0
- data/spec/lib/localtower/generators/migration_spec.rb +113 -0
- data/spec/lib/localtower/generators/model_spec.rb +43 -0
- data/spec/lib/localtower/generators/relation_spec.rb +34 -0
- data/spec/lib/localtower/tools_spec.rb +14 -0
- data/spec/spec_helper.rb +47 -0
- metadata +401 -0
@@ -0,0 +1,404 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
Creative Tim Modifications
|
6
|
+
|
7
|
+
Lines: 239, 240 was changed from top: 5px to top: 50% and we added margin-top: -13px. In this way the close button will be aligned vertically
|
8
|
+
Line:242 - modified when the icon is set, we add the class "alert-with-icon", so there will be enough space for the icon.
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
*/
|
14
|
+
|
15
|
+
|
16
|
+
/*
|
17
|
+
* Project: Bootstrap Notify = v3.1.5
|
18
|
+
* Description: Turns standard Bootstrap alerts into "Growl-like" notifications.
|
19
|
+
* Author: Mouse0270 aka Robert McIntosh
|
20
|
+
* License: MIT License
|
21
|
+
* Website: https://github.com/mouse0270/bootstrap-growl
|
22
|
+
*/
|
23
|
+
|
24
|
+
/* global define:false, require: false, jQuery:false */
|
25
|
+
|
26
|
+
(function (factory) {
|
27
|
+
if (typeof define === 'function' && define.amd) {
|
28
|
+
// AMD. Register as an anonymous module.
|
29
|
+
define(['jquery'], factory);
|
30
|
+
} else if (typeof exports === 'object') {
|
31
|
+
// Node/CommonJS
|
32
|
+
factory(require('jquery'));
|
33
|
+
} else {
|
34
|
+
// Browser globals
|
35
|
+
factory(jQuery);
|
36
|
+
}
|
37
|
+
}(function ($) {
|
38
|
+
// Create the defaults once
|
39
|
+
var defaults = {
|
40
|
+
element: 'body',
|
41
|
+
position: null,
|
42
|
+
type: "info",
|
43
|
+
allow_dismiss: true,
|
44
|
+
allow_duplicates: true,
|
45
|
+
newest_on_top: false,
|
46
|
+
showProgressbar: false,
|
47
|
+
placement: {
|
48
|
+
from: "top",
|
49
|
+
align: "right"
|
50
|
+
},
|
51
|
+
offset: 20,
|
52
|
+
spacing: 10,
|
53
|
+
z_index: 1031,
|
54
|
+
delay: 5000,
|
55
|
+
timer: 1000,
|
56
|
+
url_target: '_blank',
|
57
|
+
mouse_over: null,
|
58
|
+
animate: {
|
59
|
+
enter: 'animated fadeInDown',
|
60
|
+
exit: 'animated fadeOutUp'
|
61
|
+
},
|
62
|
+
onShow: null,
|
63
|
+
onShown: null,
|
64
|
+
onClose: null,
|
65
|
+
onClosed: null,
|
66
|
+
icon_type: 'class',
|
67
|
+
template: '<div data-notify="container" class="col-xs-11 col-sm-4 alert alert-{0}" role="alert"><button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>'
|
68
|
+
};
|
69
|
+
|
70
|
+
String.format = function () {
|
71
|
+
var str = arguments[0];
|
72
|
+
for (var i = 1; i < arguments.length; i++) {
|
73
|
+
str = str.replace(RegExp("\\{" + (i - 1) + "\\}", "gm"), arguments[i]);
|
74
|
+
}
|
75
|
+
return str;
|
76
|
+
};
|
77
|
+
|
78
|
+
function isDuplicateNotification(notification) {
|
79
|
+
var isDupe = false;
|
80
|
+
|
81
|
+
$('[data-notify="container"]').each(function (i, el) {
|
82
|
+
var $el = $(el);
|
83
|
+
var title = $el.find('[data-notify="title"]').text().trim();
|
84
|
+
var message = $el.find('[data-notify="message"]').html().trim();
|
85
|
+
|
86
|
+
// The input string might be different than the actual parsed HTML string!
|
87
|
+
// (<br> vs <br /> for example)
|
88
|
+
// So we have to force-parse this as HTML here!
|
89
|
+
var isSameTitle = title === $("<div>" + notification.settings.content.title + "</div>").html().trim();
|
90
|
+
var isSameMsg = message === $("<div>" + notification.settings.content.message + "</div>").html().trim();
|
91
|
+
var isSameType = $el.hasClass('alert-' + notification.settings.type);
|
92
|
+
|
93
|
+
if (isSameTitle && isSameMsg && isSameType) {
|
94
|
+
//we found the dupe. Set the var and stop checking.
|
95
|
+
isDupe = true;
|
96
|
+
}
|
97
|
+
return !isDupe;
|
98
|
+
});
|
99
|
+
|
100
|
+
return isDupe;
|
101
|
+
}
|
102
|
+
|
103
|
+
function Notify(element, content, options) {
|
104
|
+
// Setup Content of Notify
|
105
|
+
var contentObj = {
|
106
|
+
content: {
|
107
|
+
message: typeof content === 'object' ? content.message : content,
|
108
|
+
title: content.title ? content.title : '',
|
109
|
+
icon: content.icon ? content.icon : '',
|
110
|
+
url: content.url ? content.url : '#',
|
111
|
+
target: content.target ? content.target : '-'
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
options = $.extend(true, {}, contentObj, options);
|
116
|
+
this.settings = $.extend(true, {}, defaults, options);
|
117
|
+
this._defaults = defaults;
|
118
|
+
if (this.settings.content.target === "-") {
|
119
|
+
this.settings.content.target = this.settings.url_target;
|
120
|
+
}
|
121
|
+
this.animations = {
|
122
|
+
start: 'webkitAnimationStart oanimationstart MSAnimationStart animationstart',
|
123
|
+
end: 'webkitAnimationEnd oanimationend MSAnimationEnd animationend'
|
124
|
+
};
|
125
|
+
|
126
|
+
if (typeof this.settings.offset === 'number') {
|
127
|
+
this.settings.offset = {
|
128
|
+
x: this.settings.offset,
|
129
|
+
y: this.settings.offset
|
130
|
+
};
|
131
|
+
}
|
132
|
+
|
133
|
+
//if duplicate messages are not allowed, then only continue if this new message is not a duplicate of one that it already showing
|
134
|
+
if (this.settings.allow_duplicates || (!this.settings.allow_duplicates && !isDuplicateNotification(this))) {
|
135
|
+
this.init();
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
$.extend(Notify.prototype, {
|
140
|
+
init: function () {
|
141
|
+
var self = this;
|
142
|
+
|
143
|
+
this.buildNotify();
|
144
|
+
if (this.settings.content.icon) {
|
145
|
+
this.setIcon();
|
146
|
+
}
|
147
|
+
if (this.settings.content.url != "#") {
|
148
|
+
this.styleURL();
|
149
|
+
}
|
150
|
+
this.styleDismiss();
|
151
|
+
this.placement();
|
152
|
+
this.bind();
|
153
|
+
|
154
|
+
this.notify = {
|
155
|
+
$ele: this.$ele,
|
156
|
+
update: function (command, update) {
|
157
|
+
var commands = {};
|
158
|
+
if (typeof command === "string") {
|
159
|
+
commands[command] = update;
|
160
|
+
} else {
|
161
|
+
commands = command;
|
162
|
+
}
|
163
|
+
for (var cmd in commands) {
|
164
|
+
switch (cmd) {
|
165
|
+
case "type":
|
166
|
+
this.$ele.removeClass('alert-' + self.settings.type);
|
167
|
+
this.$ele.find('[data-notify="progressbar"] > .progress-bar').removeClass('progress-bar-' + self.settings.type);
|
168
|
+
self.settings.type = commands[cmd];
|
169
|
+
this.$ele.addClass('alert-' + commands[cmd]).find('[data-notify="progressbar"] > .progress-bar').addClass('progress-bar-' + commands[cmd]);
|
170
|
+
break;
|
171
|
+
case "icon":
|
172
|
+
var $icon = this.$ele.find('[data-notify="icon"]');
|
173
|
+
if (self.settings.icon_type.toLowerCase() === 'class') {
|
174
|
+
$icon.removeClass(self.settings.content.icon).addClass(commands[cmd]);
|
175
|
+
} else {
|
176
|
+
if (!$icon.is('img')) {
|
177
|
+
$icon.find('img');
|
178
|
+
}
|
179
|
+
$icon.attr('src', commands[cmd]);
|
180
|
+
}
|
181
|
+
break;
|
182
|
+
case "progress":
|
183
|
+
var newDelay = self.settings.delay - (self.settings.delay * (commands[cmd] / 100));
|
184
|
+
this.$ele.data('notify-delay', newDelay);
|
185
|
+
this.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', commands[cmd]).css('width', commands[cmd] + '%');
|
186
|
+
break;
|
187
|
+
case "url":
|
188
|
+
this.$ele.find('[data-notify="url"]').attr('href', commands[cmd]);
|
189
|
+
break;
|
190
|
+
case "target":
|
191
|
+
this.$ele.find('[data-notify="url"]').attr('target', commands[cmd]);
|
192
|
+
break;
|
193
|
+
default:
|
194
|
+
this.$ele.find('[data-notify="' + cmd + '"]').html(commands[cmd]);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
var posX = this.$ele.outerHeight() + parseInt(self.settings.spacing) + parseInt(self.settings.offset.y);
|
198
|
+
self.reposition(posX);
|
199
|
+
},
|
200
|
+
close: function () {
|
201
|
+
self.close();
|
202
|
+
}
|
203
|
+
};
|
204
|
+
|
205
|
+
},
|
206
|
+
buildNotify: function () {
|
207
|
+
var content = this.settings.content;
|
208
|
+
this.$ele = $(String.format(this.settings.template, this.settings.type, content.title, content.message, content.url, content.target));
|
209
|
+
this.$ele.attr('data-notify-position', this.settings.placement.from + '-' + this.settings.placement.align);
|
210
|
+
if (!this.settings.allow_dismiss) {
|
211
|
+
this.$ele.find('[data-notify="dismiss"]').css('display', 'none');
|
212
|
+
}
|
213
|
+
if ((this.settings.delay <= 0 && !this.settings.showProgressbar) || !this.settings.showProgressbar) {
|
214
|
+
this.$ele.find('[data-notify="progressbar"]').remove();
|
215
|
+
}
|
216
|
+
},
|
217
|
+
setIcon: function () {
|
218
|
+
|
219
|
+
this.$ele.addClass('alert-with-icon');
|
220
|
+
|
221
|
+
if (this.settings.icon_type.toLowerCase() === 'class') {
|
222
|
+
this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon);
|
223
|
+
} else {
|
224
|
+
if (this.$ele.find('[data-notify="icon"]').is('img')) {
|
225
|
+
this.$ele.find('[data-notify="icon"]').attr('src', this.settings.content.icon);
|
226
|
+
} else {
|
227
|
+
this.$ele.find('[data-notify="icon"]').append('<img src="' + this.settings.content.icon + '" alt="Notify Icon" />');
|
228
|
+
}
|
229
|
+
}
|
230
|
+
},
|
231
|
+
styleDismiss: function () {
|
232
|
+
this.$ele.find('[data-notify="dismiss"]').css({
|
233
|
+
position: 'absolute',
|
234
|
+
right: '10px',
|
235
|
+
top: '50%',
|
236
|
+
marginTop: '-13px',
|
237
|
+
zIndex: this.settings.z_index + 2
|
238
|
+
});
|
239
|
+
},
|
240
|
+
styleURL: function () {
|
241
|
+
this.$ele.find('[data-notify="url"]').css({
|
242
|
+
backgroundImage: 'url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)',
|
243
|
+
height: '100%',
|
244
|
+
left: 0,
|
245
|
+
position: 'absolute',
|
246
|
+
top: 0,
|
247
|
+
width: '100%',
|
248
|
+
zIndex: this.settings.z_index + 1
|
249
|
+
});
|
250
|
+
},
|
251
|
+
placement: function () {
|
252
|
+
var self = this,
|
253
|
+
offsetAmt = this.settings.offset.y,
|
254
|
+
css = {
|
255
|
+
display: 'inline-block',
|
256
|
+
margin: '0px auto',
|
257
|
+
position: this.settings.position ? this.settings.position : (this.settings.element === 'body' ? 'fixed' : 'absolute'),
|
258
|
+
transition: 'all .5s ease-in-out',
|
259
|
+
zIndex: this.settings.z_index
|
260
|
+
},
|
261
|
+
hasAnimation = false,
|
262
|
+
settings = this.settings;
|
263
|
+
|
264
|
+
$('[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])').each(function () {
|
265
|
+
offsetAmt = Math.max(offsetAmt, parseInt($(this).css(settings.placement.from)) + parseInt($(this).outerHeight()) + parseInt(settings.spacing));
|
266
|
+
});
|
267
|
+
if (this.settings.newest_on_top === true) {
|
268
|
+
offsetAmt = this.settings.offset.y;
|
269
|
+
}
|
270
|
+
css[this.settings.placement.from] = offsetAmt + 'px';
|
271
|
+
|
272
|
+
switch (this.settings.placement.align) {
|
273
|
+
case "left":
|
274
|
+
case "right":
|
275
|
+
css[this.settings.placement.align] = this.settings.offset.x + 'px';
|
276
|
+
break;
|
277
|
+
case "center":
|
278
|
+
css.left = 0;
|
279
|
+
css.right = 0;
|
280
|
+
break;
|
281
|
+
}
|
282
|
+
this.$ele.css(css).addClass(this.settings.animate.enter);
|
283
|
+
$.each(Array('webkit-', 'moz-', 'o-', 'ms-', ''), function (index, prefix) {
|
284
|
+
self.$ele[0].style[prefix + 'AnimationIterationCount'] = 1;
|
285
|
+
});
|
286
|
+
|
287
|
+
$(this.settings.element).append(this.$ele);
|
288
|
+
|
289
|
+
if (this.settings.newest_on_top === true) {
|
290
|
+
offsetAmt = (parseInt(offsetAmt) + parseInt(this.settings.spacing)) + this.$ele.outerHeight();
|
291
|
+
this.reposition(offsetAmt);
|
292
|
+
}
|
293
|
+
|
294
|
+
if ($.isFunction(self.settings.onShow)) {
|
295
|
+
self.settings.onShow.call(this.$ele);
|
296
|
+
}
|
297
|
+
|
298
|
+
this.$ele.one(this.animations.start, function () {
|
299
|
+
hasAnimation = true;
|
300
|
+
}).one(this.animations.end, function () {
|
301
|
+
if ($.isFunction(self.settings.onShown)) {
|
302
|
+
self.settings.onShown.call(this);
|
303
|
+
}
|
304
|
+
});
|
305
|
+
|
306
|
+
setTimeout(function () {
|
307
|
+
if (!hasAnimation) {
|
308
|
+
if ($.isFunction(self.settings.onShown)) {
|
309
|
+
self.settings.onShown.call(this);
|
310
|
+
}
|
311
|
+
}
|
312
|
+
}, 600);
|
313
|
+
},
|
314
|
+
bind: function () {
|
315
|
+
var self = this;
|
316
|
+
|
317
|
+
this.$ele.find('[data-notify="dismiss"]').on('click', function () {
|
318
|
+
self.close();
|
319
|
+
});
|
320
|
+
|
321
|
+
this.$ele.mouseover(function () {
|
322
|
+
$(this).data('data-hover', "true");
|
323
|
+
}).mouseout(function () {
|
324
|
+
$(this).data('data-hover', "false");
|
325
|
+
});
|
326
|
+
this.$ele.data('data-hover', "false");
|
327
|
+
|
328
|
+
if (this.settings.delay > 0) {
|
329
|
+
self.$ele.data('notify-delay', self.settings.delay);
|
330
|
+
var timer = setInterval(function () {
|
331
|
+
var delay = parseInt(self.$ele.data('notify-delay')) - self.settings.timer;
|
332
|
+
if ((self.$ele.data('data-hover') === 'false' && self.settings.mouse_over === "pause") || self.settings.mouse_over != "pause") {
|
333
|
+
var percent = ((self.settings.delay - delay) / self.settings.delay) * 100;
|
334
|
+
self.$ele.data('notify-delay', delay);
|
335
|
+
self.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', percent).css('width', percent + '%');
|
336
|
+
}
|
337
|
+
if (delay <= -(self.settings.timer)) {
|
338
|
+
clearInterval(timer);
|
339
|
+
self.close();
|
340
|
+
}
|
341
|
+
}, self.settings.timer);
|
342
|
+
}
|
343
|
+
},
|
344
|
+
close: function () {
|
345
|
+
var self = this,
|
346
|
+
posX = parseInt(this.$ele.css(this.settings.placement.from)),
|
347
|
+
hasAnimation = false;
|
348
|
+
|
349
|
+
this.$ele.data('closing', 'true').addClass(this.settings.animate.exit);
|
350
|
+
self.reposition(posX);
|
351
|
+
|
352
|
+
if ($.isFunction(self.settings.onClose)) {
|
353
|
+
self.settings.onClose.call(this.$ele);
|
354
|
+
}
|
355
|
+
|
356
|
+
this.$ele.one(this.animations.start, function () {
|
357
|
+
hasAnimation = true;
|
358
|
+
}).one(this.animations.end, function () {
|
359
|
+
$(this).remove();
|
360
|
+
if ($.isFunction(self.settings.onClosed)) {
|
361
|
+
self.settings.onClosed.call(this);
|
362
|
+
}
|
363
|
+
});
|
364
|
+
|
365
|
+
setTimeout(function () {
|
366
|
+
if (!hasAnimation) {
|
367
|
+
self.$ele.remove();
|
368
|
+
if (self.settings.onClosed) {
|
369
|
+
self.settings.onClosed(self.$ele);
|
370
|
+
}
|
371
|
+
}
|
372
|
+
}, 600);
|
373
|
+
},
|
374
|
+
reposition: function (posX) {
|
375
|
+
var self = this,
|
376
|
+
notifies = '[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])',
|
377
|
+
$elements = this.$ele.nextAll(notifies);
|
378
|
+
if (this.settings.newest_on_top === true) {
|
379
|
+
$elements = this.$ele.prevAll(notifies);
|
380
|
+
}
|
381
|
+
$elements.each(function () {
|
382
|
+
$(this).css(self.settings.placement.from, posX);
|
383
|
+
posX = (parseInt(posX) + parseInt(self.settings.spacing)) + $(this).outerHeight();
|
384
|
+
});
|
385
|
+
}
|
386
|
+
});
|
387
|
+
|
388
|
+
$.notify = function (content, options) {
|
389
|
+
var plugin = new Notify(this, content, options);
|
390
|
+
return plugin.notify;
|
391
|
+
};
|
392
|
+
$.notifyDefaults = function (options) {
|
393
|
+
defaults = $.extend(true, {}, defaults, options);
|
394
|
+
return defaults;
|
395
|
+
};
|
396
|
+
$.notifyClose = function (command) {
|
397
|
+
if (typeof command === "undefined" || command === "all") {
|
398
|
+
$('[data-notify]').find('[data-notify="dismiss"]').trigger('click');
|
399
|
+
} else {
|
400
|
+
$('[data-notify-position="' + command + '"]').find('[data-notify="dismiss"]').trigger('click');
|
401
|
+
}
|
402
|
+
};
|
403
|
+
|
404
|
+
}));
|
@@ -0,0 +1,438 @@
|
|
1
|
+
!function($) {
|
2
|
+
var Selectpicker = function(element, options, e) {
|
3
|
+
if (e ) {
|
4
|
+
e.stopPropagation();
|
5
|
+
e.preventDefault();
|
6
|
+
}
|
7
|
+
this.$element = $(element);
|
8
|
+
this.$newElement = null;
|
9
|
+
this.button = null;
|
10
|
+
|
11
|
+
//Merge defaults, options and data-attributes to make our options
|
12
|
+
this.options = $.extend({}, $.fn.selectpicker.defaults, this.$element.data(), typeof options == 'object' && options);
|
13
|
+
|
14
|
+
//If we have no title yet, check the attribute 'title' (this is missed by jq as its not a data-attribute
|
15
|
+
if(this.options.title==null)
|
16
|
+
this.options.title = this.$element.attr('title');
|
17
|
+
|
18
|
+
//Expose public methods
|
19
|
+
this.val = Selectpicker.prototype.val;
|
20
|
+
this.render = Selectpicker.prototype.render;
|
21
|
+
this.init();
|
22
|
+
};
|
23
|
+
|
24
|
+
Selectpicker.prototype = {
|
25
|
+
|
26
|
+
constructor: Selectpicker,
|
27
|
+
|
28
|
+
init: function (e) {
|
29
|
+
var _this = this;
|
30
|
+
this.$element.hide();
|
31
|
+
this.multiple = this.$element.prop('multiple');
|
32
|
+
|
33
|
+
|
34
|
+
var classList = this.$element.attr('class') !== undefined ? this.$element.attr('class').split(/\s+/) : '';
|
35
|
+
var id = this.$element.attr('id');
|
36
|
+
this.$element.after( this.createView() );
|
37
|
+
this.$newElement = this.$element.next('.select');
|
38
|
+
var select = this.$newElement;
|
39
|
+
var menu = this.$newElement.find('.dropdown-menu');
|
40
|
+
var menuArrow = this.$newElement.find('.dropdown-arrow');
|
41
|
+
var menuA = menu.find('li > a');
|
42
|
+
var liHeight = select.addClass('open').find('.dropdown-menu li > a').outerHeight();
|
43
|
+
select.removeClass('open');
|
44
|
+
var divHeight = menu.find('li .divider').outerHeight(true);
|
45
|
+
var selectOffset_top = this.$newElement.offset().top;
|
46
|
+
var size = 0;
|
47
|
+
var menuHeight = 0;
|
48
|
+
var selectHeight = this.$newElement.outerHeight();
|
49
|
+
this.button = this.$newElement.find('> button');
|
50
|
+
if (id !== undefined) {
|
51
|
+
this.button.attr('id', id);
|
52
|
+
$('label[for="' + id + '"]').click(function(){ select.find('button#'+id).focus(); })
|
53
|
+
}
|
54
|
+
for (var i = 0; i < classList.length; i++) {
|
55
|
+
if(classList[i] != 'selectpicker') {
|
56
|
+
this.$newElement.addClass(classList[i]);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
//If we are multiple, then add the show-tick class by default
|
60
|
+
if(this.multiple) {
|
61
|
+
this.$newElement.addClass('select-multiple');
|
62
|
+
}
|
63
|
+
this.button.addClass(this.options.style);
|
64
|
+
menu.addClass(this.options.menuStyle);
|
65
|
+
menuArrow.addClass(function() {
|
66
|
+
if (_this.options.menuStyle) {
|
67
|
+
return _this.options.menuStyle.replace('dropdown-', 'dropdown-arrow-');
|
68
|
+
}
|
69
|
+
});
|
70
|
+
this.checkDisabled();
|
71
|
+
this.checkTabIndex();
|
72
|
+
this.clickListener();
|
73
|
+
var menuPadding = parseInt(menu.css('padding-top')) + parseInt(menu.css('padding-bottom')) + parseInt(menu.css('border-top-width')) + parseInt(menu.css('border-bottom-width'));
|
74
|
+
if (this.options.size == 'auto') {
|
75
|
+
|
76
|
+
// Creative Tim Changes: We changed the regular function made in bootstrap-select with this function so the getSize() will not be triggered one million times per second while you scroll.
|
77
|
+
|
78
|
+
var getSize = debounce(function() {
|
79
|
+
var selectOffset_top_scroll = selectOffset_top - $(window).scrollTop();
|
80
|
+
var windowHeight = $(window).innerHeight();
|
81
|
+
var menuExtras = menuPadding + parseInt(menu.css('margin-top')) + parseInt(menu.css('margin-bottom')) + 2;
|
82
|
+
var selectOffset_bot = windowHeight - selectOffset_top_scroll - selectHeight - menuExtras;
|
83
|
+
menuHeight = selectOffset_bot;
|
84
|
+
if (select.hasClass('dropup')) {
|
85
|
+
menuHeight = selectOffset_top_scroll - menuExtras;
|
86
|
+
}
|
87
|
+
//limit menuHeight to 300px to have a smooth transition with cubic bezier on dropdown
|
88
|
+
if(menuHeight >= 300){
|
89
|
+
menuHeight = 300;
|
90
|
+
}
|
91
|
+
|
92
|
+
menu.css({'max-height' : menuHeight + 'px', 'overflow-y' : 'auto', 'min-height' : liHeight * 3 + 'px'});
|
93
|
+
|
94
|
+
}, 50);
|
95
|
+
|
96
|
+
getSize;
|
97
|
+
$(window).on('scroll', getSize);
|
98
|
+
$(window).on('resize', getSize);
|
99
|
+
|
100
|
+
if (window.MutationObserver) {
|
101
|
+
new MutationObserver(getSize).observe(this.$element.get(0), {
|
102
|
+
childList: true
|
103
|
+
});
|
104
|
+
} else {
|
105
|
+
this.$element.bind('DOMNodeInserted', getSize);
|
106
|
+
}
|
107
|
+
} else if (this.options.size && this.options.size != 'auto' && menu.find('li').length > this.options.size) {
|
108
|
+
var optIndex = menu.find("li > *").filter(':not(.divider)').slice(0,this.options.size).last().parent().index();
|
109
|
+
var divLength = menu.find("li").slice(0,optIndex + 1).find('.divider').length;
|
110
|
+
menuHeight = liHeight*this.options.size + divLength*divHeight + menuPadding;
|
111
|
+
menu.css({'max-height' : menuHeight + 'px', 'overflow-y' : 'scroll'});
|
112
|
+
//console.log('sunt in if');
|
113
|
+
}
|
114
|
+
|
115
|
+
// Listen for updates to the DOM and re render... (Use Mutation Observer when availiable)
|
116
|
+
if (window.MutationObserver) {
|
117
|
+
new MutationObserver($.proxy(this.reloadLi, this)).observe(this.$element.get(0), {
|
118
|
+
childList: true
|
119
|
+
});
|
120
|
+
} else {
|
121
|
+
this.$element.bind('DOMNodeInserted', $.proxy(this.reloadLi, this));
|
122
|
+
}
|
123
|
+
|
124
|
+
this.render();
|
125
|
+
},
|
126
|
+
|
127
|
+
createDropdown: function() {
|
128
|
+
var drop =
|
129
|
+
"<div class='btn-group select'>" +
|
130
|
+
"<button class='btn dropdown-toggle clearfix' data-toggle='dropdown'>" +
|
131
|
+
"<span class='filter-option'></span> " +
|
132
|
+
"<span class='caret'></span>" +
|
133
|
+
"</button>" +
|
134
|
+
"<span class='dropdown-arrow'></span>" +
|
135
|
+
"<ul class='dropdown-menu' role='menu'>" +
|
136
|
+
"</ul>" +
|
137
|
+
"</div>";
|
138
|
+
|
139
|
+
return $(drop);
|
140
|
+
},
|
141
|
+
|
142
|
+
|
143
|
+
createView: function() {
|
144
|
+
var $drop = this.createDropdown();
|
145
|
+
var $li = this.createLi();
|
146
|
+
$drop.find('ul').append($li);
|
147
|
+
return $drop;
|
148
|
+
},
|
149
|
+
|
150
|
+
reloadLi: function() {
|
151
|
+
//Remove all children.
|
152
|
+
this.destroyLi();
|
153
|
+
//Re build
|
154
|
+
$li = this.createLi();
|
155
|
+
this.$newElement.find('ul').append( $li );
|
156
|
+
//render view
|
157
|
+
this.render();
|
158
|
+
},
|
159
|
+
|
160
|
+
destroyLi:function() {
|
161
|
+
this.$newElement.find('li').remove();
|
162
|
+
},
|
163
|
+
|
164
|
+
createLi: function() {
|
165
|
+
|
166
|
+
var _this = this;
|
167
|
+
var _li = [];
|
168
|
+
var _liA = [];
|
169
|
+
var _liHtml = '';
|
170
|
+
|
171
|
+
this.$element.find('option').each(function(){
|
172
|
+
_li.push($(this).text());
|
173
|
+
});
|
174
|
+
|
175
|
+
this.$element.find('option').each(function(index) {
|
176
|
+
//Get the class and text for the option
|
177
|
+
var optionClass = $(this).attr("class") !== undefined ? $(this).attr("class") : '';
|
178
|
+
var text = $(this).text();
|
179
|
+
var subtext = $(this).data('subtext') !== undefined ? '<small class="muted">'+$(this).data('subtext')+'</small>' : '';
|
180
|
+
|
181
|
+
//Append any subtext to the main text.
|
182
|
+
text+=subtext;
|
183
|
+
|
184
|
+
if ($(this).parent().is('optgroup') && $(this).data('divider') != true) {
|
185
|
+
if ($(this).index() == 0) {
|
186
|
+
//Get the opt group label
|
187
|
+
var label = $(this).parent().attr('label');
|
188
|
+
var labelSubtext = $(this).parent().data('subtext') !== undefined ? '<small class="muted">'+$(this).parent().data('subtext')+'</small>' : '';
|
189
|
+
label += labelSubtext;
|
190
|
+
|
191
|
+
if ($(this)[0].index != 0) {
|
192
|
+
_liA.push(
|
193
|
+
'<div class="divider"></div>'+
|
194
|
+
'<dt>'+label+'</dt>'+
|
195
|
+
_this.createA(text, "opt " + optionClass )
|
196
|
+
);
|
197
|
+
} else {
|
198
|
+
_liA.push(
|
199
|
+
'<dt>'+label+'</dt>'+
|
200
|
+
_this.createA(text, "opt " + optionClass ));
|
201
|
+
}
|
202
|
+
} else {
|
203
|
+
_liA.push( _this.createA(text, "opt " + optionClass ) );
|
204
|
+
}
|
205
|
+
} else if ($(this).data('divider') == true) {
|
206
|
+
_liA.push('<div class="divider"></div>');
|
207
|
+
} else if ($(this).data('hidden') == true) {
|
208
|
+
_liA.push('');
|
209
|
+
} else {
|
210
|
+
_liA.push( _this.createA(text, optionClass ) );
|
211
|
+
}
|
212
|
+
});
|
213
|
+
|
214
|
+
if (_li.length > 0) {
|
215
|
+
for (var i = 0; i < _li.length; i++) {
|
216
|
+
var $option = this.$element.find('option').eq(i);
|
217
|
+
_liHtml += "<li rel=" + i + ">" + _liA[i] + "</li>";
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
//If we dont have a selected item, and we dont have a title, select the first element so something is set in the button
|
222
|
+
if(this.$element.find('option:selected').length==0 && !_this.options.title) {
|
223
|
+
this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected');
|
224
|
+
}
|
225
|
+
|
226
|
+
return $(_liHtml);
|
227
|
+
},
|
228
|
+
|
229
|
+
createA:function(test, classes) {
|
230
|
+
return '<a tabindex="-1" href="#" class="'+classes+'">' +
|
231
|
+
'<span class="">' + test + '</span>' +
|
232
|
+
'</a>';
|
233
|
+
|
234
|
+
},
|
235
|
+
|
236
|
+
render:function() {
|
237
|
+
var _this = this;
|
238
|
+
|
239
|
+
//Set width of select
|
240
|
+
if (this.options.width == 'auto') {
|
241
|
+
var ulWidth = this.$newElement.find('.dropdown-menu').css('width');
|
242
|
+
this.$newElement.css('width',ulWidth);
|
243
|
+
} else if (this.options.width && this.options.width != 'auto') {
|
244
|
+
this.$newElement.css('width',this.options.width);
|
245
|
+
}
|
246
|
+
|
247
|
+
//Update the LI to match the SELECT
|
248
|
+
this.$element.find('option').each(function(index) {
|
249
|
+
_this.setDisabled(index, $(this).is(':disabled') || $(this).parent().is(':disabled') );
|
250
|
+
_this.setSelected(index, $(this).is(':selected') );
|
251
|
+
});
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
var selectedItems = this.$element.find('option:selected').map(function(index,value) {
|
256
|
+
if($(this).attr('title')!=undefined) {
|
257
|
+
return $(this).attr('title');
|
258
|
+
} else {
|
259
|
+
return $(this).text();
|
260
|
+
}
|
261
|
+
}).toArray();
|
262
|
+
|
263
|
+
//Convert all the values into a comma delimited string
|
264
|
+
var title = selectedItems.join(", ");
|
265
|
+
|
266
|
+
//If this is multi select, and the selectText type is count, the show 1 of 2 selected etc..
|
267
|
+
if(_this.multiple && _this.options.selectedTextFormat.indexOf('count') > -1) {
|
268
|
+
var max = _this.options.selectedTextFormat.split(">");
|
269
|
+
if( (max.length>1 && selectedItems.length > max[1]) || (max.length==1 && selectedItems.length>=2)) {
|
270
|
+
title = selectedItems.length +' of ' + this.$element.find('option').length + ' selected';
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
//If we dont have a title, then use the default, or if nothing is set at all, use the not selected text
|
275
|
+
if(!title) {
|
276
|
+
title = _this.options.title != undefined ? _this.options.title : _this.options.noneSelectedText;
|
277
|
+
}
|
278
|
+
|
279
|
+
this.$element.next('.select').find('.filter-option').html( title );
|
280
|
+
},
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
setSelected:function(index, selected) {
|
285
|
+
if(selected) {
|
286
|
+
this.$newElement.find('li').eq(index).addClass('selected');
|
287
|
+
} else {
|
288
|
+
this.$newElement.find('li').eq(index).removeClass('selected');
|
289
|
+
}
|
290
|
+
},
|
291
|
+
|
292
|
+
setDisabled:function(index, disabled) {
|
293
|
+
if(disabled) {
|
294
|
+
this.$newElement.find('li').eq(index).addClass('disabled');
|
295
|
+
} else {
|
296
|
+
this.$newElement.find('li').eq(index).removeClass('disabled');
|
297
|
+
}
|
298
|
+
},
|
299
|
+
|
300
|
+
checkDisabled: function() {
|
301
|
+
if (this.$element.is(':disabled')) {
|
302
|
+
this.button.addClass('disabled');
|
303
|
+
this.button.click(function(e) {
|
304
|
+
e.preventDefault();
|
305
|
+
});
|
306
|
+
}
|
307
|
+
},
|
308
|
+
|
309
|
+
checkTabIndex: function() {
|
310
|
+
if (this.$element.is('[tabindex]')) {
|
311
|
+
var tabindex = this.$element.attr("tabindex");
|
312
|
+
this.button.attr('tabindex', tabindex);
|
313
|
+
}
|
314
|
+
},
|
315
|
+
|
316
|
+
clickListener: function() {
|
317
|
+
var _this = this;
|
318
|
+
|
319
|
+
$('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); });
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
this.$newElement.on('click', 'li a', function(e){
|
324
|
+
var clickedIndex = $(this).parent().index(),
|
325
|
+
$this = $(this).parent(),
|
326
|
+
$select = $this.parents('.select');
|
327
|
+
|
328
|
+
|
329
|
+
//Dont close on multi choice menu
|
330
|
+
if(_this.multiple) {
|
331
|
+
e.stopPropagation();
|
332
|
+
}
|
333
|
+
|
334
|
+
e.preventDefault();
|
335
|
+
|
336
|
+
//Dont run if we have been disabled
|
337
|
+
if ($select.prev('select').not(':disabled') && !$(this).parent().hasClass('disabled')){
|
338
|
+
//Deselect all others if not multi select box
|
339
|
+
if (!_this.multiple) {
|
340
|
+
$select.prev('select').find('option').removeAttr('selected');
|
341
|
+
$select.prev('select').find('option').eq(clickedIndex).prop('selected', true).attr('selected', 'selected');
|
342
|
+
}
|
343
|
+
//Else toggle the one we have chosen if we are multi selet.
|
344
|
+
else {
|
345
|
+
var selected = $select.prev('select').find('option').eq(clickedIndex).prop('selected');
|
346
|
+
|
347
|
+
if(selected) {
|
348
|
+
$select.prev('select').find('option').eq(clickedIndex).removeAttr('selected');
|
349
|
+
} else {
|
350
|
+
$select.prev('select').find('option').eq(clickedIndex).prop('selected', true).attr('selected', 'selected');
|
351
|
+
}
|
352
|
+
}
|
353
|
+
|
354
|
+
|
355
|
+
$select.find('.filter-option').html($this.text());
|
356
|
+
$select.find('button').focus();
|
357
|
+
|
358
|
+
// Trigger select 'change'
|
359
|
+
$select.prev('select').trigger('change');
|
360
|
+
}
|
361
|
+
|
362
|
+
});
|
363
|
+
|
364
|
+
this.$newElement.on('click', 'li.disabled a, li dt, li .divider', function(e) {
|
365
|
+
e.preventDefault();
|
366
|
+
e.stopPropagation();
|
367
|
+
$select = $(this).parent().parents('.select');
|
368
|
+
$select.find('button').focus();
|
369
|
+
});
|
370
|
+
|
371
|
+
this.$element.on('change', function(e) {
|
372
|
+
_this.render();
|
373
|
+
});
|
374
|
+
},
|
375
|
+
|
376
|
+
val:function(value) {
|
377
|
+
|
378
|
+
if(value!=undefined) {
|
379
|
+
this.$element.val( value );
|
380
|
+
|
381
|
+
this.$element.trigger('change');
|
382
|
+
return this.$element;
|
383
|
+
} else {
|
384
|
+
return this.$element.val();
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
};
|
389
|
+
|
390
|
+
$.fn.selectpicker = function(option, event) {
|
391
|
+
//get the args of the outer function..
|
392
|
+
var args = arguments;
|
393
|
+
var value;
|
394
|
+
var chain = this.each(function () {
|
395
|
+
var $this = $(this),
|
396
|
+
data = $this.data('selectpicker'),
|
397
|
+
options = typeof option == 'object' && option;
|
398
|
+
|
399
|
+
if (!data) {
|
400
|
+
$this.data('selectpicker', (data = new Selectpicker(this, options, event)));
|
401
|
+
} else {
|
402
|
+
for(var i in option) {
|
403
|
+
data[i]=option[i];
|
404
|
+
}
|
405
|
+
}
|
406
|
+
|
407
|
+
if (typeof option == 'string') {
|
408
|
+
//Copy the value of option, as once we shift the arguments
|
409
|
+
//it also shifts the value of option.
|
410
|
+
property = option;
|
411
|
+
if(data[property] instanceof Function) {
|
412
|
+
[].shift.apply(args);
|
413
|
+
value = data[property].apply(data, args);
|
414
|
+
} else {
|
415
|
+
value = data[property];
|
416
|
+
}
|
417
|
+
}
|
418
|
+
});
|
419
|
+
|
420
|
+
if(value!=undefined) {
|
421
|
+
return value;
|
422
|
+
} else {
|
423
|
+
return chain;
|
424
|
+
}
|
425
|
+
};
|
426
|
+
|
427
|
+
$.fn.selectpicker.defaults = {
|
428
|
+
style: null,
|
429
|
+
size: 'auto',
|
430
|
+
title: null,
|
431
|
+
selectedTextFormat : 'values',
|
432
|
+
noneSelectedText : 'Nothing selected',
|
433
|
+
width: null,
|
434
|
+
menuStyle: null,
|
435
|
+
toggleSize: null
|
436
|
+
}
|
437
|
+
|
438
|
+
}(window.jQuery);
|