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.

907 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
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
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
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
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.2 - 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. module.add.keyboardShortcuts();
  314. module.save.focus();
  315. module.set.active();
  316. if(settings.autofocus) {
  317. module.set.autofocus();
  318. }
  319. callback();
  320. }
  321. })
  322. ;
  323. }
  324. else {
  325. module.error(error.noTransition);
  326. }
  327. }
  328. }
  329. else {
  330. module.debug('Modal is already visible');
  331. }
  332. },
  333. hideModal: function(callback, keepDimmed) {
  334. callback = $.isFunction(callback)
  335. ? callback
  336. : function(){}
  337. ;
  338. module.debug('Hiding modal');
  339. if(settings.onHide.call(element, $(this)) === false) {
  340. module.verbose('Hide callback returned false cancelling hide');
  341. return;
  342. }
  343. if( module.is.animating() || module.is.active() ) {
  344. if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
  345. module.remove.active();
  346. $module
  347. .transition({
  348. debug : settings.debug,
  349. animation : settings.transition + ' out',
  350. queue : settings.queue,
  351. duration : settings.duration,
  352. useFailSafe : true,
  353. onStart : function() {
  354. if(!module.others.active() && !keepDimmed) {
  355. module.hideDimmer();
  356. }
  357. module.remove.keyboardShortcuts();
  358. },
  359. onComplete : function() {
  360. settings.onHidden.call(element);
  361. module.restore.focus();
  362. callback();
  363. }
  364. })
  365. ;
  366. }
  367. else {
  368. module.error(error.noTransition);
  369. }
  370. }
  371. },
  372. showDimmer: function() {
  373. if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) {
  374. module.debug('Showing dimmer');
  375. $dimmable.dimmer('show');
  376. }
  377. else {
  378. module.debug('Dimmer already visible');
  379. }
  380. },
  381. hideDimmer: function() {
  382. if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) {
  383. $dimmable.dimmer('hide', function() {
  384. module.remove.clickaway();
  385. module.remove.screenHeight();
  386. });
  387. }
  388. else {
  389. module.debug('Dimmer is not visible cannot hide');
  390. return;
  391. }
  392. },
  393. hideAll: function(callback) {
  394. var
  395. $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating)
  396. ;
  397. callback = $.isFunction(callback)
  398. ? callback
  399. : function(){}
  400. ;
  401. if( $visibleModals.length > 0 ) {
  402. module.debug('Hiding all visible modals');
  403. module.hideDimmer();
  404. $visibleModals
  405. .modal('hide modal', callback)
  406. ;
  407. }
  408. },
  409. hideOthers: function(callback) {
  410. var
  411. $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating)
  412. ;
  413. callback = $.isFunction(callback)
  414. ? callback
  415. : function(){}
  416. ;
  417. if( $visibleModals.length > 0 ) {
  418. module.debug('Hiding other modals', $otherModals);
  419. $visibleModals
  420. .modal('hide modal', callback, true)
  421. ;
  422. }
  423. },
  424. others: {
  425. active: function() {
  426. return ($otherModals.filter('.' + className.active).length > 0);
  427. },
  428. animating: function() {
  429. return ($otherModals.filter('.' + className.animating).length > 0);
  430. }
  431. },
  432. add: {
  433. keyboardShortcuts: function() {
  434. module.verbose('Adding keyboard shortcuts');
  435. $document
  436. .on('keyup' + eventNamespace, module.event.keyboard)
  437. ;
  438. }
  439. },
  440. save: {
  441. focus: function() {
  442. $focusedElement = $(document.activeElement).blur();
  443. }
  444. },
  445. restore: {
  446. focus: function() {
  447. if($focusedElement && $focusedElement.length > 0) {
  448. $focusedElement.focus();
  449. }
  450. }
  451. },
  452. remove: {
  453. active: function() {
  454. $module.removeClass(className.active);
  455. },
  456. clickaway: function() {
  457. if(settings.closable) {
  458. $dimmer
  459. .off('click' + elementEventNamespace)
  460. ;
  461. }
  462. },
  463. bodyStyle: function() {
  464. if($body.attr('style') === '') {
  465. module.verbose('Removing style attribute');
  466. $body.removeAttr('style');
  467. }
  468. },
  469. screenHeight: function() {
  470. module.debug('Removing page height');
  471. $body
  472. .css('height', '')
  473. ;
  474. },
  475. keyboardShortcuts: function() {
  476. module.verbose('Removing keyboard shortcuts');
  477. $document
  478. .off('keyup' + eventNamespace)
  479. ;
  480. },
  481. scrolling: function() {
  482. $dimmable.removeClass(className.scrolling);
  483. $module.removeClass(className.scrolling);
  484. }
  485. },
  486. cacheSizes: function() {
  487. var
  488. modalHeight = $module.outerHeight()
  489. ;
  490. if(module.cache === undefined || modalHeight !== 0) {
  491. module.cache = {
  492. pageHeight : $(document).outerHeight(),
  493. height : modalHeight + settings.offset,
  494. contextHeight : (settings.context == 'body')
  495. ? $(window).height()
  496. : $dimmable.height()
  497. };
  498. }
  499. module.debug('Caching modal and container sizes', module.cache);
  500. },
  501. can: {
  502. fit: function() {
  503. return ( ( module.cache.height + (settings.padding * 2) ) < module.cache.contextHeight);
  504. }
  505. },
  506. is: {
  507. active: function() {
  508. return $module.hasClass(className.active);
  509. },
  510. animating: function() {
  511. return $module.transition('is supported')
  512. ? $module.transition('is animating')
  513. : $module.is(':visible')
  514. ;
  515. },
  516. scrolling: function() {
  517. return $dimmable.hasClass(className.scrolling);
  518. },
  519. modernBrowser: function() {
  520. // appName for IE11 reports 'Netscape' can no longer use
  521. return !(window.ActiveXObject || "ActiveXObject" in window);
  522. }
  523. },
  524. set: {
  525. autofocus: function() {
  526. var
  527. $inputs = $module.find(':input').filter(':visible'),
  528. $autofocus = $inputs.filter('[autofocus]'),
  529. $input = ($autofocus.length > 0)
  530. ? $autofocus.first()
  531. : $inputs.first()
  532. ;
  533. if($input.length > 0) {
  534. $input.focus();
  535. }
  536. },
  537. clickaway: function() {
  538. if(settings.closable) {
  539. $dimmer
  540. .on('click' + elementEventNamespace, module.event.click)
  541. ;
  542. }
  543. },
  544. screenHeight: function() {
  545. if( module.can.fit() ) {
  546. $body.css('height', '');
  547. }
  548. else {
  549. module.debug('Modal is taller than page content, resizing page height');
  550. $body
  551. .css('height', module.cache.height + (settings.padding * 2) )
  552. ;
  553. }
  554. },
  555. active: function() {
  556. $module.addClass(className.active);
  557. },
  558. scrolling: function() {
  559. $dimmable.addClass(className.scrolling);
  560. $module.addClass(className.scrolling);
  561. },
  562. type: function() {
  563. if(module.can.fit()) {
  564. module.verbose('Modal fits on screen');
  565. if(!module.others.active() && !module.others.animating()) {
  566. module.remove.scrolling();
  567. }
  568. }
  569. else {
  570. module.verbose('Modal cannot fit on screen setting to scrolling');
  571. module.set.scrolling();
  572. }
  573. },
  574. position: function() {
  575. module.verbose('Centering modal on page', module.cache);
  576. if(module.can.fit()) {
  577. $module
  578. .css({
  579. top: '',
  580. marginTop: -(module.cache.height / 2)
  581. })
  582. ;
  583. }
  584. else {
  585. $module
  586. .css({
  587. marginTop : '',
  588. top : $document.scrollTop()
  589. })
  590. ;
  591. }
  592. },
  593. undetached: function() {
  594. $dimmable.addClass(className.undetached);
  595. }
  596. },
  597. setting: function(name, value) {
  598. module.debug('Changing setting', name, value);
  599. if( $.isPlainObject(name) ) {
  600. $.extend(true, settings, name);
  601. }
  602. else if(value !== undefined) {
  603. if($.isPlainObject(settings[name])) {
  604. $.extend(true, settings[name], value);
  605. }
  606. else {
  607. settings[name] = value;
  608. }
  609. }
  610. else {
  611. return settings[name];
  612. }
  613. },
  614. internal: function(name, value) {
  615. if( $.isPlainObject(name) ) {
  616. $.extend(true, module, name);
  617. }
  618. else if(value !== undefined) {
  619. module[name] = value;
  620. }
  621. else {
  622. return module[name];
  623. }
  624. },
  625. debug: function() {
  626. if(!settings.silent && settings.debug) {
  627. if(settings.performance) {
  628. module.performance.log(arguments);
  629. }
  630. else {
  631. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  632. module.debug.apply(console, arguments);
  633. }
  634. }
  635. },
  636. verbose: function() {
  637. if(!settings.silent && settings.verbose && settings.debug) {
  638. if(settings.performance) {
  639. module.performance.log(arguments);
  640. }
  641. else {
  642. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  643. module.verbose.apply(console, arguments);
  644. }
  645. }
  646. },
  647. error: function() {
  648. if(!settings.silent) {
  649. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  650. module.error.apply(console, arguments);
  651. }
  652. },
  653. performance: {
  654. log: function(message) {
  655. var
  656. currentTime,
  657. executionTime,
  658. previousTime
  659. ;
  660. if(settings.performance) {
  661. currentTime = new Date().getTime();
  662. previousTime = time || currentTime;
  663. executionTime = currentTime - previousTime;
  664. time = currentTime;
  665. performance.push({
  666. 'Name' : message[0],
  667. 'Arguments' : [].slice.call(message, 1) || '',
  668. 'Element' : element,
  669. 'Execution Time' : executionTime
  670. });
  671. }
  672. clearTimeout(module.performance.timer);
  673. module.performance.timer = setTimeout(module.performance.display, 500);
  674. },
  675. display: function() {
  676. var
  677. title = settings.name + ':',
  678. totalTime = 0
  679. ;
  680. time = false;
  681. clearTimeout(module.performance.timer);
  682. $.each(performance, function(index, data) {
  683. totalTime += data['Execution Time'];
  684. });
  685. title += ' ' + totalTime + 'ms';
  686. if(moduleSelector) {
  687. title += ' \'' + moduleSelector + '\'';
  688. }
  689. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  690. console.groupCollapsed(title);
  691. if(console.table) {
  692. console.table(performance);
  693. }
  694. else {
  695. $.each(performance, function(index, data) {
  696. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  697. });
  698. }
  699. console.groupEnd();
  700. }
  701. performance = [];
  702. }
  703. },
  704. invoke: function(query, passedArguments, context) {
  705. var
  706. object = instance,
  707. maxDepth,
  708. found,
  709. response
  710. ;
  711. passedArguments = passedArguments || queryArguments;
  712. context = element || context;
  713. if(typeof query == 'string' && object !== undefined) {
  714. query = query.split(/[\. ]/);
  715. maxDepth = query.length - 1;
  716. $.each(query, function(depth, value) {
  717. var camelCaseValue = (depth != maxDepth)
  718. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  719. : query
  720. ;
  721. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  722. object = object[camelCaseValue];
  723. }
  724. else if( object[camelCaseValue] !== undefined ) {
  725. found = object[camelCaseValue];
  726. return false;
  727. }
  728. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  729. object = object[value];
  730. }
  731. else if( object[value] !== undefined ) {
  732. found = object[value];
  733. return false;
  734. }
  735. else {
  736. return false;
  737. }
  738. });
  739. }
  740. if ( $.isFunction( found ) ) {
  741. response = found.apply(context, passedArguments);
  742. }
  743. else if(found !== undefined) {
  744. response = found;
  745. }
  746. if($.isArray(returnedValue)) {
  747. returnedValue.push(response);
  748. }
  749. else if(returnedValue !== undefined) {
  750. returnedValue = [returnedValue, response];
  751. }
  752. else if(response !== undefined) {
  753. returnedValue = response;
  754. }
  755. return found;
  756. }
  757. };
  758. if(methodInvoked) {
  759. if(instance === undefined) {
  760. module.initialize();
  761. }
  762. module.invoke(query);
  763. }
  764. else {
  765. if(instance !== undefined) {
  766. instance.invoke('destroy');
  767. }
  768. module.initialize();
  769. }
  770. })
  771. ;
  772. return (returnedValue !== undefined)
  773. ? returnedValue
  774. : this
  775. ;
  776. };
  777. $.fn.modal.settings = {
  778. name : 'Modal',
  779. namespace : 'modal',
  780. silent : false,
  781. debug : false,
  782. verbose : false,
  783. performance : true,
  784. observeChanges : false,
  785. allowMultiple : false,
  786. detachable : true,
  787. closable : true,
  788. autofocus : true,
  789. inverted : false,
  790. blurring : false,
  791. dimmerSettings : {
  792. closable : false,
  793. useCSS : true
  794. },
  795. context : 'body',
  796. queue : false,
  797. duration : 500,
  798. offset : 0,
  799. transition : 'scale',
  800. // padding with edge of page
  801. padding : 50,
  802. // called before show animation
  803. onShow : function(){},
  804. // called after show animation
  805. onVisible : function(){},
  806. // called before hide animation
  807. onHide : function(){ return true; },
  808. // called after hide animation
  809. onHidden : function(){},
  810. // called after approve selector match
  811. onApprove : function(){ return true; },
  812. // called after deny selector match
  813. onDeny : function(){ return true; },
  814. selector : {
  815. close : '> .close',
  816. approve : '.actions .positive, .actions .approve, .actions .ok',
  817. deny : '.actions .negative, .actions .deny, .actions .cancel',
  818. modal : '.ui.modal'
  819. },
  820. error : {
  821. dimmer : 'UI Dimmer, a required component is not included in this page',
  822. method : 'The method you called is not defined.',
  823. notFound : 'The element you specified could not be found'
  824. },
  825. className : {
  826. active : 'active',
  827. animating : 'animating',
  828. blurring : 'blurring',
  829. scrolling : 'scrolling',
  830. undetached : 'undetached'
  831. }
  832. };
  833. })( jQuery, window, document );