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.

908 lines
27 KiB

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