Version Description
- Fix WP 3.8 admin styles.
Download this release
Release Info
Developer | ujimoto |
Plugin | Uji Countdown |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- css/admin.countdown.css +14 -3
- js/jquery.countdown.dev.js +953 -0
- readme.txt +6 -2
- uji-countdown.php +1 -1
css/admin.countdown.css
CHANGED
@@ -8,10 +8,11 @@
|
|
8 |
margin-left: 20px!important;
|
9 |
}
|
10 |
.cancel{
|
11 |
-
padding: 5px 10px 4px 10px!important;
|
12 |
float: left;
|
13 |
-
display: inline;
|
|
|
14 |
}
|
|
|
15 |
.widefat{
|
16 |
width: 525px;
|
17 |
}
|
@@ -38,11 +39,21 @@
|
|
38 |
display: block;
|
39 |
overflow: hidden;
|
40 |
margin-bottom: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
|
|
42 |
#ujic-add label{
|
43 |
float: left;
|
44 |
width: 160px;
|
45 |
font-weight: bold;
|
|
|
46 |
}
|
47 |
#ujic-add input{
|
48 |
display: inline;
|
@@ -62,7 +73,7 @@
|
|
62 |
}
|
63 |
#ujic-add #ujic_col_dw, #ujic-add #ujic_col_up, #ujic-add #ujic_col_txt, #ujic-add #ujic_col_sw{
|
64 |
margin: 10px 0 0 10px;
|
65 |
-
width:
|
66 |
}
|
67 |
#uji_pos_0, #uji_pos_1, #uji_pos_2, #uji_pos_3{
|
68 |
display: inline-block;
|
8 |
margin-left: 20px!important;
|
9 |
}
|
10 |
.cancel{
|
|
|
11 |
float: left;
|
12 |
+
display: inline-block!important;
|
13 |
+
margin-left: 4px!important;
|
14 |
}
|
15 |
+
|
16 |
.widefat{
|
17 |
width: 525px;
|
18 |
}
|
39 |
display: block;
|
40 |
overflow: hidden;
|
41 |
margin-bottom: 10px;
|
42 |
+
font-size: 12px;
|
43 |
+
}
|
44 |
+
|
45 |
+
#ujic-add input[type="checkbox"],
|
46 |
+
#ujic-add input[type="radio"] {
|
47 |
+
margin: 2px 0 0 0 !important;
|
48 |
+
width: 13px!important;
|
49 |
+
height: 13px!important;
|
50 |
}
|
51 |
+
|
52 |
#ujic-add label{
|
53 |
float: left;
|
54 |
width: 160px;
|
55 |
font-weight: bold;
|
56 |
+
font-size: 12px;
|
57 |
}
|
58 |
#ujic-add input{
|
59 |
display: inline;
|
73 |
}
|
74 |
#ujic-add #ujic_col_dw, #ujic-add #ujic_col_up, #ujic-add #ujic_col_txt, #ujic-add #ujic_col_sw{
|
75 |
margin: 10px 0 0 10px;
|
76 |
+
width: 80px;
|
77 |
}
|
78 |
#uji_pos_0, #uji_pos_1, #uji_pos_2, #uji_pos_3{
|
79 |
display: inline-block;
|
js/jquery.countdown.dev.js
ADDED
@@ -0,0 +1,953 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* http://keith-wood.name/countdown.html
|
2 |
+
Countdown for jQuery v1.6.3.
|
3 |
+
Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
|
4 |
+
Available under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license.
|
5 |
+
Please attribute the author if you use it. */
|
6 |
+
|
7 |
+
/* Display a countdown timer.
|
8 |
+
Attach it with options like:
|
9 |
+
$('div selector').countdown(
|
10 |
+
{until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */
|
11 |
+
|
12 |
+
(function($) { // Hide scope, no $ conflict
|
13 |
+
|
14 |
+
/* Countdown manager. */
|
15 |
+
function Countdown() {
|
16 |
+
this.regional = []; // Available regional settings, indexed by language code
|
17 |
+
this.regional[''] = { // Default regional settings
|
18 |
+
// The display texts for the counters
|
19 |
+
labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
|
20 |
+
// The display texts for the counters if only one
|
21 |
+
labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
|
22 |
+
compactLabels: ['y', 'm', 'w', 'd'], // The compact texts for the counters
|
23 |
+
whichLabels: null, // Function to determine which labels to use
|
24 |
+
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], // The digits to display
|
25 |
+
timeSeparator: ':', // Separator for time periods
|
26 |
+
isRTL: false // True for right-to-left languages, false for left-to-right
|
27 |
+
};
|
28 |
+
this._defaults = {
|
29 |
+
//<ujimoto
|
30 |
+
text_size: '35',
|
31 |
+
animate_sec: false,
|
32 |
+
color_down : '#3A3A3A',
|
33 |
+
color_up : '#635b63',
|
34 |
+
color_txt : '#ffffff',
|
35 |
+
color_sw : '#000000',
|
36 |
+
ujic_txt : true,
|
37 |
+
ujic_url : false,
|
38 |
+
//ujimoto>
|
39 |
+
until: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
|
40 |
+
// or numeric for seconds offset, or string for unit offset(s):
|
41 |
+
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
|
42 |
+
since: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count up from
|
43 |
+
// or numeric for seconds offset, or string for unit offset(s):
|
44 |
+
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
|
45 |
+
timezone: null, // The timezone (hours or minutes from GMT) for the target times,
|
46 |
+
// or null for client local
|
47 |
+
serverSync: null, // A function to retrieve the current server time for synchronisation
|
48 |
+
format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
|
49 |
+
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
|
50 |
+
layout: '', // Build your own layout for the countdown
|
51 |
+
compact: false, // True to display in a compact format, false for an expanded one
|
52 |
+
significant: 0, // The number of periods with values to show, zero for all
|
53 |
+
description: '', // The description displayed for the countdown
|
54 |
+
expiryUrl: '', // A URL to load upon expiry, replacing the current page
|
55 |
+
expiryText: '', // Text to display upon expiry, replacing the countdown
|
56 |
+
alwaysExpire: false, // True to trigger onExpiry even if never counted down
|
57 |
+
onExpiry: null, // Callback when the countdown expires -
|
58 |
+
// receives no parameters and 'this' is the containing division
|
59 |
+
onTick: null, // Callback when the countdown is updated -
|
60 |
+
// receives int[7] being the breakdown by period (based on format)
|
61 |
+
// and 'this' is the containing division
|
62 |
+
tickInterval: 1 // Interval (seconds) between onTick callbacks
|
63 |
+
};
|
64 |
+
$.extend(this._defaults, this.regional['']);
|
65 |
+
this._serverSyncs = [];
|
66 |
+
var now = (typeof Date.now == 'function' ? Date.now :
|
67 |
+
function() { return new Date().getTime(); });
|
68 |
+
var perfAvail = (window.performance && typeof window.performance.now == 'function');
|
69 |
+
// Shared timer for all countdowns
|
70 |
+
function timerCallBack(timestamp) {
|
71 |
+
var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer
|
72 |
+
(perfAvail ? (performance.now() + performance.timing.navigationStart) : now()) :
|
73 |
+
// Integer milliseconds since unix epoch
|
74 |
+
timestamp || now());
|
75 |
+
if (drawStart - animationStartTime >= 1000) {
|
76 |
+
plugin._updateTargets();
|
77 |
+
animationStartTime = drawStart;
|
78 |
+
}
|
79 |
+
requestAnimationFrame(timerCallBack);
|
80 |
+
}
|
81 |
+
var requestAnimationFrame = window.requestAnimationFrame ||
|
82 |
+
window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
|
83 |
+
window.oRequestAnimationFrame || window.msRequestAnimationFrame || null;
|
84 |
+
// This is when we expect a fall-back to setInterval as it's much more fluid
|
85 |
+
var animationStartTime = 0;
|
86 |
+
if (!requestAnimationFrame || $.noRequestAnimationFrame) {
|
87 |
+
$.noRequestAnimationFrame = null;
|
88 |
+
setInterval(function() { plugin._updateTargets(); }, 980); // Fall back to good old setInterval
|
89 |
+
}
|
90 |
+
else {
|
91 |
+
animationStartTime = window.animationStartTime ||
|
92 |
+
window.webkitAnimationStartTime || window.mozAnimationStartTime ||
|
93 |
+
window.oAnimationStartTime || window.msAnimationStartTime || now();
|
94 |
+
requestAnimationFrame(timerCallBack);
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
var Y = 0; // Years
|
99 |
+
var O = 1; // Months
|
100 |
+
var W = 2; // Weeks
|
101 |
+
var D = 3; // Days
|
102 |
+
var H = 4; // Hours
|
103 |
+
var M = 5; // Minutes
|
104 |
+
var S = 6; // Seconds
|
105 |
+
|
106 |
+
$.extend(Countdown.prototype, {
|
107 |
+
/* Class name added to elements to indicate already configured with countdown. */
|
108 |
+
markerClassName: 'hasCountdown',
|
109 |
+
/* Name of the data property for instance settings. */
|
110 |
+
propertyName: 'countdown',
|
111 |
+
|
112 |
+
/* Class name for the right-to-left marker. */
|
113 |
+
_rtlClass: 'countdown_rtl',
|
114 |
+
/* Class name for the countdown section marker. */
|
115 |
+
_sectionClass: 'countdown_section',
|
116 |
+
/* Class name for the period amount marker. */
|
117 |
+
_amountClass: 'countdown_amount',
|
118 |
+
/* Class name for the countdown row marker. */
|
119 |
+
_rowClass: 'countdown_row',
|
120 |
+
/* Class name for the holding countdown marker. */
|
121 |
+
_holdingClass: 'countdown_holding',
|
122 |
+
/* Class name for the showing countdown marker. */
|
123 |
+
_showClass: 'countdown_show',
|
124 |
+
/* Class name for the description marker. */
|
125 |
+
_descrClass: 'countdown_descr',
|
126 |
+
|
127 |
+
/* List of currently active countdown targets. */
|
128 |
+
_timerTargets: [],
|
129 |
+
|
130 |
+
/* Override the default settings for all instances of the countdown widget.
|
131 |
+
@param options (object) the new settings to use as defaults */
|
132 |
+
setDefaults: function(options) {
|
133 |
+
this._resetExtraLabels(this._defaults, options);
|
134 |
+
$.extend(this._defaults, options || {});
|
135 |
+
},
|
136 |
+
|
137 |
+
/* Convert a date/time to UTC.
|
138 |
+
@param tz (number) the hour or minute offset from GMT, e.g. +9, -360
|
139 |
+
@param year (Date) the date/time in that timezone or
|
140 |
+
(number) the year in that timezone
|
141 |
+
@param month (number, optional) the month (0 - 11) (omit if year is a Date)
|
142 |
+
@param day (number, optional) the day (omit if year is a Date)
|
143 |
+
@param hours (number, optional) the hour (omit if year is a Date)
|
144 |
+
@param mins (number, optional) the minute (omit if year is a Date)
|
145 |
+
@param secs (number, optional) the second (omit if year is a Date)
|
146 |
+
@param ms (number, optional) the millisecond (omit if year is a Date)
|
147 |
+
@return (Date) the equivalent UTC date/time */
|
148 |
+
UTCDate: function(tz, year, month, day, hours, mins, secs, ms) {
|
149 |
+
if (typeof year == 'object' && year.constructor == Date) {
|
150 |
+
ms = year.getMilliseconds();
|
151 |
+
secs = year.getSeconds();
|
152 |
+
mins = year.getMinutes();
|
153 |
+
hours = year.getHours();
|
154 |
+
day = year.getDate();
|
155 |
+
month = year.getMonth();
|
156 |
+
year = year.getFullYear();
|
157 |
+
}
|
158 |
+
var d = new Date();
|
159 |
+
d.setUTCFullYear(year);
|
160 |
+
d.setUTCDate(1);
|
161 |
+
d.setUTCMonth(month || 0);
|
162 |
+
d.setUTCDate(day || 1);
|
163 |
+
d.setUTCHours(hours || 0);
|
164 |
+
d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz));
|
165 |
+
d.setUTCSeconds(secs || 0);
|
166 |
+
d.setUTCMilliseconds(ms || 0);
|
167 |
+
return d;
|
168 |
+
},
|
169 |
+
|
170 |
+
/* Convert a set of periods into seconds.
|
171 |
+
Averaged for months and years.
|
172 |
+
@param periods (number[7]) the periods per year/month/week/day/hour/minute/second
|
173 |
+
@return (number) the corresponding number of seconds */
|
174 |
+
periodsToSeconds: function(periods) {
|
175 |
+
return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 +
|
176 |
+
periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
|
177 |
+
},
|
178 |
+
|
179 |
+
/* Attach the countdown widget to a div.
|
180 |
+
@param target (element) the containing division
|
181 |
+
@param options (object) the initial settings for the countdown */
|
182 |
+
_attachPlugin: function(target, options) {
|
183 |
+
target = $(target);
|
184 |
+
if (target.hasClass(this.markerClassName)) {
|
185 |
+
return;
|
186 |
+
}
|
187 |
+
var inst = {options: $.extend({}, this._defaults), _periods: [0, 0, 0, 0, 0, 0, 0]};
|
188 |
+
target.addClass(this.markerClassName).data(this.propertyName, inst);
|
189 |
+
this._optionPlugin(target, options);
|
190 |
+
},
|
191 |
+
|
192 |
+
/* Add a target to the list of active ones.
|
193 |
+
@param target (element) the countdown target */
|
194 |
+
_addTarget: function(target) {
|
195 |
+
if (!this._hasTarget(target)) {
|
196 |
+
this._timerTargets.push(target);
|
197 |
+
}
|
198 |
+
},
|
199 |
+
|
200 |
+
/* See if a target is in the list of active ones.
|
201 |
+
@param target (element) the countdown target
|
202 |
+
@return (boolean) true if present, false if not */
|
203 |
+
_hasTarget: function(target) {
|
204 |
+
return ($.inArray(target, this._timerTargets) > -1);
|
205 |
+
},
|
206 |
+
|
207 |
+
/* Remove a target from the list of active ones.
|
208 |
+
@param target (element) the countdown target */
|
209 |
+
_removeTarget: function(target) {
|
210 |
+
this._timerTargets = $.map(this._timerTargets,
|
211 |
+
function(value) { return (value == target ? null : value); }); // delete entry
|
212 |
+
},
|
213 |
+
|
214 |
+
/* Update each active timer target. */
|
215 |
+
_updateTargets: function() {
|
216 |
+
for (var i = this._timerTargets.length - 1; i >= 0; i--) {
|
217 |
+
this._updateCountdown(this._timerTargets[i]);
|
218 |
+
}
|
219 |
+
},
|
220 |
+
|
221 |
+
/* Reconfigure the settings for a countdown div.
|
222 |
+
@param target (element) the control to affect
|
223 |
+
@param options (object) the new options for this instance or
|
224 |
+
(string) an individual property name
|
225 |
+
@param value (any) the individual property value (omit if options
|
226 |
+
is an object or to retrieve the value of a setting)
|
227 |
+
@return (any) if retrieving a value */
|
228 |
+
_optionPlugin: function(target, options, value) {
|
229 |
+
target = $(target);
|
230 |
+
var inst = target.data(this.propertyName);
|
231 |
+
if (!options || (typeof options == 'string' && value == null)) { // Get option
|
232 |
+
var name = options;
|
233 |
+
options = (inst || {}).options;
|
234 |
+
return (options && name ? options[name] : options);
|
235 |
+
}
|
236 |
+
|
237 |
+
if (!target.hasClass(this.markerClassName)) {
|
238 |
+
return;
|
239 |
+
}
|
240 |
+
options = options || {};
|
241 |
+
if (typeof options == 'string') {
|
242 |
+
var name = options;
|
243 |
+
options = {};
|
244 |
+
options[name] = value;
|
245 |
+
}
|
246 |
+
if (options.layout) {
|
247 |
+
options.layout = options.layout.replace(/</g, '<').replace(/>/g, '>');
|
248 |
+
}
|
249 |
+
this._resetExtraLabels(inst.options, options);
|
250 |
+
var timezoneChanged = (inst.options.timezone != options.timezone);
|
251 |
+
$.extend(inst.options, options);
|
252 |
+
this._adjustSettings(target, inst,
|
253 |
+
options.until != null || options.since != null || timezoneChanged);
|
254 |
+
var now = new Date();
|
255 |
+
if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) {
|
256 |
+
this._addTarget(target[0]);
|
257 |
+
}
|
258 |
+
this._updateCountdown(target, inst);
|
259 |
+
},
|
260 |
+
|
261 |
+
/* Redisplay the countdown with an updated display.
|
262 |
+
@param target (jQuery) the containing division
|
263 |
+
@param inst (object) the current settings for this instance */
|
264 |
+
_updateCountdown: function(target, inst) {
|
265 |
+
var $target = $(target);
|
266 |
+
inst = inst || $target.data(this.propertyName);
|
267 |
+
if (!inst) {
|
268 |
+
return;
|
269 |
+
}
|
270 |
+
$target.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL);
|
271 |
+
|
272 |
+
//<ujimoto
|
273 |
+
|
274 |
+
|
275 |
+
var ujic_url = inst.options.ujic_url;
|
276 |
+
var ujic_until = inst.options.until;
|
277 |
+
|
278 |
+
var foo = new Date; // Generic JS date object
|
279 |
+
var unixtime = parseInt(foo.getTime() / 1000);
|
280 |
+
var until_time = parseInt(ujic_until.getTime() / 1000)-2;
|
281 |
+
/*delay 2 seconds for run process*/
|
282 |
+
if(ujic_url == "false") ujic_url = false;
|
283 |
+
if(ujic_url && (unixtime>until_time)){
|
284 |
+
window.location.replace(ujic_url);
|
285 |
+
}
|
286 |
+
|
287 |
+
var color_down = inst.options.color_down;
|
288 |
+
var color_up = inst.options.color_up;
|
289 |
+
|
290 |
+
jQuery('#ujiCountdown .countdown_amount').css("background-image", "linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
|
291 |
+
jQuery('#ujiCountdown .countdown_amount').css("background-image", "-o-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
|
292 |
+
jQuery('#ujiCountdown .countdown_amount').css("background-image", "-moz-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
|
293 |
+
jQuery('#ujiCountdown .countdown_amount').css("background-image", "-webkit-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
|
294 |
+
jQuery('#ujiCountdown .countdown_amount').css("background-image", "-ms-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
|
295 |
+
jQuery('#ujiCountdown .countdown_amount').css("filter", "progid:DXImageTransform.Microsoft.Gradient(startColorstr='"+color_down+"', endColorstr='"+color_up+"')");
|
296 |
+
|
297 |
+
var color_txt = inst.options.color_txt;
|
298 |
+
var color_sw = inst.options.color_sw;
|
299 |
+
jQuery('#ujiCountdown .countdown_amount').css("color", color_txt);
|
300 |
+
jQuery('#ujiCountdown .countdown_amount').css("text-shadow",'1px 1px 1px ' + color_sw);
|
301 |
+
|
302 |
+
|
303 |
+
var ujic_txt = inst.options.ujic_txt;
|
304 |
+
if(ujic_txt){
|
305 |
+
jQuery('#ujiCountdown .countdown_txt').css("display","block");
|
306 |
+
}else{
|
307 |
+
jQuery('#ujiCountdown .countdown_txt').css("display","none");
|
308 |
+
}
|
309 |
+
//Anime fix small font
|
310 |
+
var text_size = inst.options.text_size;
|
311 |
+
var anim_fix = 0;
|
312 |
+
switch (parseInt(text_size))
|
313 |
+
{
|
314 |
+
case 10:
|
315 |
+
anim_fix = 5;
|
316 |
+
break;
|
317 |
+
case 11:
|
318 |
+
anim_fix = 3;
|
319 |
+
break;
|
320 |
+
case 12:
|
321 |
+
anim_fix = 3;
|
322 |
+
break;
|
323 |
+
case 13:
|
324 |
+
anim_fix = 1;
|
325 |
+
break;
|
326 |
+
}
|
327 |
+
|
328 |
+
jQuery( '#ujiCountdown .countdown_amount').css("font", text_size+"px/1.5 'Open Sans Condensed',sans-serif");
|
329 |
+
if(text_size < 15) {
|
330 |
+
jQuery( '#ujiCountdown .countdown_amount').css({"padding" : "2px 5px", "margin-right" : "1px"});
|
331 |
+
jQuery( '#ujiCountdown .countdown_section').css("margin", "0px 6px 0px 0px");
|
332 |
+
jQuery( '#ujiCountdown .countdown_txt').css("font","9px 'Open Sans Condensed',sans-serif");
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
var animate_sec = inst.options.animate_sec;
|
337 |
+
if(animate_sec){
|
338 |
+
var wsec = jQuery('#ujiCountdown').find('#uji_sec').find('.countdown_section').width();
|
339 |
+
jQuery('#ujiCountdown').find('#uji_sec').find('.countdown_section').css({"width": wsec+"px"});
|
340 |
+
jQuery('#ujiCountdown').find('#uji_sec').find('.countdown_amount').eq(1).css({"top": "-74px", "right": 0, "position": "absolute", opacity:1});
|
341 |
+
jQuery('#ujiCountdown').find('#uji_sec').find('.countdown_amount').eq(1).animate({"top": anim_fix+"px", "right": 0, opacity:1},700,function(){
|
342 |
+
// Animation complete.
|
343 |
+
// $("#uji_sec").find('.countdown_amount').eq(1).animate({ opacity:1}, 500);
|
344 |
+
jQuery('#ujiCountdown').find('#uji_sec').find('.countdown_amount').eq(1).animate({opacity:0}, 300);
|
345 |
+
});
|
346 |
+
}
|
347 |
+
|
348 |
+
//ujimoto>
|
349 |
+
|
350 |
+
if ($.isFunction(inst.options.onTick)) {
|
351 |
+
var periods = inst._hold != 'lap' ? inst._periods :
|
352 |
+
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date());
|
353 |
+
if (inst.options.tickInterval == 1 ||
|
354 |
+
this.periodsToSeconds(periods) % inst.options.tickInterval == 0) {
|
355 |
+
inst.options.onTick.apply(target, [periods]);
|
356 |
+
}
|
357 |
+
}
|
358 |
+
var expired = inst._hold != 'pause' &&
|
359 |
+
(inst._since ? inst._now.getTime() < inst._since.getTime() :
|
360 |
+
inst._now.getTime() >= inst._until.getTime());
|
361 |
+
if (expired && !inst._expiring) {
|
362 |
+
inst._expiring = true;
|
363 |
+
if (this._hasTarget(target) || inst.options.alwaysExpire) {
|
364 |
+
this._removeTarget(target);
|
365 |
+
if ($.isFunction(inst.options.onExpiry)) {
|
366 |
+
inst.options.onExpiry.apply(target, []);
|
367 |
+
}
|
368 |
+
if (inst.options.expiryText) {
|
369 |
+
var layout = inst.options.layout;
|
370 |
+
inst.options.layout = inst.options.expiryText;
|
371 |
+
this._updateCountdown(target, inst);
|
372 |
+
inst.options.layout = layout;
|
373 |
+
}
|
374 |
+
if (inst.options.expiryUrl) {
|
375 |
+
window.location = inst.options.expiryUrl;
|
376 |
+
}
|
377 |
+
}
|
378 |
+
inst._expiring = false;
|
379 |
+
}
|
380 |
+
else if (inst._hold == 'pause') {
|
381 |
+
this._removeTarget(target);
|
382 |
+
}
|
383 |
+
$target.data(this.propertyName, inst);
|
384 |
+
},
|
385 |
+
|
386 |
+
/* Reset any extra labelsn and compactLabelsn entries if changing labels.
|
387 |
+
@param base (object) the options to be updated
|
388 |
+
@param options (object) the new option values */
|
389 |
+
_resetExtraLabels: function(base, options) {
|
390 |
+
var changingLabels = false;
|
391 |
+
for (var n in options) {
|
392 |
+
if (n != 'whichLabels' && n.match(/[Ll]abels/)) {
|
393 |
+
changingLabels = true;
|
394 |
+
break;
|
395 |
+
}
|
396 |
+
}
|
397 |
+
if (changingLabels) {
|
398 |
+
for (var n in base) { // Remove custom numbered labels
|
399 |
+
if (n.match(/[Ll]abels[02-9]|compactLabels1/)) {
|
400 |
+
base[n] = null;
|
401 |
+
}
|
402 |
+
}
|
403 |
+
}
|
404 |
+
},
|
405 |
+
|
406 |
+
/* Calculate interal settings for an instance.
|
407 |
+
@param target (element) the containing division
|
408 |
+
@param inst (object) the current settings for this instance
|
409 |
+
@param recalc (boolean) true if until or since are set */
|
410 |
+
_adjustSettings: function(target, inst, recalc) {
|
411 |
+
var now;
|
412 |
+
var serverOffset = 0;
|
413 |
+
var serverEntry = null;
|
414 |
+
for (var i = 0; i < this._serverSyncs.length; i++) {
|
415 |
+
if (this._serverSyncs[i][0] == inst.options.serverSync) {
|
416 |
+
serverEntry = this._serverSyncs[i][1];
|
417 |
+
break;
|
418 |
+
}
|
419 |
+
}
|
420 |
+
if (serverEntry != null) {
|
421 |
+
serverOffset = (inst.options.serverSync ? serverEntry : 0);
|
422 |
+
now = new Date();
|
423 |
+
}
|
424 |
+
else {
|
425 |
+
var serverResult = ($.isFunction(inst.options.serverSync) ?
|
426 |
+
inst.options.serverSync.apply(target, []) : null);
|
427 |
+
now = new Date();
|
428 |
+
serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0);
|
429 |
+
this._serverSyncs.push([inst.options.serverSync, serverOffset]);
|
430 |
+
}
|
431 |
+
var timezone = inst.options.timezone;
|
432 |
+
timezone = (timezone == null ? -now.getTimezoneOffset() : timezone);
|
433 |
+
if (recalc || (!recalc && inst._until == null && inst._since == null)) {
|
434 |
+
inst._since = inst.options.since;
|
435 |
+
if (inst._since != null) {
|
436 |
+
inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
|
437 |
+
if (inst._since && serverOffset) {
|
438 |
+
inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset);
|
439 |
+
}
|
440 |
+
}
|
441 |
+
inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now));
|
442 |
+
if (serverOffset) {
|
443 |
+
inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset);
|
444 |
+
}
|
445 |
+
}
|
446 |
+
inst._show = this._determineShow(inst);
|
447 |
+
},
|
448 |
+
|
449 |
+
/* Remove the countdown widget from a div.
|
450 |
+
@param target (element) the containing division */
|
451 |
+
_destroyPlugin: function(target) {
|
452 |
+
target = $(target);
|
453 |
+
if (!target.hasClass(this.markerClassName)) {
|
454 |
+
return;
|
455 |
+
}
|
456 |
+
this._removeTarget(target[0]);
|
457 |
+
target.removeClass(this.markerClassName).empty().removeData(this.propertyName);
|
458 |
+
},
|
459 |
+
|
460 |
+
/* Pause a countdown widget at the current time.
|
461 |
+
Stop it running but remember and display the current time.
|
462 |
+
@param target (element) the containing division */
|
463 |
+
_pausePlugin: function(target) {
|
464 |
+
this._hold(target, 'pause');
|
465 |
+
},
|
466 |
+
|
467 |
+
/* Pause a countdown widget at the current time.
|
468 |
+
Stop the display but keep the countdown running.
|
469 |
+
@param target (element) the containing division */
|
470 |
+
_lapPlugin: function(target) {
|
471 |
+
this._hold(target, 'lap');
|
472 |
+
},
|
473 |
+
|
474 |
+
/* Resume a paused countdown widget.
|
475 |
+
@param target (element) the containing division */
|
476 |
+
_resumePlugin: function(target) {
|
477 |
+
this._hold(target, null);
|
478 |
+
},
|
479 |
+
|
480 |
+
/* Pause or resume a countdown widget.
|
481 |
+
@param target (element) the containing division
|
482 |
+
@param hold (string) the new hold setting */
|
483 |
+
_hold: function(target, hold) {
|
484 |
+
var inst = $.data(target, this.propertyName);
|
485 |
+
if (inst) {
|
486 |
+
if (inst._hold == 'pause' && !hold) {
|
487 |
+
inst._periods = inst._savePeriods;
|
488 |
+
var sign = (inst._since ? '-' : '+');
|
489 |
+
inst[inst._since ? '_since' : '_until'] =
|
490 |
+
this._determineTime(sign + inst._periods[0] + 'y' +
|
491 |
+
sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' +
|
492 |
+
sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' +
|
493 |
+
sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's');
|
494 |
+
this._addTarget(target);
|
495 |
+
}
|
496 |
+
inst._hold = hold;
|
497 |
+
inst._savePeriods = (hold == 'pause' ? inst._periods : null);
|
498 |
+
$.data(target, this.propertyName, inst);
|
499 |
+
this._updateCountdown(target, inst);
|
500 |
+
}
|
501 |
+
},
|
502 |
+
|
503 |
+
/* Return the current time periods.
|
504 |
+
@param target (element) the containing division
|
505 |
+
@return (number[7]) the current periods for the countdown */
|
506 |
+
_getTimesPlugin: function(target) {
|
507 |
+
var inst = $.data(target, this.propertyName);
|
508 |
+
return (!inst ? null : (inst._hold == 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods :
|
509 |
+
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()))));
|
510 |
+
},
|
511 |
+
|
512 |
+
/* A time may be specified as an exact value or a relative one.
|
513 |
+
@param setting (string or number or Date) - the date/time value
|
514 |
+
as a relative or absolute value
|
515 |
+
@param defaultTime (Date) the date/time to use if no other is supplied
|
516 |
+
@return (Date) the corresponding date/time */
|
517 |
+
_determineTime: function(setting, defaultTime) {
|
518 |
+
var offsetNumeric = function(offset) { // e.g. +300, -2
|
519 |
+
var time = new Date();
|
520 |
+
time.setTime(time.getTime() + offset * 1000);
|
521 |
+
return time;
|
522 |
+
};
|
523 |
+
var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m'
|
524 |
+
offset = offset.toLowerCase();
|
525 |
+
var time = new Date();
|
526 |
+
var year = time.getFullYear();
|
527 |
+
var month = time.getMonth();
|
528 |
+
var day = time.getDate();
|
529 |
+
var hour = time.getHours();
|
530 |
+
var minute = time.getMinutes();
|
531 |
+
var second = time.getSeconds();
|
532 |
+
var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
|
533 |
+
var matches = pattern.exec(offset);
|
534 |
+
while (matches) {
|
535 |
+
switch (matches[2] || 's') {
|
536 |
+
case 's': second += parseInt(matches[1], 10); break;
|
537 |
+
case 'm': minute += parseInt(matches[1], 10); break;
|
538 |
+
case 'h': hour += parseInt(matches[1], 10); break;
|
539 |
+
case 'd': day += parseInt(matches[1], 10); break;
|
540 |
+
case 'w': day += parseInt(matches[1], 10) * 7; break;
|
541 |
+
case 'o':
|
542 |
+
month += parseInt(matches[1], 10);
|
543 |
+
day = Math.min(day, plugin._getDaysInMonth(year, month));
|
544 |
+
break;
|
545 |
+
case 'y':
|
546 |
+
year += parseInt(matches[1], 10);
|
547 |
+
day = Math.min(day, plugin._getDaysInMonth(year, month));
|
548 |
+
break;
|
549 |
+
}
|
550 |
+
matches = pattern.exec(offset);
|
551 |
+
}
|
552 |
+
return new Date(year, month, day, hour, minute, second, 0);
|
553 |
+
};
|
554 |
+
var time = (setting == null ? defaultTime :
|
555 |
+
(typeof setting == 'string' ? offsetString(setting) :
|
556 |
+
(typeof setting == 'number' ? offsetNumeric(setting) : setting)));
|
557 |
+
if (time) time.setMilliseconds(0);
|
558 |
+
return time;
|
559 |
+
},
|
560 |
+
|
561 |
+
/* Determine the number of days in a month.
|
562 |
+
@param year (number) the year
|
563 |
+
@param month (number) the month
|
564 |
+
@return (number) the days in that month */
|
565 |
+
_getDaysInMonth: function(year, month) {
|
566 |
+
return 32 - new Date(year, month, 32).getDate();
|
567 |
+
},
|
568 |
+
|
569 |
+
/* Determine which set of labels should be used for an amount.
|
570 |
+
@param num (number) the amount to be displayed
|
571 |
+
@return (number) the set of labels to be used for this amount */
|
572 |
+
_normalLabels: function(num) {
|
573 |
+
return num;
|
574 |
+
},
|
575 |
+
|
576 |
+
/* Generate the HTML to display the countdown widget.
|
577 |
+
@param inst (object) the current settings for this instance
|
578 |
+
@return (string) the new HTML for the countdown display */
|
579 |
+
_generateHTML: function(inst) {
|
580 |
+
var self = this;
|
581 |
+
// Determine what to show
|
582 |
+
inst._periods = (inst._hold ? inst._periods :
|
583 |
+
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()));
|
584 |
+
// Show all 'asNeeded' after first non-zero value
|
585 |
+
var shownNonZero = false;
|
586 |
+
var showCount = 0;
|
587 |
+
var sigCount = inst.options.significant;
|
588 |
+
var show = $.extend({}, inst._show);
|
589 |
+
for (var period = Y; period <= S; period++) {
|
590 |
+
shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0);
|
591 |
+
show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]);
|
592 |
+
showCount += (show[period] ? 1 : 0);
|
593 |
+
sigCount -= (inst._periods[period] > 0 ? 1 : 0);
|
594 |
+
}
|
595 |
+
var showSignificant = [false, false, false, false, false, false, false];
|
596 |
+
for (var period = S; period >= Y; period--) { // Determine significant periods
|
597 |
+
if (inst._show[period]) {
|
598 |
+
if (inst._periods[period]) {
|
599 |
+
showSignificant[period] = true;
|
600 |
+
}
|
601 |
+
else {
|
602 |
+
showSignificant[period] = sigCount > 0;
|
603 |
+
sigCount--;
|
604 |
+
}
|
605 |
+
}
|
606 |
+
}
|
607 |
+
var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels);
|
608 |
+
var whichLabels = inst.options.whichLabels || this._normalLabels;
|
609 |
+
var showCompact = function(period) {
|
610 |
+
var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])];
|
611 |
+
return (show[period] ? self._translateDigits(inst, inst._periods[period]) +
|
612 |
+
(labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
|
613 |
+
};
|
614 |
+
/*var showFull = function(period) {
|
615 |
+
var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])];
|
616 |
+
return ((!inst.options.significant && show[period]) ||
|
617 |
+
(inst.options.significant && showSignificant[period]) ?
|
618 |
+
'<span class="' + plugin._sectionClass + '">' +
|
619 |
+
'<span class="' + plugin._amountClass + '">' +
|
620 |
+
self._translateDigits(inst, inst._periods[period]) + '</span><br/>' +
|
621 |
+
(labelsNum ? labelsNum[period] : labels[period]) + '</span>' : '');
|
622 |
+
};*/
|
623 |
+
|
624 |
+
var showFull = function(period) {
|
625 |
+
//ujimoto
|
626 |
+
//var labelsNum = $.countdown._get(inst, 'labels' + whichLabels(inst._periods[period]));
|
627 |
+
var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])];
|
628 |
+
|
629 |
+
if((!significant && show[period]) || (significant && showSignificant[period])){
|
630 |
+
var ujinum ='';
|
631 |
+
if(inst._periods[period].toString().length == 1){
|
632 |
+
ujinum = '<span class="countdown_amount">' + 0+ '</span>' + '<span class="countdown_amount">' + inst._periods[period] + '</span>';
|
633 |
+
} else{
|
634 |
+
for (var i = 0; i < inst._periods[period].toString().length; i++) {
|
635 |
+
ujinum += '<span class="countdown_amount">' + inst._periods[period].toString().charAt(i) + '</span>';
|
636 |
+
}
|
637 |
+
}
|
638 |
+
return '<span class="countdown_section">' +
|
639 |
+
ujinum + '<span class="countdown_txt">' +
|
640 |
+
(labelsNum ? labelsNum[period] : labels[period]) + '</span></span>';
|
641 |
+
|
642 |
+
}else {
|
643 |
+
return '';
|
644 |
+
}
|
645 |
+
//ujimoto
|
646 |
+
};
|
647 |
+
|
648 |
+
|
649 |
+
var layout = inst.options.layout;
|
650 |
+
var compact = inst.options.compact;
|
651 |
+
var significant = inst.options.significant;
|
652 |
+
var description = inst.options.description;
|
653 |
+
|
654 |
+
return (layout ? this._buildLayout(inst, show, layout, compact, significant, showSignificant) :
|
655 |
+
((compact ? // Compact version
|
656 |
+
'<span class="countdown_row countdown_amount' +
|
657 |
+
(inst._hold ? ' countdown_holding' : '') + '">' +
|
658 |
+
showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) +
|
659 |
+
(show[H] ? this._minDigits(inst._periods[H], 2) : '') +
|
660 |
+
(show[M] ? (show[H] ? timeSeparator : '') +
|
661 |
+
this._minDigits(inst._periods[M], 2) : '') +
|
662 |
+
(show[S] ? (show[H] || show[M] ? timeSeparator : '') +
|
663 |
+
this._minDigits(inst._periods[S], 2) : '') :
|
664 |
+
// Full version
|
665 |
+
'<span class="countdown_row countdown_show' + (significant || showCount) +
|
666 |
+
(inst._hold ? ' countdown_holding' : '') + '">' +
|
667 |
+
showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
|
668 |
+
showFull(H) + showFull(M) + '<span id="uji_sec">'+ showFull(S)) + '</span>' + '</span>' +
|
669 |
+
(description ? '<span class="countdown_row countdown_descr">' + description + '</span>' : '')));
|
670 |
+
|
671 |
+
|
672 |
+
|
673 |
+
|
674 |
+
|
675 |
+
|
676 |
+
/* return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout,
|
677 |
+
inst.options.compact, inst.options.significant, showSignificant) :
|
678 |
+
((inst.options.compact ? // Compact version
|
679 |
+
'<span class="' + this._rowClass + ' ' + this._amountClass +
|
680 |
+
(inst._hold ? ' ' + this._holdingClass : '') + '">' +
|
681 |
+
showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) +
|
682 |
+
(show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') +
|
683 |
+
(show[M] ? (show[H] ? inst.options.timeSeparator : '') +
|
684 |
+
this._minDigits(inst, inst._periods[M], 2) : '') +
|
685 |
+
(show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') +
|
686 |
+
this._minDigits(inst, inst._periods[S], 2) : '') :
|
687 |
+
// Full version
|
688 |
+
'<span class="' + this._rowClass + ' ' + this._showClass + (inst.options.significant || showCount) +
|
689 |
+
(inst._hold ? ' ' + this._holdingClass : '') + '">' +
|
690 |
+
showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
|
691 |
+
showFull(H) + showFull(M) + showFull(S)) + '</span>' +
|
692 |
+
(inst.options.description ? '<span class="' + this._rowClass + ' ' + this._descrClass + '">' +
|
693 |
+
inst.options.description + '</span>' : '')));*/
|
694 |
+
},
|
695 |
+
|
696 |
+
|
697 |
+
/* Construct a custom layout.
|
698 |
+
@param inst (object) the current settings for this instance
|
699 |
+
@param show (string[7]) flags indicating which periods are requested
|
700 |
+
@param layout (string) the customised layout
|
701 |
+
@param compact (boolean) true if using compact labels
|
702 |
+
@param significant (number) the number of periods with values to show, zero for all
|
703 |
+
@param showSignificant (boolean[7]) other periods to show for significance
|
704 |
+
@return (string) the custom HTML */
|
705 |
+
_buildLayout: function(inst, show, layout, compact, significant, showSignificant) {
|
706 |
+
var labels = inst.options[compact ? 'compactLabels' : 'labels'];
|
707 |
+
var whichLabels = inst.options.whichLabels || this._normalLabels;
|
708 |
+
var labelFor = function(index) {
|
709 |
+
return (inst.options[(compact ? 'compactLabels' : 'labels') +
|
710 |
+
whichLabels(inst._periods[index])] || labels)[index];
|
711 |
+
};
|
712 |
+
var digit = function(value, position) {
|
713 |
+
return inst.options.digits[Math.floor(value / position) % 10];
|
714 |
+
};
|
715 |
+
var subs = {desc: inst.options.description, sep: inst.options.timeSeparator,
|
716 |
+
yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1),
|
717 |
+
ynn: this._minDigits(inst, inst._periods[Y], 2),
|
718 |
+
ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1),
|
719 |
+
y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100),
|
720 |
+
y1000: digit(inst._periods[Y], 1000),
|
721 |
+
ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1),
|
722 |
+
onn: this._minDigits(inst, inst._periods[O], 2),
|
723 |
+
onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1),
|
724 |
+
o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100),
|
725 |
+
o1000: digit(inst._periods[O], 1000),
|
726 |
+
wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1),
|
727 |
+
wnn: this._minDigits(inst, inst._periods[W], 2),
|
728 |
+
wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1),
|
729 |
+
w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100),
|
730 |
+
w1000: digit(inst._periods[W], 1000),
|
731 |
+
dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1),
|
732 |
+
dnn: this._minDigits(inst, inst._periods[D], 2),
|
733 |
+
dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1),
|
734 |
+
d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100),
|
735 |
+
d1000: digit(inst._periods[D], 1000),
|
736 |
+
hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1),
|
737 |
+
hnn: this._minDigits(inst, inst._periods[H], 2),
|
738 |
+
hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1),
|
739 |
+
h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100),
|
740 |
+
h1000: digit(inst._periods[H], 1000),
|
741 |
+
ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1),
|
742 |
+
mnn: this._minDigits(inst, inst._periods[M], 2),
|
743 |
+
mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1),
|
744 |
+
m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100),
|
745 |
+
m1000: digit(inst._periods[M], 1000),
|
746 |
+
sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1),
|
747 |
+
snn: this._minDigits(inst, inst._periods[S], 2),
|
748 |
+
snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1),
|
749 |
+
s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100),
|
750 |
+
s1000: digit(inst._periods[S], 1000)};
|
751 |
+
var html = layout;
|
752 |
+
// Replace period containers: {p<}...{p>}
|
753 |
+
for (var i = Y; i <= S; i++) {
|
754 |
+
var period = 'yowdhms'.charAt(i);
|
755 |
+
var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g');
|
756 |
+
html = html.replace(re, ((!significant && show[i]) ||
|
757 |
+
(significant && showSignificant[i]) ? '$1' : ''));
|
758 |
+
}
|
759 |
+
// Replace period values: {pn}
|
760 |
+
$.each(subs, function(n, v) {
|
761 |
+
var re = new RegExp('\\{' + n + '\\}', 'g');
|
762 |
+
html = html.replace(re, v);
|
763 |
+
});
|
764 |
+
return html;
|
765 |
+
},
|
766 |
+
|
767 |
+
/* Ensure a numeric value has at least n digits for display.
|
768 |
+
@param inst (object) the current settings for this instance
|
769 |
+
@param value (number) the value to display
|
770 |
+
@param len (number) the minimum length
|
771 |
+
@return (string) the display text */
|
772 |
+
_minDigits: function(inst, value, len) {
|
773 |
+
value = '' + value;
|
774 |
+
if (value.length >= len) {
|
775 |
+
return this._translateDigits(inst, value);
|
776 |
+
}
|
777 |
+
value = '0000000000' + value;
|
778 |
+
return this._translateDigits(inst, value.substr(value.length - len));
|
779 |
+
},
|
780 |
+
|
781 |
+
/* Translate digits into other representations.
|
782 |
+
@param inst (object) the current settings for this instance
|
783 |
+
@param value (string) the text to translate
|
784 |
+
@return (string) the translated text */
|
785 |
+
_translateDigits: function(inst, value) {
|
786 |
+
return ('' + value).replace(/[0-9]/g, function(digit) {
|
787 |
+
return inst.options.digits[digit];
|
788 |
+
});
|
789 |
+
},
|
790 |
+
|
791 |
+
/* Translate the format into flags for each period.
|
792 |
+
@param inst (object) the current settings for this instance
|
793 |
+
@return (string[7]) flags indicating which periods are requested (?) or
|
794 |
+
required (!) by year, month, week, day, hour, minute, second */
|
795 |
+
_determineShow: function(inst) {
|
796 |
+
var format = inst.options.format;
|
797 |
+
var show = [];
|
798 |
+
show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null));
|
799 |
+
show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null));
|
800 |
+
show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null));
|
801 |
+
show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null));
|
802 |
+
show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null));
|
803 |
+
show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null));
|
804 |
+
show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null));
|
805 |
+
return show;
|
806 |
+
},
|
807 |
+
|
808 |
+
/* Calculate the requested periods between now and the target time.
|
809 |
+
@param inst (object) the current settings for this instance
|
810 |
+
@param show (string[7]) flags indicating which periods are requested/required
|
811 |
+
@param significant (number) the number of periods with values to show, zero for all
|
812 |
+
@param now (Date) the current date and time
|
813 |
+
@return (number[7]) the current time periods (always positive)
|
814 |
+
by year, month, week, day, hour, minute, second */
|
815 |
+
_calculatePeriods: function(inst, show, significant, now) {
|
816 |
+
// Find endpoints
|
817 |
+
inst._now = now;
|
818 |
+
inst._now.setMilliseconds(0);
|
819 |
+
var until = new Date(inst._now.getTime());
|
820 |
+
if (inst._since) {
|
821 |
+
if (now.getTime() < inst._since.getTime()) {
|
822 |
+
inst._now = now = until;
|
823 |
+
}
|
824 |
+
else {
|
825 |
+
now = inst._since;
|
826 |
+
}
|
827 |
+
}
|
828 |
+
else {
|
829 |
+
until.setTime(inst._until.getTime());
|
830 |
+
if (now.getTime() > inst._until.getTime()) {
|
831 |
+
inst._now = now = until;
|
832 |
+
}
|
833 |
+
}
|
834 |
+
// Calculate differences by period
|
835 |
+
var periods = [0, 0, 0, 0, 0, 0, 0];
|
836 |
+
if (show[Y] || show[O]) {
|
837 |
+
// Treat end of months as the same
|
838 |
+
var lastNow = plugin._getDaysInMonth(now.getFullYear(), now.getMonth());
|
839 |
+
var lastUntil = plugin._getDaysInMonth(until.getFullYear(), until.getMonth());
|
840 |
+
var sameDay = (until.getDate() == now.getDate() ||
|
841 |
+
(until.getDate() >= Math.min(lastNow, lastUntil) &&
|
842 |
+
now.getDate() >= Math.min(lastNow, lastUntil)));
|
843 |
+
var getSecs = function(date) {
|
844 |
+
return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds();
|
845 |
+
};
|
846 |
+
var months = Math.max(0,
|
847 |
+
(until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() +
|
848 |
+
((until.getDate() < now.getDate() && !sameDay) ||
|
849 |
+
(sameDay && getSecs(until) < getSecs(now)) ? -1 : 0));
|
850 |
+
periods[Y] = (show[Y] ? Math.floor(months / 12) : 0);
|
851 |
+
periods[O] = (show[O] ? months - periods[Y] * 12 : 0);
|
852 |
+
// Adjust for months difference and end of month if necessary
|
853 |
+
now = new Date(now.getTime());
|
854 |
+
var wasLastDay = (now.getDate() == lastNow);
|
855 |
+
var lastDay = plugin._getDaysInMonth(now.getFullYear() + periods[Y],
|
856 |
+
now.getMonth() + periods[O]);
|
857 |
+
if (now.getDate() > lastDay) {
|
858 |
+
now.setDate(lastDay);
|
859 |
+
}
|
860 |
+
now.setFullYear(now.getFullYear() + periods[Y]);
|
861 |
+
now.setMonth(now.getMonth() + periods[O]);
|
862 |
+
if (wasLastDay) {
|
863 |
+
now.setDate(lastDay);
|
864 |
+
}
|
865 |
+
}
|
866 |
+
var diff = Math.floor((until.getTime() - now.getTime()) / 1000);
|
867 |
+
var extractPeriod = function(period, numSecs) {
|
868 |
+
periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0);
|
869 |
+
diff -= periods[period] * numSecs;
|
870 |
+
};
|
871 |
+
extractPeriod(W, 604800);
|
872 |
+
extractPeriod(D, 86400);
|
873 |
+
extractPeriod(H, 3600);
|
874 |
+
extractPeriod(M, 60);
|
875 |
+
extractPeriod(S, 1);
|
876 |
+
if (diff > 0 && !inst._since) { // Round up if left overs
|
877 |
+
var multiplier = [1, 12, 4.3482, 7, 24, 60, 60];
|
878 |
+
var lastShown = S;
|
879 |
+
var max = 1;
|
880 |
+
for (var period = S; period >= Y; period--) {
|
881 |
+
if (show[period]) {
|
882 |
+
if (periods[lastShown] >= max) {
|
883 |
+
periods[lastShown] = 0;
|
884 |
+
diff = 1;
|
885 |
+
}
|
886 |
+
if (diff > 0) {
|
887 |
+
periods[period]++;
|
888 |
+
diff = 0;
|
889 |
+
lastShown = period;
|
890 |
+
max = 1;
|
891 |
+
}
|
892 |
+
}
|
893 |
+
max *= multiplier[period];
|
894 |
+
}
|
895 |
+
}
|
896 |
+
if (significant) { // Zero out insignificant periods
|
897 |
+
for (var period = Y; period <= S; period++) {
|
898 |
+
if (significant && periods[period]) {
|
899 |
+
significant--;
|
900 |
+
}
|
901 |
+
else if (!significant) {
|
902 |
+
periods[period] = 0;
|
903 |
+
}
|
904 |
+
}
|
905 |
+
}
|
906 |
+
return periods;
|
907 |
+
}
|
908 |
+
});
|
909 |
+
|
910 |
+
// The list of commands that return values and don't permit chaining
|
911 |
+
var getters = ['getTimes'];
|
912 |
+
|
913 |
+
/* Determine whether a command is a getter and doesn't permit chaining.
|
914 |
+
@param command (string, optional) the command to run
|
915 |
+
@param otherArgs ([], optional) any other arguments for the command
|
916 |
+
@return true if the command is a getter, false if not */
|
917 |
+
function isNotChained(command, otherArgs) {
|
918 |
+
if (command == 'option' && (otherArgs.length == 0 ||
|
919 |
+
(otherArgs.length == 1 && typeof otherArgs[0] == 'string'))) {
|
920 |
+
return true;
|
921 |
+
}
|
922 |
+
return $.inArray(command, getters) > -1;
|
923 |
+
}
|
924 |
+
|
925 |
+
/* Process the countdown functionality for a jQuery selection.
|
926 |
+
@param options (object) the new settings to use for these instances (optional) or
|
927 |
+
(string) the command to run (optional)
|
928 |
+
@return (jQuery) for chaining further calls or
|
929 |
+
(any) getter value */
|
930 |
+
$.fn.countdown = function(options) {
|
931 |
+
var otherArgs = Array.prototype.slice.call(arguments, 1);
|
932 |
+
if (isNotChained(options, otherArgs)) {
|
933 |
+
return plugin['_' + options + 'Plugin'].
|
934 |
+
apply(plugin, [this[0]].concat(otherArgs));
|
935 |
+
}
|
936 |
+
return this.each(function() {
|
937 |
+
if (typeof options == 'string') {
|
938 |
+
if (!plugin['_' + options + 'Plugin']) {
|
939 |
+
throw 'Unknown command: ' + options;
|
940 |
+
}
|
941 |
+
plugin['_' + options + 'Plugin'].
|
942 |
+
apply(plugin, [this].concat(otherArgs));
|
943 |
+
}
|
944 |
+
else {
|
945 |
+
plugin._attachPlugin(this, options || {});
|
946 |
+
}
|
947 |
+
});
|
948 |
+
};
|
949 |
+
|
950 |
+
/* Initialise the countdown functionality. */
|
951 |
+
var plugin = $.countdown = new Countdown(); // Singleton instance
|
952 |
+
|
953 |
+
})(jQuery);
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: ujimoto
|
|
3 |
Donate link: http://wpmanage.com/Uji-countdown
|
4 |
Tags: countdown, counter, html5 countdown, animated countdown, countdown timer, count down, countdown clock, jQuery countdown, clock, timer
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.3.
|
8 |
|
9 |
Uji Countdown - HTML5 Customizable Countdown Timer
|
10 |
|
@@ -47,6 +47,10 @@ WPmanage [(http://www.wpmanage.com/uji-countdown/)](http://www.wpmanage.com/uji-
|
|
47 |
|
48 |
== Changelog ==
|
49 |
|
|
|
|
|
|
|
|
|
50 |
= 1.3.1 =
|
51 |
|
52 |
* Fix seconds animation
|
3 |
Donate link: http://wpmanage.com/Uji-countdown
|
4 |
Tags: countdown, counter, html5 countdown, animated countdown, countdown timer, count down, countdown clock, jQuery countdown, clock, timer
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.8
|
7 |
+
Stable tag: 1.3.2
|
8 |
|
9 |
Uji Countdown - HTML5 Customizable Countdown Timer
|
10 |
|
47 |
|
48 |
== Changelog ==
|
49 |
|
50 |
+
= 1.3.2 =
|
51 |
+
|
52 |
+
* Fix WP 3.8 admin styles.
|
53 |
+
|
54 |
= 1.3.1 =
|
55 |
|
56 |
* Fix seconds animation
|
uji-countdown.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Uji Countdown
|
4 |
Plugin URI: http://www.wpmanage.com/uji-countdown/
|
5 |
Description: HTML5 Countdown.
|
6 |
-
Version: 1.3.
|
7 |
Author: Ujog Raul
|
8 |
Author URI: http://www.wpmanage.com
|
9 |
|
3 |
Plugin Name: Uji Countdown
|
4 |
Plugin URI: http://www.wpmanage.com/uji-countdown/
|
5 |
Description: HTML5 Countdown.
|
6 |
+
Version: 1.3.2
|
7 |
Author: Ujog Raul
|
8 |
Author URI: http://www.wpmanage.com
|
9 |
|