PluginProbe ʕ •ᴥ•ʔ
Nested Pages / 1.3.4
Nested Pages v1.3.4
3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / assets / js / lib / bs-modal.js
wp-nested-pages / assets / js / lib Last commit date
bs-modal.js 11 years ago jquery.mjs.nestedSortable.js 11 years ago jquery.ui.touch-punch.min.js 11 years ago nestedpages.js 11 years ago
bs-modal.js
282 lines
1 /* ========================================================================
2 * Bootstrap: modal.js v3.3.0
3 * http://getbootstrap.com/javascript/#modals
4 * ========================================================================
5 * Copyright 2011-2014 Twitter, Inc.
6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7 * ======================================================================== */
8
9
10 +function ($) {
11 'use strict';
12
13 // MODAL CLASS DEFINITION
14 // ======================
15
16 var Modal = function (element, options) {
17 this.options = options
18 this.$body = $(document.body)
19 this.$element = $(element)
20 this.$backdrop =
21 this.isShown = null
22 this.scrollbarWidth = 0
23
24 if (this.options.remote) {
25 this.$element
26 .find('.modal-content')
27 .load(this.options.remote, $.proxy(function () {
28 this.$element.trigger('loaded.bs.modal')
29 }, this))
30 }
31 }
32
33 Modal.VERSION = '3.3.0'
34
35 Modal.TRANSITION_DURATION = 300
36 Modal.BACKDROP_TRANSITION_DURATION = 150
37
38 Modal.DEFAULTS = {
39 backdrop: true,
40 keyboard: true,
41 show: true
42 }
43
44 Modal.prototype.toggle = function (_relatedTarget) {
45 return this.isShown ? this.hide() : this.show(_relatedTarget)
46 }
47
48 Modal.prototype.show = function (_relatedTarget) {
49 var that = this
50 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
51
52 this.$element.trigger(e)
53
54 if (this.isShown || e.isDefaultPrevented()) return
55
56 this.isShown = true
57
58 this.checkScrollbar()
59 this.$body.addClass('modal-open')
60
61 this.setScrollbar()
62 this.escape()
63
64 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
65
66 this.backdrop(function () {
67 var transition = $.support.transition && that.$element.hasClass('fade')
68
69 if (!that.$element.parent().length) {
70 that.$element.appendTo(that.$body) // don't move modals dom position
71 }
72
73 that.$element
74 .show()
75 .scrollTop(0)
76
77 if (transition) {
78 that.$element[0].offsetWidth // force reflow
79 }
80
81 that.$element
82 .addClass('in')
83 .attr('aria-hidden', false)
84
85 that.enforceFocus()
86
87 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
88
89 transition ?
90 that.$element.find('.modal-dialog') // wait for modal to slide in
91 .one('bsTransitionEnd', function () {
92 that.$element.trigger('focus').trigger(e)
93 })
94 .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
95 that.$element.trigger('focus').trigger(e)
96 })
97 }
98
99 Modal.prototype.hide = function (e) {
100 if (e) e.preventDefault()
101
102 e = $.Event('hide.bs.modal')
103
104 this.$element.trigger(e)
105
106 if (!this.isShown || e.isDefaultPrevented()) return
107
108 this.isShown = false
109
110 this.escape()
111
112 $(document).off('focusin.bs.modal')
113
114 this.$element
115 .removeClass('in')
116 .attr('aria-hidden', true)
117 .off('click.dismiss.bs.modal')
118
119 $.support.transition && this.$element.hasClass('fade') ?
120 this.$element
121 .one('bsTransitionEnd', $.proxy(this.hideModal, this))
122 .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
123 this.hideModal()
124 }
125
126 Modal.prototype.enforceFocus = function () {
127 $(document)
128 .off('focusin.bs.modal') // guard against infinite focus loop
129 .on('focusin.bs.modal', $.proxy(function (e) {
130 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
131 this.$element.trigger('focus')
132 }
133 }, this))
134 }
135
136 Modal.prototype.escape = function () {
137 if (this.isShown && this.options.keyboard) {
138 this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
139 e.which == 27 && this.hide()
140 }, this))
141 } else if (!this.isShown) {
142 this.$element.off('keydown.dismiss.bs.modal')
143 }
144 }
145
146 Modal.prototype.hideModal = function () {
147 var that = this
148 this.$element.hide()
149 this.backdrop(function () {
150 that.$body.removeClass('modal-open')
151 that.resetScrollbar()
152 that.$element.trigger('hidden.bs.modal')
153 })
154 }
155
156 Modal.prototype.removeBackdrop = function () {
157 this.$backdrop && this.$backdrop.remove()
158 this.$backdrop = null
159 }
160
161 Modal.prototype.backdrop = function (callback) {
162 var that = this
163 var animate = this.$element.hasClass('fade') ? 'fade' : ''
164
165 if (this.isShown && this.options.backdrop) {
166 var doAnimate = $.support.transition && animate
167
168 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
169 .prependTo(this.$element)
170 .on('click.dismiss.bs.modal', $.proxy(function (e) {
171 if (e.target !== e.currentTarget) return
172 this.options.backdrop == 'static'
173 ? this.$element[0].focus.call(this.$element[0])
174 : this.hide.call(this)
175 }, this))
176
177 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
178
179 this.$backdrop.addClass('in')
180
181 if (!callback) return
182
183 doAnimate ?
184 this.$backdrop
185 .one('bsTransitionEnd', callback)
186 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
187 callback()
188
189 } else if (!this.isShown && this.$backdrop) {
190 this.$backdrop.removeClass('in')
191
192 var callbackRemove = function () {
193 that.removeBackdrop()
194 callback && callback()
195 }
196 $.support.transition && this.$element.hasClass('fade') ?
197 this.$backdrop
198 .one('bsTransitionEnd', callbackRemove)
199 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
200 callbackRemove()
201
202 } else if (callback) {
203 callback()
204 }
205 }
206
207 Modal.prototype.checkScrollbar = function () {
208 this.scrollbarWidth = this.measureScrollbar()
209 }
210
211 Modal.prototype.setScrollbar = function () {
212 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
213 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
214 }
215
216 Modal.prototype.resetScrollbar = function () {
217 this.$body.css('padding-right', '')
218 }
219
220 Modal.prototype.measureScrollbar = function () { // thx walsh
221 if (document.body.clientWidth >= window.innerWidth) return 0
222 var scrollDiv = document.createElement('div')
223 scrollDiv.className = 'modal-scrollbar-measure'
224 this.$body.append(scrollDiv)
225 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
226 this.$body[0].removeChild(scrollDiv)
227 return scrollbarWidth
228 }
229
230
231 // MODAL PLUGIN DEFINITION
232 // =======================
233
234 function Plugin(option, _relatedTarget) {
235 return this.each(function () {
236 var $this = $(this)
237 var data = $this.data('bs.modal')
238 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
239
240 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
241 if (typeof option == 'string') data[option](_relatedTarget)
242 else if (options.show) data.show(_relatedTarget)
243 })
244 }
245
246 var old = $.fn.modal
247
248 $.fn.modal = Plugin
249 $.fn.modal.Constructor = Modal
250
251
252 // MODAL NO CONFLICT
253 // =================
254
255 $.fn.modal.noConflict = function () {
256 $.fn.modal = old
257 return this
258 }
259
260
261 // MODAL DATA-API
262 // ==============
263
264 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
265 var $this = $(this)
266 var href = $this.attr('href')
267 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
268 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
269
270 if ($this.is('a')) e.preventDefault()
271
272 $target.one('show.bs.modal', function (showEvent) {
273 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
274 $target.one('hidden.bs.modal', function () {
275 $this.is(':visible') && $this.trigger('focus')
276 })
277 })
278 Plugin.call($target, option, this)
279 })
280
281 }(jQuery);
282