You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

913 lines
27 KiB

10 years ago
8 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
8 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
8 years ago
10 years ago
10 years ago
8 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
8 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
8 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
9 years ago
8 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
8 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
8 years ago
9 years ago
10 years ago
8 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
8 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
  1. /*!
  2. * # Semantic UI 2.2.7 - Modal
  3. * http://github.com/semantic-org/semantic-ui/
  4. *
  5. *
  6. * Released under the MIT license
  7. * http://opensource.org/licenses/MIT
  8. *
  9. */
  10. ;(function ($, window, document, undefined) {
  11. "use strict";
  12. window = (typeof window != 'undefined' && window.Math == Math)
  13. ? window
  14. : (typeof self != 'undefined' && self.Math == Math)
  15. ? self
  16. : Function('return this')()
  17. ;
  18. $.fn.modal = function(parameters) {
  19. var
  20. $allModules = $(this),
  21. $window = $(window),
  22. $document = $(document),
  23. $body = $('body'),
  24. moduleSelector = $allModules.selector || '',
  25. time = new Date().getTime(),
  26. performance = [],
  27. query = arguments[0],
  28. methodInvoked = (typeof query == 'string'),
  29. queryArguments = [].slice.call(arguments, 1),
  30. requestAnimationFrame = window.requestAnimationFrame
  31. || window.mozRequestAnimationFrame
  32. || window.webkitRequestAnimationFrame
  33. || window.msRequestAnimationFrame
  34. || function(callback) { setTimeout(callback, 0); },
  35. returnedValue
  36. ;
  37. $allModules
  38. .each(function() {
  39. var
  40. settings = ( $.isPlainObject(parameters) )
  41. ? $.extend(true, {}, $.fn.modal.settings, parameters)
  42. : $.extend({}, $.fn.modal.settings),
  43. selector = settings.selector,
  44. className = settings.className,
  45. namespace = settings.namespace,
  46. error = settings.error,
  47. eventNamespace = '.' + namespace,
  48. moduleNamespace = 'module-' + namespace,
  49. $module = $(this),
  50. $context = $(settings.context),
  51. $close = $module.find(selector.close),
  52. $allModals,
  53. $otherModals,
  54. $focusedElement,
  55. $dimmable,
  56. $dimmer,
  57. element = this,
  58. instance = $module.data(moduleNamespace),
  59. elementEventNamespace,
  60. id,
  61. observer,
  62. module
  63. ;
  64. module = {
  65. initialize: function() {
  66. module.verbose('Initializing dimmer', $context);
  67. module.create.id();
  68. module.create.dimmer();
  69. module.refreshModals();
  70. module.bind.events();
  71. if(settings.observeChanges) {
  72. module.observeChanges();
  73. }
  74. module.instantiate();
  75. },
  76. instantiate: function() {
  77. module.verbose('Storing instance of modal');
  78. instance = module;
  79. $module
  80. .data(moduleNamespace, instance)
  81. ;
  82. },
  83. create: {
  84. dimmer: function() {
  85. var
  86. defaultSettings = {
  87. debug : settings.debug,
  88. dimmerName : 'modals',
  89. duration : {
  90. show : settings.duration,
  91. hide : settings.duration
  92. }
  93. },
  94. dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
  95. ;
  96. if(settings.inverted) {
  97. dimmerSettings.variation = (dimmerSettings.variation !== undefined)
  98. ? dimmerSettings.variation + ' inverted'
  99. : 'inverted'
  100. ;
  101. }
  102. if($.fn.dimmer === undefined) {
  103. module.error(error.dimmer);
  104. return;
  105. }
  106. module.debug('Creating dimmer with settings', dimmerSettings);
  107. $dimmable = $context.dimmer(dimmerSettings);
  108. if(settings.detachable) {
  109. module.verbose('Modal is detachable, moving content into dimmer');
  110. $dimmable.dimmer('add content', $module);
  111. }
  112. else {
  113. module.set.undetached();
  114. }
  115. if(settings.blurring) {
  116. $dimmable.addClass(className.blurring);
  117. }
  118. $dimmer = $dimmable.dimmer('get dimmer');
  119. },
  120. id: function() {
  121. id = (Math.random().toString(16) + '000000000').substr(2,8);
  122. elementEventNamespace = '.' + id;
  123. module.verbose('Creating unique id for element', id);
  124. }
  125. },
  126. destroy: function() {
  127. module.verbose('Destroying previous modal');
  128. $module
  129. .removeData(moduleNamespace)
  130. .off(eventNamespace)
  131. ;
  132. $window.off(elementEventNamespace);
  133. $dimmer.off(elementEventNamespace);
  134. $close.off(eventNamespace);
  135. $context.dimmer('destroy');
  136. },
  137. observeChanges: function() {
  138. if('MutationObserver' in window) {
  139. observer = new MutationObserver(function(mutations) {
  140. module.debug('DOM tree modified, refreshing');
  141. module.refresh();
  142. });
  143. observer.observe(element, {
  144. childList : true,
  145. subtree : true
  146. });
  147. module.debug('Setting up mutation observer', observer);
  148. }
  149. },
  150. refresh: function() {
  151. module.remove.scrolling();
  152. module.cacheSizes();
  153. module.set.screenHeight();
  154. module.set.type();
  155. module.set.position();
  156. },
  157. refreshModals: function() {
  158. $otherModals = $module.siblings(selector.modal);
  159. $allModals = $otherModals.add($module);
  160. },
  161. attachEvents: function(selector, event) {
  162. var
  163. $toggle = $(selector)
  164. ;
  165. event = $.isFunction(module[event])
  166. ? module[event]
  167. : module.toggle
  168. ;
  169. if($toggle.length > 0) {
  170. module.debug('Attaching modal events to element', selector, event);
  171. $toggle
  172. .off(eventNamespace)
  173. .on('click' + eventNamespace, event)
  174. ;
  175. }
  176. else {
  177. module.error(error.notFound, selector);
  178. }
  179. },
  180. bind: {
  181. events: function() {
  182. module.verbose('Attaching events');
  183. $module
  184. .on('click' + eventNamespace, selector.close, module.event.close)
  185. .on('click' + eventNamespace, selector.approve, module.event.approve)
  186. .on('click' + eventNamespace, selector.deny, module.event.deny)
  187. ;
  188. $window
  189. .on('resize' + elementEventNamespace, module.event.resize)
  190. ;
  191. }
  192. },
  193. get: {
  194. id: function() {
  195. return (Math.random().toString(16) + '000000000').substr(2,8);
  196. }
  197. },
  198. event: {
  199. approve: function() {
  200. if(settings.onApprove.call(element, $(this)) === false) {
  201. module.verbose('Approve callback returned false cancelling hide');
  202. return;
  203. }
  204. module.hide();
  205. },
  206. deny: function() {
  207. if(settings.onDeny.call(element, $(this)) === false) {
  208. module.verbose('Deny callback returned false cancelling hide');
  209. return;
  210. }
  211. module.hide();
  212. },
  213. close: function() {
  214. module.hide();
  215. },
  216. click: function(event) {
  217. var
  218. $target = $(event.target),
  219. isInModal = ($target.closest(selector.modal).length > 0),
  220. isInDOM = $.contains(document.documentElement, event.target)
  221. ;
  222. if(!isInModal && isInDOM) {
  223. module.debug('Dimmer clicked, hiding all modals');
  224. if( module.is.active() ) {
  225. module.remove.clickaway();
  226. if(settings.allowMultiple) {
  227. module.hide();
  228. }
  229. else {
  230. module.hideAll();
  231. }
  232. }
  233. }
  234. },
  235. debounce: function(method, delay) {
  236. clearTimeout(module.timer);
  237. module.timer = setTimeout(method, delay);
  238. },
  239. keyboard: function(event) {
  240. var
  241. keyCode = event.which,
  242. escapeKey = 27
  243. ;
  244. if(keyCode == escapeKey) {
  245. if(settings.closable) {
  246. module.debug('Escape key pressed hiding modal');
  247. module.hide();
  248. }
  249. else {
  250. module.debug('Escape key pressed, but closable is set to false');
  251. }
  252. event.preventDefault();
  253. }
  254. },
  255. resize: function() {
  256. if( $dimmable.dimmer('is active') ) {
  257. requestAnimationFrame(module.refresh);
  258. }
  259. }
  260. },
  261. toggle: function() {
  262. if( module.is.active() || module.is.animating() ) {
  263. module.hide();
  264. }
  265. else {
  266. module.show();
  267. }
  268. },
  269. show: function(callback) {
  270. callback = $.isFunction(callback)
  271. ? callback
  272. : function(){}
  273. ;
  274. module.refreshModals();
  275. module.showModal(callback);
  276. },
  277. hide: function(callback) {
  278. callback = $.isFunction(callback)
  279. ? callback
  280. : function(){}
  281. ;
  282. module.refreshModals();
  283. module.hideModal(callback);
  284. },
  285. showModal: function(callback) {
  286. callback = $.isFunction(callback)
  287. ? callback
  288. : function(){}
  289. ;
  290. if( module.is.animating() || !module.is.active() ) {
  291. module.showDimmer();
  292. module.cacheSizes();
  293. module.set.position();
  294. module.set.screenHeight();
  295. module.set.type();
  296. module.set.clickaway();
  297. if( !settings.allowMultiple && module.others.active() ) {
  298. module.hideOthers(module.showModal);
  299. }
  300. else {
  301. settings.onShow.call(element);
  302. if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
  303. module.debug('Showing modal with css animations');
  304. $module
  305. .transition({
  306. debug : settings.debug,
  307. animation : settings.transition + ' in',
  308. queue : settings.queue,
  309. duration : settings.duration,
  310. useFailSafe : true,
  311. onComplete : function() {
  312. settings.onVisible.apply(element);
  313. if(settings.keyboardShortcuts) {
  314. module.add.keyboardShortcuts();
  315. }
  316. module.save.focus();
  317. module.set.active();
  318. if(settings.autofocus) {
  319. module.set.autofocus();
  320. }
  321. callback();
  322. }
  323. })
  324. ;
  325. }
  326. else {
  327. module.error(error.noTransition);
  328. }
  329. }
  330. }
  331. else {
  332. module.debug('Modal is already visible');
  333. }
  334. },
  335. hideModal: function(callback, keepDimmed) {
  336. callback = $.isFunction(callback)
  337. ? callback
  338. : function(){}
  339. ;
  340. module.debug('Hiding modal');
  341. if(settings.onHide.call(element, $(this)) === false) {
  342. module.verbose('Hide callback returned false cancelling hide');
  343. return;
  344. }
  345. if( module.is.animating() || module.is.active() ) {
  346. if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
  347. module.remove.active();
  348. $module
  349. .transition({
  350. debug : settings.debug,
  351. animation : settings.transition + ' out',
  352. queue : settings.queue,
  353. duration : settings.duration,
  354. useFailSafe : true,
  355. onStart : function() {
  356. if(!module.others.active() && !keepDimmed) {
  357. module.hideDimmer();
  358. }
  359. if(settings.keyboardShortcuts) {
  360. module.remove.keyboardShortcuts();
  361. }
  362. },
  363. onComplete : function() {
  364. settings.onHidden.call(element);
  365. module.restore.focus();
  366. callback();
  367. }
  368. })
  369. ;
  370. }
  371. else {
  372. module.error(error.noTransition);
  373. }
  374. }
  375. },
  376. showDimmer: function() {
  377. if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) {
  378. module.debug('Showing dimmer');
  379. $dimmable.dimmer('show');
  380. }
  381. else {
  382. module.debug('Dimmer already visible');
  383. }
  384. },
  385. hideDimmer: function() {
  386. if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) {
  387. $dimmable.dimmer('hide', function() {
  388. module.remove.clickaway();
  389. module.remove.screenHeight();
  390. });
  391. }
  392. else {
  393. module.debug('Dimmer is not visible cannot hide');
  394. return;
  395. }
  396. },
  397. hideAll: function(callback) {
  398. var
  399. $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating)
  400. ;
  401. callback = $.isFunction(callback)
  402. ? callback
  403. : function(){}
  404. ;
  405. if( $visibleModals.length > 0 ) {
  406. module.debug('Hiding all visible modals');
  407. module.hideDimmer();
  408. $visibleModals
  409. .modal('hide modal', callback)
  410. ;
  411. }
  412. },
  413. hideOthers: function(callback) {
  414. var
  415. $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating)
  416. ;
  417. callback = $.isFunction(callback)
  418. ? callback
  419. : function(){}
  420. ;
  421. if( $visibleModals.length > 0 ) {
  422. module.debug('Hiding other modals', $otherModals);
  423. $visibleModals
  424. .modal('hide modal', callback, true)
  425. ;
  426. }
  427. },
  428. others: {
  429. active: function() {
  430. return ($otherModals.filter('.' + className.active).length > 0);
  431. },
  432. animating: function() {
  433. return ($otherModals.filter('.' + className.animating).length > 0);
  434. }
  435. },
  436. add: {
  437. keyboardShortcuts: function() {
  438. module.verbose('Adding keyboard shortcuts');
  439. $document
  440. .on('keyup' + eventNamespace, module.event.keyboard)
  441. ;
  442. }
  443. },
  444. save: {
  445. focus: function() {
  446. $focusedElement = $(document.activeElement).blur();
  447. }
  448. },
  449. restore: {
  450. focus: function() {
  451. if($focusedElement && $focusedElement.length > 0) {
  452. $focusedElement.focus();
  453. }
  454. }
  455. },
  456. remove: {
  457. active: function() {
  458. $module.removeClass(className.active);
  459. },
  460. clickaway: function() {
  461. if(settings.closable) {
  462. $dimmer
  463. .off('click' + elementEventNamespace)
  464. ;
  465. }
  466. },
  467. bodyStyle: function() {
  468. if($body.attr('style') === '') {
  469. module.verbose('Removing style attribute');
  470. $body.removeAttr('style');
  471. }
  472. },
  473. screenHeight: function() {
  474. module.debug('Removing page height');
  475. $body
  476. .css('height', '')
  477. ;
  478. },
  479. keyboardShortcuts: function() {
  480. module.verbose('Removing keyboard shortcuts');
  481. $document
  482. .off('keyup' + eventNamespace)
  483. ;
  484. },
  485. scrolling: function() {
  486. $dimmable.removeClass(className.scrolling);
  487. $module.removeClass(className.scrolling);
  488. }
  489. },
  490. cacheSizes: function() {
  491. var
  492. modalHeight = $module.outerHeight()
  493. ;
  494. if(module.cache === undefined || modalHeight !== 0) {
  495. module.cache = {
  496. pageHeight : $(document).outerHeight(),
  497. height : modalHeight + settings.offset,
  498. contextHeight : (settings.context == 'body')
  499. ? $(window).height()
  500. : $dimmable.height()
  501. };
  502. }
  503. module.debug('Caching modal and container sizes', module.cache);
  504. },
  505. can: {
  506. fit: function() {
  507. return ( ( module.cache.height + (settings.padding * 2) ) < module.cache.contextHeight);
  508. }
  509. },
  510. is: {
  511. active: function() {
  512. return $module.hasClass(className.active);
  513. },
  514. animating: function() {
  515. return $module.transition('is supported')
  516. ? $module.transition('is animating')
  517. : $module.is(':visible')
  518. ;
  519. },
  520. scrolling: function() {
  521. return $dimmable.hasClass(className.scrolling);
  522. },
  523. modernBrowser: function() {
  524. // appName for IE11 reports 'Netscape' can no longer use
  525. return !(window.ActiveXObject || "ActiveXObject" in window);
  526. }
  527. },
  528. set: {
  529. autofocus: function() {
  530. var
  531. $inputs = $module.find('[tabindex], :input').filter(':visible'),
  532. $autofocus = $inputs.filter('[autofocus]'),
  533. $input = ($autofocus.length > 0)
  534. ? $autofocus.first()
  535. : $inputs.first()
  536. ;
  537. if($input.length > 0) {
  538. $input.focus();
  539. }
  540. },
  541. clickaway: function() {
  542. if(settings.closable) {
  543. $dimmer
  544. .on('click' + elementEventNamespace, module.event.click)
  545. ;
  546. }
  547. },
  548. screenHeight: function() {
  549. if( module.can.fit() ) {
  550. $body.css('height', '');
  551. }
  552. else {
  553. module.debug('Modal is taller than page content, resizing page height');
  554. $body
  555. .css('height', module.cache.height + (settings.padding * 2) )
  556. ;
  557. }
  558. },
  559. active: function() {
  560. $module.addClass(className.active);
  561. },
  562. scrolling: function() {
  563. $dimmable.addClass(className.scrolling);
  564. $module.addClass(className.scrolling);
  565. },
  566. type: function() {
  567. if(module.can.fit()) {
  568. module.verbose('Modal fits on screen');
  569. if(!module.others.active() && !module.others.animating()) {
  570. module.remove.scrolling();
  571. }
  572. }
  573. else {
  574. module.verbose('Modal cannot fit on screen setting to scrolling');
  575. module.set.scrolling();
  576. }
  577. },
  578. position: function() {
  579. module.verbose('Centering modal on page', module.cache);
  580. if(module.can.fit()) {
  581. $module
  582. .css({
  583. top: '',
  584. marginTop: -(module.cache.height / 2)
  585. })
  586. ;
  587. }
  588. else {
  589. $module
  590. .css({
  591. marginTop : '',
  592. top : $document.scrollTop()
  593. })
  594. ;
  595. }
  596. },
  597. undetached: function() {
  598. $dimmable.addClass(className.undetached);
  599. }
  600. },
  601. setting: function(name, value) {
  602. module.debug('Changing setting', name, value);
  603. if( $.isPlainObject(name) ) {
  604. $.extend(true, settings, name);
  605. }
  606. else if(value !== undefined) {
  607. if($.isPlainObject(settings[name])) {
  608. $.extend(true, settings[name], value);
  609. }
  610. else {
  611. settings[name] = value;
  612. }
  613. }
  614. else {
  615. return settings[name];
  616. }
  617. },
  618. internal: function(name, value) {
  619. if( $.isPlainObject(name) ) {
  620. $.extend(true, module, name);
  621. }
  622. else if(value !== undefined) {
  623. module[name] = value;
  624. }
  625. else {
  626. return module[name];
  627. }
  628. },
  629. debug: function() {
  630. if(!settings.silent && settings.debug) {
  631. if(settings.performance) {
  632. module.performance.log(arguments);
  633. }
  634. else {
  635. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  636. module.debug.apply(console, arguments);
  637. }
  638. }
  639. },
  640. verbose: function() {
  641. if(!settings.silent && settings.verbose && settings.debug) {
  642. if(settings.performance) {
  643. module.performance.log(arguments);
  644. }
  645. else {
  646. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  647. module.verbose.apply(console, arguments);
  648. }
  649. }
  650. },
  651. error: function() {
  652. if(!settings.silent) {
  653. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  654. module.error.apply(console, arguments);
  655. }
  656. },
  657. performance: {
  658. log: function(message) {
  659. var
  660. currentTime,
  661. executionTime,
  662. previousTime
  663. ;
  664. if(settings.performance) {
  665. currentTime = new Date().getTime();
  666. previousTime = time || currentTime;
  667. executionTime = currentTime - previousTime;
  668. time = currentTime;
  669. performance.push({
  670. 'Name' : message[0],
  671. 'Arguments' : [].slice.call(message, 1) || '',
  672. 'Element' : element,
  673. 'Execution Time' : executionTime
  674. });
  675. }
  676. clearTimeout(module.performance.timer);
  677. module.performance.timer = setTimeout(module.performance.display, 500);
  678. },
  679. display: function() {
  680. var
  681. title = settings.name + ':',
  682. totalTime = 0
  683. ;
  684. time = false;
  685. clearTimeout(module.performance.timer);
  686. $.each(performance, function(index, data) {
  687. totalTime += data['Execution Time'];
  688. });
  689. title += ' ' + totalTime + 'ms';
  690. if(moduleSelector) {
  691. title += ' \'' + moduleSelector + '\'';
  692. }
  693. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  694. console.groupCollapsed(title);
  695. if(console.table) {
  696. console.table(performance);
  697. }
  698. else {
  699. $.each(performance, function(index, data) {
  700. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  701. });
  702. }
  703. console.groupEnd();
  704. }
  705. performance = [];
  706. }
  707. },
  708. invoke: function(query, passedArguments, context) {
  709. var
  710. object = instance,
  711. maxDepth,
  712. found,
  713. response
  714. ;
  715. passedArguments = passedArguments || queryArguments;
  716. context = element || context;
  717. if(typeof query == 'string' && object !== undefined) {
  718. query = query.split(/[\. ]/);
  719. maxDepth = query.length - 1;
  720. $.each(query, function(depth, value) {
  721. var camelCaseValue = (depth != maxDepth)
  722. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  723. : query
  724. ;
  725. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  726. object = object[camelCaseValue];
  727. }
  728. else if( object[camelCaseValue] !== undefined ) {
  729. found = object[camelCaseValue];
  730. return false;
  731. }
  732. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  733. object = object[value];
  734. }
  735. else if( object[value] !== undefined ) {
  736. found = object[value];
  737. return false;
  738. }
  739. else {
  740. return false;
  741. }
  742. });
  743. }
  744. if ( $.isFunction( found ) ) {
  745. response = found.apply(context, passedArguments);
  746. }
  747. else if(found !== undefined) {
  748. response = found;
  749. }
  750. if($.isArray(returnedValue)) {
  751. returnedValue.push(response);
  752. }
  753. else if(returnedValue !== undefined) {
  754. returnedValue = [returnedValue, response];
  755. }
  756. else if(response !== undefined) {
  757. returnedValue = response;
  758. }
  759. return found;
  760. }
  761. };
  762. if(methodInvoked) {
  763. if(instance === undefined) {
  764. module.initialize();
  765. }
  766. module.invoke(query);
  767. }
  768. else {
  769. if(instance !== undefined) {
  770. instance.invoke('destroy');
  771. }
  772. module.initialize();
  773. }
  774. })
  775. ;
  776. return (returnedValue !== undefined)
  777. ? returnedValue
  778. : this
  779. ;
  780. };
  781. $.fn.modal.settings = {
  782. name : 'Modal',
  783. namespace : 'modal',
  784. silent : false,
  785. debug : false,
  786. verbose : false,
  787. performance : true,
  788. observeChanges : false,
  789. allowMultiple : false,
  790. detachable : true,
  791. closable : true,
  792. autofocus : true,
  793. inverted : false,
  794. blurring : false,
  795. dimmerSettings : {
  796. closable : false,
  797. useCSS : true
  798. },
  799. // whether to use keyboard shortcuts
  800. keyboardShortcuts: true,
  801. context : 'body',
  802. queue : false,
  803. duration : 500,
  804. offset : 0,
  805. transition : 'scale',
  806. // padding with edge of page
  807. padding : 50,
  808. // called before show animation
  809. onShow : function(){},
  810. // called after show animation
  811. onVisible : function(){},
  812. // called before hide animation
  813. onHide : function(){ return true; },
  814. // called after hide animation
  815. onHidden : function(){},
  816. // called after approve selector match
  817. onApprove : function(){ return true; },
  818. // called after deny selector match
  819. onDeny : function(){ return true; },
  820. selector : {
  821. close : '> .close',
  822. approve : '.actions .positive, .actions .approve, .actions .ok',
  823. deny : '.actions .negative, .actions .deny, .actions .cancel',
  824. modal : '.ui.modal'
  825. },
  826. error : {
  827. dimmer : 'UI Dimmer, a required component is not included in this page',
  828. method : 'The method you called is not defined.',
  829. notFound : 'The element you specified could not be found'
  830. },
  831. className : {
  832. active : 'active',
  833. animating : 'animating',
  834. blurring : 'blurring',
  835. scrolling : 'scrolling',
  836. undetached : 'undetached'
  837. }
  838. };
  839. })( jQuery, window, document );