| @@ 14741-15651 (lines=911) @@ | ||
| 14738 | * |
|
| 14739 | */ |
|
| 14740 | ||
| 14741 | ;(function ($, window, document, undefined) { |
|
| 14742 | ||
| 14743 | "use strict"; |
|
| 14744 | ||
| 14745 | window = (typeof window != 'undefined' && window.Math == Math) |
|
| 14746 | ? window |
|
| 14747 | : (typeof self != 'undefined' && self.Math == Math) |
|
| 14748 | ? self |
|
| 14749 | : Function('return this')() |
|
| 14750 | ; |
|
| 14751 | ||
| 14752 | $.fn.shape = function(parameters) { |
|
| 14753 | var |
|
| 14754 | $allModules = $(this), |
|
| 14755 | $body = $('body'), |
|
| 14756 | ||
| 14757 | time = new Date().getTime(), |
|
| 14758 | performance = [], |
|
| 14759 | ||
| 14760 | query = arguments[0], |
|
| 14761 | methodInvoked = (typeof query == 'string'), |
|
| 14762 | queryArguments = [].slice.call(arguments, 1), |
|
| 14763 | ||
| 14764 | requestAnimationFrame = window.requestAnimationFrame |
|
| 14765 | || window.mozRequestAnimationFrame |
|
| 14766 | || window.webkitRequestAnimationFrame |
|
| 14767 | || window.msRequestAnimationFrame |
|
| 14768 | || function(callback) { setTimeout(callback, 0); }, |
|
| 14769 | ||
| 14770 | returnedValue |
|
| 14771 | ; |
|
| 14772 | ||
| 14773 | $allModules |
|
| 14774 | .each(function() { |
|
| 14775 | var |
|
| 14776 | moduleSelector = $allModules.selector || '', |
|
| 14777 | settings = ( $.isPlainObject(parameters) ) |
|
| 14778 | ? $.extend(true, {}, $.fn.shape.settings, parameters) |
|
| 14779 | : $.extend({}, $.fn.shape.settings), |
|
| 14780 | ||
| 14781 | // internal aliases |
|
| 14782 | namespace = settings.namespace, |
|
| 14783 | selector = settings.selector, |
|
| 14784 | error = settings.error, |
|
| 14785 | className = settings.className, |
|
| 14786 | ||
| 14787 | // define namespaces for modules |
|
| 14788 | eventNamespace = '.' + namespace, |
|
| 14789 | moduleNamespace = 'module-' + namespace, |
|
| 14790 | ||
| 14791 | // selector cache |
|
| 14792 | $module = $(this), |
|
| 14793 | $sides = $module.find(selector.sides), |
|
| 14794 | $side = $module.find(selector.side), |
|
| 14795 | ||
| 14796 | // private variables |
|
| 14797 | nextIndex = false, |
|
| 14798 | $activeSide, |
|
| 14799 | $nextSide, |
|
| 14800 | ||
| 14801 | // standard module |
|
| 14802 | element = this, |
|
| 14803 | instance = $module.data(moduleNamespace), |
|
| 14804 | module |
|
| 14805 | ; |
|
| 14806 | ||
| 14807 | module = { |
|
| 14808 | ||
| 14809 | initialize: function() { |
|
| 14810 | module.verbose('Initializing module for', element); |
|
| 14811 | module.set.defaultSide(); |
|
| 14812 | module.instantiate(); |
|
| 14813 | }, |
|
| 14814 | ||
| 14815 | instantiate: function() { |
|
| 14816 | module.verbose('Storing instance of module', module); |
|
| 14817 | instance = module; |
|
| 14818 | $module |
|
| 14819 | .data(moduleNamespace, instance) |
|
| 14820 | ; |
|
| 14821 | }, |
|
| 14822 | ||
| 14823 | destroy: function() { |
|
| 14824 | module.verbose('Destroying previous module for', element); |
|
| 14825 | $module |
|
| 14826 | .removeData(moduleNamespace) |
|
| 14827 | .off(eventNamespace) |
|
| 14828 | ; |
|
| 14829 | }, |
|
| 14830 | ||
| 14831 | refresh: function() { |
|
| 14832 | module.verbose('Refreshing selector cache for', element); |
|
| 14833 | $module = $(element); |
|
| 14834 | $sides = $(this).find(selector.shape); |
|
| 14835 | $side = $(this).find(selector.side); |
|
| 14836 | }, |
|
| 14837 | ||
| 14838 | repaint: function() { |
|
| 14839 | module.verbose('Forcing repaint event'); |
|
| 14840 | var |
|
| 14841 | shape = $sides[0] || document.createElement('div'), |
|
| 14842 | fakeAssignment = shape.offsetWidth |
|
| 14843 | ; |
|
| 14844 | }, |
|
| 14845 | ||
| 14846 | animate: function(propertyObject, callback) { |
|
| 14847 | module.verbose('Animating box with properties', propertyObject); |
|
| 14848 | callback = callback || function(event) { |
|
| 14849 | module.verbose('Executing animation callback'); |
|
| 14850 | if(event !== undefined) { |
|
| 14851 | event.stopPropagation(); |
|
| 14852 | } |
|
| 14853 | module.reset(); |
|
| 14854 | module.set.active(); |
|
| 14855 | }; |
|
| 14856 | settings.beforeChange.call($nextSide[0]); |
|
| 14857 | if(module.get.transitionEvent()) { |
|
| 14858 | module.verbose('Starting CSS animation'); |
|
| 14859 | $module |
|
| 14860 | .addClass(className.animating) |
|
| 14861 | ; |
|
| 14862 | $sides |
|
| 14863 | .css(propertyObject) |
|
| 14864 | .one(module.get.transitionEvent(), callback) |
|
| 14865 | ; |
|
| 14866 | module.set.duration(settings.duration); |
|
| 14867 | requestAnimationFrame(function() { |
|
| 14868 | $module |
|
| 14869 | .addClass(className.animating) |
|
| 14870 | ; |
|
| 14871 | $activeSide |
|
| 14872 | .addClass(className.hidden) |
|
| 14873 | ; |
|
| 14874 | }); |
|
| 14875 | } |
|
| 14876 | else { |
|
| 14877 | callback(); |
|
| 14878 | } |
|
| 14879 | }, |
|
| 14880 | ||
| 14881 | queue: function(method) { |
|
| 14882 | module.debug('Queueing animation of', method); |
|
| 14883 | $sides |
|
| 14884 | .one(module.get.transitionEvent(), function() { |
|
| 14885 | module.debug('Executing queued animation'); |
|
| 14886 | setTimeout(function(){ |
|
| 14887 | $module.shape(method); |
|
| 14888 | }, 0); |
|
| 14889 | }) |
|
| 14890 | ; |
|
| 14891 | }, |
|
| 14892 | ||
| 14893 | reset: function() { |
|
| 14894 | module.verbose('Animating states reset'); |
|
| 14895 | $module |
|
| 14896 | .removeClass(className.animating) |
|
| 14897 | .attr('style', '') |
|
| 14898 | .removeAttr('style') |
|
| 14899 | ; |
|
| 14900 | // removeAttr style does not consistently work in safari |
|
| 14901 | $sides |
|
| 14902 | .attr('style', '') |
|
| 14903 | .removeAttr('style') |
|
| 14904 | ; |
|
| 14905 | $side |
|
| 14906 | .attr('style', '') |
|
| 14907 | .removeAttr('style') |
|
| 14908 | .removeClass(className.hidden) |
|
| 14909 | ; |
|
| 14910 | $nextSide |
|
| 14911 | .removeClass(className.animating) |
|
| 14912 | .attr('style', '') |
|
| 14913 | .removeAttr('style') |
|
| 14914 | ; |
|
| 14915 | }, |
|
| 14916 | ||
| 14917 | is: { |
|
| 14918 | complete: function() { |
|
| 14919 | return ($side.filter('.' + className.active)[0] == $nextSide[0]); |
|
| 14920 | }, |
|
| 14921 | animating: function() { |
|
| 14922 | return $module.hasClass(className.animating); |
|
| 14923 | } |
|
| 14924 | }, |
|
| 14925 | ||
| 14926 | set: { |
|
| 14927 | ||
| 14928 | defaultSide: function() { |
|
| 14929 | $activeSide = $module.find('.' + settings.className.active); |
|
| 14930 | $nextSide = ( $activeSide.next(selector.side).length > 0 ) |
|
| 14931 | ? $activeSide.next(selector.side) |
|
| 14932 | : $module.find(selector.side).first() |
|
| 14933 | ; |
|
| 14934 | nextIndex = false; |
|
| 14935 | module.verbose('Active side set to', $activeSide); |
|
| 14936 | module.verbose('Next side set to', $nextSide); |
|
| 14937 | }, |
|
| 14938 | ||
| 14939 | duration: function(duration) { |
|
| 14940 | duration = duration || settings.duration; |
|
| 14941 | duration = (typeof duration == 'number') |
|
| 14942 | ? duration + 'ms' |
|
| 14943 | : duration |
|
| 14944 | ; |
|
| 14945 | module.verbose('Setting animation duration', duration); |
|
| 14946 | if(settings.duration || settings.duration === 0) { |
|
| 14947 | $sides.add($side) |
|
| 14948 | .css({ |
|
| 14949 | '-webkit-transition-duration': duration, |
|
| 14950 | '-moz-transition-duration': duration, |
|
| 14951 | '-ms-transition-duration': duration, |
|
| 14952 | '-o-transition-duration': duration, |
|
| 14953 | 'transition-duration': duration |
|
| 14954 | }) |
|
| 14955 | ; |
|
| 14956 | } |
|
| 14957 | }, |
|
| 14958 | ||
| 14959 | currentStageSize: function() { |
|
| 14960 | var |
|
| 14961 | $activeSide = $module.find('.' + settings.className.active), |
|
| 14962 | width = $activeSide.outerWidth(true), |
|
| 14963 | height = $activeSide.outerHeight(true) |
|
| 14964 | ; |
|
| 14965 | $module |
|
| 14966 | .css({ |
|
| 14967 | width: width, |
|
| 14968 | height: height |
|
| 14969 | }) |
|
| 14970 | ; |
|
| 14971 | }, |
|
| 14972 | ||
| 14973 | stageSize: function() { |
|
| 14974 | var |
|
| 14975 | $clone = $module.clone().addClass(className.loading), |
|
| 14976 | $activeSide = $clone.find('.' + settings.className.active), |
|
| 14977 | $nextSide = (nextIndex) |
|
| 14978 | ? $clone.find(selector.side).eq(nextIndex) |
|
| 14979 | : ( $activeSide.next(selector.side).length > 0 ) |
|
| 14980 | ? $activeSide.next(selector.side) |
|
| 14981 | : $clone.find(selector.side).first(), |
|
| 14982 | newWidth = (settings.width == 'next') |
|
| 14983 | ? $nextSide.outerWidth(true) |
|
| 14984 | : (settings.width == 'initial') |
|
| 14985 | ? $module.width() |
|
| 14986 | : settings.width, |
|
| 14987 | newHeight = (settings.height == 'next') |
|
| 14988 | ? $nextSide.outerHeight(true) |
|
| 14989 | : (settings.height == 'initial') |
|
| 14990 | ? $module.height() |
|
| 14991 | : settings.height |
|
| 14992 | ; |
|
| 14993 | $activeSide.removeClass(className.active); |
|
| 14994 | $nextSide.addClass(className.active); |
|
| 14995 | $clone.insertAfter($module); |
|
| 14996 | $clone.remove(); |
|
| 14997 | if(settings.width != 'auto') { |
|
| 14998 | $module.css('width', newWidth + settings.jitter); |
|
| 14999 | module.verbose('Specifying width during animation', newWidth); |
|
| 15000 | } |
|
| 15001 | if(settings.height != 'auto') { |
|
| 15002 | $module.css('height', newHeight + settings.jitter); |
|
| 15003 | module.verbose('Specifying height during animation', newHeight); |
|
| 15004 | } |
|
| 15005 | }, |
|
| 15006 | ||
| 15007 | nextSide: function(selector) { |
|
| 15008 | nextIndex = selector; |
|
| 15009 | $nextSide = $side.filter(selector); |
|
| 15010 | nextIndex = $side.index($nextSide); |
|
| 15011 | if($nextSide.length === 0) { |
|
| 15012 | module.set.defaultSide(); |
|
| 15013 | module.error(error.side); |
|
| 15014 | } |
|
| 15015 | module.verbose('Next side manually set to', $nextSide); |
|
| 15016 | }, |
|
| 15017 | ||
| 15018 | active: function() { |
|
| 15019 | module.verbose('Setting new side to active', $nextSide); |
|
| 15020 | $side |
|
| 15021 | .removeClass(className.active) |
|
| 15022 | ; |
|
| 15023 | $nextSide |
|
| 15024 | .addClass(className.active) |
|
| 15025 | ; |
|
| 15026 | settings.onChange.call($nextSide[0]); |
|
| 15027 | module.set.defaultSide(); |
|
| 15028 | } |
|
| 15029 | }, |
|
| 15030 | ||
| 15031 | flip: { |
|
| 15032 | ||
| 15033 | up: function() { |
|
| 15034 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 15035 | module.debug('Side already visible', $nextSide); |
|
| 15036 | return; |
|
| 15037 | } |
|
| 15038 | if( !module.is.animating()) { |
|
| 15039 | module.debug('Flipping up', $nextSide); |
|
| 15040 | var |
|
| 15041 | transform = module.get.transform.up() |
|
| 15042 | ; |
|
| 15043 | module.set.stageSize(); |
|
| 15044 | module.stage.above(); |
|
| 15045 | module.animate(transform); |
|
| 15046 | } |
|
| 15047 | else { |
|
| 15048 | module.queue('flip up'); |
|
| 15049 | } |
|
| 15050 | }, |
|
| 15051 | ||
| 15052 | down: function() { |
|
| 15053 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 15054 | module.debug('Side already visible', $nextSide); |
|
| 15055 | return; |
|
| 15056 | } |
|
| 15057 | if( !module.is.animating()) { |
|
| 15058 | module.debug('Flipping down', $nextSide); |
|
| 15059 | var |
|
| 15060 | transform = module.get.transform.down() |
|
| 15061 | ; |
|
| 15062 | module.set.stageSize(); |
|
| 15063 | module.stage.below(); |
|
| 15064 | module.animate(transform); |
|
| 15065 | } |
|
| 15066 | else { |
|
| 15067 | module.queue('flip down'); |
|
| 15068 | } |
|
| 15069 | }, |
|
| 15070 | ||
| 15071 | left: function() { |
|
| 15072 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 15073 | module.debug('Side already visible', $nextSide); |
|
| 15074 | return; |
|
| 15075 | } |
|
| 15076 | if( !module.is.animating()) { |
|
| 15077 | module.debug('Flipping left', $nextSide); |
|
| 15078 | var |
|
| 15079 | transform = module.get.transform.left() |
|
| 15080 | ; |
|
| 15081 | module.set.stageSize(); |
|
| 15082 | module.stage.left(); |
|
| 15083 | module.animate(transform); |
|
| 15084 | } |
|
| 15085 | else { |
|
| 15086 | module.queue('flip left'); |
|
| 15087 | } |
|
| 15088 | }, |
|
| 15089 | ||
| 15090 | right: function() { |
|
| 15091 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 15092 | module.debug('Side already visible', $nextSide); |
|
| 15093 | return; |
|
| 15094 | } |
|
| 15095 | if( !module.is.animating()) { |
|
| 15096 | module.debug('Flipping right', $nextSide); |
|
| 15097 | var |
|
| 15098 | transform = module.get.transform.right() |
|
| 15099 | ; |
|
| 15100 | module.set.stageSize(); |
|
| 15101 | module.stage.right(); |
|
| 15102 | module.animate(transform); |
|
| 15103 | } |
|
| 15104 | else { |
|
| 15105 | module.queue('flip right'); |
|
| 15106 | } |
|
| 15107 | }, |
|
| 15108 | ||
| 15109 | over: function() { |
|
| 15110 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 15111 | module.debug('Side already visible', $nextSide); |
|
| 15112 | return; |
|
| 15113 | } |
|
| 15114 | if( !module.is.animating()) { |
|
| 15115 | module.debug('Flipping over', $nextSide); |
|
| 15116 | module.set.stageSize(); |
|
| 15117 | module.stage.behind(); |
|
| 15118 | module.animate(module.get.transform.over() ); |
|
| 15119 | } |
|
| 15120 | else { |
|
| 15121 | module.queue('flip over'); |
|
| 15122 | } |
|
| 15123 | }, |
|
| 15124 | ||
| 15125 | back: function() { |
|
| 15126 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 15127 | module.debug('Side already visible', $nextSide); |
|
| 15128 | return; |
|
| 15129 | } |
|
| 15130 | if( !module.is.animating()) { |
|
| 15131 | module.debug('Flipping back', $nextSide); |
|
| 15132 | module.set.stageSize(); |
|
| 15133 | module.stage.behind(); |
|
| 15134 | module.animate(module.get.transform.back() ); |
|
| 15135 | } |
|
| 15136 | else { |
|
| 15137 | module.queue('flip back'); |
|
| 15138 | } |
|
| 15139 | } |
|
| 15140 | ||
| 15141 | }, |
|
| 15142 | ||
| 15143 | get: { |
|
| 15144 | ||
| 15145 | transform: { |
|
| 15146 | up: function() { |
|
| 15147 | var |
|
| 15148 | translate = { |
|
| 15149 | y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), |
|
| 15150 | z: -($activeSide.outerHeight(true) / 2) |
|
| 15151 | } |
|
| 15152 | ; |
|
| 15153 | return { |
|
| 15154 | transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(-90deg)' |
|
| 15155 | }; |
|
| 15156 | }, |
|
| 15157 | ||
| 15158 | down: function() { |
|
| 15159 | var |
|
| 15160 | translate = { |
|
| 15161 | y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), |
|
| 15162 | z: -($activeSide.outerHeight(true) / 2) |
|
| 15163 | } |
|
| 15164 | ; |
|
| 15165 | return { |
|
| 15166 | transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(90deg)' |
|
| 15167 | }; |
|
| 15168 | }, |
|
| 15169 | ||
| 15170 | left: function() { |
|
| 15171 | var |
|
| 15172 | translate = { |
|
| 15173 | x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2), |
|
| 15174 | z : -($activeSide.outerWidth(true) / 2) |
|
| 15175 | } |
|
| 15176 | ; |
|
| 15177 | return { |
|
| 15178 | transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(90deg)' |
|
| 15179 | }; |
|
| 15180 | }, |
|
| 15181 | ||
| 15182 | right: function() { |
|
| 15183 | var |
|
| 15184 | translate = { |
|
| 15185 | x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2), |
|
| 15186 | z : -($activeSide.outerWidth(true) / 2) |
|
| 15187 | } |
|
| 15188 | ; |
|
| 15189 | return { |
|
| 15190 | transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(-90deg)' |
|
| 15191 | }; |
|
| 15192 | }, |
|
| 15193 | ||
| 15194 | over: function() { |
|
| 15195 | var |
|
| 15196 | translate = { |
|
| 15197 | x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2) |
|
| 15198 | } |
|
| 15199 | ; |
|
| 15200 | return { |
|
| 15201 | transform: 'translateX(' + translate.x + 'px) rotateY(180deg)' |
|
| 15202 | }; |
|
| 15203 | }, |
|
| 15204 | ||
| 15205 | back: function() { |
|
| 15206 | var |
|
| 15207 | translate = { |
|
| 15208 | x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2) |
|
| 15209 | } |
|
| 15210 | ; |
|
| 15211 | return { |
|
| 15212 | transform: 'translateX(' + translate.x + 'px) rotateY(-180deg)' |
|
| 15213 | }; |
|
| 15214 | } |
|
| 15215 | }, |
|
| 15216 | ||
| 15217 | transitionEvent: function() { |
|
| 15218 | var |
|
| 15219 | element = document.createElement('element'), |
|
| 15220 | transitions = { |
|
| 15221 | 'transition' :'transitionend', |
|
| 15222 | 'OTransition' :'oTransitionEnd', |
|
| 15223 | 'MozTransition' :'transitionend', |
|
| 15224 | 'WebkitTransition' :'webkitTransitionEnd' |
|
| 15225 | }, |
|
| 15226 | transition |
|
| 15227 | ; |
|
| 15228 | for(transition in transitions){ |
|
| 15229 | if( element.style[transition] !== undefined ){ |
|
| 15230 | return transitions[transition]; |
|
| 15231 | } |
|
| 15232 | } |
|
| 15233 | }, |
|
| 15234 | ||
| 15235 | nextSide: function() { |
|
| 15236 | return ( $activeSide.next(selector.side).length > 0 ) |
|
| 15237 | ? $activeSide.next(selector.side) |
|
| 15238 | : $module.find(selector.side).first() |
|
| 15239 | ; |
|
| 15240 | } |
|
| 15241 | ||
| 15242 | }, |
|
| 15243 | ||
| 15244 | stage: { |
|
| 15245 | ||
| 15246 | above: function() { |
|
| 15247 | var |
|
| 15248 | box = { |
|
| 15249 | origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), |
|
| 15250 | depth : { |
|
| 15251 | active : ($nextSide.outerHeight(true) / 2), |
|
| 15252 | next : ($activeSide.outerHeight(true) / 2) |
|
| 15253 | } |
|
| 15254 | } |
|
| 15255 | ; |
|
| 15256 | module.verbose('Setting the initial animation position as above', $nextSide, box); |
|
| 15257 | $sides |
|
| 15258 | .css({ |
|
| 15259 | 'transform' : 'translateZ(-' + box.depth.active + 'px)' |
|
| 15260 | }) |
|
| 15261 | ; |
|
| 15262 | $activeSide |
|
| 15263 | .css({ |
|
| 15264 | 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' |
|
| 15265 | }) |
|
| 15266 | ; |
|
| 15267 | $nextSide |
|
| 15268 | .addClass(className.animating) |
|
| 15269 | .css({ |
|
| 15270 | 'top' : box.origin + 'px', |
|
| 15271 | 'transform' : 'rotateX(90deg) translateZ(' + box.depth.next + 'px)' |
|
| 15272 | }) |
|
| 15273 | ; |
|
| 15274 | }, |
|
| 15275 | ||
| 15276 | below: function() { |
|
| 15277 | var |
|
| 15278 | box = { |
|
| 15279 | origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), |
|
| 15280 | depth : { |
|
| 15281 | active : ($nextSide.outerHeight(true) / 2), |
|
| 15282 | next : ($activeSide.outerHeight(true) / 2) |
|
| 15283 | } |
|
| 15284 | } |
|
| 15285 | ; |
|
| 15286 | module.verbose('Setting the initial animation position as below', $nextSide, box); |
|
| 15287 | $sides |
|
| 15288 | .css({ |
|
| 15289 | 'transform' : 'translateZ(-' + box.depth.active + 'px)' |
|
| 15290 | }) |
|
| 15291 | ; |
|
| 15292 | $activeSide |
|
| 15293 | .css({ |
|
| 15294 | 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' |
|
| 15295 | }) |
|
| 15296 | ; |
|
| 15297 | $nextSide |
|
| 15298 | .addClass(className.animating) |
|
| 15299 | .css({ |
|
| 15300 | 'top' : box.origin + 'px', |
|
| 15301 | 'transform' : 'rotateX(-90deg) translateZ(' + box.depth.next + 'px)' |
|
| 15302 | }) |
|
| 15303 | ; |
|
| 15304 | }, |
|
| 15305 | ||
| 15306 | left: function() { |
|
| 15307 | var |
|
| 15308 | height = { |
|
| 15309 | active : $activeSide.outerWidth(true), |
|
| 15310 | next : $nextSide.outerWidth(true) |
|
| 15311 | }, |
|
| 15312 | box = { |
|
| 15313 | origin : ( ( height.active - height.next ) / 2), |
|
| 15314 | depth : { |
|
| 15315 | active : (height.next / 2), |
|
| 15316 | next : (height.active / 2) |
|
| 15317 | } |
|
| 15318 | } |
|
| 15319 | ; |
|
| 15320 | module.verbose('Setting the initial animation position as left', $nextSide, box); |
|
| 15321 | $sides |
|
| 15322 | .css({ |
|
| 15323 | 'transform' : 'translateZ(-' + box.depth.active + 'px)' |
|
| 15324 | }) |
|
| 15325 | ; |
|
| 15326 | $activeSide |
|
| 15327 | .css({ |
|
| 15328 | 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' |
|
| 15329 | }) |
|
| 15330 | ; |
|
| 15331 | $nextSide |
|
| 15332 | .addClass(className.animating) |
|
| 15333 | .css({ |
|
| 15334 | 'left' : box.origin + 'px', |
|
| 15335 | 'transform' : 'rotateY(-90deg) translateZ(' + box.depth.next + 'px)' |
|
| 15336 | }) |
|
| 15337 | ; |
|
| 15338 | }, |
|
| 15339 | ||
| 15340 | right: function() { |
|
| 15341 | var |
|
| 15342 | height = { |
|
| 15343 | active : $activeSide.outerWidth(true), |
|
| 15344 | next : $nextSide.outerWidth(true) |
|
| 15345 | }, |
|
| 15346 | box = { |
|
| 15347 | origin : ( ( height.active - height.next ) / 2), |
|
| 15348 | depth : { |
|
| 15349 | active : (height.next / 2), |
|
| 15350 | next : (height.active / 2) |
|
| 15351 | } |
|
| 15352 | } |
|
| 15353 | ; |
|
| 15354 | module.verbose('Setting the initial animation position as left', $nextSide, box); |
|
| 15355 | $sides |
|
| 15356 | .css({ |
|
| 15357 | 'transform' : 'translateZ(-' + box.depth.active + 'px)' |
|
| 15358 | }) |
|
| 15359 | ; |
|
| 15360 | $activeSide |
|
| 15361 | .css({ |
|
| 15362 | 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' |
|
| 15363 | }) |
|
| 15364 | ; |
|
| 15365 | $nextSide |
|
| 15366 | .addClass(className.animating) |
|
| 15367 | .css({ |
|
| 15368 | 'left' : box.origin + 'px', |
|
| 15369 | 'transform' : 'rotateY(90deg) translateZ(' + box.depth.next + 'px)' |
|
| 15370 | }) |
|
| 15371 | ; |
|
| 15372 | }, |
|
| 15373 | ||
| 15374 | behind: function() { |
|
| 15375 | var |
|
| 15376 | height = { |
|
| 15377 | active : $activeSide.outerWidth(true), |
|
| 15378 | next : $nextSide.outerWidth(true) |
|
| 15379 | }, |
|
| 15380 | box = { |
|
| 15381 | origin : ( ( height.active - height.next ) / 2), |
|
| 15382 | depth : { |
|
| 15383 | active : (height.next / 2), |
|
| 15384 | next : (height.active / 2) |
|
| 15385 | } |
|
| 15386 | } |
|
| 15387 | ; |
|
| 15388 | module.verbose('Setting the initial animation position as behind', $nextSide, box); |
|
| 15389 | $activeSide |
|
| 15390 | .css({ |
|
| 15391 | 'transform' : 'rotateY(0deg)' |
|
| 15392 | }) |
|
| 15393 | ; |
|
| 15394 | $nextSide |
|
| 15395 | .addClass(className.animating) |
|
| 15396 | .css({ |
|
| 15397 | 'left' : box.origin + 'px', |
|
| 15398 | 'transform' : 'rotateY(-180deg)' |
|
| 15399 | }) |
|
| 15400 | ; |
|
| 15401 | } |
|
| 15402 | }, |
|
| 15403 | setting: function(name, value) { |
|
| 15404 | module.debug('Changing setting', name, value); |
|
| 15405 | if( $.isPlainObject(name) ) { |
|
| 15406 | $.extend(true, settings, name); |
|
| 15407 | } |
|
| 15408 | else if(value !== undefined) { |
|
| 15409 | if($.isPlainObject(settings[name])) { |
|
| 15410 | $.extend(true, settings[name], value); |
|
| 15411 | } |
|
| 15412 | else { |
|
| 15413 | settings[name] = value; |
|
| 15414 | } |
|
| 15415 | } |
|
| 15416 | else { |
|
| 15417 | return settings[name]; |
|
| 15418 | } |
|
| 15419 | }, |
|
| 15420 | internal: function(name, value) { |
|
| 15421 | if( $.isPlainObject(name) ) { |
|
| 15422 | $.extend(true, module, name); |
|
| 15423 | } |
|
| 15424 | else if(value !== undefined) { |
|
| 15425 | module[name] = value; |
|
| 15426 | } |
|
| 15427 | else { |
|
| 15428 | return module[name]; |
|
| 15429 | } |
|
| 15430 | }, |
|
| 15431 | debug: function() { |
|
| 15432 | if(!settings.silent && settings.debug) { |
|
| 15433 | if(settings.performance) { |
|
| 15434 | module.performance.log(arguments); |
|
| 15435 | } |
|
| 15436 | else { |
|
| 15437 | module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
| 15438 | module.debug.apply(console, arguments); |
|
| 15439 | } |
|
| 15440 | } |
|
| 15441 | }, |
|
| 15442 | verbose: function() { |
|
| 15443 | if(!settings.silent && settings.verbose && settings.debug) { |
|
| 15444 | if(settings.performance) { |
|
| 15445 | module.performance.log(arguments); |
|
| 15446 | } |
|
| 15447 | else { |
|
| 15448 | module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
| 15449 | module.verbose.apply(console, arguments); |
|
| 15450 | } |
|
| 15451 | } |
|
| 15452 | }, |
|
| 15453 | error: function() { |
|
| 15454 | if(!settings.silent) { |
|
| 15455 | module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); |
|
| 15456 | module.error.apply(console, arguments); |
|
| 15457 | } |
|
| 15458 | }, |
|
| 15459 | performance: { |
|
| 15460 | log: function(message) { |
|
| 15461 | var |
|
| 15462 | currentTime, |
|
| 15463 | executionTime, |
|
| 15464 | previousTime |
|
| 15465 | ; |
|
| 15466 | if(settings.performance) { |
|
| 15467 | currentTime = new Date().getTime(); |
|
| 15468 | previousTime = time || currentTime; |
|
| 15469 | executionTime = currentTime - previousTime; |
|
| 15470 | time = currentTime; |
|
| 15471 | performance.push({ |
|
| 15472 | 'Name' : message[0], |
|
| 15473 | 'Arguments' : [].slice.call(message, 1) || '', |
|
| 15474 | 'Element' : element, |
|
| 15475 | 'Execution Time' : executionTime |
|
| 15476 | }); |
|
| 15477 | } |
|
| 15478 | clearTimeout(module.performance.timer); |
|
| 15479 | module.performance.timer = setTimeout(module.performance.display, 500); |
|
| 15480 | }, |
|
| 15481 | display: function() { |
|
| 15482 | var |
|
| 15483 | title = settings.name + ':', |
|
| 15484 | totalTime = 0 |
|
| 15485 | ; |
|
| 15486 | time = false; |
|
| 15487 | clearTimeout(module.performance.timer); |
|
| 15488 | $.each(performance, function(index, data) { |
|
| 15489 | totalTime += data['Execution Time']; |
|
| 15490 | }); |
|
| 15491 | title += ' ' + totalTime + 'ms'; |
|
| 15492 | if(moduleSelector) { |
|
| 15493 | title += ' \'' + moduleSelector + '\''; |
|
| 15494 | } |
|
| 15495 | if($allModules.length > 1) { |
|
| 15496 | title += ' ' + '(' + $allModules.length + ')'; |
|
| 15497 | } |
|
| 15498 | if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { |
|
| 15499 | console.groupCollapsed(title); |
|
| 15500 | if(console.table) { |
|
| 15501 | console.table(performance); |
|
| 15502 | } |
|
| 15503 | else { |
|
| 15504 | $.each(performance, function(index, data) { |
|
| 15505 | console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); |
|
| 15506 | }); |
|
| 15507 | } |
|
| 15508 | console.groupEnd(); |
|
| 15509 | } |
|
| 15510 | performance = []; |
|
| 15511 | } |
|
| 15512 | }, |
|
| 15513 | invoke: function(query, passedArguments, context) { |
|
| 15514 | var |
|
| 15515 | object = instance, |
|
| 15516 | maxDepth, |
|
| 15517 | found, |
|
| 15518 | response |
|
| 15519 | ; |
|
| 15520 | passedArguments = passedArguments || queryArguments; |
|
| 15521 | context = element || context; |
|
| 15522 | if(typeof query == 'string' && object !== undefined) { |
|
| 15523 | query = query.split(/[\. ]/); |
|
| 15524 | maxDepth = query.length - 1; |
|
| 15525 | $.each(query, function(depth, value) { |
|
| 15526 | var camelCaseValue = (depth != maxDepth) |
|
| 15527 | ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) |
|
| 15528 | : query |
|
| 15529 | ; |
|
| 15530 | if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { |
|
| 15531 | object = object[camelCaseValue]; |
|
| 15532 | } |
|
| 15533 | else if( object[camelCaseValue] !== undefined ) { |
|
| 15534 | found = object[camelCaseValue]; |
|
| 15535 | return false; |
|
| 15536 | } |
|
| 15537 | else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { |
|
| 15538 | object = object[value]; |
|
| 15539 | } |
|
| 15540 | else if( object[value] !== undefined ) { |
|
| 15541 | found = object[value]; |
|
| 15542 | return false; |
|
| 15543 | } |
|
| 15544 | else { |
|
| 15545 | return false; |
|
| 15546 | } |
|
| 15547 | }); |
|
| 15548 | } |
|
| 15549 | if ( $.isFunction( found ) ) { |
|
| 15550 | response = found.apply(context, passedArguments); |
|
| 15551 | } |
|
| 15552 | else if(found !== undefined) { |
|
| 15553 | response = found; |
|
| 15554 | } |
|
| 15555 | if($.isArray(returnedValue)) { |
|
| 15556 | returnedValue.push(response); |
|
| 15557 | } |
|
| 15558 | else if(returnedValue !== undefined) { |
|
| 15559 | returnedValue = [returnedValue, response]; |
|
| 15560 | } |
|
| 15561 | else if(response !== undefined) { |
|
| 15562 | returnedValue = response; |
|
| 15563 | } |
|
| 15564 | return found; |
|
| 15565 | } |
|
| 15566 | }; |
|
| 15567 | ||
| 15568 | if(methodInvoked) { |
|
| 15569 | if(instance === undefined) { |
|
| 15570 | module.initialize(); |
|
| 15571 | } |
|
| 15572 | module.invoke(query); |
|
| 15573 | } |
|
| 15574 | else { |
|
| 15575 | if(instance !== undefined) { |
|
| 15576 | instance.invoke('destroy'); |
|
| 15577 | } |
|
| 15578 | module.initialize(); |
|
| 15579 | } |
|
| 15580 | }) |
|
| 15581 | ; |
|
| 15582 | ||
| 15583 | return (returnedValue !== undefined) |
|
| 15584 | ? returnedValue |
|
| 15585 | : this |
|
| 15586 | ; |
|
| 15587 | }; |
|
| 15588 | ||
| 15589 | $.fn.shape.settings = { |
|
| 15590 | ||
| 15591 | // module info |
|
| 15592 | name : 'Shape', |
|
| 15593 | ||
| 15594 | // hide all debug content |
|
| 15595 | silent : false, |
|
| 15596 | ||
| 15597 | // debug content outputted to console |
|
| 15598 | debug : false, |
|
| 15599 | ||
| 15600 | // verbose debug output |
|
| 15601 | verbose : false, |
|
| 15602 | ||
| 15603 | // fudge factor in pixels when swapping from 2d to 3d (can be useful to correct rounding errors) |
|
| 15604 | jitter : 0, |
|
| 15605 | ||
| 15606 | // performance data output |
|
| 15607 | performance: true, |
|
| 15608 | ||
| 15609 | // event namespace |
|
| 15610 | namespace : 'shape', |
|
| 15611 | ||
| 15612 | // width during animation, can be set to 'auto', initial', 'next' or pixel amount |
|
| 15613 | width: 'initial', |
|
| 15614 | ||
| 15615 | // height during animation, can be set to 'auto', 'initial', 'next' or pixel amount |
|
| 15616 | height: 'initial', |
|
| 15617 | ||
| 15618 | // callback occurs on side change |
|
| 15619 | beforeChange : function() {}, |
|
| 15620 | onChange : function() {}, |
|
| 15621 | ||
| 15622 | // allow animation to same side |
|
| 15623 | allowRepeats: false, |
|
| 15624 | ||
| 15625 | // animation duration |
|
| 15626 | duration : false, |
|
| 15627 | ||
| 15628 | // possible errors |
|
| 15629 | error: { |
|
| 15630 | side : 'You tried to switch to a side that does not exist.', |
|
| 15631 | method : 'The method you called is not defined' |
|
| 15632 | }, |
|
| 15633 | ||
| 15634 | // classnames used |
|
| 15635 | className : { |
|
| 15636 | animating : 'animating', |
|
| 15637 | hidden : 'hidden', |
|
| 15638 | loading : 'loading', |
|
| 15639 | active : 'active' |
|
| 15640 | }, |
|
| 15641 | ||
| 15642 | // selectors used |
|
| 15643 | selector : { |
|
| 15644 | sides : '.sides', |
|
| 15645 | side : '.side' |
|
| 15646 | } |
|
| 15647 | ||
| 15648 | }; |
|
| 15649 | ||
| 15650 | ||
| 15651 | })( jQuery, window, document ); |
|
| 15652 | ||
| 15653 | /*! |
|
| 15654 | * # Semantic UI 2.2.11 - Sidebar |
|
| @@ 11-921 (lines=911) @@ | ||
| 8 | * |
|
| 9 | */ |
|
| 10 | ||
| 11 | ;(function ($, window, document, undefined) { |
|
| 12 | ||
| 13 | "use strict"; |
|
| 14 | ||
| 15 | window = (typeof window != 'undefined' && window.Math == Math) |
|
| 16 | ? window |
|
| 17 | : (typeof self != 'undefined' && self.Math == Math) |
|
| 18 | ? self |
|
| 19 | : Function('return this')() |
|
| 20 | ; |
|
| 21 | ||
| 22 | $.fn.shape = function(parameters) { |
|
| 23 | var |
|
| 24 | $allModules = $(this), |
|
| 25 | $body = $('body'), |
|
| 26 | ||
| 27 | time = new Date().getTime(), |
|
| 28 | performance = [], |
|
| 29 | ||
| 30 | query = arguments[0], |
|
| 31 | methodInvoked = (typeof query == 'string'), |
|
| 32 | queryArguments = [].slice.call(arguments, 1), |
|
| 33 | ||
| 34 | requestAnimationFrame = window.requestAnimationFrame |
|
| 35 | || window.mozRequestAnimationFrame |
|
| 36 | || window.webkitRequestAnimationFrame |
|
| 37 | || window.msRequestAnimationFrame |
|
| 38 | || function(callback) { setTimeout(callback, 0); }, |
|
| 39 | ||
| 40 | returnedValue |
|
| 41 | ; |
|
| 42 | ||
| 43 | $allModules |
|
| 44 | .each(function() { |
|
| 45 | var |
|
| 46 | moduleSelector = $allModules.selector || '', |
|
| 47 | settings = ( $.isPlainObject(parameters) ) |
|
| 48 | ? $.extend(true, {}, $.fn.shape.settings, parameters) |
|
| 49 | : $.extend({}, $.fn.shape.settings), |
|
| 50 | ||
| 51 | // internal aliases |
|
| 52 | namespace = settings.namespace, |
|
| 53 | selector = settings.selector, |
|
| 54 | error = settings.error, |
|
| 55 | className = settings.className, |
|
| 56 | ||
| 57 | // define namespaces for modules |
|
| 58 | eventNamespace = '.' + namespace, |
|
| 59 | moduleNamespace = 'module-' + namespace, |
|
| 60 | ||
| 61 | // selector cache |
|
| 62 | $module = $(this), |
|
| 63 | $sides = $module.find(selector.sides), |
|
| 64 | $side = $module.find(selector.side), |
|
| 65 | ||
| 66 | // private variables |
|
| 67 | nextIndex = false, |
|
| 68 | $activeSide, |
|
| 69 | $nextSide, |
|
| 70 | ||
| 71 | // standard module |
|
| 72 | element = this, |
|
| 73 | instance = $module.data(moduleNamespace), |
|
| 74 | module |
|
| 75 | ; |
|
| 76 | ||
| 77 | module = { |
|
| 78 | ||
| 79 | initialize: function() { |
|
| 80 | module.verbose('Initializing module for', element); |
|
| 81 | module.set.defaultSide(); |
|
| 82 | module.instantiate(); |
|
| 83 | }, |
|
| 84 | ||
| 85 | instantiate: function() { |
|
| 86 | module.verbose('Storing instance of module', module); |
|
| 87 | instance = module; |
|
| 88 | $module |
|
| 89 | .data(moduleNamespace, instance) |
|
| 90 | ; |
|
| 91 | }, |
|
| 92 | ||
| 93 | destroy: function() { |
|
| 94 | module.verbose('Destroying previous module for', element); |
|
| 95 | $module |
|
| 96 | .removeData(moduleNamespace) |
|
| 97 | .off(eventNamespace) |
|
| 98 | ; |
|
| 99 | }, |
|
| 100 | ||
| 101 | refresh: function() { |
|
| 102 | module.verbose('Refreshing selector cache for', element); |
|
| 103 | $module = $(element); |
|
| 104 | $sides = $(this).find(selector.shape); |
|
| 105 | $side = $(this).find(selector.side); |
|
| 106 | }, |
|
| 107 | ||
| 108 | repaint: function() { |
|
| 109 | module.verbose('Forcing repaint event'); |
|
| 110 | var |
|
| 111 | shape = $sides[0] || document.createElement('div'), |
|
| 112 | fakeAssignment = shape.offsetWidth |
|
| 113 | ; |
|
| 114 | }, |
|
| 115 | ||
| 116 | animate: function(propertyObject, callback) { |
|
| 117 | module.verbose('Animating box with properties', propertyObject); |
|
| 118 | callback = callback || function(event) { |
|
| 119 | module.verbose('Executing animation callback'); |
|
| 120 | if(event !== undefined) { |
|
| 121 | event.stopPropagation(); |
|
| 122 | } |
|
| 123 | module.reset(); |
|
| 124 | module.set.active(); |
|
| 125 | }; |
|
| 126 | settings.beforeChange.call($nextSide[0]); |
|
| 127 | if(module.get.transitionEvent()) { |
|
| 128 | module.verbose('Starting CSS animation'); |
|
| 129 | $module |
|
| 130 | .addClass(className.animating) |
|
| 131 | ; |
|
| 132 | $sides |
|
| 133 | .css(propertyObject) |
|
| 134 | .one(module.get.transitionEvent(), callback) |
|
| 135 | ; |
|
| 136 | module.set.duration(settings.duration); |
|
| 137 | requestAnimationFrame(function() { |
|
| 138 | $module |
|
| 139 | .addClass(className.animating) |
|
| 140 | ; |
|
| 141 | $activeSide |
|
| 142 | .addClass(className.hidden) |
|
| 143 | ; |
|
| 144 | }); |
|
| 145 | } |
|
| 146 | else { |
|
| 147 | callback(); |
|
| 148 | } |
|
| 149 | }, |
|
| 150 | ||
| 151 | queue: function(method) { |
|
| 152 | module.debug('Queueing animation of', method); |
|
| 153 | $sides |
|
| 154 | .one(module.get.transitionEvent(), function() { |
|
| 155 | module.debug('Executing queued animation'); |
|
| 156 | setTimeout(function(){ |
|
| 157 | $module.shape(method); |
|
| 158 | }, 0); |
|
| 159 | }) |
|
| 160 | ; |
|
| 161 | }, |
|
| 162 | ||
| 163 | reset: function() { |
|
| 164 | module.verbose('Animating states reset'); |
|
| 165 | $module |
|
| 166 | .removeClass(className.animating) |
|
| 167 | .attr('style', '') |
|
| 168 | .removeAttr('style') |
|
| 169 | ; |
|
| 170 | // removeAttr style does not consistently work in safari |
|
| 171 | $sides |
|
| 172 | .attr('style', '') |
|
| 173 | .removeAttr('style') |
|
| 174 | ; |
|
| 175 | $side |
|
| 176 | .attr('style', '') |
|
| 177 | .removeAttr('style') |
|
| 178 | .removeClass(className.hidden) |
|
| 179 | ; |
|
| 180 | $nextSide |
|
| 181 | .removeClass(className.animating) |
|
| 182 | .attr('style', '') |
|
| 183 | .removeAttr('style') |
|
| 184 | ; |
|
| 185 | }, |
|
| 186 | ||
| 187 | is: { |
|
| 188 | complete: function() { |
|
| 189 | return ($side.filter('.' + className.active)[0] == $nextSide[0]); |
|
| 190 | }, |
|
| 191 | animating: function() { |
|
| 192 | return $module.hasClass(className.animating); |
|
| 193 | } |
|
| 194 | }, |
|
| 195 | ||
| 196 | set: { |
|
| 197 | ||
| 198 | defaultSide: function() { |
|
| 199 | $activeSide = $module.find('.' + settings.className.active); |
|
| 200 | $nextSide = ( $activeSide.next(selector.side).length > 0 ) |
|
| 201 | ? $activeSide.next(selector.side) |
|
| 202 | : $module.find(selector.side).first() |
|
| 203 | ; |
|
| 204 | nextIndex = false; |
|
| 205 | module.verbose('Active side set to', $activeSide); |
|
| 206 | module.verbose('Next side set to', $nextSide); |
|
| 207 | }, |
|
| 208 | ||
| 209 | duration: function(duration) { |
|
| 210 | duration = duration || settings.duration; |
|
| 211 | duration = (typeof duration == 'number') |
|
| 212 | ? duration + 'ms' |
|
| 213 | : duration |
|
| 214 | ; |
|
| 215 | module.verbose('Setting animation duration', duration); |
|
| 216 | if(settings.duration || settings.duration === 0) { |
|
| 217 | $sides.add($side) |
|
| 218 | .css({ |
|
| 219 | '-webkit-transition-duration': duration, |
|
| 220 | '-moz-transition-duration': duration, |
|
| 221 | '-ms-transition-duration': duration, |
|
| 222 | '-o-transition-duration': duration, |
|
| 223 | 'transition-duration': duration |
|
| 224 | }) |
|
| 225 | ; |
|
| 226 | } |
|
| 227 | }, |
|
| 228 | ||
| 229 | currentStageSize: function() { |
|
| 230 | var |
|
| 231 | $activeSide = $module.find('.' + settings.className.active), |
|
| 232 | width = $activeSide.outerWidth(true), |
|
| 233 | height = $activeSide.outerHeight(true) |
|
| 234 | ; |
|
| 235 | $module |
|
| 236 | .css({ |
|
| 237 | width: width, |
|
| 238 | height: height |
|
| 239 | }) |
|
| 240 | ; |
|
| 241 | }, |
|
| 242 | ||
| 243 | stageSize: function() { |
|
| 244 | var |
|
| 245 | $clone = $module.clone().addClass(className.loading), |
|
| 246 | $activeSide = $clone.find('.' + settings.className.active), |
|
| 247 | $nextSide = (nextIndex) |
|
| 248 | ? $clone.find(selector.side).eq(nextIndex) |
|
| 249 | : ( $activeSide.next(selector.side).length > 0 ) |
|
| 250 | ? $activeSide.next(selector.side) |
|
| 251 | : $clone.find(selector.side).first(), |
|
| 252 | newWidth = (settings.width == 'next') |
|
| 253 | ? $nextSide.outerWidth(true) |
|
| 254 | : (settings.width == 'initial') |
|
| 255 | ? $module.width() |
|
| 256 | : settings.width, |
|
| 257 | newHeight = (settings.height == 'next') |
|
| 258 | ? $nextSide.outerHeight(true) |
|
| 259 | : (settings.height == 'initial') |
|
| 260 | ? $module.height() |
|
| 261 | : settings.height |
|
| 262 | ; |
|
| 263 | $activeSide.removeClass(className.active); |
|
| 264 | $nextSide.addClass(className.active); |
|
| 265 | $clone.insertAfter($module); |
|
| 266 | $clone.remove(); |
|
| 267 | if(settings.width != 'auto') { |
|
| 268 | $module.css('width', newWidth + settings.jitter); |
|
| 269 | module.verbose('Specifying width during animation', newWidth); |
|
| 270 | } |
|
| 271 | if(settings.height != 'auto') { |
|
| 272 | $module.css('height', newHeight + settings.jitter); |
|
| 273 | module.verbose('Specifying height during animation', newHeight); |
|
| 274 | } |
|
| 275 | }, |
|
| 276 | ||
| 277 | nextSide: function(selector) { |
|
| 278 | nextIndex = selector; |
|
| 279 | $nextSide = $side.filter(selector); |
|
| 280 | nextIndex = $side.index($nextSide); |
|
| 281 | if($nextSide.length === 0) { |
|
| 282 | module.set.defaultSide(); |
|
| 283 | module.error(error.side); |
|
| 284 | } |
|
| 285 | module.verbose('Next side manually set to', $nextSide); |
|
| 286 | }, |
|
| 287 | ||
| 288 | active: function() { |
|
| 289 | module.verbose('Setting new side to active', $nextSide); |
|
| 290 | $side |
|
| 291 | .removeClass(className.active) |
|
| 292 | ; |
|
| 293 | $nextSide |
|
| 294 | .addClass(className.active) |
|
| 295 | ; |
|
| 296 | settings.onChange.call($nextSide[0]); |
|
| 297 | module.set.defaultSide(); |
|
| 298 | } |
|
| 299 | }, |
|
| 300 | ||
| 301 | flip: { |
|
| 302 | ||
| 303 | up: function() { |
|
| 304 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 305 | module.debug('Side already visible', $nextSide); |
|
| 306 | return; |
|
| 307 | } |
|
| 308 | if( !module.is.animating()) { |
|
| 309 | module.debug('Flipping up', $nextSide); |
|
| 310 | var |
|
| 311 | transform = module.get.transform.up() |
|
| 312 | ; |
|
| 313 | module.set.stageSize(); |
|
| 314 | module.stage.above(); |
|
| 315 | module.animate(transform); |
|
| 316 | } |
|
| 317 | else { |
|
| 318 | module.queue('flip up'); |
|
| 319 | } |
|
| 320 | }, |
|
| 321 | ||
| 322 | down: function() { |
|
| 323 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 324 | module.debug('Side already visible', $nextSide); |
|
| 325 | return; |
|
| 326 | } |
|
| 327 | if( !module.is.animating()) { |
|
| 328 | module.debug('Flipping down', $nextSide); |
|
| 329 | var |
|
| 330 | transform = module.get.transform.down() |
|
| 331 | ; |
|
| 332 | module.set.stageSize(); |
|
| 333 | module.stage.below(); |
|
| 334 | module.animate(transform); |
|
| 335 | } |
|
| 336 | else { |
|
| 337 | module.queue('flip down'); |
|
| 338 | } |
|
| 339 | }, |
|
| 340 | ||
| 341 | left: function() { |
|
| 342 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 343 | module.debug('Side already visible', $nextSide); |
|
| 344 | return; |
|
| 345 | } |
|
| 346 | if( !module.is.animating()) { |
|
| 347 | module.debug('Flipping left', $nextSide); |
|
| 348 | var |
|
| 349 | transform = module.get.transform.left() |
|
| 350 | ; |
|
| 351 | module.set.stageSize(); |
|
| 352 | module.stage.left(); |
|
| 353 | module.animate(transform); |
|
| 354 | } |
|
| 355 | else { |
|
| 356 | module.queue('flip left'); |
|
| 357 | } |
|
| 358 | }, |
|
| 359 | ||
| 360 | right: function() { |
|
| 361 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 362 | module.debug('Side already visible', $nextSide); |
|
| 363 | return; |
|
| 364 | } |
|
| 365 | if( !module.is.animating()) { |
|
| 366 | module.debug('Flipping right', $nextSide); |
|
| 367 | var |
|
| 368 | transform = module.get.transform.right() |
|
| 369 | ; |
|
| 370 | module.set.stageSize(); |
|
| 371 | module.stage.right(); |
|
| 372 | module.animate(transform); |
|
| 373 | } |
|
| 374 | else { |
|
| 375 | module.queue('flip right'); |
|
| 376 | } |
|
| 377 | }, |
|
| 378 | ||
| 379 | over: function() { |
|
| 380 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 381 | module.debug('Side already visible', $nextSide); |
|
| 382 | return; |
|
| 383 | } |
|
| 384 | if( !module.is.animating()) { |
|
| 385 | module.debug('Flipping over', $nextSide); |
|
| 386 | module.set.stageSize(); |
|
| 387 | module.stage.behind(); |
|
| 388 | module.animate(module.get.transform.over() ); |
|
| 389 | } |
|
| 390 | else { |
|
| 391 | module.queue('flip over'); |
|
| 392 | } |
|
| 393 | }, |
|
| 394 | ||
| 395 | back: function() { |
|
| 396 | if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) { |
|
| 397 | module.debug('Side already visible', $nextSide); |
|
| 398 | return; |
|
| 399 | } |
|
| 400 | if( !module.is.animating()) { |
|
| 401 | module.debug('Flipping back', $nextSide); |
|
| 402 | module.set.stageSize(); |
|
| 403 | module.stage.behind(); |
|
| 404 | module.animate(module.get.transform.back() ); |
|
| 405 | } |
|
| 406 | else { |
|
| 407 | module.queue('flip back'); |
|
| 408 | } |
|
| 409 | } |
|
| 410 | ||
| 411 | }, |
|
| 412 | ||
| 413 | get: { |
|
| 414 | ||
| 415 | transform: { |
|
| 416 | up: function() { |
|
| 417 | var |
|
| 418 | translate = { |
|
| 419 | y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), |
|
| 420 | z: -($activeSide.outerHeight(true) / 2) |
|
| 421 | } |
|
| 422 | ; |
|
| 423 | return { |
|
| 424 | transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(-90deg)' |
|
| 425 | }; |
|
| 426 | }, |
|
| 427 | ||
| 428 | down: function() { |
|
| 429 | var |
|
| 430 | translate = { |
|
| 431 | y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), |
|
| 432 | z: -($activeSide.outerHeight(true) / 2) |
|
| 433 | } |
|
| 434 | ; |
|
| 435 | return { |
|
| 436 | transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(90deg)' |
|
| 437 | }; |
|
| 438 | }, |
|
| 439 | ||
| 440 | left: function() { |
|
| 441 | var |
|
| 442 | translate = { |
|
| 443 | x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2), |
|
| 444 | z : -($activeSide.outerWidth(true) / 2) |
|
| 445 | } |
|
| 446 | ; |
|
| 447 | return { |
|
| 448 | transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(90deg)' |
|
| 449 | }; |
|
| 450 | }, |
|
| 451 | ||
| 452 | right: function() { |
|
| 453 | var |
|
| 454 | translate = { |
|
| 455 | x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2), |
|
| 456 | z : -($activeSide.outerWidth(true) / 2) |
|
| 457 | } |
|
| 458 | ; |
|
| 459 | return { |
|
| 460 | transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(-90deg)' |
|
| 461 | }; |
|
| 462 | }, |
|
| 463 | ||
| 464 | over: function() { |
|
| 465 | var |
|
| 466 | translate = { |
|
| 467 | x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2) |
|
| 468 | } |
|
| 469 | ; |
|
| 470 | return { |
|
| 471 | transform: 'translateX(' + translate.x + 'px) rotateY(180deg)' |
|
| 472 | }; |
|
| 473 | }, |
|
| 474 | ||
| 475 | back: function() { |
|
| 476 | var |
|
| 477 | translate = { |
|
| 478 | x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2) |
|
| 479 | } |
|
| 480 | ; |
|
| 481 | return { |
|
| 482 | transform: 'translateX(' + translate.x + 'px) rotateY(-180deg)' |
|
| 483 | }; |
|
| 484 | } |
|
| 485 | }, |
|
| 486 | ||
| 487 | transitionEvent: function() { |
|
| 488 | var |
|
| 489 | element = document.createElement('element'), |
|
| 490 | transitions = { |
|
| 491 | 'transition' :'transitionend', |
|
| 492 | 'OTransition' :'oTransitionEnd', |
|
| 493 | 'MozTransition' :'transitionend', |
|
| 494 | 'WebkitTransition' :'webkitTransitionEnd' |
|
| 495 | }, |
|
| 496 | transition |
|
| 497 | ; |
|
| 498 | for(transition in transitions){ |
|
| 499 | if( element.style[transition] !== undefined ){ |
|
| 500 | return transitions[transition]; |
|
| 501 | } |
|
| 502 | } |
|
| 503 | }, |
|
| 504 | ||
| 505 | nextSide: function() { |
|
| 506 | return ( $activeSide.next(selector.side).length > 0 ) |
|
| 507 | ? $activeSide.next(selector.side) |
|
| 508 | : $module.find(selector.side).first() |
|
| 509 | ; |
|
| 510 | } |
|
| 511 | ||
| 512 | }, |
|
| 513 | ||
| 514 | stage: { |
|
| 515 | ||
| 516 | above: function() { |
|
| 517 | var |
|
| 518 | box = { |
|
| 519 | origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), |
|
| 520 | depth : { |
|
| 521 | active : ($nextSide.outerHeight(true) / 2), |
|
| 522 | next : ($activeSide.outerHeight(true) / 2) |
|
| 523 | } |
|
| 524 | } |
|
| 525 | ; |
|
| 526 | module.verbose('Setting the initial animation position as above', $nextSide, box); |
|
| 527 | $sides |
|
| 528 | .css({ |
|
| 529 | 'transform' : 'translateZ(-' + box.depth.active + 'px)' |
|
| 530 | }) |
|
| 531 | ; |
|
| 532 | $activeSide |
|
| 533 | .css({ |
|
| 534 | 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' |
|
| 535 | }) |
|
| 536 | ; |
|
| 537 | $nextSide |
|
| 538 | .addClass(className.animating) |
|
| 539 | .css({ |
|
| 540 | 'top' : box.origin + 'px', |
|
| 541 | 'transform' : 'rotateX(90deg) translateZ(' + box.depth.next + 'px)' |
|
| 542 | }) |
|
| 543 | ; |
|
| 544 | }, |
|
| 545 | ||
| 546 | below: function() { |
|
| 547 | var |
|
| 548 | box = { |
|
| 549 | origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2), |
|
| 550 | depth : { |
|
| 551 | active : ($nextSide.outerHeight(true) / 2), |
|
| 552 | next : ($activeSide.outerHeight(true) / 2) |
|
| 553 | } |
|
| 554 | } |
|
| 555 | ; |
|
| 556 | module.verbose('Setting the initial animation position as below', $nextSide, box); |
|
| 557 | $sides |
|
| 558 | .css({ |
|
| 559 | 'transform' : 'translateZ(-' + box.depth.active + 'px)' |
|
| 560 | }) |
|
| 561 | ; |
|
| 562 | $activeSide |
|
| 563 | .css({ |
|
| 564 | 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' |
|
| 565 | }) |
|
| 566 | ; |
|
| 567 | $nextSide |
|
| 568 | .addClass(className.animating) |
|
| 569 | .css({ |
|
| 570 | 'top' : box.origin + 'px', |
|
| 571 | 'transform' : 'rotateX(-90deg) translateZ(' + box.depth.next + 'px)' |
|
| 572 | }) |
|
| 573 | ; |
|
| 574 | }, |
|
| 575 | ||
| 576 | left: function() { |
|
| 577 | var |
|
| 578 | height = { |
|
| 579 | active : $activeSide.outerWidth(true), |
|
| 580 | next : $nextSide.outerWidth(true) |
|
| 581 | }, |
|
| 582 | box = { |
|
| 583 | origin : ( ( height.active - height.next ) / 2), |
|
| 584 | depth : { |
|
| 585 | active : (height.next / 2), |
|
| 586 | next : (height.active / 2) |
|
| 587 | } |
|
| 588 | } |
|
| 589 | ; |
|
| 590 | module.verbose('Setting the initial animation position as left', $nextSide, box); |
|
| 591 | $sides |
|
| 592 | .css({ |
|
| 593 | 'transform' : 'translateZ(-' + box.depth.active + 'px)' |
|
| 594 | }) |
|
| 595 | ; |
|
| 596 | $activeSide |
|
| 597 | .css({ |
|
| 598 | 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' |
|
| 599 | }) |
|
| 600 | ; |
|
| 601 | $nextSide |
|
| 602 | .addClass(className.animating) |
|
| 603 | .css({ |
|
| 604 | 'left' : box.origin + 'px', |
|
| 605 | 'transform' : 'rotateY(-90deg) translateZ(' + box.depth.next + 'px)' |
|
| 606 | }) |
|
| 607 | ; |
|
| 608 | }, |
|
| 609 | ||
| 610 | right: function() { |
|
| 611 | var |
|
| 612 | height = { |
|
| 613 | active : $activeSide.outerWidth(true), |
|
| 614 | next : $nextSide.outerWidth(true) |
|
| 615 | }, |
|
| 616 | box = { |
|
| 617 | origin : ( ( height.active - height.next ) / 2), |
|
| 618 | depth : { |
|
| 619 | active : (height.next / 2), |
|
| 620 | next : (height.active / 2) |
|
| 621 | } |
|
| 622 | } |
|
| 623 | ; |
|
| 624 | module.verbose('Setting the initial animation position as left', $nextSide, box); |
|
| 625 | $sides |
|
| 626 | .css({ |
|
| 627 | 'transform' : 'translateZ(-' + box.depth.active + 'px)' |
|
| 628 | }) |
|
| 629 | ; |
|
| 630 | $activeSide |
|
| 631 | .css({ |
|
| 632 | 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)' |
|
| 633 | }) |
|
| 634 | ; |
|
| 635 | $nextSide |
|
| 636 | .addClass(className.animating) |
|
| 637 | .css({ |
|
| 638 | 'left' : box.origin + 'px', |
|
| 639 | 'transform' : 'rotateY(90deg) translateZ(' + box.depth.next + 'px)' |
|
| 640 | }) |
|
| 641 | ; |
|
| 642 | }, |
|
| 643 | ||
| 644 | behind: function() { |
|
| 645 | var |
|
| 646 | height = { |
|
| 647 | active : $activeSide.outerWidth(true), |
|
| 648 | next : $nextSide.outerWidth(true) |
|
| 649 | }, |
|
| 650 | box = { |
|
| 651 | origin : ( ( height.active - height.next ) / 2), |
|
| 652 | depth : { |
|
| 653 | active : (height.next / 2), |
|
| 654 | next : (height.active / 2) |
|
| 655 | } |
|
| 656 | } |
|
| 657 | ; |
|
| 658 | module.verbose('Setting the initial animation position as behind', $nextSide, box); |
|
| 659 | $activeSide |
|
| 660 | .css({ |
|
| 661 | 'transform' : 'rotateY(0deg)' |
|
| 662 | }) |
|
| 663 | ; |
|
| 664 | $nextSide |
|
| 665 | .addClass(className.animating) |
|
| 666 | .css({ |
|
| 667 | 'left' : box.origin + 'px', |
|
| 668 | 'transform' : 'rotateY(-180deg)' |
|
| 669 | }) |
|
| 670 | ; |
|
| 671 | } |
|
| 672 | }, |
|
| 673 | setting: function(name, value) { |
|
| 674 | module.debug('Changing setting', name, value); |
|
| 675 | if( $.isPlainObject(name) ) { |
|
| 676 | $.extend(true, settings, name); |
|
| 677 | } |
|
| 678 | else if(value !== undefined) { |
|
| 679 | if($.isPlainObject(settings[name])) { |
|
| 680 | $.extend(true, settings[name], value); |
|
| 681 | } |
|
| 682 | else { |
|
| 683 | settings[name] = value; |
|
| 684 | } |
|
| 685 | } |
|
| 686 | else { |
|
| 687 | return settings[name]; |
|
| 688 | } |
|
| 689 | }, |
|
| 690 | internal: function(name, value) { |
|
| 691 | if( $.isPlainObject(name) ) { |
|
| 692 | $.extend(true, module, name); |
|
| 693 | } |
|
| 694 | else if(value !== undefined) { |
|
| 695 | module[name] = value; |
|
| 696 | } |
|
| 697 | else { |
|
| 698 | return module[name]; |
|
| 699 | } |
|
| 700 | }, |
|
| 701 | debug: function() { |
|
| 702 | if(!settings.silent && settings.debug) { |
|
| 703 | if(settings.performance) { |
|
| 704 | module.performance.log(arguments); |
|
| 705 | } |
|
| 706 | else { |
|
| 707 | module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
| 708 | module.debug.apply(console, arguments); |
|
| 709 | } |
|
| 710 | } |
|
| 711 | }, |
|
| 712 | verbose: function() { |
|
| 713 | if(!settings.silent && settings.verbose && settings.debug) { |
|
| 714 | if(settings.performance) { |
|
| 715 | module.performance.log(arguments); |
|
| 716 | } |
|
| 717 | else { |
|
| 718 | module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); |
|
| 719 | module.verbose.apply(console, arguments); |
|
| 720 | } |
|
| 721 | } |
|
| 722 | }, |
|
| 723 | error: function() { |
|
| 724 | if(!settings.silent) { |
|
| 725 | module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); |
|
| 726 | module.error.apply(console, arguments); |
|
| 727 | } |
|
| 728 | }, |
|
| 729 | performance: { |
|
| 730 | log: function(message) { |
|
| 731 | var |
|
| 732 | currentTime, |
|
| 733 | executionTime, |
|
| 734 | previousTime |
|
| 735 | ; |
|
| 736 | if(settings.performance) { |
|
| 737 | currentTime = new Date().getTime(); |
|
| 738 | previousTime = time || currentTime; |
|
| 739 | executionTime = currentTime - previousTime; |
|
| 740 | time = currentTime; |
|
| 741 | performance.push({ |
|
| 742 | 'Name' : message[0], |
|
| 743 | 'Arguments' : [].slice.call(message, 1) || '', |
|
| 744 | 'Element' : element, |
|
| 745 | 'Execution Time' : executionTime |
|
| 746 | }); |
|
| 747 | } |
|
| 748 | clearTimeout(module.performance.timer); |
|
| 749 | module.performance.timer = setTimeout(module.performance.display, 500); |
|
| 750 | }, |
|
| 751 | display: function() { |
|
| 752 | var |
|
| 753 | title = settings.name + ':', |
|
| 754 | totalTime = 0 |
|
| 755 | ; |
|
| 756 | time = false; |
|
| 757 | clearTimeout(module.performance.timer); |
|
| 758 | $.each(performance, function(index, data) { |
|
| 759 | totalTime += data['Execution Time']; |
|
| 760 | }); |
|
| 761 | title += ' ' + totalTime + 'ms'; |
|
| 762 | if(moduleSelector) { |
|
| 763 | title += ' \'' + moduleSelector + '\''; |
|
| 764 | } |
|
| 765 | if($allModules.length > 1) { |
|
| 766 | title += ' ' + '(' + $allModules.length + ')'; |
|
| 767 | } |
|
| 768 | if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { |
|
| 769 | console.groupCollapsed(title); |
|
| 770 | if(console.table) { |
|
| 771 | console.table(performance); |
|
| 772 | } |
|
| 773 | else { |
|
| 774 | $.each(performance, function(index, data) { |
|
| 775 | console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); |
|
| 776 | }); |
|
| 777 | } |
|
| 778 | console.groupEnd(); |
|
| 779 | } |
|
| 780 | performance = []; |
|
| 781 | } |
|
| 782 | }, |
|
| 783 | invoke: function(query, passedArguments, context) { |
|
| 784 | var |
|
| 785 | object = instance, |
|
| 786 | maxDepth, |
|
| 787 | found, |
|
| 788 | response |
|
| 789 | ; |
|
| 790 | passedArguments = passedArguments || queryArguments; |
|
| 791 | context = element || context; |
|
| 792 | if(typeof query == 'string' && object !== undefined) { |
|
| 793 | query = query.split(/[\. ]/); |
|
| 794 | maxDepth = query.length - 1; |
|
| 795 | $.each(query, function(depth, value) { |
|
| 796 | var camelCaseValue = (depth != maxDepth) |
|
| 797 | ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) |
|
| 798 | : query |
|
| 799 | ; |
|
| 800 | if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { |
|
| 801 | object = object[camelCaseValue]; |
|
| 802 | } |
|
| 803 | else if( object[camelCaseValue] !== undefined ) { |
|
| 804 | found = object[camelCaseValue]; |
|
| 805 | return false; |
|
| 806 | } |
|
| 807 | else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { |
|
| 808 | object = object[value]; |
|
| 809 | } |
|
| 810 | else if( object[value] !== undefined ) { |
|
| 811 | found = object[value]; |
|
| 812 | return false; |
|
| 813 | } |
|
| 814 | else { |
|
| 815 | return false; |
|
| 816 | } |
|
| 817 | }); |
|
| 818 | } |
|
| 819 | if ( $.isFunction( found ) ) { |
|
| 820 | response = found.apply(context, passedArguments); |
|
| 821 | } |
|
| 822 | else if(found !== undefined) { |
|
| 823 | response = found; |
|
| 824 | } |
|
| 825 | if($.isArray(returnedValue)) { |
|
| 826 | returnedValue.push(response); |
|
| 827 | } |
|
| 828 | else if(returnedValue !== undefined) { |
|
| 829 | returnedValue = [returnedValue, response]; |
|
| 830 | } |
|
| 831 | else if(response !== undefined) { |
|
| 832 | returnedValue = response; |
|
| 833 | } |
|
| 834 | return found; |
|
| 835 | } |
|
| 836 | }; |
|
| 837 | ||
| 838 | if(methodInvoked) { |
|
| 839 | if(instance === undefined) { |
|
| 840 | module.initialize(); |
|
| 841 | } |
|
| 842 | module.invoke(query); |
|
| 843 | } |
|
| 844 | else { |
|
| 845 | if(instance !== undefined) { |
|
| 846 | instance.invoke('destroy'); |
|
| 847 | } |
|
| 848 | module.initialize(); |
|
| 849 | } |
|
| 850 | }) |
|
| 851 | ; |
|
| 852 | ||
| 853 | return (returnedValue !== undefined) |
|
| 854 | ? returnedValue |
|
| 855 | : this |
|
| 856 | ; |
|
| 857 | }; |
|
| 858 | ||
| 859 | $.fn.shape.settings = { |
|
| 860 | ||
| 861 | // module info |
|
| 862 | name : 'Shape', |
|
| 863 | ||
| 864 | // hide all debug content |
|
| 865 | silent : false, |
|
| 866 | ||
| 867 | // debug content outputted to console |
|
| 868 | debug : false, |
|
| 869 | ||
| 870 | // verbose debug output |
|
| 871 | verbose : false, |
|
| 872 | ||
| 873 | // fudge factor in pixels when swapping from 2d to 3d (can be useful to correct rounding errors) |
|
| 874 | jitter : 0, |
|
| 875 | ||
| 876 | // performance data output |
|
| 877 | performance: true, |
|
| 878 | ||
| 879 | // event namespace |
|
| 880 | namespace : 'shape', |
|
| 881 | ||
| 882 | // width during animation, can be set to 'auto', initial', 'next' or pixel amount |
|
| 883 | width: 'initial', |
|
| 884 | ||
| 885 | // height during animation, can be set to 'auto', 'initial', 'next' or pixel amount |
|
| 886 | height: 'initial', |
|
| 887 | ||
| 888 | // callback occurs on side change |
|
| 889 | beforeChange : function() {}, |
|
| 890 | onChange : function() {}, |
|
| 891 | ||
| 892 | // allow animation to same side |
|
| 893 | allowRepeats: false, |
|
| 894 | ||
| 895 | // animation duration |
|
| 896 | duration : false, |
|
| 897 | ||
| 898 | // possible errors |
|
| 899 | error: { |
|
| 900 | side : 'You tried to switch to a side that does not exist.', |
|
| 901 | method : 'The method you called is not defined' |
|
| 902 | }, |
|
| 903 | ||
| 904 | // classnames used |
|
| 905 | className : { |
|
| 906 | animating : 'animating', |
|
| 907 | hidden : 'hidden', |
|
| 908 | loading : 'loading', |
|
| 909 | active : 'active' |
|
| 910 | }, |
|
| 911 | ||
| 912 | // selectors used |
|
| 913 | selector : { |
|
| 914 | sides : '.sides', |
|
| 915 | side : '.side' |
|
| 916 | } |
|
| 917 | ||
| 918 | }; |
|
| 919 | ||
| 920 | ||
| 921 | })( jQuery, window, document ); |
|
| 922 | ||