anjlab-widgets 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* ===========================================================
|
|
2
|
-
* bootstrap-modal.js v2.
|
|
2
|
+
* bootstrap-modal.js v2.1
|
|
3
3
|
* ===========================================================
|
|
4
4
|
* Copyright 2012 Jordan Schroter
|
|
5
5
|
*
|
|
@@ -20,85 +20,61 @@
|
|
|
20
20
|
!function ($) {
|
|
21
21
|
|
|
22
22
|
"use strict"; // jshint ;_;
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
/* MODAL CLASS DEFINITION
|
|
25
25
|
* ====================== */
|
|
26
26
|
|
|
27
27
|
var Modal = function (element, options) {
|
|
28
28
|
this.init(element, options);
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
|
|
31
31
|
Modal.prototype = {
|
|
32
32
|
|
|
33
|
-
constructor: Modal,
|
|
34
|
-
|
|
33
|
+
constructor: Modal,
|
|
34
|
+
|
|
35
35
|
init: function (element, options) {
|
|
36
36
|
this.options = options;
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
this.$element = $(element)
|
|
39
39
|
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this));
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
this.options.remote && this.$element.find('.modal-body').load(this.options.remote);
|
|
42
|
-
|
|
43
|
-
var manager = typeof this.options.manager === 'function' ?
|
|
42
|
+
|
|
43
|
+
var manager = typeof this.options.manager === 'function' ?
|
|
44
44
|
this.options.manager.call(this) : this.options.manager;
|
|
45
45
|
|
|
46
|
-
manager = manager.appendModal ?
|
|
46
|
+
manager = manager.appendModal ?
|
|
47
47
|
manager : $(manager).modalmanager().data('modalmanager');
|
|
48
48
|
|
|
49
49
|
manager.appendModal(this);
|
|
50
|
-
},
|
|
51
|
-
|
|
50
|
+
},
|
|
51
|
+
|
|
52
52
|
toggle: function () {
|
|
53
53
|
return this[!this.isShown ? 'show' : 'hide']();
|
|
54
|
-
},
|
|
55
|
-
|
|
54
|
+
},
|
|
55
|
+
|
|
56
56
|
show: function () {
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
var e = $.Event('show');
|
|
58
|
+
|
|
60
59
|
if (this.isShown) return;
|
|
61
60
|
|
|
62
|
-
this.$element.
|
|
61
|
+
this.$element.trigger(e);
|
|
63
62
|
|
|
64
63
|
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
64
|
|
|
89
65
|
this.escape();
|
|
90
66
|
|
|
91
67
|
this.tab();
|
|
92
|
-
|
|
68
|
+
|
|
93
69
|
this.options.loading && this.loading();
|
|
94
|
-
},
|
|
95
|
-
|
|
70
|
+
},
|
|
71
|
+
|
|
96
72
|
hide: function (e) {
|
|
97
73
|
e && e.preventDefault();
|
|
98
74
|
|
|
99
75
|
e = $.Event('hide');
|
|
100
76
|
|
|
101
|
-
this.$element.
|
|
77
|
+
this.$element.trigger(e);
|
|
102
78
|
|
|
103
79
|
if (!this.isShown || e.isDefaultPrevented()) return (this.isShown = false);
|
|
104
80
|
|
|
@@ -107,7 +83,7 @@
|
|
|
107
83
|
this.escape();
|
|
108
84
|
|
|
109
85
|
this.tab();
|
|
110
|
-
|
|
86
|
+
|
|
111
87
|
this.isLoading && this.loading();
|
|
112
88
|
|
|
113
89
|
$(document).off('focusin.modal');
|
|
@@ -122,108 +98,149 @@
|
|
|
122
98
|
$.support.transition && this.$element.hasClass('fade') ?
|
|
123
99
|
this.hideWithTransition() :
|
|
124
100
|
this.hideModal();
|
|
125
|
-
},
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
layout: function () {
|
|
104
|
+
var prop = this.options.height ? 'height' : 'max-height',
|
|
105
|
+
value = this.options.height || this.options.maxHeight;
|
|
106
|
+
|
|
107
|
+
if (this.options.width){
|
|
108
|
+
this.$element.css('width', this.options.width);
|
|
109
|
+
|
|
110
|
+
var that = this;
|
|
111
|
+
this.$element.css('margin-left', function () {
|
|
112
|
+
if (/%/ig.test(that.options.width)){
|
|
113
|
+
return -(parseInt(that.options.width) / 2) + '%';
|
|
114
|
+
} else {
|
|
115
|
+
return -($(this).width() / 2) + 'px';
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
this.$element.css('width', '');
|
|
120
|
+
this.$element.css('margin-left', '');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.$element.find('.modal-body')
|
|
124
|
+
.css('overflow', '')
|
|
125
|
+
.css(prop, '');
|
|
126
|
+
|
|
127
|
+
var modalOverflow = $(window).height() - 10 < this.$element.height();
|
|
128
|
+
|
|
129
|
+
if (value){
|
|
130
|
+
this.$element.find('.modal-body')
|
|
131
|
+
.css('overflow', 'auto')
|
|
132
|
+
.css(prop, value);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (modalOverflow || this.options.modalOverflow) {
|
|
136
|
+
this.$element
|
|
137
|
+
.css('margin-top', 0)
|
|
138
|
+
.addClass('modal-overflow');
|
|
139
|
+
} else {
|
|
140
|
+
this.$element
|
|
141
|
+
.css('margin-top', 0 - this.$element.height() / 2)
|
|
142
|
+
.removeClass('modal-overflow');
|
|
143
|
+
}
|
|
144
|
+
},
|
|
126
145
|
|
|
127
146
|
tab: function () {
|
|
128
147
|
var that = this;
|
|
129
148
|
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
});
|
|
149
|
+
if (this.isShown && this.options.consumeTab) {
|
|
150
|
+
this.$element.on('keydown.tabindex.modal', '[data-tabindex]', function (e) {
|
|
151
|
+
if (e.keyCode && e.keyCode == 9){
|
|
152
|
+
var $next = $(this),
|
|
153
|
+
$rollover = $(this);
|
|
154
|
+
|
|
155
|
+
that.$element.find('[data-tabindex]:enabled:not([readonly])').each(function (e) {
|
|
156
|
+
if (!e.shiftKey){
|
|
157
|
+
$next = $next.data('tabindex') < $(this).data('tabindex') ?
|
|
158
|
+
$next = $(this) :
|
|
159
|
+
$rollover = $(this);
|
|
160
|
+
} else {
|
|
161
|
+
$next = $next.data('tabindex') > $(this).data('tabindex') ?
|
|
162
|
+
$next = $(this) :
|
|
163
|
+
$rollover = $(this);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
$next[0] !== $(this)[0] ?
|
|
168
|
+
$next.focus() : $rollover.focus();
|
|
169
|
+
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
}
|
|
172
|
+
});
|
|
155
173
|
} else if (!this.isShown) {
|
|
156
174
|
this.$element.off('keydown.tabindex.modal');
|
|
157
175
|
}
|
|
158
|
-
},
|
|
159
|
-
|
|
176
|
+
},
|
|
177
|
+
|
|
160
178
|
escape: function () {
|
|
161
179
|
var that = this;
|
|
162
180
|
if (this.isShown && this.options.keyboard) {
|
|
163
181
|
if (!this.$element.attr('tabindex')) this.$element.attr('tabindex', -1);
|
|
164
|
-
|
|
182
|
+
|
|
165
183
|
this.$element.on('keyup.dismiss.modal', function (e) {
|
|
166
184
|
e.which == 27 && that.hide();
|
|
167
185
|
});
|
|
168
186
|
} else if (!this.isShown) {
|
|
169
187
|
this.$element.off('keyup.dismiss.modal')
|
|
170
188
|
}
|
|
171
|
-
},
|
|
172
|
-
|
|
189
|
+
},
|
|
190
|
+
|
|
173
191
|
hideWithTransition: function () {
|
|
174
192
|
var that = this
|
|
175
193
|
, timeout = setTimeout(function () {
|
|
176
|
-
that.$element.off($.support.transition.end)
|
|
177
|
-
that.hideModal()
|
|
194
|
+
that.$element.off($.support.transition.end);
|
|
195
|
+
that.hideModal();
|
|
178
196
|
}, 500);
|
|
179
197
|
|
|
180
198
|
this.$element.one($.support.transition.end, function () {
|
|
181
|
-
clearTimeout(timeout)
|
|
182
|
-
that.hideModal()
|
|
199
|
+
clearTimeout(timeout);
|
|
200
|
+
that.hideModal();
|
|
183
201
|
});
|
|
184
|
-
},
|
|
185
|
-
|
|
202
|
+
},
|
|
203
|
+
|
|
186
204
|
hideModal: function () {
|
|
187
205
|
this.$element
|
|
188
206
|
.hide()
|
|
189
|
-
.
|
|
190
|
-
|
|
207
|
+
.trigger('hidden');
|
|
191
208
|
|
|
192
209
|
var prop = this.options.height ? 'height' : 'max-height';
|
|
193
210
|
var value = this.options.height || this.options.maxHeight;
|
|
194
|
-
|
|
211
|
+
|
|
195
212
|
if (value){
|
|
196
213
|
this.$element.find('.modal-body')
|
|
197
214
|
.css('overflow', '')
|
|
198
215
|
.css(prop, '');
|
|
199
216
|
}
|
|
200
217
|
|
|
201
|
-
},
|
|
218
|
+
},
|
|
202
219
|
|
|
203
220
|
removeLoading: function () {
|
|
204
221
|
this.$loading.remove();
|
|
205
222
|
this.$loading = null;
|
|
206
223
|
this.isLoading = false;
|
|
207
224
|
},
|
|
208
|
-
|
|
225
|
+
|
|
209
226
|
loading: function (callback) {
|
|
210
227
|
callback = callback || function () {};
|
|
211
|
-
|
|
228
|
+
|
|
212
229
|
var animate = this.$element.hasClass('fade') ? 'fade' : '';
|
|
213
|
-
|
|
230
|
+
|
|
214
231
|
if (!this.isLoading) {
|
|
215
232
|
var doAnimate = $.support.transition && animate;
|
|
216
|
-
|
|
233
|
+
|
|
217
234
|
this.$loading = $('<div class="loading-mask ' + animate + '">')
|
|
218
235
|
.append(this.options.spinner)
|
|
219
236
|
.appendTo(this.$element);
|
|
220
237
|
|
|
221
|
-
if (doAnimate) this.$loading[0].offsetWidth // force reflow
|
|
222
|
-
|
|
223
|
-
this.$loading.addClass('in')
|
|
238
|
+
if (doAnimate) this.$loading[0].offsetWidth; // force reflow
|
|
239
|
+
|
|
240
|
+
this.$loading.addClass('in');
|
|
224
241
|
|
|
225
242
|
this.isLoading = true;
|
|
226
|
-
|
|
243
|
+
|
|
227
244
|
doAnimate ?
|
|
228
245
|
this.$loading.one($.support.transition.end, callback) :
|
|
229
246
|
callback();
|
|
@@ -240,7 +257,7 @@
|
|
|
240
257
|
callback(this.isLoading);
|
|
241
258
|
}
|
|
242
259
|
},
|
|
243
|
-
|
|
260
|
+
|
|
244
261
|
focus: function () {
|
|
245
262
|
var $focusElem = this.$element.find(this.options.focusOn);
|
|
246
263
|
|
|
@@ -269,17 +286,17 @@
|
|
|
269
286
|
|
|
270
287
|
this.focus();
|
|
271
288
|
},
|
|
272
|
-
|
|
289
|
+
|
|
273
290
|
|
|
274
291
|
destroy: function () {
|
|
275
292
|
var e = $.Event('destroy');
|
|
276
|
-
this.$element.
|
|
293
|
+
this.$element.trigger(e);
|
|
277
294
|
if (e.isDefaultPrevented()) return;
|
|
278
|
-
|
|
295
|
+
|
|
279
296
|
this.teardown();
|
|
280
297
|
},
|
|
281
|
-
|
|
282
|
-
teardown: function () {
|
|
298
|
+
|
|
299
|
+
teardown: function () {
|
|
283
300
|
if (!this.$parent.length){
|
|
284
301
|
this.$element.remove();
|
|
285
302
|
this.$element = null;
|
|
@@ -296,26 +313,26 @@
|
|
|
296
313
|
.removeClass('in')
|
|
297
314
|
.attr('aria-hidden', true);
|
|
298
315
|
}
|
|
299
|
-
}
|
|
316
|
+
};
|
|
300
317
|
|
|
301
318
|
|
|
302
319
|
/* MODAL PLUGIN DEFINITION
|
|
303
320
|
* ======================= */
|
|
304
321
|
|
|
305
|
-
$.fn.modal = function (option) {
|
|
322
|
+
$.fn.modal = function (option, args) {
|
|
306
323
|
return this.each(function () {
|
|
307
|
-
var $this = $(this),
|
|
308
|
-
data = $this.data('modal'),
|
|
324
|
+
var $this = $(this),
|
|
325
|
+
data = $this.data('modal'),
|
|
309
326
|
options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option);
|
|
310
327
|
|
|
311
|
-
if (!data) $this.data('modal', (data = new Modal(this, options)))
|
|
312
|
-
if (typeof option == 'string') data[option]()
|
|
328
|
+
if (!data) $this.data('modal', (data = new Modal(this, options)));
|
|
329
|
+
if (typeof option == 'string') data[option].apply(data, [].concat(args));
|
|
313
330
|
else if (options.show) data.show()
|
|
314
331
|
})
|
|
315
|
-
}
|
|
332
|
+
};
|
|
316
333
|
|
|
317
334
|
$.fn.modal.defaults = {
|
|
318
|
-
keyboard: true,
|
|
335
|
+
keyboard: true,
|
|
319
336
|
backdrop: true,
|
|
320
337
|
loading: false,
|
|
321
338
|
show: true,
|
|
@@ -325,22 +342,24 @@
|
|
|
325
342
|
modalOverflow: false,
|
|
326
343
|
consumeTab: true,
|
|
327
344
|
focusOn: null,
|
|
345
|
+
replace: false,
|
|
346
|
+
resize: false,
|
|
328
347
|
attentionAnimation: 'shake',
|
|
329
348
|
manager: 'body',
|
|
330
349
|
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
|
-
}
|
|
350
|
+
};
|
|
332
351
|
|
|
333
|
-
$.fn.modal.Constructor = Modal
|
|
352
|
+
$.fn.modal.Constructor = Modal;
|
|
334
353
|
|
|
335
354
|
|
|
336
355
|
/* MODAL DATA-API
|
|
337
356
|
* ============== */
|
|
338
|
-
|
|
357
|
+
|
|
339
358
|
$(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
|
|
359
|
+
$(document).off('click.modal').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
|
|
360
|
+
var $this = $(this),
|
|
361
|
+
href = $this.attr('href'),
|
|
362
|
+
$target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))), //strip for ie7
|
|
344
363
|
option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());
|
|
345
364
|
|
|
346
365
|
e.preventDefault();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* bootstrap-modalmanager.js v2.
|
|
1
|
+
/* ===========================================================
|
|
2
|
+
* bootstrap-modalmanager.js v2.1
|
|
3
3
|
* ===========================================================
|
|
4
4
|
* Copyright 2012 Jordan Schroter.
|
|
5
5
|
*
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
var ModalManager = function (element, options) {
|
|
27
27
|
this.init(element, options);
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
|
|
30
30
|
ModalManager.prototype = {
|
|
31
31
|
|
|
@@ -36,6 +36,20 @@
|
|
|
36
36
|
this.options = $.extend({}, $.fn.modalmanager.defaults, this.$element.data(), typeof options == 'object' && options);
|
|
37
37
|
this.stack = [];
|
|
38
38
|
this.backdropCount = 0;
|
|
39
|
+
|
|
40
|
+
if (this.options.resize) {
|
|
41
|
+
var resizeTimeout,
|
|
42
|
+
that = this;
|
|
43
|
+
|
|
44
|
+
$(window).on('resize.modal', function(){
|
|
45
|
+
resizeTimeout && clearTimeout(resizeTimeout);
|
|
46
|
+
resizeTimeout = setTimeout(function(){
|
|
47
|
+
for (var i = 0; i < that.stack.length; i++){
|
|
48
|
+
that.stack[i].isShown && that.stack[i].layout();
|
|
49
|
+
}
|
|
50
|
+
}, 10);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
39
53
|
},
|
|
40
54
|
|
|
41
55
|
createModal: function (element, options) {
|
|
@@ -48,47 +62,52 @@
|
|
|
48
62
|
var that = this;
|
|
49
63
|
|
|
50
64
|
modal.$element.on('show.modalmanager', targetIsSelf(function (e) {
|
|
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
|
-
|
|
65
|
+
|
|
66
|
+
var showModal = function(){
|
|
67
|
+
modal.isShown = true;
|
|
68
|
+
|
|
69
|
+
var transition = $.support.transition && modal.$element.hasClass('fade');
|
|
70
|
+
|
|
71
|
+
that.$element
|
|
72
|
+
.toggleClass('modal-open', that.hasOpenModal())
|
|
73
|
+
.toggleClass('page-overflow', $(window).height() < that.$element.height());
|
|
74
|
+
|
|
75
|
+
modal.$parent = modal.$element.parent();
|
|
76
|
+
|
|
77
|
+
modal.$container = that.createContainer(modal);
|
|
78
|
+
|
|
79
|
+
modal.$element.appendTo(modal.$container);
|
|
80
|
+
|
|
81
|
+
that.backdrop(modal, function () {
|
|
82
|
+
|
|
83
|
+
modal.$element.show();
|
|
84
|
+
|
|
85
|
+
if (transition) {
|
|
86
|
+
//modal.$element[0].style.display = 'run-in';
|
|
87
|
+
modal.$element[0].offsetWidth;
|
|
88
|
+
//modal.$element.one($.support.transition.end, function () { modal.$element[0].style.display = 'block' });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
modal.layout();
|
|
92
|
+
|
|
93
|
+
modal.$element
|
|
94
|
+
.addClass('in')
|
|
95
|
+
.attr('aria-hidden', false);
|
|
96
|
+
|
|
97
|
+
var complete = function () {
|
|
98
|
+
that.setFocus();
|
|
99
|
+
modal.$element.trigger('shown');
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
transition ?
|
|
103
|
+
modal.$element.one($.support.transition.end, complete) :
|
|
104
|
+
complete();
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
modal.options.replace ?
|
|
109
|
+
that.replace(showModal) :
|
|
110
|
+
showModal();
|
|
92
111
|
}));
|
|
93
112
|
|
|
94
113
|
modal.$element.on('hidden.modalmanager', targetIsSelf(function (e) {
|
|
@@ -96,7 +115,7 @@
|
|
|
96
115
|
that.backdrop(modal);
|
|
97
116
|
|
|
98
117
|
if (modal.$backdrop){
|
|
99
|
-
$.support.transition && modal.$element.hasClass('fade')?
|
|
118
|
+
$.support.transition && modal.$element.hasClass('fade') ?
|
|
100
119
|
modal.$backdrop.one($.support.transition.end, function () { that.destroyModal(modal) }) :
|
|
101
120
|
that.destroyModal(modal);
|
|
102
121
|
} else {
|
|
@@ -108,6 +127,7 @@
|
|
|
108
127
|
modal.$element.on('destroy.modalmanager', targetIsSelf(function (e) {
|
|
109
128
|
that.removeModal(modal);
|
|
110
129
|
}));
|
|
130
|
+
|
|
111
131
|
},
|
|
112
132
|
|
|
113
133
|
destroyModal: function (modal) {
|
|
@@ -117,7 +137,7 @@
|
|
|
117
137
|
var hasOpenModal = this.hasOpenModal();
|
|
118
138
|
|
|
119
139
|
this.$element.toggleClass('modal-open', hasOpenModal);
|
|
120
|
-
|
|
140
|
+
|
|
121
141
|
if (!hasOpenModal){
|
|
122
142
|
this.$element.removeClass('page-overflow');
|
|
123
143
|
}
|
|
@@ -164,24 +184,42 @@
|
|
|
164
184
|
}
|
|
165
185
|
},
|
|
166
186
|
|
|
187
|
+
replace: function (callback) {
|
|
188
|
+
var topModal;
|
|
189
|
+
|
|
190
|
+
for (var i = 0; i < this.stack.length; i++){
|
|
191
|
+
if (this.stack[i].isShown) topModal = this.stack[i];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (topModal) {
|
|
195
|
+
this.$backdropHandle = topModal.$backdrop;
|
|
196
|
+
topModal.$backdrop = null;
|
|
197
|
+
|
|
198
|
+
callback && topModal.$element.one('hidden',
|
|
199
|
+
targetIsSelf( $.proxy(callback, this) ));
|
|
200
|
+
|
|
201
|
+
topModal.hide();
|
|
202
|
+
} else if (callback) {
|
|
203
|
+
callback();
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
|
|
167
207
|
removeBackdrop: function (modal) {
|
|
168
208
|
modal.$backdrop.remove();
|
|
169
209
|
modal.$backdrop = null;
|
|
170
|
-
},
|
|
210
|
+
},
|
|
171
211
|
|
|
172
212
|
createBackdrop: function (animate) {
|
|
173
213
|
var $backdrop;
|
|
174
214
|
|
|
175
|
-
if (!this
|
|
215
|
+
if (!this.$backdropHandle) {
|
|
176
216
|
$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
|
177
217
|
.appendTo(this.$element);
|
|
178
|
-
|
|
179
218
|
} else {
|
|
180
|
-
$backdrop = this.$
|
|
219
|
+
$backdrop = this.$backdropHandle;
|
|
181
220
|
$backdrop.off('.modalmanager');
|
|
182
|
-
this.$
|
|
183
|
-
this.isLoading
|
|
184
|
-
this.$loading = this.$spinner = null;
|
|
221
|
+
this.$backdropHandle = null;
|
|
222
|
+
this.isLoading && this.removeSpinner();
|
|
185
223
|
}
|
|
186
224
|
|
|
187
225
|
return $backdrop
|
|
@@ -190,13 +228,13 @@
|
|
|
190
228
|
removeContainer: function (modal) {
|
|
191
229
|
modal.$container.remove();
|
|
192
230
|
modal.$container = null;
|
|
193
|
-
},
|
|
231
|
+
},
|
|
194
232
|
|
|
195
233
|
createContainer: function (modal) {
|
|
196
234
|
var $container;
|
|
197
235
|
|
|
198
236
|
$container = $('<div class="modal-scrollable">')
|
|
199
|
-
.css('z-index', getzIndex( 'modal',
|
|
237
|
+
.css('z-index', getzIndex( 'modal',
|
|
200
238
|
modal ? this.getIndexOfModal(modal) : this.stack.length ))
|
|
201
239
|
.appendTo(this.$element);
|
|
202
240
|
|
|
@@ -216,20 +254,19 @@
|
|
|
216
254
|
|
|
217
255
|
backdrop: function (modal, callback) {
|
|
218
256
|
var animate = modal.$element.hasClass('fade') ? 'fade' : '',
|
|
219
|
-
showBackdrop = modal.options.backdrop &&
|
|
257
|
+
showBackdrop = modal.options.backdrop &&
|
|
220
258
|
this.backdropCount < this.options.backdropLimit;
|
|
221
259
|
|
|
222
260
|
if (modal.isShown && showBackdrop) {
|
|
223
|
-
var doAnimate = $.support.transition && animate && !this
|
|
224
|
-
|
|
261
|
+
var doAnimate = $.support.transition && animate && !this.$backdropHandle;
|
|
225
262
|
|
|
226
263
|
modal.$backdrop = this.createBackdrop(animate);
|
|
227
264
|
|
|
228
|
-
modal.$backdrop.css('z-index', getzIndex( 'backdrop', this.getIndexOfModal(modal) ))
|
|
265
|
+
modal.$backdrop.css('z-index', getzIndex( 'backdrop', this.getIndexOfModal(modal) ));
|
|
229
266
|
|
|
230
|
-
if (doAnimate) modal.$backdrop[0].offsetWidth // force reflow
|
|
267
|
+
if (doAnimate) modal.$backdrop[0].offsetWidth; // force reflow
|
|
231
268
|
|
|
232
|
-
modal.$backdrop.addClass('in')
|
|
269
|
+
modal.$backdrop.addClass('in');
|
|
233
270
|
|
|
234
271
|
this.backdropCount += 1;
|
|
235
272
|
|
|
@@ -253,26 +290,32 @@
|
|
|
253
290
|
}
|
|
254
291
|
},
|
|
255
292
|
|
|
256
|
-
|
|
257
|
-
this.$
|
|
258
|
-
this.$
|
|
293
|
+
removeSpinner: function(){
|
|
294
|
+
this.$spinner && this.$spinner.remove();
|
|
295
|
+
this.$spinner = null;
|
|
259
296
|
this.isLoading = false;
|
|
260
297
|
},
|
|
261
298
|
|
|
299
|
+
removeLoading: function () {
|
|
300
|
+
this.$backdropHandle && this.$backdropHandle.remove();
|
|
301
|
+
this.$backdropHandle = null;
|
|
302
|
+
this.removeSpinner();
|
|
303
|
+
},
|
|
304
|
+
|
|
262
305
|
loading: function (callback) {
|
|
263
306
|
callback = callback || function () { };
|
|
264
|
-
|
|
307
|
+
|
|
265
308
|
this.$element
|
|
266
309
|
.toggleClass('modal-open', !this.isLoading || this.hasOpenModal())
|
|
267
310
|
.toggleClass('page-overflow', $(window).height() < this.$element.height());
|
|
268
|
-
|
|
311
|
+
|
|
269
312
|
if (!this.isLoading) {
|
|
270
313
|
|
|
271
|
-
this.$
|
|
314
|
+
this.$backdropHandle = this.createBackdrop('fade');
|
|
272
315
|
|
|
273
|
-
this.$
|
|
316
|
+
this.$backdropHandle[0].offsetWidth; // force reflow
|
|
274
317
|
|
|
275
|
-
this.$
|
|
318
|
+
this.$backdropHandle
|
|
276
319
|
.css('z-index', getzIndex('backdrop', this.stack.length))
|
|
277
320
|
.addClass('in');
|
|
278
321
|
|
|
@@ -288,31 +331,29 @@
|
|
|
288
331
|
this.isLoading = true;
|
|
289
332
|
|
|
290
333
|
$.support.transition ?
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
} else if (this.isLoading && this.$loading) {
|
|
295
|
-
this.$loading.removeClass('in');
|
|
334
|
+
this.$backdropHandle.one($.support.transition.end, callback) :
|
|
335
|
+
callback();
|
|
296
336
|
|
|
297
|
-
|
|
337
|
+
} else if (this.isLoading && this.$backdropHandle) {
|
|
338
|
+
this.$backdropHandle.removeClass('in');
|
|
298
339
|
|
|
299
340
|
var that = this;
|
|
300
341
|
$.support.transition ?
|
|
301
|
-
this.$
|
|
342
|
+
this.$backdropHandle.one($.support.transition.end, function () { that.removeLoading() }) :
|
|
302
343
|
that.removeLoading();
|
|
303
344
|
|
|
304
345
|
} else if (callback) {
|
|
305
346
|
callback(this.isLoading);
|
|
306
347
|
}
|
|
307
348
|
}
|
|
308
|
-
}
|
|
349
|
+
};
|
|
309
350
|
|
|
310
351
|
/* PRIVATE METHODS
|
|
311
352
|
* ======================= */
|
|
312
353
|
|
|
313
354
|
// computes and caches the zindexes
|
|
314
355
|
var getzIndex = (function () {
|
|
315
|
-
var zIndexFactor,
|
|
356
|
+
var zIndexFactor,
|
|
316
357
|
baseIndex = {};
|
|
317
358
|
|
|
318
359
|
return function (type, pos) {
|
|
@@ -321,10 +362,10 @@
|
|
|
321
362
|
var $baseModal = $('<div class="modal hide" />').appendTo('body'),
|
|
322
363
|
$baseBackdrop = $('<div class="modal-backdrop hide" />').appendTo('body');
|
|
323
364
|
|
|
324
|
-
baseIndex['modal'] = +$baseModal.css('z-index')
|
|
325
|
-
baseIndex['backdrop'] = +$baseBackdrop.css('z-index')
|
|
365
|
+
baseIndex['modal'] = +$baseModal.css('z-index');
|
|
366
|
+
baseIndex['backdrop'] = +$baseBackdrop.css('z-index');
|
|
326
367
|
zIndexFactor = baseIndex['modal'] - baseIndex['backdrop'];
|
|
327
|
-
|
|
368
|
+
|
|
328
369
|
$baseModal.remove();
|
|
329
370
|
$baseBackdrop.remove();
|
|
330
371
|
$baseBackdrop = $baseModal = null;
|
|
@@ -333,16 +374,16 @@
|
|
|
333
374
|
return baseIndex[type] + (zIndexFactor * pos);
|
|
334
375
|
|
|
335
376
|
}
|
|
336
|
-
}())
|
|
377
|
+
}());
|
|
337
378
|
|
|
338
|
-
// make sure the event target is the modal itself in order to prevent
|
|
339
|
-
// other components such as tabsfrom triggering the modal manager.
|
|
379
|
+
// make sure the event target is the modal itself in order to prevent
|
|
380
|
+
// other components such as tabsfrom triggering the modal manager.
|
|
340
381
|
// if Boostsrap namespaced events, this would not be needed.
|
|
341
382
|
function targetIsSelf(callback){
|
|
342
383
|
return function (e) {
|
|
343
384
|
if (this === e.target){
|
|
344
385
|
return callback.apply(this, arguments);
|
|
345
|
-
}
|
|
386
|
+
}
|
|
346
387
|
}
|
|
347
388
|
}
|
|
348
389
|
|
|
@@ -350,20 +391,21 @@
|
|
|
350
391
|
/* MODAL MANAGER PLUGIN DEFINITION
|
|
351
392
|
* ======================= */
|
|
352
393
|
|
|
353
|
-
$.fn.modalmanager = function (option) {
|
|
394
|
+
$.fn.modalmanager = function (option, args) {
|
|
354
395
|
return this.each(function () {
|
|
355
|
-
var $this = $(this),
|
|
396
|
+
var $this = $(this),
|
|
356
397
|
data = $this.data('modalmanager');
|
|
357
398
|
|
|
358
|
-
if (!data) $this.data('modalmanager', (data = new ModalManager(this, option)))
|
|
359
|
-
if (typeof option === 'string') data[option]()
|
|
399
|
+
if (!data) $this.data('modalmanager', (data = new ModalManager(this, option)));
|
|
400
|
+
if (typeof option === 'string') data[option].apply(data, [].concat(args))
|
|
360
401
|
})
|
|
361
|
-
}
|
|
402
|
+
};
|
|
362
403
|
|
|
363
404
|
$.fn.modalmanager.defaults = {
|
|
364
405
|
backdropLimit: 999,
|
|
406
|
+
resize: true,
|
|
365
407
|
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
|
-
}
|
|
408
|
+
};
|
|
367
409
|
|
|
368
410
|
$.fn.modalmanager.Constructor = ModalManager
|
|
369
411
|
|
metadata
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
name: anjlab-widgets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 1.0.
|
|
5
|
+
version: 1.0.2
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Yury Korolev
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-02-
|
|
12
|
+
date: 2013-02-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: anjlab-bootstrap-rails
|
|
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
172
172
|
- - ! '>='
|
|
173
173
|
- !ruby/object:Gem::Version
|
|
174
174
|
version: '0'
|
|
175
|
-
hash:
|
|
175
|
+
hash: -869637543149161080
|
|
176
176
|
segments:
|
|
177
177
|
- 0
|
|
178
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
181
181
|
- - ! '>='
|
|
182
182
|
- !ruby/object:Gem::Version
|
|
183
183
|
version: '0'
|
|
184
|
-
hash:
|
|
184
|
+
hash: -869637543149161080
|
|
185
185
|
segments:
|
|
186
186
|
- 0
|
|
187
187
|
requirements: []
|