anjlab-widgets 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
Binary file
|
@@ -0,0 +1,355 @@
|
|
1
|
+
/* ===========================================================
|
2
|
+
* bootstrap-modal.js v2.0
|
3
|
+
* ===========================================================
|
4
|
+
* Copyright 2012 Jordan Schroter
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
* ========================================================== */
|
18
|
+
|
19
|
+
|
20
|
+
!function ($) {
|
21
|
+
|
22
|
+
"use strict"; // jshint ;_;
|
23
|
+
|
24
|
+
/* MODAL CLASS DEFINITION
|
25
|
+
* ====================== */
|
26
|
+
|
27
|
+
var Modal = function (element, options) {
|
28
|
+
this.init(element, options);
|
29
|
+
}
|
30
|
+
|
31
|
+
Modal.prototype = {
|
32
|
+
|
33
|
+
constructor: Modal,
|
34
|
+
|
35
|
+
init: function (element, options) {
|
36
|
+
this.options = options;
|
37
|
+
|
38
|
+
this.$element = $(element)
|
39
|
+
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this));
|
40
|
+
|
41
|
+
this.options.remote && this.$element.find('.modal-body').load(this.options.remote);
|
42
|
+
|
43
|
+
var manager = typeof this.options.manager === 'function' ?
|
44
|
+
this.options.manager.call(this) : this.options.manager;
|
45
|
+
|
46
|
+
manager = manager.appendModal ?
|
47
|
+
manager : $(manager).modalmanager().data('modalmanager');
|
48
|
+
|
49
|
+
manager.appendModal(this);
|
50
|
+
},
|
51
|
+
|
52
|
+
toggle: function () {
|
53
|
+
return this[!this.isShown ? 'show' : 'hide']();
|
54
|
+
},
|
55
|
+
|
56
|
+
show: function () {
|
57
|
+
var that = this,
|
58
|
+
e = $.Event('show');
|
59
|
+
|
60
|
+
if (this.isShown) return;
|
61
|
+
|
62
|
+
this.$element.triggerHandler(e);
|
63
|
+
|
64
|
+
if (e.isDefaultPrevented()) return;
|
65
|
+
|
66
|
+
if (this.options.width){
|
67
|
+
this.$element.css('width', this.options.width);
|
68
|
+
|
69
|
+
var that = this;
|
70
|
+
this.$element.css('margin-left', function () {
|
71
|
+
if (/%/ig.test(that.options.width)){
|
72
|
+
return -(parseInt(that.options.width) / 2) + '%';
|
73
|
+
} else {
|
74
|
+
return -($(this).width() / 2) + 'px';
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
var prop = this.options.height ? 'height' : 'max-height';
|
80
|
+
|
81
|
+
var value = this.options.height || this.options.maxHeight;
|
82
|
+
|
83
|
+
if (value){
|
84
|
+
this.$element.find('.modal-body')
|
85
|
+
.css('overflow', 'auto')
|
86
|
+
.css(prop, value);
|
87
|
+
}
|
88
|
+
|
89
|
+
this.escape();
|
90
|
+
|
91
|
+
this.tab();
|
92
|
+
|
93
|
+
this.options.loading && this.loading();
|
94
|
+
},
|
95
|
+
|
96
|
+
hide: function (e) {
|
97
|
+
e && e.preventDefault();
|
98
|
+
|
99
|
+
e = $.Event('hide');
|
100
|
+
|
101
|
+
this.$element.triggerHandler(e);
|
102
|
+
|
103
|
+
if (!this.isShown || e.isDefaultPrevented()) return (this.isShown = false);
|
104
|
+
|
105
|
+
this.isShown = false;
|
106
|
+
|
107
|
+
this.escape();
|
108
|
+
|
109
|
+
this.tab();
|
110
|
+
|
111
|
+
this.isLoading && this.loading();
|
112
|
+
|
113
|
+
$(document).off('focusin.modal');
|
114
|
+
|
115
|
+
this.$element
|
116
|
+
.removeClass('in')
|
117
|
+
.removeClass('animated')
|
118
|
+
.removeClass(this.options.attentionAnimation)
|
119
|
+
.removeClass('modal-overflow')
|
120
|
+
.attr('aria-hidden', true);
|
121
|
+
|
122
|
+
$.support.transition && this.$element.hasClass('fade') ?
|
123
|
+
this.hideWithTransition() :
|
124
|
+
this.hideModal();
|
125
|
+
},
|
126
|
+
|
127
|
+
tab: function () {
|
128
|
+
var that = this;
|
129
|
+
|
130
|
+
if (this.isShown && this.options.consumeTab) {
|
131
|
+
this.$element.on('keydown.tabindex.modal', '[data-tabindex]', function (e) {
|
132
|
+
if (e.keyCode && e.keyCode == 9){
|
133
|
+
var $next = $(this),
|
134
|
+
$rollover = $(this);
|
135
|
+
|
136
|
+
that.$element.find('[data-tabindex]:enabled:not([readonly])').each(function (e) {
|
137
|
+
if (!e.shiftKey){
|
138
|
+
$next = $next.data('tabindex') < $(this).data('tabindex') ?
|
139
|
+
$next = $(this) :
|
140
|
+
$rollover = $(this);
|
141
|
+
} else {
|
142
|
+
$next = $next.data('tabindex') > $(this).data('tabindex') ?
|
143
|
+
$next = $(this) :
|
144
|
+
$rollover = $(this);
|
145
|
+
}
|
146
|
+
});
|
147
|
+
|
148
|
+
$next[0] !== $(this)[0] ?
|
149
|
+
$next.focus() : $rollover.focus();
|
150
|
+
|
151
|
+
e.preventDefault();
|
152
|
+
|
153
|
+
}
|
154
|
+
});
|
155
|
+
} else if (!this.isShown) {
|
156
|
+
this.$element.off('keydown.tabindex.modal');
|
157
|
+
}
|
158
|
+
},
|
159
|
+
|
160
|
+
escape: function () {
|
161
|
+
var that = this;
|
162
|
+
if (this.isShown && this.options.keyboard) {
|
163
|
+
if (!this.$element.attr('tabindex')) this.$element.attr('tabindex', -1);
|
164
|
+
|
165
|
+
this.$element.on('keyup.dismiss.modal', function (e) {
|
166
|
+
e.which == 27 && that.hide();
|
167
|
+
});
|
168
|
+
} else if (!this.isShown) {
|
169
|
+
this.$element.off('keyup.dismiss.modal')
|
170
|
+
}
|
171
|
+
},
|
172
|
+
|
173
|
+
hideWithTransition: function () {
|
174
|
+
var that = this
|
175
|
+
, timeout = setTimeout(function () {
|
176
|
+
that.$element.off($.support.transition.end)
|
177
|
+
that.hideModal()
|
178
|
+
}, 500);
|
179
|
+
|
180
|
+
this.$element.one($.support.transition.end, function () {
|
181
|
+
clearTimeout(timeout)
|
182
|
+
that.hideModal()
|
183
|
+
});
|
184
|
+
},
|
185
|
+
|
186
|
+
hideModal: function () {
|
187
|
+
this.$element
|
188
|
+
.hide()
|
189
|
+
.triggerHandler('hidden');
|
190
|
+
|
191
|
+
|
192
|
+
var prop = this.options.height ? 'height' : 'max-height';
|
193
|
+
var value = this.options.height || this.options.maxHeight;
|
194
|
+
|
195
|
+
if (value){
|
196
|
+
this.$element.find('.modal-body')
|
197
|
+
.css('overflow', '')
|
198
|
+
.css(prop, '');
|
199
|
+
}
|
200
|
+
|
201
|
+
},
|
202
|
+
|
203
|
+
removeLoading: function () {
|
204
|
+
this.$loading.remove();
|
205
|
+
this.$loading = null;
|
206
|
+
this.isLoading = false;
|
207
|
+
},
|
208
|
+
|
209
|
+
loading: function (callback) {
|
210
|
+
callback = callback || function () {};
|
211
|
+
|
212
|
+
var animate = this.$element.hasClass('fade') ? 'fade' : '';
|
213
|
+
|
214
|
+
if (!this.isLoading) {
|
215
|
+
var doAnimate = $.support.transition && animate;
|
216
|
+
|
217
|
+
this.$loading = $('<div class="loading-mask ' + animate + '">')
|
218
|
+
.append(this.options.spinner)
|
219
|
+
.appendTo(this.$element);
|
220
|
+
|
221
|
+
if (doAnimate) this.$loading[0].offsetWidth // force reflow
|
222
|
+
|
223
|
+
this.$loading.addClass('in')
|
224
|
+
|
225
|
+
this.isLoading = true;
|
226
|
+
|
227
|
+
doAnimate ?
|
228
|
+
this.$loading.one($.support.transition.end, callback) :
|
229
|
+
callback();
|
230
|
+
|
231
|
+
} else if (this.isLoading && this.$loading) {
|
232
|
+
this.$loading.removeClass('in');
|
233
|
+
|
234
|
+
var that = this;
|
235
|
+
$.support.transition && this.$element.hasClass('fade')?
|
236
|
+
this.$loading.one($.support.transition.end, function () { that.removeLoading() }) :
|
237
|
+
that.removeLoading();
|
238
|
+
|
239
|
+
} else if (callback) {
|
240
|
+
callback(this.isLoading);
|
241
|
+
}
|
242
|
+
},
|
243
|
+
|
244
|
+
focus: function () {
|
245
|
+
var $focusElem = this.$element.find(this.options.focusOn);
|
246
|
+
|
247
|
+
$focusElem = $focusElem.length ? $focusElem : this.$element;
|
248
|
+
|
249
|
+
$focusElem.focus();
|
250
|
+
},
|
251
|
+
|
252
|
+
attention: function (){
|
253
|
+
// NOTE: transitionEnd with keyframes causes odd behaviour
|
254
|
+
|
255
|
+
if (this.options.attentionAnimation){
|
256
|
+
this.$element
|
257
|
+
.removeClass('animated')
|
258
|
+
.removeClass(this.options.attentionAnimation);
|
259
|
+
|
260
|
+
var that = this;
|
261
|
+
|
262
|
+
setTimeout(function () {
|
263
|
+
that.$element
|
264
|
+
.addClass('animated')
|
265
|
+
.addClass(that.options.attentionAnimation);
|
266
|
+
}, 0);
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
this.focus();
|
271
|
+
},
|
272
|
+
|
273
|
+
|
274
|
+
destroy: function () {
|
275
|
+
var e = $.Event('destroy');
|
276
|
+
this.$element.triggerHandler(e);
|
277
|
+
if (e.isDefaultPrevented()) return;
|
278
|
+
|
279
|
+
this.teardown();
|
280
|
+
},
|
281
|
+
|
282
|
+
teardown: function () {
|
283
|
+
if (!this.$parent.length){
|
284
|
+
this.$element.remove();
|
285
|
+
this.$element = null;
|
286
|
+
return;
|
287
|
+
}
|
288
|
+
|
289
|
+
if (this.$parent !== this.$element.parent()){
|
290
|
+
this.$element.appendTo(this.$parent);
|
291
|
+
}
|
292
|
+
|
293
|
+
this.$element.off('.modal');
|
294
|
+
this.$element.removeData('modal');
|
295
|
+
this.$element
|
296
|
+
.removeClass('in')
|
297
|
+
.attr('aria-hidden', true);
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
/* MODAL PLUGIN DEFINITION
|
303
|
+
* ======================= */
|
304
|
+
|
305
|
+
$.fn.modal = function (option) {
|
306
|
+
return this.each(function () {
|
307
|
+
var $this = $(this),
|
308
|
+
data = $this.data('modal'),
|
309
|
+
options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option);
|
310
|
+
|
311
|
+
if (!data) $this.data('modal', (data = new Modal(this, options)))
|
312
|
+
if (typeof option == 'string') data[option]()
|
313
|
+
else if (options.show) data.show()
|
314
|
+
})
|
315
|
+
}
|
316
|
+
|
317
|
+
$.fn.modal.defaults = {
|
318
|
+
keyboard: true,
|
319
|
+
backdrop: true,
|
320
|
+
loading: false,
|
321
|
+
show: true,
|
322
|
+
width: null,
|
323
|
+
height: null,
|
324
|
+
maxHeight: null,
|
325
|
+
modalOverflow: false,
|
326
|
+
consumeTab: true,
|
327
|
+
focusOn: null,
|
328
|
+
attentionAnimation: 'shake',
|
329
|
+
manager: 'body',
|
330
|
+
spinner: '<div class="loading-spinner" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>'
|
331
|
+
}
|
332
|
+
|
333
|
+
$.fn.modal.Constructor = Modal
|
334
|
+
|
335
|
+
|
336
|
+
/* MODAL DATA-API
|
337
|
+
* ============== */
|
338
|
+
|
339
|
+
$(function () {
|
340
|
+
$(document).off('.modal').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
|
341
|
+
var $this = $(this),
|
342
|
+
href = $this.attr('href'),
|
343
|
+
$target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))), //strip for ie7
|
344
|
+
option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());
|
345
|
+
|
346
|
+
e.preventDefault();
|
347
|
+
$target
|
348
|
+
.modal(option)
|
349
|
+
.one('hide', function () {
|
350
|
+
$this.focus();
|
351
|
+
})
|
352
|
+
});
|
353
|
+
});
|
354
|
+
|
355
|
+
}(window.jQuery);
|
@@ -0,0 +1,370 @@
|
|
1
|
+
/* ===========================================================
|
2
|
+
* bootstrap-modalmanager.js v2.0
|
3
|
+
* ===========================================================
|
4
|
+
* Copyright 2012 Jordan Schroter.
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
* ========================================================== */
|
18
|
+
|
19
|
+
!function ($) {
|
20
|
+
|
21
|
+
"use strict"; // jshint ;_;
|
22
|
+
|
23
|
+
/* MODAL MANAGER CLASS DEFINITION
|
24
|
+
* ====================== */
|
25
|
+
|
26
|
+
var ModalManager = function (element, options) {
|
27
|
+
this.init(element, options);
|
28
|
+
}
|
29
|
+
|
30
|
+
ModalManager.prototype = {
|
31
|
+
|
32
|
+
constructor: ModalManager,
|
33
|
+
|
34
|
+
init: function (element, options) {
|
35
|
+
this.$element = $(element);
|
36
|
+
this.options = $.extend({}, $.fn.modalmanager.defaults, this.$element.data(), typeof options == 'object' && options);
|
37
|
+
this.stack = [];
|
38
|
+
this.backdropCount = 0;
|
39
|
+
},
|
40
|
+
|
41
|
+
createModal: function (element, options) {
|
42
|
+
$(element).modal($.extend({ manager: this }, options));
|
43
|
+
},
|
44
|
+
|
45
|
+
appendModal: function (modal) {
|
46
|
+
this.stack.push(modal);
|
47
|
+
|
48
|
+
var that = this;
|
49
|
+
|
50
|
+
modal.$element.on('show.modalmanager', targetIsSelf(function (e) {
|
51
|
+
modal.isShown = true;
|
52
|
+
|
53
|
+
var transition = $.support.transition && modal.$element.hasClass('fade');
|
54
|
+
|
55
|
+
that.$element
|
56
|
+
.toggleClass('modal-open', that.hasOpenModal())
|
57
|
+
.toggleClass('page-overflow', $(window).height() < that.$element.height());
|
58
|
+
|
59
|
+
modal.$parent = modal.$element.parent();
|
60
|
+
|
61
|
+
modal.$container = that.createContainer(modal);
|
62
|
+
|
63
|
+
modal.$element.appendTo(modal.$container);
|
64
|
+
|
65
|
+
var modalOverflow = $(window).height() < modal.$element.height() || modal.options.modalOverflow;
|
66
|
+
|
67
|
+
that.backdrop(modal, function () {
|
68
|
+
|
69
|
+
modal.$element.show();
|
70
|
+
|
71
|
+
if (transition) {
|
72
|
+
modal.$element[0].style.display = 'run-in';
|
73
|
+
modal.$element[0].offsetWidth;
|
74
|
+
modal.$element.one($.support.transition.end, function () { modal.$element[0].style.display = 'block' });
|
75
|
+
}
|
76
|
+
|
77
|
+
modal.$element
|
78
|
+
.toggleClass('modal-overflow', modalOverflow)
|
79
|
+
.css('margin-top', modalOverflow ? 0 : 0 - modal.$element.height()/2)
|
80
|
+
.addClass('in')
|
81
|
+
.attr('aria-hidden', false);
|
82
|
+
|
83
|
+
var complete = function () {
|
84
|
+
that.setFocus();
|
85
|
+
modal.$element.triggerHandler('shown');
|
86
|
+
}
|
87
|
+
|
88
|
+
transition ?
|
89
|
+
modal.$element.one($.support.transition.end, complete) :
|
90
|
+
complete();
|
91
|
+
});
|
92
|
+
}));
|
93
|
+
|
94
|
+
modal.$element.on('hidden.modalmanager', targetIsSelf(function (e) {
|
95
|
+
|
96
|
+
that.backdrop(modal);
|
97
|
+
|
98
|
+
if (modal.$backdrop){
|
99
|
+
$.support.transition && modal.$element.hasClass('fade')?
|
100
|
+
modal.$backdrop.one($.support.transition.end, function () { that.destroyModal(modal) }) :
|
101
|
+
that.destroyModal(modal);
|
102
|
+
} else {
|
103
|
+
that.destroyModal(modal);
|
104
|
+
}
|
105
|
+
|
106
|
+
}));
|
107
|
+
|
108
|
+
modal.$element.on('destroy.modalmanager', targetIsSelf(function (e) {
|
109
|
+
that.removeModal(modal);
|
110
|
+
}));
|
111
|
+
},
|
112
|
+
|
113
|
+
destroyModal: function (modal) {
|
114
|
+
|
115
|
+
modal.destroy();
|
116
|
+
|
117
|
+
var hasOpenModal = this.hasOpenModal();
|
118
|
+
|
119
|
+
this.$element.toggleClass('modal-open', hasOpenModal);
|
120
|
+
|
121
|
+
if (!hasOpenModal){
|
122
|
+
this.$element.removeClass('page-overflow');
|
123
|
+
}
|
124
|
+
|
125
|
+
this.removeContainer(modal);
|
126
|
+
|
127
|
+
this.setFocus();
|
128
|
+
},
|
129
|
+
|
130
|
+
hasOpenModal: function () {
|
131
|
+
for (var i = 0; i < this.stack.length; i++){
|
132
|
+
if (this.stack[i].isShown) return true;
|
133
|
+
}
|
134
|
+
|
135
|
+
return false;
|
136
|
+
},
|
137
|
+
|
138
|
+
setFocus: function () {
|
139
|
+
var topModal;
|
140
|
+
|
141
|
+
for (var i = 0; i < this.stack.length; i++){
|
142
|
+
if (this.stack[i].isShown) topModal = this.stack[i];
|
143
|
+
}
|
144
|
+
|
145
|
+
if (!topModal) return;
|
146
|
+
|
147
|
+
topModal.focus();
|
148
|
+
|
149
|
+
},
|
150
|
+
|
151
|
+
removeModal: function (modal) {
|
152
|
+
modal.$element.off('.modalmanager');
|
153
|
+
if (modal.$backdrop) this.removeBackdrop.call(modal);
|
154
|
+
this.stack.splice(this.getIndexOfModal(modal), 1);
|
155
|
+
},
|
156
|
+
|
157
|
+
getModalAt: function (index) {
|
158
|
+
return this.stack[index];
|
159
|
+
},
|
160
|
+
|
161
|
+
getIndexOfModal: function (modal) {
|
162
|
+
for (var i = 0; i < this.stack.length; i++){
|
163
|
+
if (modal === this.stack[i]) return i;
|
164
|
+
}
|
165
|
+
},
|
166
|
+
|
167
|
+
removeBackdrop: function (modal) {
|
168
|
+
modal.$backdrop.remove();
|
169
|
+
modal.$backdrop = null;
|
170
|
+
},
|
171
|
+
|
172
|
+
createBackdrop: function (animate) {
|
173
|
+
var $backdrop;
|
174
|
+
|
175
|
+
if (!this.isLoading) {
|
176
|
+
$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
177
|
+
.appendTo(this.$element);
|
178
|
+
|
179
|
+
} else {
|
180
|
+
$backdrop = this.$loading;
|
181
|
+
$backdrop.off('.modalmanager');
|
182
|
+
this.$spinner.remove();
|
183
|
+
this.isLoading = false;
|
184
|
+
this.$loading = this.$spinner = null;
|
185
|
+
}
|
186
|
+
|
187
|
+
return $backdrop
|
188
|
+
},
|
189
|
+
|
190
|
+
removeContainer: function (modal) {
|
191
|
+
modal.$container.remove();
|
192
|
+
modal.$container = null;
|
193
|
+
},
|
194
|
+
|
195
|
+
createContainer: function (modal) {
|
196
|
+
var $container;
|
197
|
+
|
198
|
+
$container = $('<div class="modal-scrollable">')
|
199
|
+
.css('z-index', getzIndex( 'modal',
|
200
|
+
modal ? this.getIndexOfModal(modal) : this.stack.length ))
|
201
|
+
.appendTo(this.$element);
|
202
|
+
|
203
|
+
if (modal && modal.options.backdrop != 'static') {
|
204
|
+
$container.on('click.modal', targetIsSelf(function (e) {
|
205
|
+
modal.hide();
|
206
|
+
}));
|
207
|
+
} else if (modal) {
|
208
|
+
$container.on('click.modal', targetIsSelf(function (e) {
|
209
|
+
modal.attention();
|
210
|
+
}));
|
211
|
+
}
|
212
|
+
|
213
|
+
return $container;
|
214
|
+
|
215
|
+
},
|
216
|
+
|
217
|
+
backdrop: function (modal, callback) {
|
218
|
+
var animate = modal.$element.hasClass('fade') ? 'fade' : '',
|
219
|
+
showBackdrop = modal.options.backdrop &&
|
220
|
+
this.backdropCount < this.options.backdropLimit;
|
221
|
+
|
222
|
+
if (modal.isShown && showBackdrop) {
|
223
|
+
var doAnimate = $.support.transition && animate && !this.isLoading;
|
224
|
+
|
225
|
+
|
226
|
+
modal.$backdrop = this.createBackdrop(animate);
|
227
|
+
|
228
|
+
modal.$backdrop.css('z-index', getzIndex( 'backdrop', this.getIndexOfModal(modal) ))
|
229
|
+
|
230
|
+
if (doAnimate) modal.$backdrop[0].offsetWidth // force reflow
|
231
|
+
|
232
|
+
modal.$backdrop.addClass('in')
|
233
|
+
|
234
|
+
this.backdropCount += 1;
|
235
|
+
|
236
|
+
doAnimate ?
|
237
|
+
modal.$backdrop.one($.support.transition.end, callback) :
|
238
|
+
callback();
|
239
|
+
|
240
|
+
} else if (!modal.isShown && modal.$backdrop) {
|
241
|
+
modal.$backdrop.removeClass('in');
|
242
|
+
|
243
|
+
this.backdropCount -= 1;
|
244
|
+
|
245
|
+
var that = this;
|
246
|
+
|
247
|
+
$.support.transition && modal.$element.hasClass('fade')?
|
248
|
+
modal.$backdrop.one($.support.transition.end, function () { that.removeBackdrop(modal) }) :
|
249
|
+
that.removeBackdrop(modal);
|
250
|
+
|
251
|
+
} else if (callback) {
|
252
|
+
callback();
|
253
|
+
}
|
254
|
+
},
|
255
|
+
|
256
|
+
removeLoading: function () {
|
257
|
+
this.$loading && this.$loading.remove();
|
258
|
+
this.$loading = null;
|
259
|
+
this.isLoading = false;
|
260
|
+
},
|
261
|
+
|
262
|
+
loading: function (callback) {
|
263
|
+
callback = callback || function () { };
|
264
|
+
|
265
|
+
this.$element
|
266
|
+
.toggleClass('modal-open', !this.isLoading || this.hasOpenModal())
|
267
|
+
.toggleClass('page-overflow', $(window).height() < this.$element.height());
|
268
|
+
|
269
|
+
if (!this.isLoading) {
|
270
|
+
|
271
|
+
this.$loading = this.createBackdrop('fade');
|
272
|
+
|
273
|
+
this.$loading[0].offsetWidth // force reflow
|
274
|
+
|
275
|
+
this.$loading
|
276
|
+
.css('z-index', getzIndex('backdrop', this.stack.length))
|
277
|
+
.addClass('in');
|
278
|
+
|
279
|
+
var $spinner = $(this.options.spinner)
|
280
|
+
.css('z-index', getzIndex('modal', this.stack.length))
|
281
|
+
.appendTo(this.$element)
|
282
|
+
.addClass('in');
|
283
|
+
|
284
|
+
this.$spinner = $(this.createContainer())
|
285
|
+
.append($spinner)
|
286
|
+
.on('click.modalmanager', $.proxy(this.loading, this));
|
287
|
+
|
288
|
+
this.isLoading = true;
|
289
|
+
|
290
|
+
$.support.transition ?
|
291
|
+
this.$loading.one($.support.transition.end, callback) :
|
292
|
+
callback();
|
293
|
+
|
294
|
+
} else if (this.isLoading && this.$loading) {
|
295
|
+
this.$loading.removeClass('in');
|
296
|
+
|
297
|
+
if (this.$spinner) this.$spinner.remove();
|
298
|
+
|
299
|
+
var that = this;
|
300
|
+
$.support.transition ?
|
301
|
+
this.$loading.one($.support.transition.end, function () { that.removeLoading() }) :
|
302
|
+
that.removeLoading();
|
303
|
+
|
304
|
+
} else if (callback) {
|
305
|
+
callback(this.isLoading);
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
/* PRIVATE METHODS
|
311
|
+
* ======================= */
|
312
|
+
|
313
|
+
// computes and caches the zindexes
|
314
|
+
var getzIndex = (function () {
|
315
|
+
var zIndexFactor,
|
316
|
+
baseIndex = {};
|
317
|
+
|
318
|
+
return function (type, pos) {
|
319
|
+
|
320
|
+
if (typeof zIndexFactor === 'undefined'){
|
321
|
+
var $baseModal = $('<div class="modal hide" />').appendTo('body'),
|
322
|
+
$baseBackdrop = $('<div class="modal-backdrop hide" />').appendTo('body');
|
323
|
+
|
324
|
+
baseIndex['modal'] = +$baseModal.css('z-index'),
|
325
|
+
baseIndex['backdrop'] = +$baseBackdrop.css('z-index'),
|
326
|
+
zIndexFactor = baseIndex['modal'] - baseIndex['backdrop'];
|
327
|
+
|
328
|
+
$baseModal.remove();
|
329
|
+
$baseBackdrop.remove();
|
330
|
+
$baseBackdrop = $baseModal = null;
|
331
|
+
}
|
332
|
+
|
333
|
+
return baseIndex[type] + (zIndexFactor * pos);
|
334
|
+
|
335
|
+
}
|
336
|
+
}())
|
337
|
+
|
338
|
+
// make sure the event target is the modal itself in order to prevent
|
339
|
+
// other components such as tabsfrom triggering the modal manager.
|
340
|
+
// if Boostsrap namespaced events, this would not be needed.
|
341
|
+
function targetIsSelf(callback){
|
342
|
+
return function (e) {
|
343
|
+
if (this === e.target){
|
344
|
+
return callback.apply(this, arguments);
|
345
|
+
}
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
|
350
|
+
/* MODAL MANAGER PLUGIN DEFINITION
|
351
|
+
* ======================= */
|
352
|
+
|
353
|
+
$.fn.modalmanager = function (option) {
|
354
|
+
return this.each(function () {
|
355
|
+
var $this = $(this),
|
356
|
+
data = $this.data('modalmanager');
|
357
|
+
|
358
|
+
if (!data) $this.data('modalmanager', (data = new ModalManager(this, option)))
|
359
|
+
if (typeof option === 'string') data[option]()
|
360
|
+
})
|
361
|
+
}
|
362
|
+
|
363
|
+
$.fn.modalmanager.defaults = {
|
364
|
+
backdropLimit: 999,
|
365
|
+
spinner: '<div class="loading-spinner fade" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>'
|
366
|
+
}
|
367
|
+
|
368
|
+
$.fn.modalmanager.Constructor = ModalManager
|
369
|
+
|
370
|
+
}(jQuery);
|
@@ -0,0 +1,215 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap Modal
|
3
|
+
*
|
4
|
+
* Copyright Jordan Schroter
|
5
|
+
* Licensed under the Apache License v2.0
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
.modal-open {
|
11
|
+
position: relative; /* safari */
|
12
|
+
overflow: hidden;
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
/* add a scroll bar to stop page from jerking around */
|
17
|
+
.modal-open.page-overflow .page-container,
|
18
|
+
.modal-open.page-overflow .page-container .navbar-fixed-top,
|
19
|
+
.modal-open.page-overflow .page-container .navbar-fixed-bottom,
|
20
|
+
.modal-open.page-overflow .modal-scrollable {
|
21
|
+
overflow-y: scroll;
|
22
|
+
}
|
23
|
+
|
24
|
+
@media (max-width: 979px) {
|
25
|
+
.modal-open.page-overflow .page-container .navbar-fixed-top,
|
26
|
+
.modal-open.page-overflow .page-container .navbar-fixed-bottom {
|
27
|
+
overflow-y: visible;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
.modal-scrollable {
|
33
|
+
position: fixed;
|
34
|
+
top: 0;
|
35
|
+
bottom: 0;
|
36
|
+
left: 0;
|
37
|
+
right: 0;
|
38
|
+
overflow: auto;
|
39
|
+
}
|
40
|
+
|
41
|
+
.modal {
|
42
|
+
outline: none;
|
43
|
+
position: absolute;
|
44
|
+
margin-top: 0;
|
45
|
+
top: 50%;
|
46
|
+
overflow: visible; /* allow content to popup out (i.e tooltips) */
|
47
|
+
}
|
48
|
+
|
49
|
+
.modal.fade {
|
50
|
+
top: -100%;
|
51
|
+
-webkit-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
|
52
|
+
-moz-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
|
53
|
+
-o-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
|
54
|
+
transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
|
55
|
+
}
|
56
|
+
|
57
|
+
.modal.fade.in {
|
58
|
+
top: 50%;
|
59
|
+
}
|
60
|
+
|
61
|
+
.modal-body {
|
62
|
+
max-height: none;
|
63
|
+
overflow: visible;
|
64
|
+
}
|
65
|
+
|
66
|
+
.modal.modal-absolute {
|
67
|
+
position: absolute;
|
68
|
+
z-index: 950;
|
69
|
+
}
|
70
|
+
|
71
|
+
.modal .loading-mask {
|
72
|
+
position: absolute;
|
73
|
+
top: 0;
|
74
|
+
bottom: 0;
|
75
|
+
left: 0;
|
76
|
+
right: 0;
|
77
|
+
background: #fff;
|
78
|
+
border-radius: 6px;
|
79
|
+
}
|
80
|
+
|
81
|
+
.modal-backdrop.modal-absolute{
|
82
|
+
position: absolute;
|
83
|
+
z-index: 940;
|
84
|
+
}
|
85
|
+
|
86
|
+
.modal-backdrop,
|
87
|
+
.modal-backdrop.fade.in{
|
88
|
+
opacity: 0.7;
|
89
|
+
filter: alpha(opacity=70);
|
90
|
+
background: #fff;
|
91
|
+
}
|
92
|
+
|
93
|
+
.modal.container {
|
94
|
+
width: 940px;
|
95
|
+
margin-left: -470px;
|
96
|
+
}
|
97
|
+
|
98
|
+
/* Modal Overflow */
|
99
|
+
|
100
|
+
.modal-overflow.modal {
|
101
|
+
top: 1%;
|
102
|
+
}
|
103
|
+
|
104
|
+
.modal-overflow.modal.fade {
|
105
|
+
top: -100%;
|
106
|
+
}
|
107
|
+
|
108
|
+
.modal-overflow.modal.fade.in {
|
109
|
+
top: 1%;
|
110
|
+
}
|
111
|
+
|
112
|
+
.modal-overflow .modal-body {
|
113
|
+
overflow: auto;
|
114
|
+
-webkit-overflow-scrolling: touch;
|
115
|
+
}
|
116
|
+
|
117
|
+
/* Responsive */
|
118
|
+
|
119
|
+
@media (min-width: 1200px) {
|
120
|
+
.modal.container {
|
121
|
+
width: 1170px;
|
122
|
+
margin-left: -585px;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
@media (max-width: 979px) {
|
127
|
+
.modal,
|
128
|
+
.modal.container,
|
129
|
+
.modal.modal-overflow {
|
130
|
+
top: 1%;
|
131
|
+
right: 1%;
|
132
|
+
left: 1%;
|
133
|
+
bottom: auto;
|
134
|
+
width: auto !important;
|
135
|
+
height: auto !important;
|
136
|
+
margin: 0 !important;
|
137
|
+
padding: 0 !important;
|
138
|
+
}
|
139
|
+
|
140
|
+
.modal.fade.in,
|
141
|
+
.modal.container.fade.in,
|
142
|
+
.modal.modal-overflow.fade.in {
|
143
|
+
top: 1%;
|
144
|
+
bottom: auto;
|
145
|
+
}
|
146
|
+
|
147
|
+
.modal-body,
|
148
|
+
.modal-overflow .modal-body {
|
149
|
+
position: static;
|
150
|
+
margin: 0;
|
151
|
+
height: auto !important;
|
152
|
+
max-height: none !important;
|
153
|
+
overflow: visible !important;
|
154
|
+
}
|
155
|
+
|
156
|
+
.modal-footer,
|
157
|
+
.modal-overflow .modal-footer {
|
158
|
+
position: static;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
.loading-spinner {
|
163
|
+
position: absolute;
|
164
|
+
top: 50%;
|
165
|
+
left: 50%;
|
166
|
+
margin: -12px 0 0 -12px;
|
167
|
+
}
|
168
|
+
|
169
|
+
/*
|
170
|
+
Animate.css - http://daneden.me/animate
|
171
|
+
Licensed under the ☺ license (http://licence.visualidiot.com/)
|
172
|
+
|
173
|
+
Copyright (c) 2012 Dan Eden*/
|
174
|
+
|
175
|
+
.animated {
|
176
|
+
-webkit-animation-duration: 1s;
|
177
|
+
-moz-animation-duration: 1s;
|
178
|
+
-o-animation-duration: 1s;
|
179
|
+
animation-duration: 1s;
|
180
|
+
-webkit-animation-fill-mode: both;
|
181
|
+
-moz-animation-fill-mode: both;
|
182
|
+
-o-animation-fill-mode: both;
|
183
|
+
animation-fill-mode: both;
|
184
|
+
}
|
185
|
+
|
186
|
+
@-webkit-keyframes shake {
|
187
|
+
0%, 100% {-webkit-transform: translateX(0);}
|
188
|
+
10%, 30%, 50%, 70%, 90% {-webkit-transform: translateX(-10px);}
|
189
|
+
20%, 40%, 60%, 80% {-webkit-transform: translateX(10px);}
|
190
|
+
}
|
191
|
+
|
192
|
+
@-moz-keyframes shake {
|
193
|
+
0%, 100% {-moz-transform: translateX(0);}
|
194
|
+
10%, 30%, 50%, 70%, 90% {-moz-transform: translateX(-10px);}
|
195
|
+
20%, 40%, 60%, 80% {-moz-transform: translateX(10px);}
|
196
|
+
}
|
197
|
+
|
198
|
+
@-o-keyframes shake {
|
199
|
+
0%, 100% {-o-transform: translateX(0);}
|
200
|
+
10%, 30%, 50%, 70%, 90% {-o-transform: translateX(-10px);}
|
201
|
+
20%, 40%, 60%, 80% {-o-transform: translateX(10px);}
|
202
|
+
}
|
203
|
+
|
204
|
+
@keyframes shake {
|
205
|
+
0%, 100% {transform: translateX(0);}
|
206
|
+
10%, 30%, 50%, 70%, 90% {transform: translateX(-10px);}
|
207
|
+
20%, 40%, 60%, 80% {transform: translateX(10px);}
|
208
|
+
}
|
209
|
+
|
210
|
+
.shake {
|
211
|
+
-webkit-animation-name: shake;
|
212
|
+
-moz-animation-name: shake;
|
213
|
+
-o-animation-name: shake;
|
214
|
+
animation-name: shake;
|
215
|
+
}
|
metadata
CHANGED
@@ -1,96 +1,96 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anjlab-widgets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.7
|
5
4
|
prerelease:
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Yury Korolev
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.3
|
20
|
+
none: false
|
21
|
+
prerelease: false
|
15
22
|
name: anjlab-bootstrap-rails
|
16
23
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
24
|
requirements:
|
19
25
|
- - ! '>='
|
20
26
|
- !ruby/object:Gem::Version
|
21
27
|
version: 2.0.3
|
28
|
+
none: false
|
22
29
|
type: :runtime
|
23
|
-
|
30
|
+
- !ruby/object:Gem::Dependency
|
24
31
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
32
|
requirements:
|
27
33
|
- - ! '>='
|
28
34
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2
|
30
|
-
|
35
|
+
version: '3.2'
|
36
|
+
none: false
|
37
|
+
prerelease: false
|
31
38
|
name: rails
|
32
39
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
40
|
requirements:
|
35
41
|
- - ! '>='
|
36
42
|
- !ruby/object:Gem::Version
|
37
43
|
version: '3.2'
|
44
|
+
none: false
|
38
45
|
type: :development
|
39
|
-
|
46
|
+
- !ruby/object:Gem::Dependency
|
40
47
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
48
|
requirements:
|
43
49
|
- - ! '>='
|
44
50
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
46
|
-
|
51
|
+
version: '1.0'
|
52
|
+
none: false
|
53
|
+
prerelease: false
|
47
54
|
name: bundler
|
48
55
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
56
|
requirements:
|
51
57
|
- - ! '>='
|
52
58
|
- !ruby/object:Gem::Version
|
53
59
|
version: '1.0'
|
60
|
+
none: false
|
54
61
|
type: :development
|
55
|
-
|
62
|
+
- !ruby/object:Gem::Dependency
|
56
63
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
64
|
requirements:
|
59
65
|
- - ! '>='
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
|
67
|
+
version: '0'
|
68
|
+
none: false
|
69
|
+
prerelease: false
|
63
70
|
name: sqlite3
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
73
|
- - ! '>='
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '0'
|
76
|
+
none: false
|
70
77
|
type: :development
|
71
|
-
|
78
|
+
- !ruby/object:Gem::Dependency
|
72
79
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
80
|
requirements:
|
75
81
|
- - ! '>='
|
76
82
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
|
83
|
+
version: 2.9.0
|
84
|
+
none: false
|
85
|
+
prerelease: false
|
79
86
|
name: rspec-rails
|
80
87
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
88
|
requirements:
|
83
89
|
- - ! '>='
|
84
90
|
- !ruby/object:Gem::Version
|
85
91
|
version: 2.9.0
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
92
|
none: false
|
90
|
-
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 2.9.0
|
93
|
+
type: :development
|
94
94
|
description: Collection of UI widgets on top of anjlab-bootstrap-rails. Datepicker
|
95
95
|
and Timepicker for now.
|
96
96
|
email:
|
@@ -147,10 +147,14 @@ files:
|
|
147
147
|
- spec/dummy/script/rails
|
148
148
|
- spec/spec_helper.rb
|
149
149
|
- spec/views/widgets/datepicker_spec.rb
|
150
|
+
- vendor/assets/images/ajax-loader.gif
|
150
151
|
- vendor/assets/javascripts/anjlab/datepicker.js.coffee
|
151
152
|
- vendor/assets/javascripts/anjlab/timepicker.js.coffee
|
153
|
+
- vendor/assets/javascripts/bootstrap-modal.js
|
154
|
+
- vendor/assets/javascripts/bootstrap-modalmanager.js
|
152
155
|
- vendor/assets/stylesheets/anjlab/datepicker.css.scss
|
153
156
|
- vendor/assets/stylesheets/anjlab/timepicker.css.scss
|
157
|
+
- vendor/assets/stylesheets/bootstrap-modal.css
|
154
158
|
homepage: https://github.com/anjlab/anjlab-widgets
|
155
159
|
licenses: []
|
156
160
|
post_install_message:
|
@@ -158,23 +162,23 @@ rdoc_options: []
|
|
158
162
|
require_paths:
|
159
163
|
- lib
|
160
164
|
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
165
|
requirements:
|
163
166
|
- - ! '>='
|
164
167
|
- !ruby/object:Gem::Version
|
165
168
|
version: '0'
|
166
169
|
segments:
|
167
170
|
- 0
|
168
|
-
hash:
|
169
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
hash: 2463130067864864405
|
170
172
|
none: false
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
174
|
requirements:
|
172
175
|
- - ! '>='
|
173
176
|
- !ruby/object:Gem::Version
|
174
177
|
version: '0'
|
175
178
|
segments:
|
176
179
|
- 0
|
177
|
-
hash:
|
180
|
+
hash: 2463130067864864405
|
181
|
+
none: false
|
178
182
|
requirements: []
|
179
183
|
rubyforge_project:
|
180
184
|
rubygems_version: 1.8.24
|