PageSourceSearch

https://wpprofitbuilder.com/wp-content/plugins/profit_builder/js/jquery.mb-comingsoon.js

js wpprofitbuilder.com collected 2026-09-25 19:48:20 UTC 13,770 bytes, 355 lines download raw bytes

1/// <reference path="../../Scripts/jquery-1.10.2-vsdoc.js" />
2
3/**************************************************************************
4 *------------------------ COMINGSOON COUNTER 1.1 ------------------------
5 * ========================================================================
6 * Copyright 2014 Bruno Milgiaretti
7 * Licensed under MIT http://opensource.org/licenses/MIT
8 * ======================================================================== 
9 Usage: 
10   Constructor:
11	$(selector).mbComingsoon(expiryDate Date or String) Expiry date of counter
12	$(selector).mbComingsoon(options plain Object) options: {
13																expiryDate: Date,   //Expiry Date required
14																interval: Number,   //Update interval in milliseconds (default = 1000))
15                                                                localization: {
16                                                                    days: "days",           //Localize labels of counter
17                                                                    hours: "hours",
18                                                                    minutes: "minutes",
19                                                                    seconds: "seconds"
20                                                                }
21																callBack: Function  //Function executed on expiry or if espired
22															}
23   Methds:
24	.mbComingSoon('start') // start counter
25	.mbComingSoon('stop') // stop counter
26	.mbComingSoon(options) // change options
27
28 Note: Max time that the counter can display is 999 days 23h 59' 59". If time is greater hours, minutes and seconds will be displayed 
29 correctly, but days will be 999 until decrease under this quota.
30 */
31
32(function ($) {
33	// Class Definition
34	var MbComingsoon;
35	MbComingsoon = function (date, element, localization, speed, callBack) {
36		this.$el = $(element);
37		this.end = date;
38		this.active = false;
39		this.interval = 1000;
40		this.speed = speed;
41		if (jQuery.isFunction(callBack))
42			this.callBack = callBack;
43		else
44		    this.callBack = null;
45		this.localization = {days:"days", hours: "hours", minutes: "minutes", seconds: "seconds"};
46		$.extend(this.localization, this.localization, localization);
47	}
48
49	MbComingsoon.prototype = {
50		// Returns an object containing counter data
51		getCounterNumbers: function () {
52			var result = {
53				days: {
54					tens: 0,
55					units: 0,
56					hundreds: 0
57				},
58				hours: {
59					tens: 0,
60					units: 0
61				},
62				minutes: {
63					tens: 0,
64					units: 0
65				},
66				seconds: {
67					tens: 0,
68					units: 0
69				}
70			}, millday = 1000 * 60 * 60 * 24,
71				millhour = 1000 * 60 * 60,
72				millminutes = 1000 * 60,
73				millseconds = 1000,
74				rest = 0
75			;
76			var now = new Date();
77            var offset = now.getTimezoneOffset()/60;
78            var offsetHours = parseInt(offset);
79            var offsetMinutes = (offset - offsetHours)*60;
80            
81            now.setHours(now.getHours() + offsetHours);
82            now.setMinutes(now.getMinutes() + offsetMinutes);
83            //now.setHours(now.getHours() + now.getTimezoneOffset()/60);
84            
85            offsetHours = parseInt(jQuery(this.$el).attr("offset-hours"));
86            offsetMinutes = parseInt(jQuery(this.$el).attr("offset-minutes"));
87            now.setHours(now.getHours() + offsetHours);
88            now.setMinutes(now.getMinutes() + offsetMinutes);
89            
90			var diff = this.end.getTime() - now.getTime();
91			// CountDown expired !!
92			if (diff <= 0)
93				return result;
94
95			// Max number of days is 99 (i will expand in future versions)
96			var days = Math.min(Math.floor(diff / millday), 999);
97			rest = diff % millday;
98
99			result.days.hundreds = Math.floor(days / 100);
100			var dayrest = days % 100;
101			result.days.tens = Math.floor(dayrest / 10);
102			result.days.units = dayrest % 10;
103
104			var hours = Math.floor(rest / millhour);
105			rest = rest % millhour;
106			result.hours.tens = Math.floor(hours / 10);
107			result.hours.units = hours % 10;
108
109			var minutes = Math.floor(rest / millminutes);
110			rest = rest % millminutes;
111			result.minutes.tens = Math.floor(minutes / 10);
112			result.minutes.units = minutes % 10;
113
114			var seconds = Math.floor(rest / 1000);
115			result.seconds.tens = Math.floor(seconds / 10);
116			result.seconds.units = seconds % 10;
117			return result;
118		},
119		// If changed update a part (day, hours, minutes, seconds) of counter
120		updatePart: function (part) {
121			var cn = this.getCounterNumbers();
122			var $part = $('.' + part, this.$el);
123			if (part == 'days') {
124				this.setDayHundreds(cn.days.hundreds > 0);
125				if ($part.find('.number.hundreds.show').html() != cn[part].hundreds) {
126					var $n1 = $('.n1.hundreds', $part);
127					var $n2 = $('.n2.hundreds', $part);
128					this.scrollNumber($n1, $n2, cn[part].hundreds);
129				}
130			}
131			if ($part.find('.number.tens.show').html() != cn[part].tens) {
132				var $n1 = $('.n1.tens', $part);
133				var $n2 = $('.n2.tens', $part);
134				this.scrollNumber($n1, $n2, cn[part].tens);
135
136			}
137			if ($part.find('.number.units.show').html() != cn[part].units) {
138				var $n1 = $('.n1.units', $part);
139				var $n2 = $('.n2.units', $part);
140				this.scrollNumber($n1, $n2, cn[part].units);
141			}
142			// Only forn day part update hundreds
143		},
144		// True if countdown is expired
145		timeOut: function () {
146			var now = new Date();
147            var offset = now.getTimezoneOffset()/60;
148            var offsetHours = parseInt(offset);
149            var offsetMinutes = (offset - offsetHours)*60;
150            
151            now.setHours(now.getHours() + offsetHours);
152            now.setMinutes(now.getMinutes() + offsetMinutes);
153            //now.setHours(now.getHours() + now.getTimezoneOffset()/60);
154            
155            offsetHours = parseInt(jQuery(this.$el).attr("offset-hours"));
156            offsetMinutes = parseInt(jQuery(this.$el).attr("offset-minutes"));
157            now.setHours(now.getHours() + offsetHours);
158            now.setMinutes(now.getMinutes() + offsetMinutes);
159            
160			var diff = this.end.getTime() - now.getTime();
161			if (diff <= 0)
162				return true;
163			return false;
164		},
165		setDayHundreds: function (action) {
166			if (action)
167				$('.counter.days', this.$el).addClass('with-hundreds');
168			else
169				$('.counter.days', this.$el).removeClass('with-hundreds');
170		},
171		// Update entire counter
172		updateCounter: function () {
173			this.updatePart('days');
174			this.updatePart('hours');
175			this.updatePart('minutes');
176			this.updatePart('seconds');
177			if (this.timeOut()) {
178				this.active = false;
179				if (this.callBack)
180					this.callBack(this);
181			}
182		},
183		localize: function (localization) {
184		    if($.isPlainObject(localization))
185		        $.extend(this.localization, this.localization, localization);
186		    $('.days', this.$el).siblings('.counter-caption').text(this.localization.days);
187		    $('.hours', this.$el).siblings('.counter-caption').text(this.localization.hours);
188		    $('.minutes', this.$el).siblings('.counter-caption').text(this.localization.minutes);
189		    $('.seconds', this.$el).siblings('.counter-caption').text(this.localization.seconds);
190		},
191		// Start automatic update (interval in milliseconds)
192		start: function (interval) {
193			if (interval)
194				this.interval = interval;
195			var i = this.interval;
196			this.active = true;
197			var me = this;
198			setTimeout(function () {
199				me.updateCounter();
200				if (me.active)
201					me.start();
202			}, i);
203		},
204		// Stop automatic update 
205		stop: function () {
206			this.active = false;
207		},
208		// Animation of a single 
209		scrollNumber: function ($n1, $n2, value) {
210			if ($n1.hasClass('show')) {
211				$n2.removeClass('hidden-down')
212					.css('top', '-100%')
213					.text(value)
214					.stop()
215					.animate({ top: 0 }, this.speed, function () {
216						$n2.addClass('show');
217					});
218				$n1.stop().animate({ top: "100%" }, this.speed, function () {
219					$n1.removeClass('show')
220						.addClass('hidden-down');
221				});
222			} else {
223				$n1.removeClass('hidden-down')
224					.css('top', '-100%')
225					.text(value)
226					.stop()
227					.animate({ top: 0 }, this.speed, function () {
228						$n1.addClass('show');
229					});
230				$n2.stop().animate({ top: "100%" }, this.speed, function () {
231					$n2.removeClass('show')
232						.addClass('hidden-down');
233				});
234			}
235		}
236	}
237
238	// jQuery plugin
239	jQuery.fn.mbComingsoon = function (opt) {
240		var defaults = {
241			interval: 1000,
242			callBack: null,
243			localization: { days: "days", hours: "hours", minutes: "minutes", seconds: "seconds" },
244            speed:500
245		}
246		var options = {};
247		var content = '   <div class="counter-group" id="myCounter">' +
248						'       <div class="counter-block">' +
249						'           <div class="counter days">' +
250						'               <div class="number show n1 hundreds">0</div>' +
251						'               <div class="number show n1 tens">0</div>' +
252						'               <div class="number show n1 units">0</div>' +
253						'               <div class="number hidden-up n2 hundreds">0</div>' +
254						'               <div class="number hidden-up n2 tens">0</div>' +
255						'               <div class="number hidden-up n2 units">0</div>' +
256						'           </div>' +
257						'           <div class="counter-caption">days</div>' +
258						'       </div>' +
259						'       <div class="counter-block">' +
260						'           <div class="counter hours">' +
261						'               <div class="number show n1 tens">0</div>' +
262						'               <div class="number show n1 units">0</div>' +
263						'               <div class="number hidden-up n2 tens">0</div>' +
264						'               <div class="number hidden-up n2 units">0</div>' +
265						'           </div>' +
266						'           <div class="counter-caption">hours</div>' +
267						'       </div>' +
268						'       <div class="counter-block">' +
269						'           <div class="counter minutes">' +
270						'               <div class="number show n1 tens">0</div>' +
271						'               <div class="number show n1 units">0</div>' +
272						'               <div class="number hidden-up n2 tens">0</div>' +
273						'               <div class="number hidden-up n2 units">0</div>' +
274						'           </div>' +
275						'           <div class="counter-caption">minutes</div>' +
276						'       </div>' +
277						'       <div class="counter-block">' +
278						'           <div class="counter seconds">' +
279						'               <div class="number show n1 tens">0</div>' +
280						'               <div class="number show n1 units">0</div>' +
281						'               <div class="number hidden-up n2 tens">0</div>' +
282						'               <div class="number hidden-up n2 units">0</div>' +
283						'           </div>' +
284						'           <div class="counter-caption">seconds</div>' +
285						'       </div>' +
286						'   </div>';
287		return this.each(function () {
288			var $this = $(this);
289			var data = $this.data('mbComingsoon');
290			if (!data) {
291				if (opt instanceof Date)
292					options.expiryDate = opt;
293				else if ($.isPlainObject(opt))
294					$.extend(options, defaults, opt);
295				else if (typeof opt == "string")
296					options.expiryDate = new Date(opt);
297				if (!options.expiryDate)
298					throw new Error('Expiry date is required!');
299				data = new MbComingsoon(options.expiryDate, $this, options.localization, options.speed, options.callBack);
300				$this.html(content);
301				data.localize();
302				data.start();
303			} else if (opt == 'start')
304				data.start();
305			else if (opt == 'stop')
306				data.stop();
307			else if ($.isPlainObject(opt)) {
308				if (opt.expiryDate instanceof Date)
309					data.end = opt.expiryDate;
310				if ($.isNumeric(opt.interval))
311					data.interval = opt.interval;
312				if ($.isFunction(opt.callBack))
313				    data.callBack = opt.callBack;
314				if ($.isPlainObject(opt.localization))
315				    this.localize(opt.localization);
316			}
317		})
318	}
319
320})(jQuery)
321/**************************************/
322// Code added by Asim Ashraf - DevBatch
323// DateTime: 28 Jan 2015
324// Code Edit Start
325/************************************/
326
327    function mbComingsoonResize() {
328        jQuery(".lightfluid").each(function () {
329                var $this = jQuery(this);
330                var col_width = $this.width();//console.log(col_width);
331
332                if (col_width > 546) {
333
334                    $this.find(".lightfluid_inner").css({'min-width': '460px', "width": ''});
335                    $this.find(".lightfluid_inner .counter-block .counter").css({'height': '', "margin": '', "width": ''});
336                    $this.find(".lightfluid_inner .counter-block .number").css({'font-size': '', "line-height": ''});
337                    $this.find(".lightfluid_inner .counter-block .counter-caption").css({'font-size': ''});
338                    $this.find(".lightfluid_inner .counter-block").css({'margin-right': ''});
339                } else {
340                    $this.find(".lightfluid_inner").css({'min-width': '', "width": col_width + 'px'});
341
342                    $this.find(".lightfluid_inner .counter-block .counter").css({'height': '48px', "margin": '0 auto', "width": '50px'});
343                    $this.find(".lightfluid_inner .counter-block .number").css({'font-size': '38px', "line-height": '49px'});
344                    $this.find(".lightfluid_inner .counter-block .counter-caption").css({'font-size': '16px'});
345                    $this.find(".lightfluid_inner .counter-block").css({'margin-right': '8px'});
346
347                }
348
349            });
350    }
351/**************************************/
352// Code added by Asim Ashraf - DevBatch
353// DateTime: 28 Jan 2015
354// Code Edit End
355/************************************/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.