{"version":3,"file":"jquery.flip.min.js","sources":["../src/jquery.flip.js"],"sourcesContent":["/*! flip - v1.0.19 - 2016-01-04\n* https://github.com/nnattawat/flip\n* Copyright (c) 2016 Nattawat Nonsung; Licensed MIT */\n(function (factory) {\n    if (typeof define === 'function' && define.amd) {\n        // AMD. Register as an anonymous module.\n        define(['jquery'], factory);\n    } else {\n        // Browser globals\n        factory(jQuery);\n    }\n}(function ($) {\n    var flip = function ($dom, callback) {\n        $dom.data(\"flipped\", true);\n\n        var rotateAxis = \"rotate\" + $dom.data(\"axis\");\n        $dom.find($dom.data(\"front\")).css({\n            transform: rotateAxis + ($dom.data(\"reverse\") ? \"(-180deg)\" : \"(180deg)\"),\n            \"z-index\": \"0\"\n        });\n\n        $dom.find($dom.data(\"back\")).css({\n            transform: rotateAxis + \"(0deg)\",\n            \"z-index\": \"1\"\n        });\n\n        //Providing a nicely wrapped up callback because transform is essentially async\n        $dom.one(whichTransitionEvent(), function () {\n            $(this).trigger('flip:done');\n            if (callback !== undefined) {\n                callback.call(this);\n            }\n        });\n    };\n\n    var unflip = function ($dom, callback) {\n        $dom.data(\"flipped\", false);\n\n        var rotateAxis = \"rotate\" + $dom.data(\"axis\");\n        $dom.find($dom.data(\"front\")).css({\n            transform: rotateAxis + \"(0deg)\",\n            \"z-index\": \"1\"\n        });\n\n        $dom.find($dom.data(\"back\")).css({\n            transform: rotateAxis + ($dom.data(\"reverse\") ? \"(180deg)\" : \"(-180deg)\"),\n            \"z-index\": \"0\"\n        });\n\n        //Providing a nicely wrapped up callback because transform is essentially async\n        $dom.one(whichTransitionEvent(), function () {\n            $(this).trigger('flip:done');\n            if (callback !== undefined) {\n                callback.call(this);\n            }\n        });\n    };\n    // Function from David Walsh: http://davidwalsh.name/css-animation-callback licensed with http://opensource.org/licenses/MIT\n    var whichTransitionEvent = function () {\n        var t,\n            el = document.createElement(\"fakeelement\"),\n            transitions = {\n                \"transition\": \"transitionend\",\n                \"OTransition\": \"oTransitionEnd\",\n                \"MozTransition\": \"transitionend\",\n                \"WebkitTransition\": \"webkitTransitionEnd\"\n            };\n\n        for (t in transitions) {\n            if (el.style[t] !== undefined) {\n                return transitions[t];\n            }\n        }\n    };\n    $.fn.flip = function (options, callback) {\n        if (typeof options == 'function') {\n            //This allows flip to be called for setup with only a callback (default settings)\n            callback = options;\n        }\n        this.each(function () {\n            var $dom = $(this);\n\n            if (options !== undefined && (typeof(options) == \"boolean\" || typeof(options) == \"string\")) { // Force flip the DOM\n                if (options == \"toggle\") {\n                    options = !$dom.data(\"flipped\");\n                }\n                if (options) {\n                    flip($dom, callback);\n                } else {\n                    unflip($dom, callback);\n                }\n                // //Providing a nicely wrapped up callback because transform is essentially async\n                //  $(this).one(whichTransitionEvent(), function(){\n                //     $(this).trigger('flip:done');\n                //     if (callback !== undefined){\n                //       callback.call(this);\n                //     }\n                //   });\n            } else if (!$dom.data(\"initiated\")) { //Init flipable DOM\n                $dom.data(\"initiated\", true);\n\n                var settings = $.extend({\n                    axis: \"y\",\n                    reverse: false,\n                    trigger: \"click\",\n                    speed: 500,\n                    forceHeight: false,\n                    forceWidth: false,\n                    autoSize: true,\n                    front: 'auto',\n                    back: 'auto'\n                }, options);\n\n                //By defualt we first check for the old front and back selectors for backward compatibility\n                //if they arent there we fall back to auto selecting the first and second div\n                if (settings.front == \"auto\") {\n                    settings.front = ($dom.find('.front').length > 0) ? '.front' : 'div:first-child';\n                } else if (settings.front == \"autostrict\") {\n                    settings.front = 'div:first-child';\n                }\n                if (settings.back == \"auto\") {\n                    //Note, we must use the old 'div:first-child + div' for IE compatibility\n                    settings.back = ($dom.find('.back').length > 0) ? '.back' : 'div:first-child + div';\n                } else if (settings.back == \"autostrict\") {\n                    settings.back = 'div:first-child + div';\n                }\n                // save reverse and axis css to DOM for performing flip\n                $dom.data(\"reverse\", settings.reverse);\n                $dom.data(\"axis\", settings.axis);\n                $dom.data(\"front\", settings.front);\n                $dom.data(\"back\", settings.back);\n\n                var rotateAxis = \"rotate\" + (settings.axis.toLowerCase() == \"x\" ? \"x\" : \"y\"),\n                    perspective = $dom[\"outer\" + (rotateAxis == \"rotatex\" ? \"Height\" : \"Width\")]() * 2;\n\n                $dom.find($dom.data(\"back\")).css({\n                    transform: rotateAxis + \"(\" + (settings.reverse ? \"180deg\" : \"-180deg\") + \")\"\n                });\n\n                $dom.css({\n                    perspective: perspective,\n                    position: \"relative\"\n                });\n\n                var speedInSec = settings.speed / 1000 || 0.5;\n                var faces = $dom.find(settings.front).add(settings.back, $dom);\n                if (settings.forceHeight) {\n                    faces.outerHeight($dom.height());\n                } else if (settings.autoSize) {\n                    faces.css({'height': '100%'});\n                }\n                if (settings.forceWidth) {\n                    faces.outerWidth($dom.width());\n                } else if (settings.autoSize) {\n                    faces.css({'width': '100%'});\n                }\n                faces.css({\n                    \"backface-visibility\": \"hidden\",\n                    \"transform-style\": \"preserve-3d\",\n                    position: \"absolute\",\n                    \"z-index\": \"1\"\n                });\n                faces.find('*').css({\n                    \"backface-visibility\": \"hidden\"\n                });\n                $dom.find($dom.data(\"back\")).css({\n                    transform: rotateAxis + \"(\" + (settings.reverse ? \"180deg\" : \"-180deg\") + \")\",\n                    \"z-index\": \"0\"\n                });\n\n                // Back face always visible on Chrome #39\n                if ((window.chrome || (window.Intl && Intl.v8BreakIterator)) && 'CSS' in window) {\n                    //Blink Engine, add preserve-3d to $dom\n                    $dom.css({\"-webkit-transform-style\": \"preserve-3d\"});\n                }\n                // /#39\n\n                // not forcing width/height may cause an initial flip to show up on\n                // page load when we apply the style to reverse the backface...\n                // To prevent this we first apply the basic styles and then give the\n                // browser a moment to apply them. Only afterwards do we add the transition.\n                setTimeout(function () {\n                    // By now the browser should have applied the styles, so the transition\n                    // will only affect subsequent flips.\n                    faces.css({\n                        transition: \"all \" + speedInSec + \"s ease-out\"\n                    });\n                    if (callback !== undefined) {\n                        callback.call(this);\n                    }\n                    //While this used to work with a setTimeout of zero, at some point that became\n                    //unstable and the initial flip returned. The reason for this is unknown but we\n                    //will temporarily use a short delay of 20 to mitigate this issue.\n                }, 20);\n\n                if (settings.trigger.toLowerCase() == \"click\") {\n                    $dom.on($.fn.tap ? \"tap.flip\" : \"click.flip\", function (event) {\n                        if (!event) {\n                            event = window.event;\n                        }\n                        if ($dom.find($(event.target).closest('button, a, input[type=\"submit\"]')).length) {\n                            return;\n                        }\n\n                        if ($dom.data(\"flipped\")) {\n                            unflip($dom);\n                        } else {\n                            flip($dom);\n                        }\n                    });\n                }\n                else if (settings.trigger.toLowerCase() == \"hover\") {\n                    var performFlip = function () {\n                        $dom.off('mouseleave.flip');\n\n                        flip($dom);\n\n                        setTimeout(function () {\n                            $dom.on('mouseleave.flip', performUnflip);\n                            if (!$dom.is(\":hover\")) {\n                                unflip($dom);\n                            }\n                        }, (settings.speed + 150));\n                    };\n\n                    var performUnflip = function () {\n                        unflip($dom);\n                    };\n\n                    $dom.on('mouseenter.flip', performFlip);\n                    $dom.on('mouseleave.flip', performUnflip);\n                }\n            } else {\n                //The element has been initiated, all we have to do is change applicable settings\n                if (options && (options.axis !== undefined || options.reverse !== undefined)) {\n                    changeSettings.call(this, options, function () {\n                        $dom.trigger('flip:change');\n                        if (callback !== undefined) {\n                            callback.call(this);\n                        }\n                    });\n                }\n            }\n        });\n\n        return this;\n    };\n    var changeSettings = function (options, callback) {\n        var changeNeeded = false;\n        if (options.axis !== undefined && $(this).data(\"axis\") != options.axis.toLowerCase()) {\n            $(this).data(\"axis\", options.axis.toLowerCase());\n            changeNeeded = true;\n        }\n        if (options.reverse !== undefined && $(this).data(\"reverse\") != options.reverse) {\n            $(this).data(\"reverse\", options.reverse);\n            changeNeeded = true;\n        }\n        if (changeNeeded) {\n            var faces = $(this).find($(this).data(\"front\")).add($(this).data(\"back\"), $(this));\n            var savedTrans = faces.css(\"transition\");\n            faces.css({\n                transition: \"none\"\n            });\n            //Only setting the axis if it needs to be\n\n            //options.axis = options.axis.toLowerCase();\n            //$(this).data(\"axis\", options.axis);\n\n            //This sets up the first flip in the new direction automatically\n            var rotateAxis = \"rotate\" + $(this).data(\"axis\");\n            if ($(this).data(\"flipped\")) {\n                $(this).find($(this).data(\"front\")).css({\n                    transform: rotateAxis + ($(this).data(\"reverse\") ? \"(-180deg)\" : \"(180deg)\"),\n                    \"z-index\": \"0\"\n                });\n            } else {\n                $(this).find($(this).data(\"back\")).css({\n                    transform: rotateAxis + \"(\" + ($(this).data(\"reverse\") ? \"180deg\" : \"-180deg\") + \")\",\n                    \"z-index\": \"0\"\n                });\n            }\n            //Providing a nicely wrapped up callback because transform is essentially async\n            setTimeout(function () {\n                faces.css({\n                    transition: savedTrans\n                });\n                callback.call(this);\n            }.bind(this), 0);\n        } else {\n            //If we didnt have to set the axis we can just call back.\n            setTimeout(callback.bind(this), 0);\n        }\n    };\n}));\n"],"names":["factory","$","flip","$dom","callback","data","rotateAxis","find","css","transform","one","whichTransitionEvent","this","trigger","undefined","call","unflip","t","el","document","createElement","transitions","style","fn","options","each","axis","reverse","changeSettings","settings","extend","speed","forceHeight","forceWidth","autoSize","front","back","length","toLowerCase","perspective","position","speedInSec","faces","add","outerHeight","height","outerWidth","width","window","chrome","Intl","v8BreakIterator","setTimeout","transition","on","tap","event","target","closest","performUnflip","off","is","changeNeeded","savedTrans","bind","define","amd","jQuery"],"mappings":"AAGC,IAAUA,QAAAA,QAQT,SAAUC,OACJC,KAAO,SAAUC,KAAMC,UACvBD,KAAKE,KAAK,WAAW,OAEjBC,WAAa,SAAWH,KAAKE,KAAK,QACtCF,KAAKI,KAAKJ,KAAKE,KAAK,UAAUG,IAAI,CAC9BC,UAAWH,YAAcH,KAAKE,KAAK,WAAa,YAAc,sBACnD,MAGfF,KAAKI,KAAKJ,KAAKE,KAAK,SAASG,IAAI,CAC7BC,UAAWH,WAAa,mBACb,MAIfH,KAAKO,IAAIC,wBAAwB,WAC7BV,EAAEW,MAAMC,QAAQ,kBACCC,IAAbV,UACAA,SAASW,KAAKH,UAKtBI,OAAS,SAAUb,KAAMC,UACzBD,KAAKE,KAAK,W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