File size: 45,115 Bytes
45d5d8a
1
{"version":3,"sources":["jquery.syotimer.js","syotimer.lang.js","jquery.syotimer.min.js"],"names":["$","DAY","HOUR","MINUTE","SECOND","DAY_IN_SEC","HOUR_IN_SEC","MINUTE_IN_SEC","LAYOUT_TYPES","d","h","m","s","UNIT_LINKED_LIST","list","next","current","currentIndex","this","indexOf","length","prev","DEFAULTS","year","month","day","hour","minute","second","timeZone","ignoreTransferTime","layout","periodic","periodInterval","periodUnit","doubleNumbers","effectType","lang","headTitle","footTitle","afterDeadline","timerBlock","bodyBlock","html","ITEMS_HAS_OPTIONS","SyoTimer","init","settings","options","extend","itemTypes","staticMethod","getItemTypesByLayout","_itemsHas","i","each","elementBox","data","_render","apply","_perSecondHandler","timerItem","getTimerItem","headBlock","class","footBlock","itemBlocks","item","clone","addClass","append","timerBlocks","css","currentDate","Date","deadLineDate","differenceInMilliSec","getDifferenceWithTimezone","secondsToDeadLine","getSecondsToDeadLine","_refreshUnitsDom","_applyEffectSwitch","unitList","unitsToDeadLine","getUnitsToDeadLine","unit","unitValue","itemBlock","format2","syotimerLang","getNumeral","element","setTimeout","unitItemBlock","nextUnit","animate","opacity","timerCellValue","text","timerCellUnit","timerCell","push","differenceInSeconds","Math","floor","additionalInUnit","differenceInUnit","periodUnitInSeconds","getPeriodUnit","fullTimeUnitsBetween","ceil","abs","unitInMilliSec","given_period_unit","amendment","differenceByLocalTimezone","getTime","amendmentOnTimezone","amendmentOnTransferTime","timezoneOffset","parseFloat","localTimezoneOffset","getTimezoneOffset","currentTimezoneOffset","deadLineTimezoneOffset","number","isUse","methods","setOption","name","value","hasOwnProperty","fn","syotimer","otherArgs","Array","prototype","slice","call","arguments","error","rus","handler","eng","por","spa","heb","universal","rusNumeral","index","cases","handlerName","jQuery"],"mappings":";;;;CAAA,SAAAA,GACA,GAAAC,GAAA,MACAC,EAAA,OACAC,EAAA,SACAC,EAAA,SACAC,EAAA,MACAC,EAAA,KACAC,EAAA,GACAC,GACAC,EAAAR,E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A,SAAAtB,GACA,MAAA,KAAAA,EAAA,EAAA,GAQAuB,WAAA,SAAAvB,GACA,GACAwB,GADAC,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAOA,OAJAD,GADAxB,EAAA,IAAA,GAAAA,EAAA,IAAA,GACA,EAEAyB,EAAAzB,EAAA,GAAA,EAAAA,EAAA,GAAA,IAYAnC,WAAA,SAAAmC,EAAAxF,EAAAgD,GACA,GAAAkE,GAAAvJ,EAAAyF,aAAApD,GAAAyG,SAAA,YACAO,EAAAnI,KAAAqI,GAAA1B,EACA,OAAA7H,GAAAyF,aAAApD,GAAAgD,GAAAgE,MC8XGG","file":"jquery.syotimer.min.js","sourcesContent":["    var DAY = \"day\",\n        HOUR = \"hour\",\n        MINUTE = \"minute\",\n        SECOND = \"second\";\n    var DAY_IN_SEC = 24 * 60 * 60;\n    var HOUR_IN_SEC = 60 * 60;\n    var MINUTE_IN_SEC = 60;\n    var LAYOUT_TYPES = {\n            d: DAY,\n            h: HOUR,\n            m: MINUTE,\n            s: SECOND\n        };\n    var UNIT_LINKED_LIST = {\n            list: [SECOND, MINUTE, HOUR, DAY],\n            next: function(current) {\n                var currentIndex = this.list.indexOf(current);\n                return (currentIndex < this.list.length ) ? this.list[currentIndex + 1] : false;\n            },\n            prev: function(current) {\n                var currentIndex = this.list.indexOf(current);\n                return (currentIndex > 0 ) ? this.list[currentIndex - 1] : false;\n            }\n        };\n\n    var DEFAULTS = {\n        year: 2014,\n        month: 7,\n        day: 31,\n        hour: 0,\n        minute: 0,\n        second: 0,\n        timeZone: 'local',          // setting the time zone of deadline.\n                                    // If 'local' then the time zone is ignored and\n                                    // the deadline is determined by local time of the user.\n                                    // Otherwise, specifies the offset from the UTC\n        ignoreTransferTime: false,  // If `true` then transfer to summer/winter time will not be considered.\n        layout: 'dhms',             // sets an order of layout of units of the timer:\n                                    // days (d) of hours ('h'), minute ('m'), second ('s').\n        periodic: false,            //`true` - the timer is periodic.\n                                    // If the date until which counts the timer is reached,\n                                    // the next value date which will count down\n                                    // the timer is incremented by the value `periodInterval`\n        periodInterval: 7,          // the period of the timer in `periodUnit`\n                                    // (if `periodic` is set to `true`)\n        periodUnit: 'd',            // the unit of measurement period timer\n\n        doubleNumbers: true,        // `true` - show hours, minutes and seconds with leading zeros\n                                    // (2 hours 5 minutes 4 seconds = 02:05:04)\n        effectType: 'none',         // The effect of changing the value of seconds\n        lang: 'eng',                // localization of a countdown signatures (days, hours, minutes, seconds)\n        headTitle: '',              // text above the countdown (may be as html string)\n        footTitle: '',              // text under the countdown (may be as html string)\n        afterDeadline: function(timerBlock){\n            timerBlock.bodyBlock.html('<p style=\"font-size: 1.2em;\">The countdown is finished!</p>');\n        }\n    };\n\n    var ITEMS_HAS_OPTIONS = {\n        second: false,\n        minute: false,\n        hour: false,\n        day: false\n    };\n\n    var SyoTimer = {\n        /**\n         * Init syotimer on DOM\n         * @param settings\n         * @returns {Array|Object|*}\n         */\n        init: function(settings) {\n            var options = $.extend({}, DEFAULTS, settings || {});\n            options.itemTypes = staticMethod.getItemTypesByLayout(options.layout);\n            options._itemsHas = $.extend({}, ITEMS_HAS_OPTIONS);\n            for (var i = 0; i < options.itemTypes.length; i++) {\n                options._itemsHas[options.itemTypes[i]] = true;\n            }\n            return this.each(function() {\n                var elementBox = $(this);\n                elementBox.data('syotimer-options', options);\n                SyoTimer._render.apply(this, []);\n                SyoTimer._perSecondHandler.apply(this, []);\n            });\n        },\n\n        /**\n         * Rendering base elements of countdown\n         * @private\n         */\n        _render: function() {\n            var elementBox = $(this),\n                options = elementBox.data('syotimer-options');\n\n            var timerItem = staticMethod.getTimerItem(),\n                headBlock = $('<div/>', {\"class\": 'syotimer__head'})\n                    .html(options.headTitle),\n                bodyBlock = $('<div/>', {\"class\": 'syotimer__body'}),\n                footBlock = $('<div/>', {\"class\": 'syotimer__footer'})\n                    .html(options.footTitle),\n                itemBlocks = {};\n\n            for (var i = 0; i < options.itemTypes.length; i++) {\n                var item = timerItem.clone();\n                item.addClass('syotimer-cell_type_' + options.itemTypes[i]);\n                bodyBlock.append(item);\n                itemBlocks[options.itemTypes[i]] = item;\n            }\n            var timerBlocks = {\n                    headBlock: headBlock,\n                    bodyBlock: bodyBlock,\n                    footBlock: footBlock\n                };\n            elementBox.data('syotimer-blocks', timerBlocks)\n                .data('syotimer-items', itemBlocks)\n                .addClass('syotimer')\n                .append(headBlock)\n                .append(bodyBlock)\n                .append(footBlock);\n        },\n\n        /**\n         * Handler called per seconds while countdown is not over\n         * @private\n         */\n        _perSecondHandler: function() {\n            var elementBox = $(this),\n                options = elementBox.data('syotimer-options');\n            $('.syotimer-cell > .syotimer-cell__value', elementBox).css( 'opacity', 1 );\n            var currentDate = new Date(),\n                deadLineDate = new Date(\n                    options.year,\n                    options.month - 1,\n                    options.day,\n                    options.hour,\n                    options.minute,\n                    options.second\n                ),\n                differenceInMilliSec = staticMethod.getDifferenceWithTimezone(currentDate, deadLineDate, options),\n                secondsToDeadLine = staticMethod.getSecondsToDeadLine(differenceInMilliSec, options);\n            if ( secondsToDeadLine >= 0 ) {\n                SyoTimer._refreshUnitsDom.apply(this, [secondsToDeadLine]);\n                SyoTimer._applyEffectSwitch.apply(this, [options.effectType]);\n            } else {\n                elementBox = $.extend(elementBox, elementBox.data('syotimer-blocks'));\n                options.afterDeadline( elementBox );\n            }\n        },\n\n        /**\n         * Refresh unit DOM of countdown\n         * @param secondsToDeadLine\n         * @private\n         */\n        _refreshUnitsDom: function(secondsToDeadLine) {\n            var elementBox = $(this),\n                options = elementBox.data('syotimer-options'),\n                itemBlocks = elementBox.data('syotimer-items'),\n                unitList = options.itemTypes,\n                unitsToDeadLine = staticMethod.getUnitsToDeadLine( secondsToDeadLine );\n\n            if ( !options._itemsHas.day ) {\n                unitsToDeadLine.hour += unitsToDeadLine.day * 24;\n            }\n            if ( !options._itemsHas.hour ) {\n                unitsToDeadLine.minute += unitsToDeadLine.hour * 60;\n            }\n            if ( !options._itemsHas.minute ) {\n                unitsToDeadLine.second += unitsToDeadLine.minute * 60;\n            }\n            for(var i = 0; i < unitList.length; i++) {\n                var unit = unitList[i],\n                    unitValue = unitsToDeadLine[unit],\n                    itemBlock = itemBlocks[unit];\n                itemBlock.data('syotimer-unit-value', unitValue);\n                $('.syotimer-cell__value', itemBlock).html(staticMethod.format2(\n                    unitValue,\n                    (unit !== DAY) ? options.doubleNumbers : false\n                ));\n                $('.syotimer-cell__unit', itemBlock).html($.syotimerLang.getNumeral(\n                    unitValue,\n                    options.lang,\n                    unit\n                ));\n            }\n        },\n\n        /**\n         * Applying effect of changing numbers\n         * @param effectType\n         * @param unit\n         * @private\n         */\n        _applyEffectSwitch: function(effectType, unit) {\n            unit = unit || SECOND;\n            var element = this,\n                elementBox = $(element);\n            if ( effectType === 'none' ) {\n                setTimeout(function () {\n                    SyoTimer._perSecondHandler.apply(element, []);\n                }, 1000);\n            } else if ( effectType === 'opacity' ) {\n                var itemBlocks = elementBox.data('syotimer-items'),\n                    unitItemBlock = itemBlocks[unit];\n                if (unitItemBlock) {\n                    var nextUnit = UNIT_LINKED_LIST.next(unit),\n                        unitValue = unitItemBlock.data('syotimer-unit-value');\n                    $('.syotimer-cell__value', unitItemBlock).animate(\n                        {opacity: 0.1},\n                        1000,\n                        'linear',\n                        function () {\n                            SyoTimer._perSecondHandler.apply(element, []);\n                        }\n                    );\n                    if (nextUnit && unitValue === 0) {\n                        SyoTimer._applyEffectSwitch.apply(element, [effectType, nextUnit]);\n                    }\n                }\n            }\n        }\n    };\n\n    var staticMethod = {\n        /**\n         * Return once cell DOM of countdown: day, hour, minute, second\n         * @returns {object}\n         */\n        getTimerItem: function() {\n            var timerCellValue = $('<div/>', {\n                    \"class\": 'syotimer-cell__value',\n                    \"text\": '0'\n                }),\n                timerCellUnit = $('<div/>', {\"class\": 'syotimer-cell__unit'}),\n                timerCell = $('<div/>', {\"class\": 'syotimer-cell'});\n            timerCell.append(timerCellValue)\n                .append(timerCellUnit);\n            return timerCell;\n        },\n\n        getItemTypesByLayout: function(layout) {\n            var itemTypes = [];\n            for (var i = 0; i < layout.length; i++) {\n                itemTypes.push(LAYOUT_TYPES[layout[i]]);\n            }\n            return itemTypes;\n        },\n\n        /**\n         * Getting count of seconds to deadline\n         * @param differenceInMilliSec\n         * @param options\n         * @returns {*}\n         */\n        getSecondsToDeadLine: function(differenceInMilliSec, options) {\n            var secondsToDeadLine,\n                differenceInSeconds = differenceInMilliSec / 1000;\n            differenceInSeconds = Math.floor( differenceInSeconds );\n            if ( options.periodic ) {\n                var additionalInUnit,\n                    differenceInUnit,\n                    periodUnitInSeconds = staticMethod.getPeriodUnit(options.periodUnit),\n                    fullTimeUnitsBetween = differenceInMilliSec / (periodUnitInSeconds * 1000);\n                fullTimeUnitsBetween = Math.ceil( fullTimeUnitsBetween );\n                fullTimeUnitsBetween = Math.abs( fullTimeUnitsBetween );\n                if ( differenceInSeconds >= 0 ) {\n                    differenceInUnit = fullTimeUnitsBetween % options.periodInterval;\n                    differenceInUnit = ( differenceInUnit === 0 )? options.periodInterval : differenceInUnit;\n                    differenceInUnit -= 1;\n                } else {\n                    differenceInUnit = options.periodInterval - fullTimeUnitsBetween % options.periodInterval;\n                }\n                additionalInUnit = differenceInSeconds % periodUnitInSeconds;\n\n                // fix когда дедлайн раньше текущей даты,\n                // возникает баг с неправильным расчетом интервала при different пропорциональной periodUnit\n                if ( ( additionalInUnit === 0 ) && ( differenceInSeconds < 0 ) ) {\n                    differenceInUnit--;\n                }\n                secondsToDeadLine = Math.abs( differenceInUnit * periodUnitInSeconds + additionalInUnit );\n            } else {\n                secondsToDeadLine = differenceInSeconds;\n            }\n            return secondsToDeadLine;\n        },\n\n        /**\n         * Getting count of units to deadline\n         * @param secondsToDeadLine\n         * @returns {{}}\n         */\n        getUnitsToDeadLine: function(secondsToDeadLine) {\n            var unit = DAY,\n                unitsToDeadLine = {};\n            do {\n                var unitInMilliSec = staticMethod.getPeriodUnit(unit);\n                unitsToDeadLine[unit] = Math.floor(secondsToDeadLine / unitInMilliSec);\n                secondsToDeadLine = secondsToDeadLine % unitInMilliSec;\n            } while (unit = UNIT_LINKED_LIST.prev(unit));\n            return unitsToDeadLine;\n        },\n\n        /**\n         * Determine a unit of period in milliseconds\n         * @param given_period_unit\n         * @returns {number}\n         */\n        getPeriodUnit: function(given_period_unit) {\n            switch (given_period_unit) {\n                case 'd':\n                case DAY:\n                    return DAY_IN_SEC;\n                case 'h':\n                case HOUR:\n                    return HOUR_IN_SEC;\n                case 'm':\n                case MINUTE:\n                    return MINUTE_IN_SEC;\n                case 's':\n                case SECOND:\n                    return 1;\n            }\n        },\n\n        getDifferenceWithTimezone: function(currentDate, deadLineDate, options) {\n            var differenceByLocalTimezone = deadLineDate.getTime() - currentDate.getTime(),\n                amendmentOnTimezone = 0,\n                amendmentOnTransferTime = 0,\n                amendment;\n            if ( options.timeZone !== 'local' ) {\n                var timezoneOffset = parseFloat(options.timeZone) * staticMethod.getPeriodUnit(HOUR),\n                    localTimezoneOffset = - currentDate.getTimezoneOffset() * staticMethod.getPeriodUnit(MINUTE);\n                amendmentOnTimezone = (timezoneOffset - localTimezoneOffset) * 1000;\n            }\n            if ( options.ignoreTransferTime ) {\n                var currentTimezoneOffset = -currentDate.getTimezoneOffset() * staticMethod.getPeriodUnit(MINUTE),\n                    deadLineTimezoneOffset = -deadLineDate.getTimezoneOffset() * staticMethod.getPeriodUnit(MINUTE);\n                amendmentOnTransferTime = (currentTimezoneOffset - deadLineTimezoneOffset) * 1000;\n            }\n            amendment = amendmentOnTimezone + amendmentOnTransferTime;\n            return differenceByLocalTimezone - amendment;\n        },\n\n        /**\n         * Formation of numbers with leading zeros\n         * @param number\n         * @param isUse\n         * @returns {string}\n         */\n        format2: function(number, isUse) {\n            isUse = (isUse !== false);\n            return ( ( number <= 9 ) && isUse ) ? ( \"0\" + number ) : ( \"\" + number );\n        }\n    };\n\n    var methods = {\n        setOption: function(name, value) {\n            var elementBox = $(this),\n                options = elementBox.data('syotimer-options');\n            if ( options.hasOwnProperty( name ) ) {\n                options[name] = value;\n                elementBox.data('syotimer-options', options);\n            }\n        }\n    };\n\n    $.fn.syotimer = function(options){\n        if ( typeof options === 'string' && ( options === \"setOption\" ) ) {\n            var otherArgs = Array.prototype.slice.call(arguments, 1);\n            return this.each(function() {\n                methods[options].apply( this, otherArgs );\n            });\n        } else if (options === null || typeof options === 'object'){\n            return SyoTimer.init.apply(this, [options]);\n        } else {\n            $.error('SyoTimer. Error in call methods: methods is not exist');\n        }\n    };\n","    $.syotimerLang = {\n        rus: {\n            second: ['секунда', 'секунды', 'секунд'],\n            minute: ['минута', 'минуты', 'минут'],\n            hour: ['час', 'часа', 'часов'],\n            day: ['день', 'дня', 'дней'],\n            handler: 'rusNumeral'\n        },\n        eng: {\n            second: ['second', 'seconds'],\n            minute: ['minute', 'minutes'],\n            hour: ['hour', 'hours'],\n            day: ['day', 'days']\n        },\n        por: {\n            second: ['segundo', 'segundos'],\n            minute: ['minuto', 'minutos'],\n            hour: ['hora', 'horas'],\n            day: ['dia', 'dias']\n        },\n        spa: {\n            second: ['segundo', 'segundos'],\n            minute: ['minuto', 'minutos'],\n            hour: ['hora', 'horas'],\n            day: ['día', 'días']\n        },\n        heb: {\n            second: ['שניה', 'שניות'],\n            minute: ['דקה', 'דקות'],\n            hour: ['שעה', 'שעות'],\n            day: ['יום', 'ימים']\n        },\n\n        /**\n         * Universal function for get correct inducement of nouns after a numeral (`number`)\n         * @param number\n         * @returns {number}\n         */\n        universal: function(number) {\n            return ( number === 1 ) ? 0 : 1;\n        },\n\n        /**\n         * Get correct inducement of nouns after a numeral for Russian language (rus)\n         * @param number\n         * @returns {number}\n         */\n        rusNumeral: function(number) {\n            var cases = [2, 0, 1, 1, 1, 2],\n                index;\n            if ( number % 100 > 4 && number % 100 < 20 ) {\n                index = 2;\n            } else {\n                index = cases[(number % 10 < 5) ? number % 10 : 5];\n            }\n            return index;\n        },\n\n        /**\n         * Getting the correct declension of words after numerals\n         * @param number\n         * @param lang\n         * @param unit\n         * @returns {string}\n         */\n        getNumeral: function(number, lang, unit) {\n            var handlerName = $.syotimerLang[lang].handler || 'universal',\n                index = this[handlerName](number);\n            return $.syotimerLang[lang][unit][index];\n        }\n    };\n","(function($){\n    var DAY = \"day\",\n        HOUR = \"hour\",\n        MINUTE = \"minute\",\n        SECOND = \"second\";\n    var DAY_IN_SEC = 24 * 60 * 60;\n    var HOUR_IN_SEC = 60 * 60;\n    var MINUTE_IN_SEC = 60;\n    var LAYOUT_TYPES = {\n            d: DAY,\n            h: HOUR,\n            m: MINUTE,\n            s: SECOND\n        };\n    var UNIT_LINKED_LIST = {\n            list: [SECOND, MINUTE, HOUR, DAY],\n            next: function(current) {\n                var currentIndex = this.list.indexOf(current);\n                return (currentIndex < this.list.length ) ? this.list[currentIndex + 1] : false;\n            },\n            prev: function(current) {\n                var currentIndex = this.list.indexOf(current);\n                return (currentIndex > 0 ) ? this.list[currentIndex - 1] : false;\n            }\n        };\n\n    var DEFAULTS = {\n        year: 2014,\n        month: 7,\n        day: 31,\n        hour: 0,\n        minute: 0,\n        second: 0,\n        timeZone: 'local',          // setting the time zone of deadline.\n                                    // If 'local' then the time zone is ignored and\n                                    // the deadline is determined by local time of the user.\n                                    // Otherwise, specifies the offset from the UTC\n        ignoreTransferTime: false,  // If `true` then transfer to summer/winter time will not be considered.\n        layout: 'dhms',             // sets an order of layout of units of the timer:\n                                    // days (d) of hours ('h'), minute ('m'), second ('s').\n        periodic: false,            //`true` - the timer is periodic.\n                                    // If the date until which counts the timer is reached,\n                                    // the next value date which will count down\n                                    // the timer is incremented by the value `periodInterval`\n        periodInterval: 7,          // the period of the timer in `periodUnit`\n                                    // (if `periodic` is set to `true`)\n        periodUnit: 'd',            // the unit of measurement period timer\n\n        doubleNumbers: true,        // `true` - show hours, minutes and seconds with leading zeros\n                                    // (2 hours 5 minutes 4 seconds = 02:05:04)\n        effectType: 'none',         // The effect of changing the value of seconds\n        lang: 'eng',                // localization of a countdown signatures (days, hours, minutes, seconds)\n        headTitle: '',              // text above the countdown (may be as html string)\n        footTitle: '',              // text under the countdown (may be as html string)\n        afterDeadline: function(timerBlock){\n            timerBlock.bodyBlock.html('<p style=\"font-size: 1.2em;\">The countdown is finished!</p>');\n        }\n    };\n\n    var ITEMS_HAS_OPTIONS = {\n        second: false,\n        minute: false,\n        hour: false,\n        day: false\n    };\n\n    var SyoTimer = {\n        /**\n         * Init syotimer on DOM\n         * @param settings\n         * @returns {Array|Object|*}\n         */\n        init: function(settings) {\n            var options = $.extend({}, DEFAULTS, settings || {});\n            options.itemTypes = staticMethod.getItemTypesByLayout(options.layout);\n            options._itemsHas = $.extend({}, ITEMS_HAS_OPTIONS);\n            for (var i = 0; i < options.itemTypes.length; i++) {\n                options._itemsHas[options.itemTypes[i]] = true;\n            }\n            return this.each(function() {\n                var elementBox = $(this);\n                elementBox.data('syotimer-options', options);\n                SyoTimer._render.apply(this, []);\n                SyoTimer._perSecondHandler.apply(this, []);\n            });\n        },\n\n        /**\n         * Rendering base elements of countdown\n         * @private\n         */\n        _render: function() {\n            var elementBox = $(this),\n                options = elementBox.data('syotimer-options');\n\n            var timerItem = staticMethod.getTimerItem(),\n                headBlock = $('<div/>', {\"class\": 'syotimer__head'})\n                    .html(options.headTitle),\n                bodyBlock = $('<div/>', {\"class\": 'syotimer__body'}),\n                footBlock = $('<div/>', {\"class\": 'syotimer__footer'})\n                    .html(options.footTitle),\n                itemBlocks = {};\n\n            for (var i = 0; i < options.itemTypes.length; i++) {\n                var item = timerItem.clone();\n                item.addClass('syotimer-cell_type_' + options.itemTypes[i]);\n                bodyBlock.append(item);\n                itemBlocks[options.itemTypes[i]] = item;\n            }\n            var timerBlocks = {\n                    headBlock: headBlock,\n                    bodyBlock: bodyBlock,\n                    footBlock: footBlock\n                };\n            elementBox.data('syotimer-blocks', timerBlocks)\n                .data('syotimer-items', itemBlocks)\n                .addClass('syotimer')\n                .append(headBlock)\n                .append(bodyBlock)\n                .append(footBlock);\n        },\n\n        /**\n         * Handler called per seconds while countdown is not over\n         * @private\n         */\n        _perSecondHandler: function() {\n            var elementBox = $(this),\n                options = elementBox.data('syotimer-options');\n            $('.syotimer-cell > .syotimer-cell__value', elementBox).css( 'opacity', 1 );\n            var currentDate = new Date(),\n                deadLineDate = new Date(\n                    options.year,\n                    options.month - 1,\n                    options.day,\n                    options.hour,\n                    options.minute,\n                    options.second\n                ),\n                differenceInMilliSec = staticMethod.getDifferenceWithTimezone(currentDate, deadLineDate, options),\n                secondsToDeadLine = staticMethod.getSecondsToDeadLine(differenceInMilliSec, options);\n            if ( secondsToDeadLine >= 0 ) {\n                SyoTimer._refreshUnitsDom.apply(this, [secondsToDeadLine]);\n                SyoTimer._applyEffectSwitch.apply(this, [options.effectType]);\n            } else {\n                elementBox = $.extend(elementBox, elementBox.data('syotimer-blocks'));\n                options.afterDeadline( elementBox );\n            }\n        },\n\n        /**\n         * Refresh unit DOM of countdown\n         * @param secondsToDeadLine\n         * @private\n         */\n        _refreshUnitsDom: function(secondsToDeadLine) {\n            var elementBox = $(this),\n                options = elementBox.data('syotimer-options'),\n                itemBlocks = elementBox.data('syotimer-items'),\n                unitList = options.itemTypes,\n                unitsToDeadLine = staticMethod.getUnitsToDeadLine( secondsToDeadLine );\n\n            if ( !options._itemsHas.day ) {\n                unitsToDeadLine.hour += unitsToDeadLine.day * 24;\n            }\n            if ( !options._itemsHas.hour ) {\n                unitsToDeadLine.minute += unitsToDeadLine.hour * 60;\n            }\n            if ( !options._itemsHas.minute ) {\n                unitsToDeadLine.second += unitsToDeadLine.minute * 60;\n            }\n            for(var i = 0; i < unitList.length; i++) {\n                var unit = unitList[i],\n                    unitValue = unitsToDeadLine[unit],\n                    itemBlock = itemBlocks[unit];\n                itemBlock.data('syotimer-unit-value', unitValue);\n                $('.syotimer-cell__value', itemBlock).html(staticMethod.format2(\n                    unitValue,\n                    (unit !== DAY) ? options.doubleNumbers : false\n                ));\n                $('.syotimer-cell__unit', itemBlock).html($.syotimerLang.getNumeral(\n                    unitValue,\n                    options.lang,\n                    unit\n                ));\n            }\n        },\n\n        /**\n         * Applying effect of changing numbers\n         * @param effectType\n         * @param unit\n         * @private\n         */\n        _applyEffectSwitch: function(effectType, unit) {\n            unit = unit || SECOND;\n            var element = this,\n                elementBox = $(element);\n            if ( effectType === 'none' ) {\n                setTimeout(function () {\n                    SyoTimer._perSecondHandler.apply(element, []);\n                }, 1000);\n            } else if ( effectType === 'opacity' ) {\n                var itemBlocks = elementBox.data('syotimer-items'),\n                    unitItemBlock = itemBlocks[unit];\n                if (unitItemBlock) {\n                    var nextUnit = UNIT_LINKED_LIST.next(unit),\n                        unitValue = unitItemBlock.data('syotimer-unit-value');\n                    $('.syotimer-cell__value', unitItemBlock).animate(\n                        {opacity: 0.1},\n                        1000,\n                        'linear',\n                        function () {\n                            SyoTimer._perSecondHandler.apply(element, []);\n                        }\n                    );\n                    if (nextUnit && unitValue === 0) {\n                        SyoTimer._applyEffectSwitch.apply(element, [effectType, nextUnit]);\n                    }\n                }\n            }\n        }\n    };\n\n    var staticMethod = {\n        /**\n         * Return once cell DOM of countdown: day, hour, minute, second\n         * @returns {object}\n         */\n        getTimerItem: function() {\n            var timerCellValue = $('<div/>', {\n                    \"class\": 'syotimer-cell__value',\n                    \"text\": '0'\n                }),\n                timerCellUnit = $('<div/>', {\"class\": 'syotimer-cell__unit'}),\n                timerCell = $('<div/>', {\"class\": 'syotimer-cell'});\n            timerCell.append(timerCellValue)\n                .append(timerCellUnit);\n            return timerCell;\n        },\n\n        getItemTypesByLayout: function(layout) {\n            var itemTypes = [];\n            for (var i = 0; i < layout.length; i++) {\n                itemTypes.push(LAYOUT_TYPES[layout[i]]);\n            }\n            return itemTypes;\n        },\n\n        /**\n         * Getting count of seconds to deadline\n         * @param differenceInMilliSec\n         * @param options\n         * @returns {*}\n         */\n        getSecondsToDeadLine: function(differenceInMilliSec, options) {\n            var secondsToDeadLine,\n                differenceInSeconds = differenceInMilliSec / 1000;\n            differenceInSeconds = Math.floor( differenceInSeconds );\n            if ( options.periodic ) {\n                var additionalInUnit,\n                    differenceInUnit,\n                    periodUnitInSeconds = staticMethod.getPeriodUnit(options.periodUnit),\n                    fullTimeUnitsBetween = differenceInMilliSec / (periodUnitInSeconds * 1000);\n                fullTimeUnitsBetween = Math.ceil( fullTimeUnitsBetween );\n                fullTimeUnitsBetween = Math.abs( fullTimeUnitsBetween );\n                if ( differenceInSeconds >= 0 ) {\n                    differenceInUnit = fullTimeUnitsBetween % options.periodInterval;\n                    differenceInUnit = ( differenceInUnit === 0 )? options.periodInterval : differenceInUnit;\n                    differenceInUnit -= 1;\n                } else {\n                    differenceInUnit = options.periodInterval - fullTimeUnitsBetween % options.periodInterval;\n                }\n                additionalInUnit = differenceInSeconds % periodUnitInSeconds;\n\n                // fix когда дедлайн раньше текущей даты,\n                // возникает баг с неправильным расчетом интервала при different пропорциональной periodUnit\n                if ( ( additionalInUnit === 0 ) && ( differenceInSeconds < 0 ) ) {\n                    differenceInUnit--;\n                }\n                secondsToDeadLine = Math.abs( differenceInUnit * periodUnitInSeconds + additionalInUnit );\n            } else {\n                secondsToDeadLine = differenceInSeconds;\n            }\n            return secondsToDeadLine;\n        },\n\n        /**\n         * Getting count of units to deadline\n         * @param secondsToDeadLine\n         * @returns {{}}\n         */\n        getUnitsToDeadLine: function(secondsToDeadLine) {\n            var unit = DAY,\n                unitsToDeadLine = {};\n            do {\n                var unitInMilliSec = staticMethod.getPeriodUnit(unit);\n                unitsToDeadLine[unit] = Math.floor(secondsToDeadLine / unitInMilliSec);\n                secondsToDeadLine = secondsToDeadLine % unitInMilliSec;\n            } while (unit = UNIT_LINKED_LIST.prev(unit));\n            return unitsToDeadLine;\n        },\n\n        /**\n         * Determine a unit of period in milliseconds\n         * @param given_period_unit\n         * @returns {number}\n         */\n        getPeriodUnit: function(given_period_unit) {\n            switch (given_period_unit) {\n                case 'd':\n                case DAY:\n                    return DAY_IN_SEC;\n                case 'h':\n                case HOUR:\n                    return HOUR_IN_SEC;\n                case 'm':\n                case MINUTE:\n                    return MINUTE_IN_SEC;\n                case 's':\n                case SECOND:\n                    return 1;\n            }\n        },\n\n        getDifferenceWithTimezone: function(currentDate, deadLineDate, options) {\n            var differenceByLocalTimezone = deadLineDate.getTime() - currentDate.getTime(),\n                amendmentOnTimezone = 0,\n                amendmentOnTransferTime = 0,\n                amendment;\n            if ( options.timeZone !== 'local' ) {\n                var timezoneOffset = parseFloat(options.timeZone) * staticMethod.getPeriodUnit(HOUR),\n                    localTimezoneOffset = - currentDate.getTimezoneOffset() * staticMethod.getPeriodUnit(MINUTE);\n                amendmentOnTimezone = (timezoneOffset - localTimezoneOffset) * 1000;\n            }\n            if ( options.ignoreTransferTime ) {\n                var currentTimezoneOffset = -currentDate.getTimezoneOffset() * staticMethod.getPeriodUnit(MINUTE),\n                    deadLineTimezoneOffset = -deadLineDate.getTimezoneOffset() * staticMethod.getPeriodUnit(MINUTE);\n                amendmentOnTransferTime = (currentTimezoneOffset - deadLineTimezoneOffset) * 1000;\n            }\n            amendment = amendmentOnTimezone + amendmentOnTransferTime;\n            return differenceByLocalTimezone - amendment;\n        },\n\n        /**\n         * Formation of numbers with leading zeros\n         * @param number\n         * @param isUse\n         * @returns {string}\n         */\n        format2: function(number, isUse) {\n            isUse = (isUse !== false);\n            return ( ( number <= 9 ) && isUse ) ? ( \"0\" + number ) : ( \"\" + number );\n        }\n    };\n\n    var methods = {\n        setOption: function(name, value) {\n            var elementBox = $(this),\n                options = elementBox.data('syotimer-options');\n            if ( options.hasOwnProperty( name ) ) {\n                options[name] = value;\n                elementBox.data('syotimer-options', options);\n            }\n        }\n    };\n\n    $.fn.syotimer = function(options){\n        if ( typeof options === 'string' && ( options === \"setOption\" ) ) {\n            var otherArgs = Array.prototype.slice.call(arguments, 1);\n            return this.each(function() {\n                methods[options].apply( this, otherArgs );\n            });\n        } else if (options === null || typeof options === 'object'){\n            return SyoTimer.init.apply(this, [options]);\n        } else {\n            $.error('SyoTimer. Error in call methods: methods is not exist');\n        }\n    };\n\n    $.syotimerLang = {\n        rus: {\n            second: ['секунда', 'секунды', 'секунд'],\n            minute: ['минута', 'минуты', 'минут'],\n            hour: ['час', 'часа', 'часов'],\n            day: ['день', 'дня', 'дней'],\n            handler: 'rusNumeral'\n        },\n        eng: {\n            second: ['second', 'seconds'],\n            minute: ['minute', 'minutes'],\n            hour: ['hour', 'hours'],\n            day: ['day', 'days']\n        },\n        por: {\n            second: ['segundo', 'segundos'],\n            minute: ['minuto', 'minutos'],\n            hour: ['hora', 'horas'],\n            day: ['dia', 'dias']\n        },\n        spa: {\n            second: ['segundo', 'segundos'],\n            minute: ['minuto', 'minutos'],\n            hour: ['hora', 'horas'],\n            day: ['día', 'días']\n        },\n        heb: {\n            second: ['שניה', 'שניות'],\n            minute: ['דקה', 'דקות'],\n            hour: ['שעה', 'שעות'],\n            day: ['יום', 'ימים']\n        },\n\n        /**\n         * Universal function for get correct inducement of nouns after a numeral (`number`)\n         * @param number\n         * @returns {number}\n         */\n        universal: function(number) {\n            return ( number === 1 ) ? 0 : 1;\n        },\n\n        /**\n         * Get correct inducement of nouns after a numeral for Russian language (rus)\n         * @param number\n         * @returns {number}\n         */\n        rusNumeral: function(number) {\n            var cases = [2, 0, 1, 1, 1, 2],\n                index;\n            if ( number % 100 > 4 && number % 100 < 20 ) {\n                index = 2;\n            } else {\n                index = cases[(number % 10 < 5) ? number % 10 : 5];\n            }\n            return index;\n        },\n\n        /**\n         * Getting the correct declension of words after numerals\n         * @param number\n         * @param lang\n         * @param unit\n         * @returns {string}\n         */\n        getNumeral: function(number, lang, unit) {\n            var handlerName = $.syotimerLang[lang].handler || 'universal',\n                index = this[handlerName](number);\n            return $.syotimerLang[lang][unit][index];\n        }\n    };\n})(jQuery);\n"]}