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.

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