1 /* =========================================================== |
1 /* =========================================================== |
2 * bootstrap-modal.js v2.2.4+ |
2 * bootstrap-modal.js v2.2.5 |
3 * =========================================================== |
3 * =========================================================== |
4 * Copyright 2012 Jordan Schroter |
4 * Copyright 2012 Jordan Schroter |
5 * |
5 * |
6 * Modified in january 2014 by Thierry Florac <tflorac@ulthar.net> |
6 * Modified in january 2014 by Thierry Florac <tflorac@ulthar.net> |
7 * - add 'overflow' selector to handle selection of overflow content |
7 * - add 'overflow' selector to handle selection of overflow content |
140 .style(prop, (typeof(value) == 'function' ? value() : value) + 'px', 'important'); |
140 .style(prop, (typeof(value) == 'function' ? value() : value) + 'px', 'important'); |
141 } |
141 } |
142 |
142 |
143 var modalOverflow = $(window).height() - 10 < this.$element.height(); |
143 var modalOverflow = $(window).height() - 10 < this.$element.height(); |
144 |
144 |
145 if (modalOverflow || this.options.modalOverflow) { |
145 // if (modalOverflow || this.options.modalOverflow) { |
146 this.$element |
146 this.$element |
147 .css('margin-top', 0) |
147 .css('margin-top', 0) |
148 .addClass('modal-overflow'); |
148 .addClass('modal-overflow'); |
149 } else { |
149 // } else { |
150 this.$element |
150 // this.$element |
151 .css('margin-top', 0 - this.$element.height() / 2) |
151 // .css('margin-top', 0 - this.$element.height() / 2) |
152 .removeClass('modal-overflow'); |
152 // .removeClass('modal-overflow'); |
153 } |
153 // } |
154 }, |
154 }, |
155 |
155 |
156 tab: function () { |
156 tab: function () { |
157 var that = this; |
157 var that = this; |
158 |
158 |
159 if (this.isShown && this.options.consumeTab) { |
159 if (this.isShown && this.options.consumeTab) { |
160 this.$element.on('keydown.tabindex.modal', '[data-tabindex]', function (e) { |
160 this.$element.on('keydown.tabindex.modal', '[data-tabindex]', function (e) { |
161 if (e.keyCode && e.keyCode == 9) { |
161 if (e.keyCode && e.keyCode == 9) { |
162 var $next = $(this), |
162 var elements = [], |
163 $rollover = $(this); |
163 tabindex = Number($(this).data('tabindex')); |
164 |
164 |
165 that.$element.find('[data-tabindex]:enabled:not([readonly])').each(function (e) { |
165 that.$element.find('[data-tabindex]:enabled:visible:not([readonly])').each(function (ev) { |
166 if (!e.shiftKey) { |
166 elements.push(Number($(this).data('tabindex'))); |
167 $next = $next.data('tabindex') < $(this).data('tabindex') ? |
|
168 $next = $(this) : |
|
169 $rollover = $(this); |
|
170 } else { |
|
171 $next = $next.data('tabindex') > $(this).data('tabindex') ? |
|
172 $next = $(this) : |
|
173 $rollover = $(this); |
|
174 } |
|
175 }); |
167 }); |
176 |
168 elements.sort(function(a,b){return a-b}); |
177 $next[0] !== $(this)[0] ? |
169 |
178 $next.focus() : $rollover.focus(); |
170 var arrayPos = $.inArray(tabindex, elements); |
|
171 if (!e.shiftKey){ |
|
172 arrayPos < elements.length-1 ? |
|
173 that.$element.find('[data-tabindex='+elements[arrayPos+1]+']').focus() : |
|
174 that.$element.find('[data-tabindex='+elements[0]+']').focus(); |
|
175 } else { |
|
176 arrayPos == 0 ? |
|
177 that.$element.find('[data-tabindex='+elements[elements.length-1]+']').focus() : |
|
178 that.$element.find('[data-tabindex='+elements[arrayPos-1]+']').focus(); |
|
179 } |
179 |
180 |
180 e.preventDefault(); |
181 e.preventDefault(); |
181 } |
182 } |
182 }); |
183 }); |
183 } else if (!this.isShown) { |
184 } else if (!this.isShown) { |
231 this.$loading = null; |
232 this.$loading = null; |
232 this.isLoading = false; |
233 this.isLoading = false; |
233 }, |
234 }, |
234 |
235 |
235 loading: function (callback) { |
236 loading: function (callback) { |
236 callback = callback || function () { |
237 callback = callback || function () {}; |
237 }; |
|
238 |
238 |
239 var animate = this.$element.hasClass('fade') ? 'fade' : ''; |
239 var animate = this.$element.hasClass('fade') ? 'fade' : ''; |
240 |
240 |
241 if (!this.isLoading) { |
241 if (!this.isLoading) { |
242 var doAnimate = $.support.transition && animate; |
242 var doAnimate = $.support.transition && animate; |
303 destroy: function () { |
303 destroy: function () { |
304 var e = $.Event('destroy'); |
304 var e = $.Event('destroy'); |
305 this.$element.trigger(e); |
305 this.$element.trigger(e); |
306 if (e.isDefaultPrevented()) return; |
306 if (e.isDefaultPrevented()) return; |
307 |
307 |
308 this.teardown(); |
308 this.$element |
309 }, |
309 .off('.modal') |
310 |
310 .removeData('modal') |
311 teardown: function () { |
311 .removeClass('in') |
312 if (!this.$parent.length) { |
312 .attr('aria-hidden', true); |
|
313 |
|
314 if (this.$parent !== this.$element.parent()) { |
|
315 this.$element.appendTo(this.$parent); |
|
316 } else if (!this.$parent.length) { |
|
317 // modal is not part of the DOM so remove it. |
313 this.$element.remove(); |
318 this.$element.remove(); |
314 this.$element = null; |
319 this.$element = null; |
315 return; |
320 } |
316 } |
321 |
317 |
322 this.$element.trigger('destroyed'); |
318 if (this.$parent !== this.$element.parent()) { |
|
319 this.$element.appendTo(this.$parent); |
|
320 } |
|
321 |
|
322 this.$element.off('.modal'); |
|
323 this.$element.removeData('modal'); |
|
324 this.$element |
|
325 .removeClass('in') |
|
326 .attr('aria-hidden', true) |
|
327 .trigger('destroyed'); |
|
328 } |
323 } |
329 }; |
324 }; |
330 |
325 |
331 |
326 |
332 /* MODAL PLUGIN DEFINITION |
327 /* MODAL PLUGIN DEFINITION |