| @@ 8906-9841 (lines=936) @@ | ||
| 8903 | * |
|
| 8904 | */ |
|
| 8905 | ||
| 8906 | ;(function ($, window, document, undefined) { |
|
| 8907 | ||
| 8908 | "use strict"; |
|
| 8909 | ||
| 8910 | window = (typeof window != 'undefined' && window.Math == Math) |
|
| 8911 | ? window |
|
| 8912 | : (typeof self != 'undefined' && self.Math == Math) |
|
| 8913 | ? self |
|
| 8914 | : Function('return this')() |
|
| 8915 | ; |
|
| 8916 | ||
| 8917 | $.fn.modal = function(parameters) { |
|
| 8918 | var |
|
| 8919 | $allModules = $(this), |
|
| 8920 | $window = $(window), |
|
| 8921 | $document = $(document), |
|
| 8922 | $body = $('body'), |
|
| 8923 | ||
| 8924 | moduleSelector = $allModules.selector || '', |
|
| 8925 | ||
| 8926 | time = new Date().getTime(), |
|
| 8927 | performance = [], |
|
| 8928 | ||
| 8929 | query = arguments[0], |
|
| 8930 | methodInvoked = (typeof query == 'string'), |
|
| 8931 | queryArguments = [].slice.call(arguments, 1), |
|
| 8932 | ||
| 8933 | requestAnimationFrame = window.requestAnimationFrame |
|
| 8934 | || window.mozRequestAnimationFrame |
|
| 8935 | || window.webkitRequestAnimationFrame |
|
| 8936 | || window.msRequestAnimationFrame |
|
| 8937 | || function(callback) { setTimeout(callback, 0); }, |
|
| 8938 | ||
| 8939 | returnedValue |
|
| 8940 | ; |
|
| 8941 | ||
| 8942 | $allModules |
|
| 8943 | .each(function() { |
|
| 8944 | var |
|
| 8945 | settings = ( $.isPlainObject(parameters) ) |
|
| 8946 | ? $.extend(true, {}, $.fn.modal.settings, parameters) |
|
| 8947 | : $.extend({}, $.fn.modal.settings), |
|
| 8948 | ||
| 8949 | selector = settings.selector, |
|
| 8950 | className = settings.className, |
|
| 8951 | namespace = settings.namespace, |
|
| 8952 | error = settings.error, |
|
| 8953 | ||
| 8954 | eventNamespace = '.' + namespace, |
|
| 8955 | moduleNamespace = 'module-' + namespace, |
|
| 8956 | ||
| 8957 | $module = $(this), |
|
| 8958 | $context = $(settings.context), |
|
| 8959 | $close = $module.find(selector.close), |
|
| 8960 | ||
| 8961 | $allModals, |
|
| 8962 | $otherModals, |
|
| 8963 | $focusedElement, |
|
| 8964 | $dimmable, |
|
| 8965 | $dimmer, |
|
| 8966 | ||
| 8967 | element = this, |
|
| 8968 | instance = $module.data(moduleNamespace), |
|
| 8969 | ||
| 8970 | ignoreRepeatedEvents = false, |
|
| 8971 | ||
| 8972 | elementEventNamespace, |
|
| 8973 | id, |
|
| 8974 | observer, |
|
| 8975 | module |
|
| 8976 | ; |
|
| 8977 | module = { |
|
| 8978 | ||
| 8979 | initialize: function() { |
|
| 8980 | module.verbose('Initializing dimmer', $context); |
|
| 8981 | ||
| 8982 | module.create.id(); |
|
| 8983 | module.create.dimmer(); |
|
| 8984 | module.refreshModals(); |
|
| 8985 | ||
| 8986 | module.bind.events(); |
|
| 8987 | if(settings.observeChanges) { |
|
| 8988 | module.observeChanges(); |
|
| 8989 | } |
|
| 8990 | module.instantiate(); |
|
| 8991 | }, |
|
| 8992 | ||
| 8993 | instantiate: function() { |
|
| 8994 | module.verbose('Storing instance of modal'); |
|
| 8995 | instance = module; |
|
| 8996 | $module |
|
| 8997 | .data(moduleNamespace, instance) |
|
| 8998 | ; |
|
| 8999 | }, |
|
| 9000 | ||
| 9001 | create: { |
|
| 9002 | dimmer: function() { |
|
| 9003 | var |
|
| 9004 | defaultSettings = { |
|
| 9005 | debug : settings.debug, |
|
| 9006 | dimmerName : 'modals' |
|
| 9007 | }, |
|
| 9008 | dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings) |
|
| 9009 | ; |
|
| 9010 | if($.fn.dimmer === undefined) { |
|
| 9011 | module.error(error.dimmer); |
|
| 9012 | return; |
|
| 9013 | } |
|
| 9014 | module.debug('Creating dimmer'); |
|
| 9015 | $dimmable = $context.dimmer(dimmerSettings); |
|
| 9016 | if(settings.detachable) { |
|
| 9017 | module.verbose('Modal is detachable, moving content into dimmer'); |
|
| 9018 | $dimmable.dimmer('add content', $module); |
|
| 9019 | } |
|
| 9020 | else { |
|
| 9021 | module.set.undetached(); |
|
| 9022 | } |
|
| 9023 | $dimmer = $dimmable.dimmer('get dimmer'); |
|
| 9024 | }, |
|
| 9025 | id: function() { |
|
| 9026 | id = (Math.random().toString(16) + '000000000').substr(2,8); |
|
| 9027 | elementEventNamespace = '.' + id; |
|
| 9028 | module.verbose('Creating unique id for element', id); |
|
| 9029 | } |
|
| 9030 | }, |
|
| 9031 | ||
| 9032 | destroy: function() { |
|
| 9033 | module.verbose('Destroying previous modal'); |
|
| 9034 | $module |
|
| 9035 | .removeData(moduleNamespace) |
|
| 9036 | .off(eventNamespace) |
|
| 9037 | ; |
|
| 9038 | $window.off(elementEventNamespace); |
|
| 9039 | $dimmer.off(elementEventNamespace); |
|
| 9040 | $close.off(eventNamespace); |
|
| 9041 | $context.dimmer('destroy'); |
|
| 9042 | }, |
|
| 9043 | ||
| 9044 | observeChanges: function() { |
|
| 9045 | if('MutationObserver' in window) { |
|
| 9046 | observer = new MutationObserver(function(mutations) { |
|
| 9047 | module.debug('DOM tree modified, refreshing'); |
|
| 9048 | module.refresh(); |
|
| 9049 | }); |
|
| 9050 | observer.observe(element, { |
|
| 9051 | childList : true, |
|
| 9052 | subtree : true |
|
| 9053 | }); |
|
| 9054 | module.debug('Setting up mutation observer', observer); |
|
| 9055 | } |
|
| 9056 | }, |
|
| 9057 | ||
| 9058 | refresh: function() { |
|
| 9059 | module.remove.scrolling(); |
|
| 9060 | module.cacheSizes(); |
|
| 9061 | module.set.screenHeight(); |
|
| 9062 | module.set.type(); |
|
| 9063 | module.set.position(); |
|
| 9064 | }, |
|
| 9065 | ||
| 9066 | refreshModals: function() { |
|
| 9067 | $otherModals = $module.siblings(selector.modal); |
|
| 9068 | $allModals = $otherModals.add($module); |
|
| 9069 | }, |
|
| 9070 | ||
| 9071 | attachEvents: function(selector, event) { |
|
| 9072 | var |
|
| 9073 | $toggle = $(selector) |
|
| 9074 | ; |
|
| 9075 | event = $.isFunction(module[event]) |
|
| 9076 | ? module[event] |
|
| 9077 | : module.toggle |
|
| 9078 | ; |
|
| 9079 | if($toggle.length > 0) { |
|
| 9080 | module.debug('Attaching modal events to element', selector, event); |
|
| 9081 | $toggle |
|
| 9082 | .off(eventNamespace) |
|
| 9083 | .on('click' + eventNamespace, event) |
|
| 9084 | ; |
|
| 9085 | } |
|
| 9086 | else { |
|
| 9087 | module.error(error.notFound, selector); |
|
| 9088 | } |
|
| 9089 | }, |
|
| 9090 | ||
| 9091 | bind: { |
|
| 9092 | events: function() { |
|
| 9093 | module.verbose('Attaching events'); |
|
| 9094 | $module |
|
| 9095 | .on('click' + eventNamespace, selector.close, module.event.close) |
|
| 9096 | .on('click' + eventNamespace, selector.approve, module.event.approve) |
|
| 9097 | .on('click' + eventNamespace, selector.deny, module.event.deny) |
|
| 9098 | ; |
|
| 9099 | $window |
|
| 9100 | .on('resize' + elementEventNamespace, module.event.resize) |
|
| 9101 | ; |
|
| 9102 | } |
|
| 9103 | }, |
|
| 9104 | ||
| 9105 | get: { |
|
| 9106 | id: function() { |
|
| 9107 | return (Math.random().toString(16) + '000000000').substr(2,8); |
|
| 9108 | } |
|
| 9109 | }, |
|
| 9110 | ||
| 9111 | event: { |
|
| 9112 | approve: function() { |
|
| 9113 | if(ignoreRepeatedEvents || settings.onApprove.call(element, $(this)) === false) { |
|
| 9114 | module.verbose('Approve callback returned false cancelling hide'); |
|
| 9115 | return; |
|
| 9116 | } |
|
| 9117 | ignoreRepeatedEvents = true; |
|
| 9118 | module.hide(function() { |
|
| 9119 | ignoreRepeatedEvents = false; |
|
| 9120 | }); |
|
| 9121 | }, |
|
| 9122 | deny: function() { |
|
| 9123 | if(ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) { |
|
| 9124 | module.verbose('Deny callback returned false cancelling hide'); |
|
| 9125 | return; |
|
| 9126 | } |
|
| 9127 | ignoreRepeatedEvents = true; |
|
| 9128 | module.hide(function() { |
|
| 9129 | ignoreRepeatedEvents = false; |
|
| 9130 | }); |
|
| 9131 | }, |
|
| 9132 | close: function() { |
|
| 9133 | module.hide(); |
|
| 9134 | }, |
|
| 9135 | click: function(event) { |
|
| 9136 | var |
|
| 9137 | $target = $(event.target), |
|
| 9138 | isInModal = ($target.closest(selector.modal).length > 0), |
|
| 9139 | isInDOM = $.contains(document.documentElement, event.target) |
|
| 9140 | ; |
|
| 9141 | if(!isInModal && isInDOM) { |
|
| 9142 | module.debug('Dimmer clicked, hiding all modals'); |
|
| 9143 | if( module.is.active() ) { |
|
| 9144 | module.remove.clickaway(); |
|
| 9145 | if(settings.allowMultiple) { |
|
| 9146 | module.hide(); |
|
| 9147 | } |
|
| 9148 | else { |
|
| 9149 | module.hideAll(); |
|
| 9150 | } |
|
| 9151 | } |
|
| 9152 | } |
|
| 9153 | }, |
|
| 9154 | debounce: function(method, delay) { |
|
| 9155 | clearTimeout(module.timer); |
|
| 9156 | module.timer = setTimeout(method, delay); |
|
| 9157 | }, |
|
| 9158 | keyboard: function(event) { |
|
| 9159 | var |
|
| 9160 | keyCode = event.which, |
|
| 9161 | escapeKey = 27 |
|
| 9162 | ; |
|
| 9163 | if(keyCode == escapeKey) { |
|
| 9164 | if(settings.closable) { |
|
| 9165 | module.debug('Escape key pressed hiding modal'); |
|
| 9166 | module.hide(); |
|
| 9167 | } |
|
| 9168 | else { |
|
| 9169 | module.debug('Escape key pressed, but closable is set to false'); |
|
| 9170 | } |
|
| 9171 | event.preventDefault(); |
|
| 9172 | } |
|
| 9173 | }, |
|
| 9174 | resize: function() { |
|
| 9175 | if( $dimmable.dimmer('is active') && ( module.is.animating() || module.is.active() ) ) { |
|
| 9176 | requestAnimationFrame(module.refresh); |
|
| 9177 | } |
|
| 9178 | } |
|
| 9179 | }, |
|
| 9180 | ||
| 9181 | toggle: function() { |
|
| 9182 | if( module.is.active() || module.is.animating() ) { |
|
| 9183 | module.hide(); |
|
| 9184 | } |
|
| 9185 | else { |
|
| 9186 | module.show(); |
|
| 9187 | } |
|
| 9188 | }, |
|
| 9189 | ||
| 9190 | show: function(callback) { |
|
| 9191 | callback = $.isFunction(callback) |
|
| 9192 | ? callback |
|
| 9193 | : function(){} |
|
| 9194 | ; |
|
| 9195 | module.refreshModals(); |
|
| 9196 | module.set.dimmerSettings(); |
|
| 9197 | module.showModal(callback); |
|
| 9198 | }, |
|
| 9199 | ||
| 9200 | hide: function(callback) { |
|
| 9201 | callback = $.isFunction(callback) |
|
| 9202 | ? callback |
|
| 9203 | : function(){} |
|
| 9204 | ; |
|
| 9205 | module.refreshModals(); |
|
| 9206 | module.hideModal(callback); |
|
| 9207 | }, |
|
| 9208 | ||
| 9209 | showModal: function(callback) { |
|
| 9210 | callback = $.isFunction(callback) |
|
| 9211 | ? callback |
|
| 9212 | : function(){} |
|
| 9213 | ; |
|
| 9214 | if( module.is.animating() || !module.is.active() ) { |
|
| 9215 | ||
| 9216 | module.showDimmer(); |
|
| 9217 | module.cacheSizes(); |
|
| 9218 | module.set.position(); |
|
| 9219 | module.set.screenHeight(); |
|
| 9220 | module.set.type(); |
|
| 9221 | module.set.clickaway(); |
|
| 9222 | ||
| 9223 | if( !settings.allowMultiple && module.others.active() ) { |
|
| 9224 | module.hideOthers(module.showModal); |
|
| 9225 | } |
|
| 9226 | else { |
|
| 9227 | settings.onShow.call(element); |
|
| 9228 | if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { |
|
| 9229 | module.debug('Showing modal with css animations'); |
|
| 9230 | $module |
|
| 9231 | .transition({ |
|
| 9232 | debug : settings.debug, |
|
| 9233 | animation : settings.transition + ' in', |
|
| 9234 | queue : settings.queue, |
|
| 9235 | duration : settings.duration, |
|
| 9236 | useFailSafe : true, |
|
| 9237 | onComplete : function() { |
|
| 9238 | settings.onVisible.apply(element); |
|
| 9239 | if(settings.keyboardShortcuts) { |
|
| 9240 | module.add.keyboardShortcuts(); |
|
| 9241 | } |
|
| 9242 | module.save.focus(); |
|
| 9243 | module.set.active(); |
|
| 9244 | if(settings.autofocus) { |
|
| 9245 | module.set.autofocus(); |
|
| 9246 | } |
|
| 9247 | callback(); |
|
| 9248 | } |
|
| 9249 | }) |
|
| 9250 | ; |
|
| 9251 | } |
|
| 9252 | else { |
|
| 9253 | module.error(error.noTransition); |
|
| 9254 | } |
|
| 9255 | } |
|
| 9256 | } |
|
| 9257 | else { |
|
| 9258 | module.debug('Modal is already visible'); |
|
| 9259 | } |
|
| 9260 | }, |
|
| 9261 | ||
| 9262 | hideModal: function(callback, keepDimmed) { |
|
| 9263 | callback = $.isFunction(callback) |
|
| 9264 | ? callback |
|
| 9265 | : function(){} |
|
| 9266 | ; |
|
| 9267 | module.debug('Hiding modal'); |
|
| 9268 | if(settings.onHide.call(element, $(this)) === false) { |
|
| 9269 | module.verbose('Hide callback returned false cancelling hide'); |
|
| 9270 | return; |
|
| 9271 | } |
|
| 9272 | ||
| 9273 | if( module.is.animating() || module.is.active() ) { |
|
| 9274 | if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { |
|
| 9275 | module.remove.active(); |
|
| 9276 | $module |
|
| 9277 | .transition({ |
|
| 9278 | debug : settings.debug, |
|
| 9279 | animation : settings.transition + ' out', |
|
| 9280 | queue : settings.queue, |
|
| 9281 | duration : settings.duration, |
|
| 9282 | useFailSafe : true, |
|
| 9283 | onStart : function() { |
|
| 9284 | if(!module.others.active() && !keepDimmed) { |
|
| 9285 | module.hideDimmer(); |
|
| 9286 | } |
|
| 9287 | if(settings.keyboardShortcuts) { |
|
| 9288 | module.remove.keyboardShortcuts(); |
|
| 9289 | } |
|
| 9290 | }, |
|
| 9291 | onComplete : function() { |
|
| 9292 | settings.onHidden.call(element); |
|
| 9293 | module.restore.focus(); |
|
| 9294 | callback(); |
|
| 9295 | } |
|
| 9296 | }) |
|
| 9297 | ; |
|
| 9298 | } |
|
| 9299 | else { |
|
| 9300 | module.error(error.noTransition); |
|
| 9301 | } |
|
| 9302 | } |
|
| 9303 | }, |
|
| 9304 | ||
| 9305 | showDimmer: function() { |
|
| 9306 | if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) { |
|
| 9307 | module.debug('Showing dimmer'); |
|
| 9308 | $dimmable.dimmer('show'); |
|
| 9309 | } |
|
| 9310 | else { |
|
| 9311 | module.debug('Dimmer already visible'); |
|
| 9312 | } |
|
| 9313 | }, |
|
| 9314 | ||
| 9315 | hideDimmer: function() { |
|
| 9316 | if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) { |
|
| 9317 | $dimmable.dimmer('hide', function() { |
|
| 9318 | module.remove.clickaway(); |
|
| 9319 | module.remove.screenHeight(); |
|
| 9320 | }); |
|
| 9321 | } |
|
| 9322 | else { |
|
| 9323 | module.debug('Dimmer is not visible cannot hide'); |
|
| 9324 | return; |
|
| 9325 | } |
|
| 9326 | }, |
|
| 9327 | ||
| 9328 | hideAll: function(callback) { |
|
| 9329 | var |
|
| 9330 | $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating) |
|
| 9331 | ; |
|
| 9332 | callback = $.isFunction(callback) |
|
| 9333 | ? callback |
|
| 9334 | : function(){} |
|
| 9335 | ; |
|
| 9336 | if( $visibleModals.length > 0 ) { |
|
| 9337 | module.debug('Hiding all visible modals'); |
|
| 9338 | module.hideDimmer(); |
|
| 9339 | $visibleModals |
|
| 9340 | .modal('hide modal', callback) |
|
| 9341 | ; |
|
| 9342 | } |
|
| 9343 | }, |
|
| 9344 | ||
| 9345 | hideOthers: function(callback) { |
|
| 9346 | var |
|
| 9347 | $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating) |
|
| 9348 | ; |
|
| 9349 | callback = $.isFunction(callback) |
|
| 9350 | ? callback |
|
| 9351 | : function(){} |
|
| 9352 | ; |
|
| 9353 | if( $visibleModals.length > 0 ) { |
|
| 9354 | module.debug('Hiding other modals', $otherModals); |
|
| 9355 | $visibleModals |
|
| 9356 | .modal('hide modal', callback, true) |
|
| 9357 | ; |
|
| 9358 | } |
|
| 9359 | }, |
|
| 9360 | ||
| 9361 | others: { |
|
| 9362 | active: function() { |
|
| 9363 | return ($otherModals.filter('.' + className.active).length > 0); |
|
| 9364 | }, |
|
| 9365 | animating: function() { |
|
| 9366 | return ($otherModals.filter('.' + className.animating).length > 0); |
|
| 9367 | } |
|
| 9368 | }, |
|
| 9369 | ||
| 9370 | ||
| 9371 | add: { |
|
| 9372 | keyboardShortcuts: function() { |
|
| 9373 | module.verbose('Adding keyboard shortcuts'); |
|
| 9374 | $document |
|
| 9375 | .on('keyup' + eventNamespace, module.event.keyboard) |
|
| 9376 | ; |
|
| 9377 | } |
|
| 9378 | }, |
|
| 9379 | ||
| 9380 | save: { |
|
| 9381 | focus: function() { |
|
| 9382 | $focusedElement = $(document.activeElement).blur(); |
|
| 9383 | } |
|
| 9384 | }, |
|
| 9385 | ||
| 9386 | restore: { |
|
| 9387 | focus: function() { |
|
| 9388 | if($focusedElement && $focusedElement.length > 0) { |
|
| 9389 | $focusedElement.focus(); |
|
| 9390 | } |
|
| 9391 | } |
|
| 9392 | }, |
|
| 9393 | ||
| 9394 | remove: { |
|
| 9395 | active: function() { |
|
| 9396 | $module.removeClass(className.active); |
|
| 9397 | }, |
|
| 9398 | clickaway: function() { |
|
| 9399 | if(settings.closable) { |
|
| 9400 | $dimmer |
|
| 9401 | .off('click' + elementEventNamespace) |
|
| 9402 | ; |
|
| 9403 | } |
|
| 9404 | }, |
|
| 9405 | bodyStyle: function() { |
|
| 9406 | if($body.attr('style') === '') { |
|
| 9407 | module.verbose('Removing style attribute'); |
|
| 9408 | $body.removeAttr('style'); |
|
| 9409 | } |
|
| 9410 | }, |
|
| 9411 | screenHeight: function() { |
|
| 9412 | module.debug('Removing page height'); |
|
| 9413 | $body |
|
| 9414 | .css('height', '') |
|
| 9415 | ; |
|
| 9416 | }, |
|
| 9417 | keyboardShortcuts: function() { |
|
| 9418 | module.verbose('Removing keyboard shortcuts'); |
|
| 9419 | $document |
|
| 9420 | .off('keyup' + eventNamespace) |
|
| 9421 | ; |
|
| 9422 | }, |
|
| 9423 | scrolling: function() { |
|
| 9424 | $dimmable.removeClass(className.scrolling); |
|
| 9425 | $module.removeClass(className.scrolling); |
|
| 9426 | } |
|
| 9427 | }, |
|
| 9428 | ||
| 9429 | cacheSizes: function() { |
|
| 9430 | var |
|
| 9431 | modalHeight = $module.outerHeight() |
|
| 9432 | ; |
|
| 9433 | if(module.cache === undefined || modalHeight !== 0) { |
|
| 9434 | module.cache = { |
|
| 9435 | pageHeight : $(document).outerHeight(), |
|
| 9436 | height : modalHeight + settings.offset, |
|
| 9437 | contextHeight : (settings.context == 'body') |
|
| 9438 | ? $(window).height() |
|
| 9439 | : $dimmable.height() |
|
| 9440 | }; |
|
| 9441 | } |
|
| 9442 | module.debug('Caching modal and container sizes', module.cache); |
|
| 9443 | }, |
|
| 9444 | ||
| 9445 | can: { |
|
| 9446 | fit: function() { |
|
| 9447 | return ( ( module.cache.height + (settings.padding * 2) ) < module.cache.contextHeight); |
|
| 9448 | } |
|
| 9449 | }, |
|
| 9450 | ||
| 9451 | is: { |
|
| 9452 | active: function() { |
|
| 9453 | return $module.hasClass(className.active); |
|
| 9454 | }, |
|
| 9455 | animating: function() { |
|
| 9456 | return $module.transition('is supported') |
|
| 9457 | ? $module.transition('is animating') |
|
| 9458 | : $module.is(':visible') |
|
| 9459 | ; |
|
| 9460 | }, |
|
| 9461 | scrolling: function() { |
|
| 9462 | return $dimmable.hasClass(className.scrolling); |
|
| 9463 | }, |
|
| 9464 | modernBrowser: function() { |
|
| 9465 | // appName for IE11 reports 'Netscape' can no longer use |
|
| 9466 | return !(window.ActiveXObject || "ActiveXObject" in window); |
|
| 9467 | } |
|
| 9468 | }, |
|
| 9469 | ||
| 9470 | set: { |
|
| 9471 | autofocus: function() { |
|
| 9472 | var |
|
| 9473 | $inputs = $module.find('[tabindex], :input').filter(':visible'), |
|
| 9474 | $autofocus = $inputs.filter('[autofocus]'), |
|
| 9475 | $input = ($autofocus.length > 0) |
|
| 9476 | ? $autofocus.first() |
|
| 9477 | : $inputs.first() |
|
| 9478 | ; |
|
| 9479 | if($input.length > 0) { |
|
| 9480 | $input.focus(); |
|
| 9481 | } |
|
| 9482 | }, |
|
| 9483 | clickaway: function() { |
|
| 9484 | if(settings.closable) { |
|
| 9485 | $dimmer |
|
| 9486 | .on('click' + elementEventNamespace, module.event.click) |
|
| 9487 | ; |
|
| 9488 | } |
|
| 9489 | }, |
|
| 9490 | dimmerSettings: function() { |
|
| 9491 | if($.fn.dimmer === undefined) { |
|
| 9492 | module.error(error.dimmer); |
|
| 9493 | return; |
|
| 9494 | } |
|
| 9495 | var |
|
| 9496 | defaultSettings = { |
|
| 9497 | debug : settings.debug, |
|
| 9498 | dimmerName : 'modals', |
|
| 9499 | variation : false, |
|
| 9500 | closable : 'auto', |
|
| 9501 | duration : { |
|
| 9502 | show : settings.duration, |
|
| 9503 | hide : settings.duration |
|
| 9504 | } |
|
| 9505 | }, |
|
| 9506 | dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings) |
|
| 9507 | ; |
|
| 9508 | if(settings.inverted) { |
|
| 9509 | dimmerSettings.variation = (dimmerSettings.variation !== undefined) |
|
| 9510 | ? dimmerSettings.variation + ' inverted' |
|
| 9511 | : 'inverted' |
|
| 9512 | ; |
|
| 9513 | $dimmer.addClass(className.inverted); |
|
| 9514 | } |
|
| 9515 | else { |
|
| 9516 | $dimmer.removeClass(className.inverted); |
|
| 9517 | } |
|
| 9518 | if(settings.blurring) { |
|
| 9519 | $dimmable.addClass(className.blurring); |
|
| 9520 | } |
|
| 9521 | else { |
|
| 9522 | $dimmable.removeClass(className.blurring); |
|
| 9523 | } |
|
| 9524 | $context.dimmer('setting', dimmerSettings); |
|
| 9525 | }, |
|
| 9526 | screenHeight: function() { |
|
| 9527 | if( module.can.fit() ) { |
|
| 9528 | $body.css('height', ''); |
|
| 9529 | } |
|
| 9530 | else { |
|
| 9531 | module.debug('Modal is taller than page content, resizing page height'); |
|
| 9532 | $body |
|
| 9533 | .css('height', module.cache.height + (settings.padding * 2) ) |
|
| 9534 | ; |
|
| 9535 | } |
|
| 9536 | }, |
|
| 9537 | active: function() { |
|
| 9538 | $module.addClass(className.active); |
|
| 9539 | }, |
|
| 9540 | scrolling: function() { |
|
| 9541 | $dimmable.addClass(className.scrolling); |
|
| 9542 | $module.addClass(className.scrolling); |
|
| 9543 | }, |
|
| 9544 | type: function() { |
|
| 9545 | if(module.can.fit()) { |
|
| 9546 | module.verbose('Modal fits on screen'); |
|
| 9547 | if(!module.others.active() && !module.others.animating()) { |
|
| 9548 | module.remove.scrolling(); |
|
| 9549 | } |
|
| 9550 | } |
|
| 9551 | else { |
|
| 9552 | module.verbose('Modal cannot fit on screen setting to scrolling'); |
|
| 9553 | module.set.scrolling(); |
|
| 9554 | } |
|
| 9555 | }, |
|
| 9556 | position: function() { |
|
| 9557 | module.verbose('Centering modal on page', module.cache); |
|
| 9558 | if(module.can.fit()) { |
|
| 9559 | $module |
|
| 9560 | .css({ |
|
| 9561 | top: '', |
|
| 9562 | marginTop: -(module.cache.height / 2) |
|
| 9563 | }) |
|
| 9564 | ; |
|
| 9565 | } |
|
| 9566 | else { |
|
| 9567 | $module |
|
| 9568 | .css({ |
|
| 9569 | marginTop : '', |
|
| 9570 | top : $document.scrollTop() |
|
| 9571 | }) |
|
| 9572 | ; |
|
| 9573 | } |
|
| 9574 | }, |
|
| 9575 | undetached: function() { |
|
| 9576 | $dimmable.addClass(className.undetached); |
|
| 9577 | } |
|
| 9578 | }, |
|
| 9579 | ||
| 9580 | setting: function(name, value) { |
|
| 9581 | module.debug('Changing setting', name, value); |
|
| 9582 | if( $.isPlainObject(name) ) { |
|
| 9583 | $.extend(true, settings, name); |
|
| 9584 | } |
|
| 9585 | else if(value !== undefined) { |
|
| 9586 | if($.isPlainObject(settings[name])) { |
|
| 9587 | $.extend(true, settings[name], value); |
|
| 9588 | } |
|
| 9589 | else { |
|
| 9590 | settings[name] = value; |
|
| 9591 | } |
|
| 9592 | } |
|
| 9593 | else { |
|
| 9594 | return settings[name]; |
|
| 9595 | } |
|
| 9596 | }, |
|
| 9597 | internal: function(name, value) { |
|
| 9598 | if( $.isPlainObject(name) ) { |
|
| 9599 | $.extend(true, module, name); |
|
| 9600 | } |
|
| 9601 | else if(value !== undefined) { |
|
| 9602 | module[name] = value; |
|
| 9603 | } |
|
| 9604 | else { |
|
| 9605 | return module[name]; |
|
| 9606 | } |
|
| 9607 | }, |
|
| 9608 | debug: function() { |
|
| 9609 | if(!settings.silent && settings.debug) { |
|
| 9610 | if(settings.performance) { |
|
| 9611 | module.performance.log(arguments); |
|
| 9612 | } |
|
| 9613 | else { |
|
| 9614 | module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
| 9615 | module.debug.apply(console, arguments); |
|
| 9616 | } |
|
| 9617 | } |
|
| 9618 | }, |
|
| 9619 | verbose: function() { |
|
| 9620 | if(!settings.silent && settings.verbose && settings.debug) { |
|
| 9621 | if(settings.performance) { |
|
| 9622 | module.performance.log(arguments); |
|
| 9623 | } |
|
| 9624 | else { |
|
| 9625 | module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
| 9626 | module.verbose.apply(console, arguments); |
|
| 9627 | } |
|
| 9628 | } |
|
| 9629 | }, |
|
| 9630 | error: function() { |
|
| 9631 | if(!settings.silent) { |
|
| 9632 | module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); |
|
| 9633 | module.error.apply(console, arguments); |
|
| 9634 | } |
|
| 9635 | }, |
|
| 9636 | performance: { |
|
| 9637 | log: function(message) { |
|
| 9638 | var |
|
| 9639 | currentTime, |
|
| 9640 | executionTime, |
|
| 9641 | previousTime |
|
| 9642 | ; |
|
| 9643 | if(settings.performance) { |
|
| 9644 | currentTime = new Date().getTime(); |
|
| 9645 | previousTime = time || currentTime; |
|
| 9646 | executionTime = currentTime - previousTime; |
|
| 9647 | time = currentTime; |
|
| 9648 | performance.push({ |
|
| 9649 | 'Name' : message[0], |
|
| 9650 | 'Arguments' : [].slice.call(message, 1) || '', |
|
| 9651 | 'Element' : element, |
|
| 9652 | 'Execution Time' : executionTime |
|
| 9653 | }); |
|
| 9654 | } |
|
| 9655 | clearTimeout(module.performance.timer); |
|
| 9656 | module.performance.timer = setTimeout(module.performance.display, 500); |
|
| 9657 | }, |
|
| 9658 | display: function() { |
|
| 9659 | var |
|
| 9660 | title = settings.name + ':', |
|
| 9661 | totalTime = 0 |
|
| 9662 | ; |
|
| 9663 | time = false; |
|
| 9664 | clearTimeout(module.performance.timer); |
|
| 9665 | $.each(performance, function(index, data) { |
|
| 9666 | totalTime += data['Execution Time']; |
|
| 9667 | }); |
|
| 9668 | title += ' ' + totalTime + 'ms'; |
|
| 9669 | if(moduleSelector) { |
|
| 9670 | title += ' \'' + moduleSelector + '\''; |
|
| 9671 | } |
|
| 9672 | if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { |
|
| 9673 | console.groupCollapsed(title); |
|
| 9674 | if(console.table) { |
|
| 9675 | console.table(performance); |
|
| 9676 | } |
|
| 9677 | else { |
|
| 9678 | $.each(performance, function(index, data) { |
|
| 9679 | console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); |
|
| 9680 | }); |
|
| 9681 | } |
|
| 9682 | console.groupEnd(); |
|
| 9683 | } |
|
| 9684 | performance = []; |
|
| 9685 | } |
|
| 9686 | }, |
|
| 9687 | invoke: function(query, passedArguments, context) { |
|
| 9688 | var |
|
| 9689 | object = instance, |
|
| 9690 | maxDepth, |
|
| 9691 | found, |
|
| 9692 | response |
|
| 9693 | ; |
|
| 9694 | passedArguments = passedArguments || queryArguments; |
|
| 9695 | context = element || context; |
|
| 9696 | if(typeof query == 'string' && object !== undefined) { |
|
| 9697 | query = query.split(/[\. ]/); |
|
| 9698 | maxDepth = query.length - 1; |
|
| 9699 | $.each(query, function(depth, value) { |
|
| 9700 | var camelCaseValue = (depth != maxDepth) |
|
| 9701 | ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) |
|
| 9702 | : query |
|
| 9703 | ; |
|
| 9704 | if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { |
|
| 9705 | object = object[camelCaseValue]; |
|
| 9706 | } |
|
| 9707 | else if( object[camelCaseValue] !== undefined ) { |
|
| 9708 | found = object[camelCaseValue]; |
|
| 9709 | return false; |
|
| 9710 | } |
|
| 9711 | else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { |
|
| 9712 | object = object[value]; |
|
| 9713 | } |
|
| 9714 | else if( object[value] !== undefined ) { |
|
| 9715 | found = object[value]; |
|
| 9716 | return false; |
|
| 9717 | } |
|
| 9718 | else { |
|
| 9719 | return false; |
|
| 9720 | } |
|
| 9721 | }); |
|
| 9722 | } |
|
| 9723 | if ( $.isFunction( found ) ) { |
|
| 9724 | response = found.apply(context, passedArguments); |
|
| 9725 | } |
|
| 9726 | else if(found !== undefined) { |
|
| 9727 | response = found; |
|
| 9728 | } |
|
| 9729 | if($.isArray(returnedValue)) { |
|
| 9730 | returnedValue.push(response); |
|
| 9731 | } |
|
| 9732 | else if(returnedValue !== undefined) { |
|
| 9733 | returnedValue = [returnedValue, response]; |
|
| 9734 | } |
|
| 9735 | else if(response !== undefined) { |
|
| 9736 | returnedValue = response; |
|
| 9737 | } |
|
| 9738 | return found; |
|
| 9739 | } |
|
| 9740 | }; |
|
| 9741 | ||
| 9742 | if(methodInvoked) { |
|
| 9743 | if(instance === undefined) { |
|
| 9744 | module.initialize(); |
|
| 9745 | } |
|
| 9746 | module.invoke(query); |
|
| 9747 | } |
|
| 9748 | else { |
|
| 9749 | if(instance !== undefined) { |
|
| 9750 | instance.invoke('destroy'); |
|
| 9751 | } |
|
| 9752 | module.initialize(); |
|
| 9753 | } |
|
| 9754 | }) |
|
| 9755 | ; |
|
| 9756 | ||
| 9757 | return (returnedValue !== undefined) |
|
| 9758 | ? returnedValue |
|
| 9759 | : this |
|
| 9760 | ; |
|
| 9761 | }; |
|
| 9762 | ||
| 9763 | $.fn.modal.settings = { |
|
| 9764 | ||
| 9765 | name : 'Modal', |
|
| 9766 | namespace : 'modal', |
|
| 9767 | ||
| 9768 | silent : false, |
|
| 9769 | debug : false, |
|
| 9770 | verbose : false, |
|
| 9771 | performance : true, |
|
| 9772 | ||
| 9773 | observeChanges : false, |
|
| 9774 | ||
| 9775 | allowMultiple : false, |
|
| 9776 | detachable : true, |
|
| 9777 | closable : true, |
|
| 9778 | autofocus : true, |
|
| 9779 | ||
| 9780 | inverted : false, |
|
| 9781 | blurring : false, |
|
| 9782 | ||
| 9783 | dimmerSettings : { |
|
| 9784 | closable : false, |
|
| 9785 | useCSS : true |
|
| 9786 | }, |
|
| 9787 | ||
| 9788 | // whether to use keyboard shortcuts |
|
| 9789 | keyboardShortcuts: true, |
|
| 9790 | ||
| 9791 | context : 'body', |
|
| 9792 | ||
| 9793 | queue : false, |
|
| 9794 | duration : 500, |
|
| 9795 | offset : 0, |
|
| 9796 | transition : 'scale', |
|
| 9797 | ||
| 9798 | // padding with edge of page |
|
| 9799 | padding : 50, |
|
| 9800 | ||
| 9801 | // called before show animation |
|
| 9802 | onShow : function(){}, |
|
| 9803 | ||
| 9804 | // called after show animation |
|
| 9805 | onVisible : function(){}, |
|
| 9806 | ||
| 9807 | // called before hide animation |
|
| 9808 | onHide : function(){ return true; }, |
|
| 9809 | ||
| 9810 | // called after hide animation |
|
| 9811 | onHidden : function(){}, |
|
| 9812 | ||
| 9813 | // called after approve selector match |
|
| 9814 | onApprove : function(){ return true; }, |
|
| 9815 | ||
| 9816 | // called after deny selector match |
|
| 9817 | onDeny : function(){ return true; }, |
|
| 9818 | ||
| 9819 | selector : { |
|
| 9820 | close : '> .close', |
|
| 9821 | approve : '.actions .positive, .actions .approve, .actions .ok', |
|
| 9822 | deny : '.actions .negative, .actions .deny, .actions .cancel', |
|
| 9823 | modal : '.ui.modal' |
|
| 9824 | }, |
|
| 9825 | error : { |
|
| 9826 | dimmer : 'UI Dimmer, a required component is not included in this page', |
|
| 9827 | method : 'The method you called is not defined.', |
|
| 9828 | notFound : 'The element you specified could not be found' |
|
| 9829 | }, |
|
| 9830 | className : { |
|
| 9831 | active : 'active', |
|
| 9832 | animating : 'animating', |
|
| 9833 | blurring : 'blurring', |
|
| 9834 | inverted : 'inverted', |
|
| 9835 | scrolling : 'scrolling', |
|
| 9836 | undetached : 'undetached' |
|
| 9837 | } |
|
| 9838 | }; |
|
| 9839 | ||
| 9840 | ||
| 9841 | })( jQuery, window, document ); |
|
| 9842 | ||
| 9843 | /*! |
|
| 9844 | * # Semantic UI 2.2.11 - Nag |
|
| @@ 11-946 (lines=936) @@ | ||
| 8 | * |
|
| 9 | */ |
|
| 10 | ||
| 11 | ;(function ($, window, document, undefined) { |
|
| 12 | ||
| 13 | "use strict"; |
|
| 14 | ||
| 15 | window = (typeof window != 'undefined' && window.Math == Math) |
|
| 16 | ? window |
|
| 17 | : (typeof self != 'undefined' && self.Math == Math) |
|
| 18 | ? self |
|
| 19 | : Function('return this')() |
|
| 20 | ; |
|
| 21 | ||
| 22 | $.fn.modal = function(parameters) { |
|
| 23 | var |
|
| 24 | $allModules = $(this), |
|
| 25 | $window = $(window), |
|
| 26 | $document = $(document), |
|
| 27 | $body = $('body'), |
|
| 28 | ||
| 29 | moduleSelector = $allModules.selector || '', |
|
| 30 | ||
| 31 | time = new Date().getTime(), |
|
| 32 | performance = [], |
|
| 33 | ||
| 34 | query = arguments[0], |
|
| 35 | methodInvoked = (typeof query == 'string'), |
|
| 36 | queryArguments = [].slice.call(arguments, 1), |
|
| 37 | ||
| 38 | requestAnimationFrame = window.requestAnimationFrame |
|
| 39 | || window.mozRequestAnimationFrame |
|
| 40 | || window.webkitRequestAnimationFrame |
|
| 41 | || window.msRequestAnimationFrame |
|
| 42 | || function(callback) { setTimeout(callback, 0); }, |
|
| 43 | ||
| 44 | returnedValue |
|
| 45 | ; |
|
| 46 | ||
| 47 | $allModules |
|
| 48 | .each(function() { |
|
| 49 | var |
|
| 50 | settings = ( $.isPlainObject(parameters) ) |
|
| 51 | ? $.extend(true, {}, $.fn.modal.settings, parameters) |
|
| 52 | : $.extend({}, $.fn.modal.settings), |
|
| 53 | ||
| 54 | selector = settings.selector, |
|
| 55 | className = settings.className, |
|
| 56 | namespace = settings.namespace, |
|
| 57 | error = settings.error, |
|
| 58 | ||
| 59 | eventNamespace = '.' + namespace, |
|
| 60 | moduleNamespace = 'module-' + namespace, |
|
| 61 | ||
| 62 | $module = $(this), |
|
| 63 | $context = $(settings.context), |
|
| 64 | $close = $module.find(selector.close), |
|
| 65 | ||
| 66 | $allModals, |
|
| 67 | $otherModals, |
|
| 68 | $focusedElement, |
|
| 69 | $dimmable, |
|
| 70 | $dimmer, |
|
| 71 | ||
| 72 | element = this, |
|
| 73 | instance = $module.data(moduleNamespace), |
|
| 74 | ||
| 75 | ignoreRepeatedEvents = false, |
|
| 76 | ||
| 77 | elementEventNamespace, |
|
| 78 | id, |
|
| 79 | observer, |
|
| 80 | module |
|
| 81 | ; |
|
| 82 | module = { |
|
| 83 | ||
| 84 | initialize: function() { |
|
| 85 | module.verbose('Initializing dimmer', $context); |
|
| 86 | ||
| 87 | module.create.id(); |
|
| 88 | module.create.dimmer(); |
|
| 89 | module.refreshModals(); |
|
| 90 | ||
| 91 | module.bind.events(); |
|
| 92 | if(settings.observeChanges) { |
|
| 93 | module.observeChanges(); |
|
| 94 | } |
|
| 95 | module.instantiate(); |
|
| 96 | }, |
|
| 97 | ||
| 98 | instantiate: function() { |
|
| 99 | module.verbose('Storing instance of modal'); |
|
| 100 | instance = module; |
|
| 101 | $module |
|
| 102 | .data(moduleNamespace, instance) |
|
| 103 | ; |
|
| 104 | }, |
|
| 105 | ||
| 106 | create: { |
|
| 107 | dimmer: function() { |
|
| 108 | var |
|
| 109 | defaultSettings = { |
|
| 110 | debug : settings.debug, |
|
| 111 | dimmerName : 'modals' |
|
| 112 | }, |
|
| 113 | dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings) |
|
| 114 | ; |
|
| 115 | if($.fn.dimmer === undefined) { |
|
| 116 | module.error(error.dimmer); |
|
| 117 | return; |
|
| 118 | } |
|
| 119 | module.debug('Creating dimmer'); |
|
| 120 | $dimmable = $context.dimmer(dimmerSettings); |
|
| 121 | if(settings.detachable) { |
|
| 122 | module.verbose('Modal is detachable, moving content into dimmer'); |
|
| 123 | $dimmable.dimmer('add content', $module); |
|
| 124 | } |
|
| 125 | else { |
|
| 126 | module.set.undetached(); |
|
| 127 | } |
|
| 128 | $dimmer = $dimmable.dimmer('get dimmer'); |
|
| 129 | }, |
|
| 130 | id: function() { |
|
| 131 | id = (Math.random().toString(16) + '000000000').substr(2,8); |
|
| 132 | elementEventNamespace = '.' + id; |
|
| 133 | module.verbose('Creating unique id for element', id); |
|
| 134 | } |
|
| 135 | }, |
|
| 136 | ||
| 137 | destroy: function() { |
|
| 138 | module.verbose('Destroying previous modal'); |
|
| 139 | $module |
|
| 140 | .removeData(moduleNamespace) |
|
| 141 | .off(eventNamespace) |
|
| 142 | ; |
|
| 143 | $window.off(elementEventNamespace); |
|
| 144 | $dimmer.off(elementEventNamespace); |
|
| 145 | $close.off(eventNamespace); |
|
| 146 | $context.dimmer('destroy'); |
|
| 147 | }, |
|
| 148 | ||
| 149 | observeChanges: function() { |
|
| 150 | if('MutationObserver' in window) { |
|
| 151 | observer = new MutationObserver(function(mutations) { |
|
| 152 | module.debug('DOM tree modified, refreshing'); |
|
| 153 | module.refresh(); |
|
| 154 | }); |
|
| 155 | observer.observe(element, { |
|
| 156 | childList : true, |
|
| 157 | subtree : true |
|
| 158 | }); |
|
| 159 | module.debug('Setting up mutation observer', observer); |
|
| 160 | } |
|
| 161 | }, |
|
| 162 | ||
| 163 | refresh: function() { |
|
| 164 | module.remove.scrolling(); |
|
| 165 | module.cacheSizes(); |
|
| 166 | module.set.screenHeight(); |
|
| 167 | module.set.type(); |
|
| 168 | module.set.position(); |
|
| 169 | }, |
|
| 170 | ||
| 171 | refreshModals: function() { |
|
| 172 | $otherModals = $module.siblings(selector.modal); |
|
| 173 | $allModals = $otherModals.add($module); |
|
| 174 | }, |
|
| 175 | ||
| 176 | attachEvents: function(selector, event) { |
|
| 177 | var |
|
| 178 | $toggle = $(selector) |
|
| 179 | ; |
|
| 180 | event = $.isFunction(module[event]) |
|
| 181 | ? module[event] |
|
| 182 | : module.toggle |
|
| 183 | ; |
|
| 184 | if($toggle.length > 0) { |
|
| 185 | module.debug('Attaching modal events to element', selector, event); |
|
| 186 | $toggle |
|
| 187 | .off(eventNamespace) |
|
| 188 | .on('click' + eventNamespace, event) |
|
| 189 | ; |
|
| 190 | } |
|
| 191 | else { |
|
| 192 | module.error(error.notFound, selector); |
|
| 193 | } |
|
| 194 | }, |
|
| 195 | ||
| 196 | bind: { |
|
| 197 | events: function() { |
|
| 198 | module.verbose('Attaching events'); |
|
| 199 | $module |
|
| 200 | .on('click' + eventNamespace, selector.close, module.event.close) |
|
| 201 | .on('click' + eventNamespace, selector.approve, module.event.approve) |
|
| 202 | .on('click' + eventNamespace, selector.deny, module.event.deny) |
|
| 203 | ; |
|
| 204 | $window |
|
| 205 | .on('resize' + elementEventNamespace, module.event.resize) |
|
| 206 | ; |
|
| 207 | } |
|
| 208 | }, |
|
| 209 | ||
| 210 | get: { |
|
| 211 | id: function() { |
|
| 212 | return (Math.random().toString(16) + '000000000').substr(2,8); |
|
| 213 | } |
|
| 214 | }, |
|
| 215 | ||
| 216 | event: { |
|
| 217 | approve: function() { |
|
| 218 | if(ignoreRepeatedEvents || settings.onApprove.call(element, $(this)) === false) { |
|
| 219 | module.verbose('Approve callback returned false cancelling hide'); |
|
| 220 | return; |
|
| 221 | } |
|
| 222 | ignoreRepeatedEvents = true; |
|
| 223 | module.hide(function() { |
|
| 224 | ignoreRepeatedEvents = false; |
|
| 225 | }); |
|
| 226 | }, |
|
| 227 | deny: function() { |
|
| 228 | if(ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) { |
|
| 229 | module.verbose('Deny callback returned false cancelling hide'); |
|
| 230 | return; |
|
| 231 | } |
|
| 232 | ignoreRepeatedEvents = true; |
|
| 233 | module.hide(function() { |
|
| 234 | ignoreRepeatedEvents = false; |
|
| 235 | }); |
|
| 236 | }, |
|
| 237 | close: function() { |
|
| 238 | module.hide(); |
|
| 239 | }, |
|
| 240 | click: function(event) { |
|
| 241 | var |
|
| 242 | $target = $(event.target), |
|
| 243 | isInModal = ($target.closest(selector.modal).length > 0), |
|
| 244 | isInDOM = $.contains(document.documentElement, event.target) |
|
| 245 | ; |
|
| 246 | if(!isInModal && isInDOM) { |
|
| 247 | module.debug('Dimmer clicked, hiding all modals'); |
|
| 248 | if( module.is.active() ) { |
|
| 249 | module.remove.clickaway(); |
|
| 250 | if(settings.allowMultiple) { |
|
| 251 | module.hide(); |
|
| 252 | } |
|
| 253 | else { |
|
| 254 | module.hideAll(); |
|
| 255 | } |
|
| 256 | } |
|
| 257 | } |
|
| 258 | }, |
|
| 259 | debounce: function(method, delay) { |
|
| 260 | clearTimeout(module.timer); |
|
| 261 | module.timer = setTimeout(method, delay); |
|
| 262 | }, |
|
| 263 | keyboard: function(event) { |
|
| 264 | var |
|
| 265 | keyCode = event.which, |
|
| 266 | escapeKey = 27 |
|
| 267 | ; |
|
| 268 | if(keyCode == escapeKey) { |
|
| 269 | if(settings.closable) { |
|
| 270 | module.debug('Escape key pressed hiding modal'); |
|
| 271 | module.hide(); |
|
| 272 | } |
|
| 273 | else { |
|
| 274 | module.debug('Escape key pressed, but closable is set to false'); |
|
| 275 | } |
|
| 276 | event.preventDefault(); |
|
| 277 | } |
|
| 278 | }, |
|
| 279 | resize: function() { |
|
| 280 | if( $dimmable.dimmer('is active') && ( module.is.animating() || module.is.active() ) ) { |
|
| 281 | requestAnimationFrame(module.refresh); |
|
| 282 | } |
|
| 283 | } |
|
| 284 | }, |
|
| 285 | ||
| 286 | toggle: function() { |
|
| 287 | if( module.is.active() || module.is.animating() ) { |
|
| 288 | module.hide(); |
|
| 289 | } |
|
| 290 | else { |
|
| 291 | module.show(); |
|
| 292 | } |
|
| 293 | }, |
|
| 294 | ||
| 295 | show: function(callback) { |
|
| 296 | callback = $.isFunction(callback) |
|
| 297 | ? callback |
|
| 298 | : function(){} |
|
| 299 | ; |
|
| 300 | module.refreshModals(); |
|
| 301 | module.set.dimmerSettings(); |
|
| 302 | module.showModal(callback); |
|
| 303 | }, |
|
| 304 | ||
| 305 | hide: function(callback) { |
|
| 306 | callback = $.isFunction(callback) |
|
| 307 | ? callback |
|
| 308 | : function(){} |
|
| 309 | ; |
|
| 310 | module.refreshModals(); |
|
| 311 | module.hideModal(callback); |
|
| 312 | }, |
|
| 313 | ||
| 314 | showModal: function(callback) { |
|
| 315 | callback = $.isFunction(callback) |
|
| 316 | ? callback |
|
| 317 | : function(){} |
|
| 318 | ; |
|
| 319 | if( module.is.animating() || !module.is.active() ) { |
|
| 320 | ||
| 321 | module.showDimmer(); |
|
| 322 | module.cacheSizes(); |
|
| 323 | module.set.position(); |
|
| 324 | module.set.screenHeight(); |
|
| 325 | module.set.type(); |
|
| 326 | module.set.clickaway(); |
|
| 327 | ||
| 328 | if( !settings.allowMultiple && module.others.active() ) { |
|
| 329 | module.hideOthers(module.showModal); |
|
| 330 | } |
|
| 331 | else { |
|
| 332 | settings.onShow.call(element); |
|
| 333 | if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { |
|
| 334 | module.debug('Showing modal with css animations'); |
|
| 335 | $module |
|
| 336 | .transition({ |
|
| 337 | debug : settings.debug, |
|
| 338 | animation : settings.transition + ' in', |
|
| 339 | queue : settings.queue, |
|
| 340 | duration : settings.duration, |
|
| 341 | useFailSafe : true, |
|
| 342 | onComplete : function() { |
|
| 343 | settings.onVisible.apply(element); |
|
| 344 | if(settings.keyboardShortcuts) { |
|
| 345 | module.add.keyboardShortcuts(); |
|
| 346 | } |
|
| 347 | module.save.focus(); |
|
| 348 | module.set.active(); |
|
| 349 | if(settings.autofocus) { |
|
| 350 | module.set.autofocus(); |
|
| 351 | } |
|
| 352 | callback(); |
|
| 353 | } |
|
| 354 | }) |
|
| 355 | ; |
|
| 356 | } |
|
| 357 | else { |
|
| 358 | module.error(error.noTransition); |
|
| 359 | } |
|
| 360 | } |
|
| 361 | } |
|
| 362 | else { |
|
| 363 | module.debug('Modal is already visible'); |
|
| 364 | } |
|
| 365 | }, |
|
| 366 | ||
| 367 | hideModal: function(callback, keepDimmed) { |
|
| 368 | callback = $.isFunction(callback) |
|
| 369 | ? callback |
|
| 370 | : function(){} |
|
| 371 | ; |
|
| 372 | module.debug('Hiding modal'); |
|
| 373 | if(settings.onHide.call(element, $(this)) === false) { |
|
| 374 | module.verbose('Hide callback returned false cancelling hide'); |
|
| 375 | return; |
|
| 376 | } |
|
| 377 | ||
| 378 | if( module.is.animating() || module.is.active() ) { |
|
| 379 | if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { |
|
| 380 | module.remove.active(); |
|
| 381 | $module |
|
| 382 | .transition({ |
|
| 383 | debug : settings.debug, |
|
| 384 | animation : settings.transition + ' out', |
|
| 385 | queue : settings.queue, |
|
| 386 | duration : settings.duration, |
|
| 387 | useFailSafe : true, |
|
| 388 | onStart : function() { |
|
| 389 | if(!module.others.active() && !keepDimmed) { |
|
| 390 | module.hideDimmer(); |
|
| 391 | } |
|
| 392 | if(settings.keyboardShortcuts) { |
|
| 393 | module.remove.keyboardShortcuts(); |
|
| 394 | } |
|
| 395 | }, |
|
| 396 | onComplete : function() { |
|
| 397 | settings.onHidden.call(element); |
|
| 398 | module.restore.focus(); |
|
| 399 | callback(); |
|
| 400 | } |
|
| 401 | }) |
|
| 402 | ; |
|
| 403 | } |
|
| 404 | else { |
|
| 405 | module.error(error.noTransition); |
|
| 406 | } |
|
| 407 | } |
|
| 408 | }, |
|
| 409 | ||
| 410 | showDimmer: function() { |
|
| 411 | if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) { |
|
| 412 | module.debug('Showing dimmer'); |
|
| 413 | $dimmable.dimmer('show'); |
|
| 414 | } |
|
| 415 | else { |
|
| 416 | module.debug('Dimmer already visible'); |
|
| 417 | } |
|
| 418 | }, |
|
| 419 | ||
| 420 | hideDimmer: function() { |
|
| 421 | if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) { |
|
| 422 | $dimmable.dimmer('hide', function() { |
|
| 423 | module.remove.clickaway(); |
|
| 424 | module.remove.screenHeight(); |
|
| 425 | }); |
|
| 426 | } |
|
| 427 | else { |
|
| 428 | module.debug('Dimmer is not visible cannot hide'); |
|
| 429 | return; |
|
| 430 | } |
|
| 431 | }, |
|
| 432 | ||
| 433 | hideAll: function(callback) { |
|
| 434 | var |
|
| 435 | $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating) |
|
| 436 | ; |
|
| 437 | callback = $.isFunction(callback) |
|
| 438 | ? callback |
|
| 439 | : function(){} |
|
| 440 | ; |
|
| 441 | if( $visibleModals.length > 0 ) { |
|
| 442 | module.debug('Hiding all visible modals'); |
|
| 443 | module.hideDimmer(); |
|
| 444 | $visibleModals |
|
| 445 | .modal('hide modal', callback) |
|
| 446 | ; |
|
| 447 | } |
|
| 448 | }, |
|
| 449 | ||
| 450 | hideOthers: function(callback) { |
|
| 451 | var |
|
| 452 | $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating) |
|
| 453 | ; |
|
| 454 | callback = $.isFunction(callback) |
|
| 455 | ? callback |
|
| 456 | : function(){} |
|
| 457 | ; |
|
| 458 | if( $visibleModals.length > 0 ) { |
|
| 459 | module.debug('Hiding other modals', $otherModals); |
|
| 460 | $visibleModals |
|
| 461 | .modal('hide modal', callback, true) |
|
| 462 | ; |
|
| 463 | } |
|
| 464 | }, |
|
| 465 | ||
| 466 | others: { |
|
| 467 | active: function() { |
|
| 468 | return ($otherModals.filter('.' + className.active).length > 0); |
|
| 469 | }, |
|
| 470 | animating: function() { |
|
| 471 | return ($otherModals.filter('.' + className.animating).length > 0); |
|
| 472 | } |
|
| 473 | }, |
|
| 474 | ||
| 475 | ||
| 476 | add: { |
|
| 477 | keyboardShortcuts: function() { |
|
| 478 | module.verbose('Adding keyboard shortcuts'); |
|
| 479 | $document |
|
| 480 | .on('keyup' + eventNamespace, module.event.keyboard) |
|
| 481 | ; |
|
| 482 | } |
|
| 483 | }, |
|
| 484 | ||
| 485 | save: { |
|
| 486 | focus: function() { |
|
| 487 | $focusedElement = $(document.activeElement).blur(); |
|
| 488 | } |
|
| 489 | }, |
|
| 490 | ||
| 491 | restore: { |
|
| 492 | focus: function() { |
|
| 493 | if($focusedElement && $focusedElement.length > 0) { |
|
| 494 | $focusedElement.focus(); |
|
| 495 | } |
|
| 496 | } |
|
| 497 | }, |
|
| 498 | ||
| 499 | remove: { |
|
| 500 | active: function() { |
|
| 501 | $module.removeClass(className.active); |
|
| 502 | }, |
|
| 503 | clickaway: function() { |
|
| 504 | if(settings.closable) { |
|
| 505 | $dimmer |
|
| 506 | .off('click' + elementEventNamespace) |
|
| 507 | ; |
|
| 508 | } |
|
| 509 | }, |
|
| 510 | bodyStyle: function() { |
|
| 511 | if($body.attr('style') === '') { |
|
| 512 | module.verbose('Removing style attribute'); |
|
| 513 | $body.removeAttr('style'); |
|
| 514 | } |
|
| 515 | }, |
|
| 516 | screenHeight: function() { |
|
| 517 | module.debug('Removing page height'); |
|
| 518 | $body |
|
| 519 | .css('height', '') |
|
| 520 | ; |
|
| 521 | }, |
|
| 522 | keyboardShortcuts: function() { |
|
| 523 | module.verbose('Removing keyboard shortcuts'); |
|
| 524 | $document |
|
| 525 | .off('keyup' + eventNamespace) |
|
| 526 | ; |
|
| 527 | }, |
|
| 528 | scrolling: function() { |
|
| 529 | $dimmable.removeClass(className.scrolling); |
|
| 530 | $module.removeClass(className.scrolling); |
|
| 531 | } |
|
| 532 | }, |
|
| 533 | ||
| 534 | cacheSizes: function() { |
|
| 535 | var |
|
| 536 | modalHeight = $module.outerHeight() |
|
| 537 | ; |
|
| 538 | if(module.cache === undefined || modalHeight !== 0) { |
|
| 539 | module.cache = { |
|
| 540 | pageHeight : $(document).outerHeight(), |
|
| 541 | height : modalHeight + settings.offset, |
|
| 542 | contextHeight : (settings.context == 'body') |
|
| 543 | ? $(window).height() |
|
| 544 | : $dimmable.height() |
|
| 545 | }; |
|
| 546 | } |
|
| 547 | module.debug('Caching modal and container sizes', module.cache); |
|
| 548 | }, |
|
| 549 | ||
| 550 | can: { |
|
| 551 | fit: function() { |
|
| 552 | return ( ( module.cache.height + (settings.padding * 2) ) < module.cache.contextHeight); |
|
| 553 | } |
|
| 554 | }, |
|
| 555 | ||
| 556 | is: { |
|
| 557 | active: function() { |
|
| 558 | return $module.hasClass(className.active); |
|
| 559 | }, |
|
| 560 | animating: function() { |
|
| 561 | return $module.transition('is supported') |
|
| 562 | ? $module.transition('is animating') |
|
| 563 | : $module.is(':visible') |
|
| 564 | ; |
|
| 565 | }, |
|
| 566 | scrolling: function() { |
|
| 567 | return $dimmable.hasClass(className.scrolling); |
|
| 568 | }, |
|
| 569 | modernBrowser: function() { |
|
| 570 | // appName for IE11 reports 'Netscape' can no longer use |
|
| 571 | return !(window.ActiveXObject || "ActiveXObject" in window); |
|
| 572 | } |
|
| 573 | }, |
|
| 574 | ||
| 575 | set: { |
|
| 576 | autofocus: function() { |
|
| 577 | var |
|
| 578 | $inputs = $module.find('[tabindex], :input').filter(':visible'), |
|
| 579 | $autofocus = $inputs.filter('[autofocus]'), |
|
| 580 | $input = ($autofocus.length > 0) |
|
| 581 | ? $autofocus.first() |
|
| 582 | : $inputs.first() |
|
| 583 | ; |
|
| 584 | if($input.length > 0) { |
|
| 585 | $input.focus(); |
|
| 586 | } |
|
| 587 | }, |
|
| 588 | clickaway: function() { |
|
| 589 | if(settings.closable) { |
|
| 590 | $dimmer |
|
| 591 | .on('click' + elementEventNamespace, module.event.click) |
|
| 592 | ; |
|
| 593 | } |
|
| 594 | }, |
|
| 595 | dimmerSettings: function() { |
|
| 596 | if($.fn.dimmer === undefined) { |
|
| 597 | module.error(error.dimmer); |
|
| 598 | return; |
|
| 599 | } |
|
| 600 | var |
|
| 601 | defaultSettings = { |
|
| 602 | debug : settings.debug, |
|
| 603 | dimmerName : 'modals', |
|
| 604 | variation : false, |
|
| 605 | closable : 'auto', |
|
| 606 | duration : { |
|
| 607 | show : settings.duration, |
|
| 608 | hide : settings.duration |
|
| 609 | } |
|
| 610 | }, |
|
| 611 | dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings) |
|
| 612 | ; |
|
| 613 | if(settings.inverted) { |
|
| 614 | dimmerSettings.variation = (dimmerSettings.variation !== undefined) |
|
| 615 | ? dimmerSettings.variation + ' inverted' |
|
| 616 | : 'inverted' |
|
| 617 | ; |
|
| 618 | $dimmer.addClass(className.inverted); |
|
| 619 | } |
|
| 620 | else { |
|
| 621 | $dimmer.removeClass(className.inverted); |
|
| 622 | } |
|
| 623 | if(settings.blurring) { |
|
| 624 | $dimmable.addClass(className.blurring); |
|
| 625 | } |
|
| 626 | else { |
|
| 627 | $dimmable.removeClass(className.blurring); |
|
| 628 | } |
|
| 629 | $context.dimmer('setting', dimmerSettings); |
|
| 630 | }, |
|
| 631 | screenHeight: function() { |
|
| 632 | if( module.can.fit() ) { |
|
| 633 | $body.css('height', ''); |
|
| 634 | } |
|
| 635 | else { |
|
| 636 | module.debug('Modal is taller than page content, resizing page height'); |
|
| 637 | $body |
|
| 638 | .css('height', module.cache.height + (settings.padding * 2) ) |
|
| 639 | ; |
|
| 640 | } |
|
| 641 | }, |
|
| 642 | active: function() { |
|
| 643 | $module.addClass(className.active); |
|
| 644 | }, |
|
| 645 | scrolling: function() { |
|
| 646 | $dimmable.addClass(className.scrolling); |
|
| 647 | $module.addClass(className.scrolling); |
|
| 648 | }, |
|
| 649 | type: function() { |
|
| 650 | if(module.can.fit()) { |
|
| 651 | module.verbose('Modal fits on screen'); |
|
| 652 | if(!module.others.active() && !module.others.animating()) { |
|
| 653 | module.remove.scrolling(); |
|
| 654 | } |
|
| 655 | } |
|
| 656 | else { |
|
| 657 | module.verbose('Modal cannot fit on screen setting to scrolling'); |
|
| 658 | module.set.scrolling(); |
|
| 659 | } |
|
| 660 | }, |
|
| 661 | position: function() { |
|
| 662 | module.verbose('Centering modal on page', module.cache); |
|
| 663 | if(module.can.fit()) { |
|
| 664 | $module |
|
| 665 | .css({ |
|
| 666 | top: '', |
|
| 667 | marginTop: -(module.cache.height / 2) |
|
| 668 | }) |
|
| 669 | ; |
|
| 670 | } |
|
| 671 | else { |
|
| 672 | $module |
|
| 673 | .css({ |
|
| 674 | marginTop : '', |
|
| 675 | top : $document.scrollTop() |
|
| 676 | }) |
|
| 677 | ; |
|
| 678 | } |
|
| 679 | }, |
|
| 680 | undetached: function() { |
|
| 681 | $dimmable.addClass(className.undetached); |
|
| 682 | } |
|
| 683 | }, |
|
| 684 | ||
| 685 | setting: function(name, value) { |
|
| 686 | module.debug('Changing setting', name, value); |
|
| 687 | if( $.isPlainObject(name) ) { |
|
| 688 | $.extend(true, settings, name); |
|
| 689 | } |
|
| 690 | else if(value !== undefined) { |
|
| 691 | if($.isPlainObject(settings[name])) { |
|
| 692 | $.extend(true, settings[name], value); |
|
| 693 | } |
|
| 694 | else { |
|
| 695 | settings[name] = value; |
|
| 696 | } |
|
| 697 | } |
|
| 698 | else { |
|
| 699 | return settings[name]; |
|
| 700 | } |
|
| 701 | }, |
|
| 702 | internal: function(name, value) { |
|
| 703 | if( $.isPlainObject(name) ) { |
|
| 704 | $.extend(true, module, name); |
|
| 705 | } |
|
| 706 | else if(value !== undefined) { |
|
| 707 | module[name] = value; |
|
| 708 | } |
|
| 709 | else { |
|
| 710 | return module[name]; |
|
| 711 | } |
|
| 712 | }, |
|
| 713 | debug: function() { |
|
| 714 | if(!settings.silent && settings.debug) { |
|
| 715 | if(settings.performance) { |
|
| 716 | module.performance.log(arguments); |
|
| 717 | } |
|
| 718 | else { |
|
| 719 | module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
| 720 | module.debug.apply(console, arguments); |
|
| 721 | } |
|
| 722 | } |
|
| 723 | }, |
|
| 724 | verbose: function() { |
|
| 725 | if(!settings.silent && settings.verbose && settings.debug) { |
|
| 726 | if(settings.performance) { |
|
| 727 | module.performance.log(arguments); |
|
| 728 | } |
|
| 729 | else { |
|
| 730 | module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
| 731 | module.verbose.apply(console, arguments); |
|
| 732 | } |
|
| 733 | } |
|
| 734 | }, |
|
| 735 | error: function() { |
|
| 736 | if(!settings.silent) { |
|
| 737 | module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); |
|
| 738 | module.error.apply(console, arguments); |
|
| 739 | } |
|
| 740 | }, |
|
| 741 | performance: { |
|
| 742 | log: function(message) { |
|
| 743 | var |
|
| 744 | currentTime, |
|
| 745 | executionTime, |
|
| 746 | previousTime |
|
| 747 | ; |
|
| 748 | if(settings.performance) { |
|
| 749 | currentTime = new Date().getTime(); |
|
| 750 | previousTime = time || currentTime; |
|
| 751 | executionTime = currentTime - previousTime; |
|
| 752 | time = currentTime; |
|
| 753 | performance.push({ |
|
| 754 | 'Name' : message[0], |
|
| 755 | 'Arguments' : [].slice.call(message, 1) || '', |
|
| 756 | 'Element' : element, |
|
| 757 | 'Execution Time' : executionTime |
|
| 758 | }); |
|
| 759 | } |
|
| 760 | clearTimeout(module.performance.timer); |
|
| 761 | module.performance.timer = setTimeout(module.performance.display, 500); |
|
| 762 | }, |
|
| 763 | display: function() { |
|
| 764 | var |
|
| 765 | title = settings.name + ':', |
|
| 766 | totalTime = 0 |
|
| 767 | ; |
|
| 768 | time = false; |
|
| 769 | clearTimeout(module.performance.timer); |
|
| 770 | $.each(performance, function(index, data) { |
|
| 771 | totalTime += data['Execution Time']; |
|
| 772 | }); |
|
| 773 | title += ' ' + totalTime + 'ms'; |
|
| 774 | if(moduleSelector) { |
|
| 775 | title += ' \'' + moduleSelector + '\''; |
|
| 776 | } |
|
| 777 | if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { |
|
| 778 | console.groupCollapsed(title); |
|
| 779 | if(console.table) { |
|
| 780 | console.table(performance); |
|
| 781 | } |
|
| 782 | else { |
|
| 783 | $.each(performance, function(index, data) { |
|
| 784 | console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); |
|
| 785 | }); |
|
| 786 | } |
|
| 787 | console.groupEnd(); |
|
| 788 | } |
|
| 789 | performance = []; |
|
| 790 | } |
|
| 791 | }, |
|
| 792 | invoke: function(query, passedArguments, context) { |
|
| 793 | var |
|
| 794 | object = instance, |
|
| 795 | maxDepth, |
|
| 796 | found, |
|
| 797 | response |
|
| 798 | ; |
|
| 799 | passedArguments = passedArguments || queryArguments; |
|
| 800 | context = element || context; |
|
| 801 | if(typeof query == 'string' && object !== undefined) { |
|
| 802 | query = query.split(/[\. ]/); |
|
| 803 | maxDepth = query.length - 1; |
|
| 804 | $.each(query, function(depth, value) { |
|
| 805 | var camelCaseValue = (depth != maxDepth) |
|
| 806 | ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) |
|
| 807 | : query |
|
| 808 | ; |
|
| 809 | if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { |
|
| 810 | object = object[camelCaseValue]; |
|
| 811 | } |
|
| 812 | else if( object[camelCaseValue] !== undefined ) { |
|
| 813 | found = object[camelCaseValue]; |
|
| 814 | return false; |
|
| 815 | } |
|
| 816 | else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { |
|
| 817 | object = object[value]; |
|
| 818 | } |
|
| 819 | else if( object[value] !== undefined ) { |
|
| 820 | found = object[value]; |
|
| 821 | return false; |
|
| 822 | } |
|
| 823 | else { |
|
| 824 | return false; |
|
| 825 | } |
|
| 826 | }); |
|
| 827 | } |
|
| 828 | if ( $.isFunction( found ) ) { |
|
| 829 | response = found.apply(context, passedArguments); |
|
| 830 | } |
|
| 831 | else if(found !== undefined) { |
|
| 832 | response = found; |
|
| 833 | } |
|
| 834 | if($.isArray(returnedValue)) { |
|
| 835 | returnedValue.push(response); |
|
| 836 | } |
|
| 837 | else if(returnedValue !== undefined) { |
|
| 838 | returnedValue = [returnedValue, response]; |
|
| 839 | } |
|
| 840 | else if(response !== undefined) { |
|
| 841 | returnedValue = response; |
|
| 842 | } |
|
| 843 | return found; |
|
| 844 | } |
|
| 845 | }; |
|
| 846 | ||
| 847 | if(methodInvoked) { |
|
| 848 | if(instance === undefined) { |
|
| 849 | module.initialize(); |
|
| 850 | } |
|
| 851 | module.invoke(query); |
|
| 852 | } |
|
| 853 | else { |
|
| 854 | if(instance !== undefined) { |
|
| 855 | instance.invoke('destroy'); |
|
| 856 | } |
|
| 857 | module.initialize(); |
|
| 858 | } |
|
| 859 | }) |
|
| 860 | ; |
|
| 861 | ||
| 862 | return (returnedValue !== undefined) |
|
| 863 | ? returnedValue |
|
| 864 | : this |
|
| 865 | ; |
|
| 866 | }; |
|
| 867 | ||
| 868 | $.fn.modal.settings = { |
|
| 869 | ||
| 870 | name : 'Modal', |
|
| 871 | namespace : 'modal', |
|
| 872 | ||
| 873 | silent : false, |
|
| 874 | debug : false, |
|
| 875 | verbose : false, |
|
| 876 | performance : true, |
|
| 877 | ||
| 878 | observeChanges : false, |
|
| 879 | ||
| 880 | allowMultiple : false, |
|
| 881 | detachable : true, |
|
| 882 | closable : true, |
|
| 883 | autofocus : true, |
|
| 884 | ||
| 885 | inverted : false, |
|
| 886 | blurring : false, |
|
| 887 | ||
| 888 | dimmerSettings : { |
|
| 889 | closable : false, |
|
| 890 | useCSS : true |
|
| 891 | }, |
|
| 892 | ||
| 893 | // whether to use keyboard shortcuts |
|
| 894 | keyboardShortcuts: true, |
|
| 895 | ||
| 896 | context : 'body', |
|
| 897 | ||
| 898 | queue : false, |
|
| 899 | duration : 500, |
|
| 900 | offset : 0, |
|
| 901 | transition : 'scale', |
|
| 902 | ||
| 903 | // padding with edge of page |
|
| 904 | padding : 50, |
|
| 905 | ||
| 906 | // called before show animation |
|
| 907 | onShow : function(){}, |
|
| 908 | ||
| 909 | // called after show animation |
|
| 910 | onVisible : function(){}, |
|
| 911 | ||
| 912 | // called before hide animation |
|
| 913 | onHide : function(){ return true; }, |
|
| 914 | ||
| 915 | // called after hide animation |
|
| 916 | onHidden : function(){}, |
|
| 917 | ||
| 918 | // called after approve selector match |
|
| 919 | onApprove : function(){ return true; }, |
|
| 920 | ||
| 921 | // called after deny selector match |
|
| 922 | onDeny : function(){ return true; }, |
|
| 923 | ||
| 924 | selector : { |
|
| 925 | close : '> .close', |
|
| 926 | approve : '.actions .positive, .actions .approve, .actions .ok', |
|
| 927 | deny : '.actions .negative, .actions .deny, .actions .cancel', |
|
| 928 | modal : '.ui.modal' |
|
| 929 | }, |
|
| 930 | error : { |
|
| 931 | dimmer : 'UI Dimmer, a required component is not included in this page', |
|
| 932 | method : 'The method you called is not defined.', |
|
| 933 | notFound : 'The element you specified could not be found' |
|
| 934 | }, |
|
| 935 | className : { |
|
| 936 | active : 'active', |
|
| 937 | animating : 'animating', |
|
| 938 | blurring : 'blurring', |
|
| 939 | inverted : 'inverted', |
|
| 940 | scrolling : 'scrolling', |
|
| 941 | undetached : 'undetached' |
|
| 942 | } |
|
| 943 | }; |
|
| 944 | ||
| 945 | ||
| 946 | })( jQuery, window, document ); |
|
| 947 | ||