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.

893 lines
27 KiB

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
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
9 years ago
10 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
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
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
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
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
  1. /*!
  2. * # Semantic UI 2.2.0 - Shape
  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.shape = function(parameters) {
  20. var
  21. $allModules = $(this),
  22. $body = $('body'),
  23. time = new Date().getTime(),
  24. performance = [],
  25. query = arguments[0],
  26. methodInvoked = (typeof query == 'string'),
  27. queryArguments = [].slice.call(arguments, 1),
  28. requestAnimationFrame = window.requestAnimationFrame
  29. || window.mozRequestAnimationFrame
  30. || window.webkitRequestAnimationFrame
  31. || window.msRequestAnimationFrame
  32. || function(callback) { setTimeout(callback, 0); },
  33. returnedValue
  34. ;
  35. $allModules
  36. .each(function() {
  37. var
  38. moduleSelector = $allModules.selector || '',
  39. settings = ( $.isPlainObject(parameters) )
  40. ? $.extend(true, {}, $.fn.shape.settings, parameters)
  41. : $.extend({}, $.fn.shape.settings),
  42. // internal aliases
  43. namespace = settings.namespace,
  44. selector = settings.selector,
  45. error = settings.error,
  46. className = settings.className,
  47. // define namespaces for modules
  48. eventNamespace = '.' + namespace,
  49. moduleNamespace = 'module-' + namespace,
  50. // selector cache
  51. $module = $(this),
  52. $sides = $module.find(selector.sides),
  53. $side = $module.find(selector.side),
  54. // private variables
  55. nextIndex = false,
  56. $activeSide,
  57. $nextSide,
  58. // standard module
  59. element = this,
  60. instance = $module.data(moduleNamespace),
  61. module
  62. ;
  63. module = {
  64. initialize: function() {
  65. module.verbose('Initializing module for', element);
  66. module.set.defaultSide();
  67. module.instantiate();
  68. },
  69. instantiate: function() {
  70. module.verbose('Storing instance of module', module);
  71. instance = module;
  72. $module
  73. .data(moduleNamespace, instance)
  74. ;
  75. },
  76. destroy: function() {
  77. module.verbose('Destroying previous module for', element);
  78. $module
  79. .removeData(moduleNamespace)
  80. .off(eventNamespace)
  81. ;
  82. },
  83. refresh: function() {
  84. module.verbose('Refreshing selector cache for', element);
  85. $module = $(element);
  86. $sides = $(this).find(selector.shape);
  87. $side = $(this).find(selector.side);
  88. },
  89. repaint: function() {
  90. module.verbose('Forcing repaint event');
  91. var
  92. shape = $sides[0] || document.createElement('div'),
  93. fakeAssignment = shape.offsetWidth
  94. ;
  95. },
  96. animate: function(propertyObject, callback) {
  97. module.verbose('Animating box with properties', propertyObject);
  98. callback = callback || function(event) {
  99. module.verbose('Executing animation callback');
  100. if(event !== undefined) {
  101. event.stopPropagation();
  102. }
  103. module.reset();
  104. module.set.active();
  105. };
  106. settings.beforeChange.call($nextSide[0]);
  107. if(module.get.transitionEvent()) {
  108. module.verbose('Starting CSS animation');
  109. $module
  110. .addClass(className.animating)
  111. ;
  112. $sides
  113. .css(propertyObject)
  114. .one(module.get.transitionEvent(), callback)
  115. ;
  116. module.set.duration(settings.duration);
  117. requestAnimationFrame(function() {
  118. $module
  119. .addClass(className.animating)
  120. ;
  121. $activeSide
  122. .addClass(className.hidden)
  123. ;
  124. });
  125. }
  126. else {
  127. callback();
  128. }
  129. },
  130. queue: function(method) {
  131. module.debug('Queueing animation of', method);
  132. $sides
  133. .one(module.get.transitionEvent(), function() {
  134. module.debug('Executing queued animation');
  135. setTimeout(function(){
  136. $module.shape(method);
  137. }, 0);
  138. })
  139. ;
  140. },
  141. reset: function() {
  142. module.verbose('Animating states reset');
  143. $module
  144. .removeClass(className.animating)
  145. .attr('style', '')
  146. .removeAttr('style')
  147. ;
  148. // removeAttr style does not consistently work in safari
  149. $sides
  150. .attr('style', '')
  151. .removeAttr('style')
  152. ;
  153. $side
  154. .attr('style', '')
  155. .removeAttr('style')
  156. .removeClass(className.hidden)
  157. ;
  158. $nextSide
  159. .removeClass(className.animating)
  160. .attr('style', '')
  161. .removeAttr('style')
  162. ;
  163. },
  164. is: {
  165. complete: function() {
  166. return ($side.filter('.' + className.active)[0] == $nextSide[0]);
  167. },
  168. animating: function() {
  169. return $module.hasClass(className.animating);
  170. }
  171. },
  172. set: {
  173. defaultSide: function() {
  174. $activeSide = $module.find('.' + settings.className.active);
  175. $nextSide = ( $activeSide.next(selector.side).length > 0 )
  176. ? $activeSide.next(selector.side)
  177. : $module.find(selector.side).first()
  178. ;
  179. nextIndex = false;
  180. module.verbose('Active side set to', $activeSide);
  181. module.verbose('Next side set to', $nextSide);
  182. },
  183. duration: function(duration) {
  184. duration = duration || settings.duration;
  185. duration = (typeof duration == 'number')
  186. ? duration + 'ms'
  187. : duration
  188. ;
  189. module.verbose('Setting animation duration', duration);
  190. if(settings.duration || settings.duration === 0) {
  191. $sides.add($side)
  192. .css({
  193. '-webkit-transition-duration': duration,
  194. '-moz-transition-duration': duration,
  195. '-ms-transition-duration': duration,
  196. '-o-transition-duration': duration,
  197. 'transition-duration': duration
  198. })
  199. ;
  200. }
  201. },
  202. currentStageSize: function() {
  203. var
  204. $activeSide = $module.find('.' + settings.className.active),
  205. width = $activeSide.outerWidth(true),
  206. height = $activeSide.outerHeight(true)
  207. ;
  208. $module
  209. .css({
  210. width: width,
  211. height: height
  212. })
  213. ;
  214. },
  215. stageSize: function() {
  216. var
  217. $clone = $module.clone().addClass(className.loading),
  218. $activeSide = $clone.find('.' + settings.className.active),
  219. $nextSide = (nextIndex)
  220. ? $clone.find(selector.side).eq(nextIndex)
  221. : ( $activeSide.next(selector.side).length > 0 )
  222. ? $activeSide.next(selector.side)
  223. : $clone.find(selector.side).first(),
  224. newSize = {}
  225. ;
  226. module.set.currentStageSize();
  227. $activeSide.removeClass(className.active);
  228. $nextSide.addClass(className.active);
  229. $clone.insertAfter($module);
  230. newSize = {
  231. width : $nextSide.outerWidth(true),
  232. height : $nextSide.outerHeight(true)
  233. };
  234. $clone.remove();
  235. $module
  236. .css(newSize)
  237. ;
  238. module.verbose('Resizing stage to fit new content', newSize);
  239. },
  240. nextSide: function(selector) {
  241. nextIndex = selector;
  242. $nextSide = $side.filter(selector);
  243. nextIndex = $side.index($nextSide);
  244. if($nextSide.length === 0) {
  245. module.set.defaultSide();
  246. module.error(error.side);
  247. }
  248. module.verbose('Next side manually set to', $nextSide);
  249. },
  250. active: function() {
  251. module.verbose('Setting new side to active', $nextSide);
  252. $side
  253. .removeClass(className.active)
  254. ;
  255. $nextSide
  256. .addClass(className.active)
  257. ;
  258. settings.onChange.call($nextSide[0]);
  259. module.set.defaultSide();
  260. }
  261. },
  262. flip: {
  263. up: function() {
  264. if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
  265. module.debug('Side already visible', $nextSide);
  266. return;
  267. }
  268. if( !module.is.animating()) {
  269. module.debug('Flipping up', $nextSide);
  270. module.set.stageSize();
  271. module.stage.above();
  272. module.animate( module.get.transform.up() );
  273. }
  274. else {
  275. module.queue('flip up');
  276. }
  277. },
  278. down: function() {
  279. if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
  280. module.debug('Side already visible', $nextSide);
  281. return;
  282. }
  283. if( !module.is.animating()) {
  284. module.debug('Flipping down', $nextSide);
  285. module.set.stageSize();
  286. module.stage.below();
  287. module.animate( module.get.transform.down() );
  288. }
  289. else {
  290. module.queue('flip down');
  291. }
  292. },
  293. left: function() {
  294. if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
  295. module.debug('Side already visible', $nextSide);
  296. return;
  297. }
  298. if( !module.is.animating()) {
  299. module.debug('Flipping left', $nextSide);
  300. module.set.stageSize();
  301. module.stage.left();
  302. module.animate(module.get.transform.left() );
  303. }
  304. else {
  305. module.queue('flip left');
  306. }
  307. },
  308. right: function() {
  309. if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
  310. module.debug('Side already visible', $nextSide);
  311. return;
  312. }
  313. if( !module.is.animating()) {
  314. module.debug('Flipping right', $nextSide);
  315. module.set.stageSize();
  316. module.stage.right();
  317. module.animate(module.get.transform.right() );
  318. }
  319. else {
  320. module.queue('flip right');
  321. }
  322. },
  323. over: function() {
  324. if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
  325. module.debug('Side already visible', $nextSide);
  326. return;
  327. }
  328. if( !module.is.animating()) {
  329. module.debug('Flipping over', $nextSide);
  330. module.set.stageSize();
  331. module.stage.behind();
  332. module.animate(module.get.transform.over() );
  333. }
  334. else {
  335. module.queue('flip over');
  336. }
  337. },
  338. back: function() {
  339. if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
  340. module.debug('Side already visible', $nextSide);
  341. return;
  342. }
  343. if( !module.is.animating()) {
  344. module.debug('Flipping back', $nextSide);
  345. module.set.stageSize();
  346. module.stage.behind();
  347. module.animate(module.get.transform.back() );
  348. }
  349. else {
  350. module.queue('flip back');
  351. }
  352. }
  353. },
  354. get: {
  355. transform: {
  356. up: function() {
  357. var
  358. translate = {
  359. y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
  360. z: -($activeSide.outerHeight(true) / 2)
  361. }
  362. ;
  363. return {
  364. transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(-90deg)'
  365. };
  366. },
  367. down: function() {
  368. var
  369. translate = {
  370. y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
  371. z: -($activeSide.outerHeight(true) / 2)
  372. }
  373. ;
  374. return {
  375. transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(90deg)'
  376. };
  377. },
  378. left: function() {
  379. var
  380. translate = {
  381. x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
  382. z : -($activeSide.outerWidth(true) / 2)
  383. }
  384. ;
  385. return {
  386. transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(90deg)'
  387. };
  388. },
  389. right: function() {
  390. var
  391. translate = {
  392. x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
  393. z : -($activeSide.outerWidth(true) / 2)
  394. }
  395. ;
  396. return {
  397. transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(-90deg)'
  398. };
  399. },
  400. over: function() {
  401. var
  402. translate = {
  403. x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2)
  404. }
  405. ;
  406. return {
  407. transform: 'translateX(' + translate.x + 'px) rotateY(180deg)'
  408. };
  409. },
  410. back: function() {
  411. var
  412. translate = {
  413. x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2)
  414. }
  415. ;
  416. return {
  417. transform: 'translateX(' + translate.x + 'px) rotateY(-180deg)'
  418. };
  419. }
  420. },
  421. transitionEvent: function() {
  422. var
  423. element = document.createElement('element'),
  424. transitions = {
  425. 'transition' :'transitionend',
  426. 'OTransition' :'oTransitionEnd',
  427. 'MozTransition' :'transitionend',
  428. 'WebkitTransition' :'webkitTransitionEnd'
  429. },
  430. transition
  431. ;
  432. for(transition in transitions){
  433. if( element.style[transition] !== undefined ){
  434. return transitions[transition];
  435. }
  436. }
  437. },
  438. nextSide: function() {
  439. return ( $activeSide.next(selector.side).length > 0 )
  440. ? $activeSide.next(selector.side)
  441. : $module.find(selector.side).first()
  442. ;
  443. }
  444. },
  445. stage: {
  446. above: function() {
  447. var
  448. box = {
  449. origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
  450. depth : {
  451. active : ($nextSide.outerHeight(true) / 2),
  452. next : ($activeSide.outerHeight(true) / 2)
  453. }
  454. }
  455. ;
  456. module.verbose('Setting the initial animation position as above', $nextSide, box);
  457. $sides
  458. .css({
  459. 'transform' : 'translateZ(-' + box.depth.active + 'px)'
  460. })
  461. ;
  462. $activeSide
  463. .css({
  464. 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
  465. })
  466. ;
  467. $nextSide
  468. .addClass(className.animating)
  469. .css({
  470. 'top' : box.origin + 'px',
  471. 'transform' : 'rotateX(90deg) translateZ(' + box.depth.next + 'px)'
  472. })
  473. ;
  474. },
  475. below: function() {
  476. var
  477. box = {
  478. origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
  479. depth : {
  480. active : ($nextSide.outerHeight(true) / 2),
  481. next : ($activeSide.outerHeight(true) / 2)
  482. }
  483. }
  484. ;
  485. module.verbose('Setting the initial animation position as below', $nextSide, box);
  486. $sides
  487. .css({
  488. 'transform' : 'translateZ(-' + box.depth.active + 'px)'
  489. })
  490. ;
  491. $activeSide
  492. .css({
  493. 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
  494. })
  495. ;
  496. $nextSide
  497. .addClass(className.animating)
  498. .css({
  499. 'top' : box.origin + 'px',
  500. 'transform' : 'rotateX(-90deg) translateZ(' + box.depth.next + 'px)'
  501. })
  502. ;
  503. },
  504. left: function() {
  505. var
  506. height = {
  507. active : $activeSide.outerWidth(true),
  508. next : $nextSide.outerWidth(true)
  509. },
  510. box = {
  511. origin : ( ( height.active - height.next ) / 2),
  512. depth : {
  513. active : (height.next / 2),
  514. next : (height.active / 2)
  515. }
  516. }
  517. ;
  518. module.verbose('Setting the initial animation position as left', $nextSide, box);
  519. $sides
  520. .css({
  521. 'transform' : 'translateZ(-' + box.depth.active + 'px)'
  522. })
  523. ;
  524. $activeSide
  525. .css({
  526. 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
  527. })
  528. ;
  529. $nextSide
  530. .addClass(className.animating)
  531. .css({
  532. 'left' : box.origin + 'px',
  533. 'transform' : 'rotateY(-90deg) translateZ(' + box.depth.next + 'px)'
  534. })
  535. ;
  536. },
  537. right: function() {
  538. var
  539. height = {
  540. active : $activeSide.outerWidth(true),
  541. next : $nextSide.outerWidth(true)
  542. },
  543. box = {
  544. origin : ( ( height.active - height.next ) / 2),
  545. depth : {
  546. active : (height.next / 2),
  547. next : (height.active / 2)
  548. }
  549. }
  550. ;
  551. module.verbose('Setting the initial animation position as left', $nextSide, box);
  552. $sides
  553. .css({
  554. 'transform' : 'translateZ(-' + box.depth.active + 'px)'
  555. })
  556. ;
  557. $activeSide
  558. .css({
  559. 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
  560. })
  561. ;
  562. $nextSide
  563. .addClass(className.animating)
  564. .css({
  565. 'left' : box.origin + 'px',
  566. 'transform' : 'rotateY(90deg) translateZ(' + box.depth.next + 'px)'
  567. })
  568. ;
  569. },
  570. behind: function() {
  571. var
  572. height = {
  573. active : $activeSide.outerWidth(true),
  574. next : $nextSide.outerWidth(true)
  575. },
  576. box = {
  577. origin : ( ( height.active - height.next ) / 2),
  578. depth : {
  579. active : (height.next / 2),
  580. next : (height.active / 2)
  581. }
  582. }
  583. ;
  584. module.verbose('Setting the initial animation position as behind', $nextSide, box);
  585. $activeSide
  586. .css({
  587. 'transform' : 'rotateY(0deg)'
  588. })
  589. ;
  590. $nextSide
  591. .addClass(className.animating)
  592. .css({
  593. 'left' : box.origin + 'px',
  594. 'transform' : 'rotateY(-180deg)'
  595. })
  596. ;
  597. }
  598. },
  599. setting: function(name, value) {
  600. module.debug('Changing setting', name, value);
  601. if( $.isPlainObject(name) ) {
  602. $.extend(true, settings, name);
  603. }
  604. else if(value !== undefined) {
  605. if($.isPlainObject(settings[name])) {
  606. $.extend(true, settings[name], value);
  607. }
  608. else {
  609. settings[name] = value;
  610. }
  611. }
  612. else {
  613. return settings[name];
  614. }
  615. },
  616. internal: function(name, value) {
  617. if( $.isPlainObject(name) ) {
  618. $.extend(true, module, name);
  619. }
  620. else if(value !== undefined) {
  621. module[name] = value;
  622. }
  623. else {
  624. return module[name];
  625. }
  626. },
  627. debug: function() {
  628. if(!settings.silent && settings.debug) {
  629. if(settings.performance) {
  630. module.performance.log(arguments);
  631. }
  632. else {
  633. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  634. module.debug.apply(console, arguments);
  635. }
  636. }
  637. },
  638. verbose: function() {
  639. if(!settings.silent && settings.verbose && settings.debug) {
  640. if(settings.performance) {
  641. module.performance.log(arguments);
  642. }
  643. else {
  644. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  645. module.verbose.apply(console, arguments);
  646. }
  647. }
  648. },
  649. error: function() {
  650. if(!settings.silent) {
  651. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  652. module.error.apply(console, arguments);
  653. }
  654. },
  655. performance: {
  656. log: function(message) {
  657. var
  658. currentTime,
  659. executionTime,
  660. previousTime
  661. ;
  662. if(settings.performance) {
  663. currentTime = new Date().getTime();
  664. previousTime = time || currentTime;
  665. executionTime = currentTime - previousTime;
  666. time = currentTime;
  667. performance.push({
  668. 'Name' : message[0],
  669. 'Arguments' : [].slice.call(message, 1) || '',
  670. 'Element' : element,
  671. 'Execution Time' : executionTime
  672. });
  673. }
  674. clearTimeout(module.performance.timer);
  675. module.performance.timer = setTimeout(module.performance.display, 500);
  676. },
  677. display: function() {
  678. var
  679. title = settings.name + ':',
  680. totalTime = 0
  681. ;
  682. time = false;
  683. clearTimeout(module.performance.timer);
  684. $.each(performance, function(index, data) {
  685. totalTime += data['Execution Time'];
  686. });
  687. title += ' ' + totalTime + 'ms';
  688. if(moduleSelector) {
  689. title += ' \'' + moduleSelector + '\'';
  690. }
  691. if($allModules.length > 1) {
  692. title += ' ' + '(' + $allModules.length + ')';
  693. }
  694. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  695. console.groupCollapsed(title);
  696. if(console.table) {
  697. console.table(performance);
  698. }
  699. else {
  700. $.each(performance, function(index, data) {
  701. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  702. });
  703. }
  704. console.groupEnd();
  705. }
  706. performance = [];
  707. }
  708. },
  709. invoke: function(query, passedArguments, context) {
  710. var
  711. object = instance,
  712. maxDepth,
  713. found,
  714. response
  715. ;
  716. passedArguments = passedArguments || queryArguments;
  717. context = element || context;
  718. if(typeof query == 'string' && object !== undefined) {
  719. query = query.split(/[\. ]/);
  720. maxDepth = query.length - 1;
  721. $.each(query, function(depth, value) {
  722. var camelCaseValue = (depth != maxDepth)
  723. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  724. : query
  725. ;
  726. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  727. object = object[camelCaseValue];
  728. }
  729. else if( object[camelCaseValue] !== undefined ) {
  730. found = object[camelCaseValue];
  731. return false;
  732. }
  733. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  734. object = object[value];
  735. }
  736. else if( object[value] !== undefined ) {
  737. found = object[value];
  738. return false;
  739. }
  740. else {
  741. return false;
  742. }
  743. });
  744. }
  745. if ( $.isFunction( found ) ) {
  746. response = found.apply(context, passedArguments);
  747. }
  748. else if(found !== undefined) {
  749. response = found;
  750. }
  751. if($.isArray(returnedValue)) {
  752. returnedValue.push(response);
  753. }
  754. else if(returnedValue !== undefined) {
  755. returnedValue = [returnedValue, response];
  756. }
  757. else if(response !== undefined) {
  758. returnedValue = response;
  759. }
  760. return found;
  761. }
  762. };
  763. if(methodInvoked) {
  764. if(instance === undefined) {
  765. module.initialize();
  766. }
  767. module.invoke(query);
  768. }
  769. else {
  770. if(instance !== undefined) {
  771. instance.invoke('destroy');
  772. }
  773. module.initialize();
  774. }
  775. })
  776. ;
  777. return (returnedValue !== undefined)
  778. ? returnedValue
  779. : this
  780. ;
  781. };
  782. $.fn.shape.settings = {
  783. // module info
  784. name : 'Shape',
  785. // hide all debug content
  786. silent : false,
  787. // debug content outputted to console
  788. debug : false,
  789. // verbose debug output
  790. verbose : false,
  791. // performance data output
  792. performance: true,
  793. // event namespace
  794. namespace : 'shape',
  795. // callback occurs on side change
  796. beforeChange : function() {},
  797. onChange : function() {},
  798. // allow animation to same side
  799. allowRepeats: false,
  800. // animation duration
  801. duration : false,
  802. // possible errors
  803. error: {
  804. side : 'You tried to switch to a side that does not exist.',
  805. method : 'The method you called is not defined'
  806. },
  807. // classnames used
  808. className : {
  809. animating : 'animating',
  810. hidden : 'hidden',
  811. loading : 'loading',
  812. active : 'active'
  813. },
  814. // selectors used
  815. selector : {
  816. sides : '.sides',
  817. side : '.side'
  818. }
  819. };
  820. })( jQuery, window, document );