/*jslint eqeq: true, plusplus: true, undef: true, sloppy: true, vars: true, forin: true */
/*!
* jQuery MobiScroll v2.5.1
*
*
* Copyright 2010-2013, Acid Media
* Licensed under the MIT license.
*
*/
(function ($) {
function Scroller(elem, settings) {
var m,
hi,
v,
dw,
ww, // Window width
wh, // Window height
rwh,
mw, // Modal width
mh, // Modal height
anim,
debounce,
that = this,
ms = $.mobiscroll,
e = elem,
elm = $(e),
theme,
lang,
s = extend({}, defaults),
pres = {},
warr = [],
iv = {},
pixels = {},
input = ('input'),
visible = false;
// Private functions
function isReadOnly(wh) {
if ($.isArray()) {
var i = $('.dwwl', dw).index(wh);
return [i];
}
return ;
}
function generateWheelItems(i) {
var html = '<div class="dw-bf">',
l = 1,
j;
for (j in warr[i]) {
if (l % 20 == 0) {
html += '</div><div class="dw-bf">';
}
html += '<div class="dw-li dw-v" data-val="' + j + '" style="height:' + hi + 'px;line-height:' + hi + 'px;"><div class="dw-i">' + warr[i][j] + '</div></div>';
l++;
}
html += '</div>';
return html;
}
function setGlobals(t) {
min = $('.dw-li', t).index($('.dw-v', t).eq(0));
max = $('.dw-li', t).index($('.dw-v', t).eq(-1));
index = $('.dw-ul', dw).index(t);
h = hi;
inst = that;
}
function formatHeader(v) {
var t = ;
return t ? (typeof t === 'function' ? (e, v) : (/\{value\}/i, v)) : '';
}
function read() {
= ((input && !== null && != ()) || === null) ? (() || '', that) : (0);
(true);
}
function scrollToPos(time, index, manual, dir, orig) {
// Call validation event
if (event('validate', [dw, index, time]) !== false) {
// Set scrollers to position
$('.dw-ul', dw).each(function (i) {
var t = $(this),
cell = $('.dw-li[data-val="' + [i] + '"]', t),
cells = $('.dw-li', t),
v = (cell),
l = ,
sc = i == index || index === undefined;
// Scroll to a valid cell
if (!('dw-v')) {
var cell1 = cell,
cell2 = cell,
dist1 = 0,
dist2 = 0;
while (v - dist1 >= 0 && !('dw-v')) {
dist1++;
cell1 = (v - dist1);
}
while (v + dist2 < l && !('dw-v')) {
dist2++;
cell2 = (v + dist2);
}
// If we have direction (+/- or mouse wheel), the distance does not count
if (((dist2 < dist1 && dist2 && dir !== 2) || !dist1 || (v - dist1 < 0) || dir == 1) && ('dw-v')) {
cell = cell2;
v = v + dist2;
} else {
cell = cell1;
v = v - dist1;
}
}
if (!(('dw-sel')) || sc) {
// Set valid value
[i] = ('data-val');
// Add selected class to cell
$('.dw-sel', t).removeClass('dw-sel');
('dw-sel');
// Scroll to position
//(t, i, v, time);
(t, i, v, sc ? time : 0.1, sc ? orig : undefined);
}
});
// Reformat value if validation changed something
(manual);
}
}
function position(check) {
if ( == 'inline' || (ww === $(window).width() && rwh === $(window).height() && check)) {
return;
}
var w,
l,
t,
aw, // anchor width
ah, // anchor height
ap, // anchor position
at, // anchor top
al, // anchor left
arr, // arrow
arrw, // arrow width
arrl, // arrow left
scroll,
totalw = 0,
minw = 0,
st = $(window).scrollTop(),
wr = $('.dwwr', dw),
d = $('.dw', dw),
css = {},
anchor = === undefined ? elm : ;
ww = $(window).width();
rwh = $(window).height();
wh = ; // on iOS we need innerHeight
wh = wh || rwh;
if (/modal|bubble/.test()) {
$('.dwc', dw).each(function () {
w = $(this).outerWidth(true);
totalw += w;
minw = (w > minw) ? w : minw;
});
w = totalw > ww ? minw : totalw;
(w);
}
mw = ();
mh = (true);
if ( == 'modal') {
l = (ww - mw) / 2;
t = st + (wh - mh) / 2;
} else if ( == 'bubble') {
scroll = true;
arr = $('.dw-arrw-i', dw);
ap = ();
at = ;
al = ;
// horizontal positioning
aw = ();
ah = ();
l = al - ((true) - aw) / 2;
l = l > (ww - mw) ? (ww - (mw + 20)) : l;
l = l >= 0 ? l : 20;
// vertical positioning
t = at - mh; //(mh + 3); // above the input
if ((t < st) || (at > st + wh)) { // if doesn't fit above or the input is out of the screen
('dw-bubble-top').addClass('dw-bubble-bottom');
t = at + ah;// + 3; // below the input
} else {
('dw-bubble-bottom').addClass('dw-bubble-top');
}
//t = t >= st ? t : st;
// Calculate Arrow position
arrw = ();
arrl = al + aw / 2 - (l + (mw - arrw) / 2);
// Limit Arrow position to [0, ] intervall
$('.dw-arr', dw).css({ left: arrl > arrw ? arrw : arrl });
} else {
= '100%';
if ( == 'top') {
t = st;
} else if ( == 'bottom') {
t = st + wh - mh;
}
}
= t < 0 ? 0 : t;
= l;
(css);
// If top + modal height > doc height, increase doc height
$('.dw-persp', dw).height(0).height(t + mh > $(document).height() ? t + mh : $(document).height());
// Scroll needed
if (scroll && ((t + mh > st + wh) || (at > st + wh))) {
$(window).scrollTop(t + mh - wh);
}
}
function testTouch(e) {
if ( === 'touchstart') {
touch = true;
setTimeout(function () {
touch = false; // Reset if mouse event was not fired
}, 500);
} else if (touch) {
touch = false;
return false;
}
return true;
}
function event(name, args) {
var ret;
(that);
$.each([, pres, settings], function (i, v) {
if (v[name]) { // Call preset event
ret = v[name].apply(e, args);
}
});
return ret;
}
function plus(t) {
var p = +('pos'),
val = p + 1;
calc(t, val > max ? min : val, 1, true);
}
function minus(t) {
var p = +('pos'),
val = p - 1;
calc(t, val < min ? max : val, 2, true);
}
// Public functions
/**
* Enables the scroller and the associated input.
*/
= function () {
= false;
if (input) {
('disabled', false);
}
};
/**
* Disables the scroller and the associated input.
*/
= function () {
= true;
if (input) {
('disabled', true);
}
};
/**
* Scrolls target to the specified position
* @param {Object} t - Target wheel jQuery object.
* @param {Number} index - Index of the changed wheel.
* @param {Number} val - Value.
* @param {Number} time - Duration of the animation, optional.
* @param {Number} orig - Original value.
*/
= function (t, index, val, time, orig) {
function getVal(t, b, c, d) {
return c * (t / d * ( / 2)) + b;
}
function ready() {
clearInterval(iv[index]);
delete iv[index];
('pos', val).closest('.dwwl').removeClass('dwa');
}
var px = (m - val) * hi,
i;
if (px == pixels[index] && iv[index]) {
return;
}
if (time && px != pixels[index]) {
// Trigger animation start event
event('onAnimStart', [dw, index, time]);
}
pixels[index] = px;
('style', (prefix + '-transition:all ' + (time ? (3) : 0) + 's ease-out;') + (has3d ? (prefix + '-transform:translate3d(0,' + px + 'px,0);') : ('top:' + px + 'px;')));
if (iv[index]) {
ready();
}
if (time && orig !== undefined) {
i = 0;
('.dwwl').addClass('dwa');
iv[index] = setInterval(function () {
i += 0.1;
('pos', (getVal(i, orig, val - orig, time)));
if (i >= time) {
ready();
}
}, 100);
} else {
('pos', val);
}
};
/**
* Gets the selected wheel values, formats it, and set the value of the scroller instance.
* If input parameter is true, populates the associated input element.
* @param {Boolean} sc - Scroll the wheel in position.
* @param {Boolean} fill - Also set the value of the associated input element. Default is true.
* @param {Number} time - Animation time
* @param {Boolean} temp - If true, then only set the temporary value.(only scroll there but not set the value)
*/
= function (sc, fill, time, temp) {
if (!$.isArray()) {
= ( + '', that);
}
if (visible && sc) {
scrollToPos(time);
}
v = ();
if (!temp) {
= (0);
= v;
}
if (fill) {
if (input) {
(v).trigger('change');
}
}
};
= function () {
var ret = [],
i;
for (i in that._selectedValues) {
(that._selectedValues[i]);
}
return ret;
};
/**
* Checks if the current selected values are valid together.
* In case of date presets it checks the number of days in a month.
* @param {Number} time - Animation time
* @param {Number} orig - Original value
* @param {Number} i - Currently changed wheel index, -1 if initial validation.
* @param {Number} dir - Scroll direction
*/
= function (i, dir, time, orig) {
scrollToPos(time, i, true, dir, orig);
};
/**
*
*/
= function (manual) {
v = ();
if ( == 'inline') {
(false, manual);
} else {
$('.dwv', dw).html(formatHeader(v));
}
if (manual) {
event('onChange', [v]);
}
};
/**
* Changes the values of a wheel, and scrolls to the correct position
*/
= function (idx, time) {
if (dw) {
var i = 0,
j,
k,
nr = ;
for (j in ) {
for (k in [j]) {
if ($.inArray(i, idx) > -1) {
warr[i] = [j][k];
$('.dw-ul', dw).eq(i).html(generateWheelItems(i));
nr--;
if (!nr) {
position();
scrollToPos(time, undefined, true);
return;
}
}
i++;
}
}
}
};
/**
* Return true if the scroller is currently visible.
*/
= function () {
return visible;
};
/**
*
*/
= function (el, handler) {
var startX,
startY;
if () {
('touchstart', function (e) {
();
startX = getCoord(e, 'X');
startY = getCoord(e, 'Y');
}).bind('touchend', function (e) {
// If movement is less than 20px, fire the click event handler
if ((getCoord(e, 'X') - startX) < 20 && (getCoord(e, 'Y') - startY) < 20) {
(this, e);
}
tap = true;
setTimeout(function () {
tap = false;
}, 300);
});
}
('click', function (e) {
if (!tap) {
// If handler was not called on touchend, call it on click;
(this, e);
}
});
};
/**
* Shows the scroller instance.
* @param {Boolean} prevAnim - Prevent animation if true
*/
= function (prevAnim) {
if ( || visible) {
return false;
}
if ( == 'top') {
anim = 'slidedown';
}
if ( == 'bottom') {
anim = 'slideup';
}
// Parse value from input
read();
event('onBeforeShow', [dw]);
// Create wheels
var l = 0,
i,
label,
mAnim = '';
if (anim && !prevAnim) {
mAnim = 'dw-' + anim + ' dw-in';
}
// Create wheels containers
var html = '<div class="dw-trans ' + + ' dw-' + + '">' + ( == 'inline' ? '<div class="dw dwbg dwi"><div class="dwwr">' : '<div class="dw-persp">' + '<div class="dwo"></div><div class="dw dwbg ' + mAnim + '"><div class="dw-arrw"><div class="dw-arrw-i"><div class="dw-arr"></div></div></div><div class="dwwr">' + ( ? '<div class="dwv"></div>' : ''));
for (i = 0; i < ; i++) {
html += '<div class="dwc' + ( != 'scroller' ? ' dwpm' : ' dwsc') + ( ? '' : ' dwhl') + '"><div class="dwwc dwrc"><table cellpadding="0" cellspacing="0"><tr>';
// Create wheels
for (label in [i]) {
warr[l] = [i][label];
html += '<td><div class="dwwl dwrc dwwl' + l + '">' + ( != 'scroller' ? '<div class="dwwb dwwbp" style="height:' + hi + 'px;line-height:' + hi + 'px;"><span>+</span></div><div class="dwwb dwwbm" style="height:' + hi + 'px;line-height:' + hi + 'px;"><span>–</span></div>' : '') + '<div class="dwl">' + label + '</div><div class="dww" style="height:' + ( * hi) + 'px;min-width:' + + 'px;"><div class="dw-ul">';
// Create wheel values
html += generateWheelItems(l);
html += '</div><div class="dwwo"></div></div><div class="dwwol"></div></div></td>';
l++;
}
html += '</tr></table></div></div>';
}
html += ( != 'inline' ? '<div class="dwbc' + (s.button3 ? ' dwbc-p' : '') + '"><span class="dwbw dwb-s"><span class="dwb">' + + '</span></span>' + (s.button3 ? '<span class="dwbw dwb-n"><span class="dwb">' + s.button3Text + '</span></span>' : '') + '<span class="dwbw dwb-c"><span class="dwb">' + + '</span></span></div></div>' : '<div class="dwcc"></div>') + '</div></div></div>';
dw = $(html);
scrollToPos();
event('onMarkupReady', [dw]);
// Show
if ( != 'inline') {
('body');
// Remove animation class
setTimeout(function () {
('dw-trans').find('.dw').removeClass(mAnim);
}, 350);
} else if (('div')) {
(dw);
} else {
(elm);
}
event('onMarkupInserted', [dw]);
visible = true;
// Theme init
(dw, that);
if ( != 'inline') {
// Init buttons
($('.dwb-s span', dw), function () {
if ((false, 'set') !== false) {
(false, true);
event('onSelect', []);
}
});
($('.dwb-c span', dw), function () {
();
});
if (s.button3) {
($('.dwb-n span', dw), s.button3);
}
// prevent scrolling if not specified otherwise
if () {
('touchmove', function (e) {
if (mh <= wh && mw <= ww) {
();
}
});
}
// Disable inputs to prevent bleed through (Android bug)
$('input,select,button').each(function () {
if (!$(this).prop('disabled')) {
$(this).addClass('dwtd').prop('disabled', true);
}
});
// Set position
position();
$(window).bind('', function () {
// Sometimes scrollTop is not correctly set, so we wait a little
clearTimeout(debounce);
debounce = setTimeout(function () {
position(true);
}, 100);
});
}
// Events
('.dwwl', 'DOMMouseScroll mousewheel', function (e) {
if (!isReadOnly(this)) {
();
e = ;
var delta = ? ( / 120) : ( ? (- / 3) : 0),
t = $('.dw-ul', this),
p = +('pos'),
val = (p - delta);
setGlobals(t);
calc(t, val, delta < 0 ? 1 : 2);
}
}).delegate('.dwb, .dwwb', START_EVENT, function (e) {
// Active button
$(this).addClass('dwb-a');
}).delegate('.dwwb', START_EVENT, function (e) {
();
();
var w = $(this).closest('.dwwl');
if (testTouch(e) && !isReadOnly(w) && !('dwa')) {
click = true;
// + Button
var t = ('.dw-ul'),
func = $(this).hasClass('dwwbp') ? plus : minus;
setGlobals(t);
clearInterval(timer);
timer = setInterval(function () { func(t); }, );
func(t);
}
}).delegate('.dwwl', START_EVENT, function (e) {
// Prevent scroll
();
// Scroll start
if (testTouch(e) && !move && !isReadOnly(this) && !click) {
move = true;
$(document).bind(MOVE_EVENT, onMove);
target = $('.dw-ul', this);
scrollable = != 'clickpick';
pos = +('pos');
setGlobals(target);
moved = iv[index] !== undefined; // Don't allow tap, if still moving
start = getCoord(e, 'Y');
startTime = new Date();
stop = start;
(target, index, pos, 0.001);
if (scrollable) {
('.dwwl').addClass('dwa');
}
}
});
event('onShow', [dw, v]);
};
/**
* Hides the scroller instance.
*/
= function (prevAnim, btn) {
// If onClose handler returns false, prevent hide
if (!visible || event('onClose', [v, btn]) === false) {
return false;
}
// Re-enable temporary disabled fields
$('.dwtd').prop('disabled', false).removeClass('dwtd');
();
// Hide wheels and overlay
if (dw) {
if ( != 'inline' && anim && !prevAnim) {
('dw-trans').find('.dw').addClass('dw-' + anim + ' dw-out');
setTimeout(function () {
();
dw = null;
}, 350);
} else {
();
dw = null;
}
visible = false;
pixels = {};
// Stop positioning on window resize
$(window).unbind('.dw');
}
};
/**
* Cancel and hide the scroller instance.
*/
= function () {
if ((false, 'cancel') !== false) {
event('onCancel', []);
}
};
/**
* Scroller initialization.
*/
= function (ss) {
// Get theme defaults
theme = extend({ defaults: {}, init: empty }, [ || ]);
// Get language defaults
lang = ms.i18n[ || ];
extend(settings, ss); // Update original user settings
extend(s, , lang, settings);
= s;
// Unbind all events (if re-init)
('.dw');
var preset = [];
if (preset) {
pres = (e, that);
extend(s, pres, settings); // Load preset settings
extend(methods, ); // Extend core methods
}
// Set private members
m = ( / 2);
hi = ;
anim = ;
if (('dwro') !== undefined) {
= bool(('dwro'));
}
if (visible) {
();
}
if ( == 'inline') {
();
} else {
read();
if (input && ) {
// Set element readonly, save original state
('dwro', );
= true;
// Init show datewheel
('', function () { (); });
}
}
};
= function (name, params) {
return event(name, params);
};
= null;
= null;
= null;
that._selectedValues = {}; // [];
(settings);
}
function testProps(props) {
var i;
for (i in props) {
if (mod[props[i]] !== undefined) {
return true;
}
}
return false;
}
function testPrefix() {
var prefixes = ['Webkit', 'Moz', 'O', 'ms'],
p;
for (p in prefixes) {
if (testProps([prefixes[p] + 'Transform'])) {
return '-' + prefixes[p].toLowerCase();
}
}
return '';
}
function getInst(e) {
return scrollers[];
}
function getCoord(e, c) {
var org = ,
ct = ;
return ct || (org && ) ? (org ? [0]['page' + c] : ct[0]['page' + c]) : e['page' + c];
}
function bool(v) {
return (v === true || v == 'true');
}
function constrain(val, min, max) {
val = val > max ? max : val;
val = val < min ? min : val;
return val;
}
function calc(t, val, dir, anim, orig) {
val = constrain(val, min, max);
var cell = $('.dw-li', t).eq(val),
o = orig === undefined ? val : orig,
idx = index,
time = anim ? (val == o ? 0.1 : ((val - o) * 0.1)) : 0;
// Set selected scroller value
[idx] = ('data-val');
(t, idx, val, time, orig);
setTimeout(function () {
// Validate
(idx, dir, time, orig);
}, 10);
}
function init(that, method, args) {
if (methods[method]) {
return methods[method].apply(that, (args, 1));
}
if (typeof method === 'object') {
return (that, method);
}
return that;
}
var scrollers = {},
timer,
empty = function () { },
h,
min,
max,
inst, // Current instance
date = new Date(),
uuid = (),
move,
click,
target,
index,
start,
stop,
startTime,
pos,
moved,
scrollable,
mod = ('modernizr').style,
has3d = testProps(['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']),
prefix = testPrefix(),
extend = $.extend,
tap,
touch,
START_EVENT = 'touchstart mousedown',
MOVE_EVENT = 'touchmove mousemove',
END_EVENT = 'touchend mouseup',
onMove = function (e) {
if (scrollable) {
();
stop = getCoord(e, 'Y');
(target, index, constrain(pos + (start - stop) / h, min - 1, max + 1));
}
moved = true;
},
defaults = {
// Options
width: 70,
height: 40,
rows: 3,
delay: 300,
disabled: false,
readonly: false,
showOnFocus: true,
showLabel: true,
wheels: [],
theme: '',
headerText: '{value}',
display: 'modal',
mode: 'scroller',
preset: '',
lang: 'en-US',
setText: 'Set',
cancelText: 'Cancel',
scrollLock: true,
tap: true,
formatResult: function (d) {
return (' ');
},
parseValue: function (value, inst) {
var w = ,
val = (' '),
ret = [],
j = 0,
i,
l,
v;
for (i = 0; i < ; i++) {
for (l in w[i]) {
if (w[i][l][val[j]] !== undefined) {
(val[j]);
} else {
for (v in w[i][l]) { // Select first value from wheel
(v);
break;
}
}
j++;
}
}
return ret;
}
},
methods = {
init: function (options) {
if (options === undefined) {
options = {};
}
return (function () {
if (!) {
uuid += 1;
= 'scoller' + uuid;
}
scrollers[] = new Scroller(this, options);
});
},
enable: function () {
return (function () {
var inst = getInst(this);
if (inst) {
();
}
});
},
disable: function () {
return (function () {
var inst = getInst(this);
if (inst) {
();
}
});
},
isDisabled: function () {
var inst = getInst(this[0]);
if (inst) {
return ;
}
},
isVisible: function () {
var inst = getInst(this[0]);
if (inst) {
return ();
}
},
option: function (option, value) {
return (function () {
var inst = getInst(this);
if (inst) {
var obj = {};
if (typeof option === 'object') {
obj = option;
} else {
obj[option] = value;
}
(obj);
}
});
},
setValue: function (d, fill, time, temp) {
return (function () {
var inst = getInst(this);
if (inst) {
= d;
(true, fill, time, temp);
}
});
},
getInst: function () {
return getInst(this[0]);
},
getValue: function () {
var inst = getInst(this[0]);
if (inst) {
return ;
}
},
getValues: function () {
var inst = getInst(this[0]);
if (inst) {
return ();
}
},
show: function () {
var inst = getInst(this[0]);
if (inst) {
return ();
}
},
hide: function () {
return (function () {
var inst = getInst(this);
if (inst) {
();
}
});
},
destroy: function () {
return (function () {
var inst = getInst(this);
if (inst) {
();
$(this).unbind('.dw');
delete scrollers[];
if ($(this).is('input')) {
= bool($(this).data('dwro'));
}
}
});
}
};
$(document).bind(END_EVENT, function (e) {
if (move) {
var time = new Date() - startTime,
val = constrain(pos + (start - stop) / h, min - 1, max + 1),
speed,
dist,
tindex,
ttop = ().top;
if (time < 300) {
speed = (stop - start) / time;
dist = (speed * speed) / (2 * 0.0006);
if (stop - start < 0) {
dist = -dist;
}
} else {
dist = stop - start;
}
tindex = (pos - dist / h);
if (!dist && !moved) { // this is a "tap"
var idx = ((stop - ttop) / h),
li = $('.dw-li', target).eq(idx),
hl = scrollable;
if (('onValueTap', [li]) !== false) {
tindex = idx;
} else {
hl = true;
}
if (hl) {
('dw-hl'); // Highlight
setTimeout(function () {
('dw-hl');
}, 200);
}
}
if (scrollable) {
calc(target, tindex, 0, true, (val));
}
move = false;
target = null;
$(document).unbind(MOVE_EVENT, onMove);
}
if (click) {
clearInterval(timer);
click = false;
}
$('.dwb-a').removeClass('dwb-a');
}).bind('mouseover mouseup mousedown click', function (e) { // Prevent standard behaviour on body click
if (tap) {
();
();
return false;
}
});
$. = function (method) {
extend(this, $.);
return init(this, method, arguments);
};
$.mobiscroll = $.mobiscroll || {
/**
* Set settings for all instances.
* @param {Object} o - New default settings.
*/
setDefaults: function (o) {
extend(defaults, o);
},
presetShort: function (name) {
[name] = function (method) {
return init(this, extend(method, { preset: name }), arguments);
};
},
shorts: {},
presets: {},
themes: {},
i18n: {}
};
$.scroller = $.scroller || $.mobiscroll;
$. = $. || $.;
})(jQuery);
(function ($) {
$.mobiscroll. = $.extend($.mobiscroll., {
setText: '确定',
cancelText: '取消'
});
})(jQuery);
/*jslint eqeq: true, plusplus: true, undef: true, sloppy: true, vars: true, forin: true */
(function ($) {
var ms = $.mobiscroll,
date = new Date(),
defaults = {
dateFormat: 'mm/dd/yy',
dateOrder: 'mmddy',
timeWheels: 'hhiiA',
timeFormat: 'hh:ii A',
startYear: () - 100,
endYear: () + 1,
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
shortYearCutoff: '+10',
monthText: 'Month',
dayText: 'Day',
yearText: 'Year',
hourText: 'Hours',
minuteText: 'Minutes',
secText: 'Seconds',
ampmText: ' ',
nowText: 'Now',
showNow: false,
stepHour: 1,
stepMinute: 1,
stepSecond: 1,
separator: ' '
},
preset = function (inst) {
var that = $(this),
html5def = {},
format;
// Force format for html5 date inputs (experimental)
if (('input')) {
switch (('type')) {
case 'date':
format = 'yy-mm-dd';
break;
case 'datetime':
format = 'yy-mm-ddTHH:ii:ssZ';
break;
case 'datetime-local':
format = 'yy-mm-ddTHH:ii:ss';
break;
case 'month':
format = 'yy-mm';
= 'mmyy';
break;
case 'time':
format = 'HH:ii:ss';
break;
}
// Check for min/max attributes
var min = ('min'),
max = ('max');
if (min) {
= (format, min);
}
if (max) {
= (format, max);
}
}
// Set year-month-day order
var s = $.extend({}, defaults, html5def, ),
offset = 0,
wheels = [],
ord = [],
o = {},
i,
k,
f = { y: 'getFullYear', m: 'getMonth', d: 'getDate', h: getHour, i: getMinute, s: getSecond, a: getAmPm },
p = ,
dord = ,
tord = ,
regen = (/D/),
ampm = (/a/i),
hampm = (/h/),
hformat = p == 'datetime' ? + + : p == 'time' ? : ,
defd = new Date(),
stepH = ,
stepM = ,
stepS = ,
mind = || new Date(, 0, 1),
maxd = || new Date(, 11, 31, 23, 59, 59);
= s;
format = format || hformat;
if ((/date/i)) {
// Determine the order of year, month, day wheels
$.each(['y', 'm', 'd'], function (j, v) {
i = (new RegExp(v, 'i'));
if (i > -1) {
({ o: i, v: v });
}
});
(function (a, b) { return > ? 1 : -1; });
$.each(ord, function (i, v) {
o[] = i;
});
var w = {};
for (k = 0; k < 3; k++) {
if (k == ) {
offset++;
w[] = {};
var start = (),
end = ();
for (i = start; i <= end; i++) {
w[][i] = (/yy/i) ? i : (i + '').substr(2, 2);
}
} else if (k == ) {
offset++;
w[] = {};
for (i = 0; i < 12; i++) {
var str = (/[dy]/gi, '').replace(/mm/, i < 9 ? '0' + (i + 1) : i + 1).replace(/m/, (i + 1));
w[][i] = (/MM/) ? (/MM/, '<span class="dw-mon">' + [i] + '</span>') : (/M/, '<span class="dw-mon">' + [i] + '</span>');
}
} else if (k == ) {
offset++;
w[] = {};
for (i = 1; i < 32; i++) {
w[][i] = (/dd/i) && i < 10 ? '0' + i : i;
}
}
}
(w);
}
if ((/time/i)) {
// Determine the order of hours, minutes, seconds wheels
ord = [];
$.each(['h', 'i', 's', 'a'], function (i, v) {
i = (new RegExp(v, 'i'));
if (i > -1) {
({ o: i, v: v });
}
});
(function (a, b) {
return > ? 1 : -1;
});
$.each(ord, function (i, v) {
o[] = offset + i;
});
w = {};
for (k = offset; k < offset + 4; k++) {
if (k == ) {
offset++;
w[] = {};
for (i = 0; i < (hampm ? 12 : 24); i += stepH) {
w[][i] = hampm && i == 0 ? 12 : (/hh/i) && i < 10 ? '0' + i : i;
}
} else if (k == ) {
offset++;
w[] = {};
for (i = 0; i < 60; i += stepM) {
w[][i] = (/ii/) && i < 10 ? '0' + i : i;
}
} else if (k == ) {
offset++;
w[] = {};
for (i = 0; i < 60; i += stepS) {
w[][i] = (/ss/) && i < 10 ? '0' + i : i;
}
} else if (k == ) {
offset++;
var upper = (/A/);
w[] = { 0: upper ? 'AM' : 'am', 1: upper ? 'PM' : 'pm' };
}
}
(w);
}
function get(d, i, def) {
if (o[i] !== undefined) {
return +d[o[i]];
}
if (def !== undefined) {
return def;
}
return defd[f[i]] ? defd[f[i]]() : f[i](defd);
}
function step(v, st) {
return (v / st) * st;
}
function getHour(d) {
var hour = ();
hour = hampm && hour >= 12 ? hour - 12 : hour;
return step(hour, stepH);
}
function getMinute(d) {
return step((), stepM);
}
function getSecond(d) {
return step((), stepS);
}
function getAmPm(d) {
return ampm && () > 11 ? 1 : 0;
}
function getDate(d) {
var hour = get(d, 'h', 0);
return new Date(get(d, 'y'), get(d, 'm'), get(d, 'd', 1), get(d, 'a') ? hour + 12 : hour, get(d, 'i', 0), get(d, 's', 0));
}
= function (d, fill, time, temp) {
var i;
// Set wheels
for (i in o) {
[o[i]] = d[f[i]] ? d[f[i]]() : f[i](d);
}
(true, fill, time, temp);
};
= function (d) {
return getDate(d);
};
return {
button3Text: ? : undefined,
button3: ? function () { (new Date(), false, 0.3, true); } : undefined,
wheels: wheels,
headerText: function (v) {
return (hformat, getDate(), s);
},
/**
* Builds a date object from the wheel selections and formats it to the given date/time format
* @param {Array} d - An array containing the selected wheel values
* @return {String} - The formatted date string
*/
formatResult: function (d) {
return (format, getDate(d), s);
},
/**
* Builds a date object from the input value and returns an array to set wheel values
* @return {Array} - An array containing the wheel values to set
*/
parseValue: function (val) {
var d = new Date(),
i,
result = [];
try {
d = (format, val, s);
} catch (e) {
}
// Set wheels
for (i in o) {
result[o[i]] = d[f[i]] ? d[f[i]]() : f[i](d);
}
return result;
},
/**
* Validates the selected date to be in the minDate / maxDate range and sets unselectable values to disabled
* @param {Object} dw - jQuery object containing the generated html
* @param {Integer} [i] - Index of the changed wheel, not set for initial validation
*/
validate: function (dw, i) {
var temp = , //.slice(0),
mins = { y: (), m: 0, d: 1, h: 0, i: 0, s: 0, a: 0 },
maxs = { y: (), m: 11, d: 31, h: step(hampm ? 11 : 23, stepH), i: step(59, stepM), s: step(59, stepS), a: 1 },
minprop = true,
maxprop = true;
$.each(['y', 'm', 'd', 'a', 'h', 'i', 's'], function (x, i) {
if (o[i] !== undefined) {
var min = mins[i],
max = maxs[i],
maxdays = 31,
val = get(temp, i),
t = $('.dw-ul', dw).eq(o[i]),
y,
m;
if (i == 'd') {
y = get(temp, 'y');
m = get(temp, 'm');
maxdays = 32 - new Date(y, m, 32).getDate();
max = maxdays;
if (regen) {
$('.dw-li', t).each(function () {
var that = $(this),
d = ('val'),
w = new Date(y, m, d).getDay(),
str = (/[my]/gi, '').replace(/dd/, d < 10 ? '0' + d : d).replace(/d/, d);
$('.dw-i', that).html((/DD/) ? (/DD/, '<span class="dw-day">' + [w] + '</span>') : (/D/, '<span class="dw-day">' + [w] + '</span>'));
});
}
}
if (minprop && mind) {
min = mind[f[i]] ? mind[f[i]]() : f[i](mind);
}
if (maxprop && maxd) {
max = maxd[f[i]] ? maxd[f[i]]() : f[i](maxd);
}
if (i != 'y') {
var i1 = $('.dw-li', t).index($('.dw-li[data-val="' + min + '"]', t)),
i2 = $('.dw-li', t).index($('.dw-li[data-val="' + max + '"]', t));
$('.dw-li', t).removeClass('dw-v').slice(i1, i2 + 1).addClass('dw-v');
if (i == 'd') { // Hide days not in month
$('.dw-li', t).removeClass('dw-h').slice(maxdays).addClass('dw-h');
}
}
if (val < min) {
val = min;
}
if (val > max) {
val = max;
}
if (minprop) {
minprop = val == min;
}
if (maxprop) {
maxprop = val == max;
}
// Disable some days
if ( && i == 'd') {
var idx = [];
// Disable exact dates
if () {
$.each(, function (i, v) {
if (() == y && () == m) {
(() - 1);
}
});
}
// Disable days of week
if () {
var first = new Date(y, m, 1).getDay(),
j;
$.each(, function (i, v) {
for (j = v - first; j < maxdays; j += 7) {
if (j >= 0) {
(j);
}
}
});
}
// Disable days of month
if () {
$.each(, function (i, v) {
v = (v + '').split('/');
if (v[1]) {
if (v[0] - 1 == m) {
(v[1] - 1);
}
} else {
(v[0] - 1);
}
});
}
$.each(idx, function (i, v) {
$('.dw-li', t).eq(v).removeClass('dw-v');
});
}
// Set modified value
temp[o[i]] = val;
}
});
},
methods: {
/**
* Returns the currently selected date.
* @param {Boolean} temp - If true, return the currently shown date on the picker, otherwise the last selected one
* @return {Date}
*/
getDate: function (temp) {
var inst = $(this).mobiscroll('getInst');
if (inst) {
return (temp ? : );
}
},
/**
* Sets the selected date
* @param {Date} d - Date to select.
* @param {Boolean} [fill] - Also set the value of the associated input element. Default is true.
* @return {Object} - jQuery object to maintain chainability
*/
setDate: function (d, fill, time, temp) {
if (fill == undefined) {
fill = false;
}
return (function () {
var inst = $(this).mobiscroll('getInst');
if (inst) {
(d, fill, time, temp);
}
});
}
}
};
};
$.each(['date', 'time', 'datetime'], function (i, v) {
[v] = preset;
(v);
});
/**
* Format a date into a string value with a specified format.
* @param {String} format - Output format.
* @param {Date} date - Date to format.
* @param {Object} settings - Settings.
* @return {String} - Returns the formatted date string.
*/
= function (format, date, settings) {
if (!date) {
return null;
}
var s = $.extend({}, defaults, settings),
look = function (m) { // Check whether a format character is doubled
var n = 0;
while (i + 1 < && (i + 1) == m) {
n++;
i++;
}
return n;
},
f1 = function (m, val, len) { // Format a number, with leading zero if necessary
var n = '' + val;
if (look(m)) {
while ( < len) {
n = '0' + n;
}
}
return n;
},
f2 = function (m, val, s, l) { // Format a name, short or long as requested
return (look(m) ? l[val] : s[val]);
},
i,
output = '',
literal = false;
for (i = 0; i < ; i++) {
if (literal) {
if ((i) == "'" && !look("'")) {
literal = false;
} else {
output += (i);
}
} else {
switch ((i)) {
case 'd':
output += f1('d', (), 2);
break;
case 'D':
output += f2('D', (), , );
break;
case 'o':
output += f1('o', (() - new Date((), 0, 0).getTime()) / 86400000, 3);
break;
case 'm':
output += f1('m', () + 1, 2);
break;
case 'M':
output += f2('M', (), , );
break;
case 'y':
output += (look('y') ? () : (() % 100 < 10 ? '0' : '') + () % 100);
break;
case 'h':
var h = ();
output += f1('h', (h > 12 ? (h - 12) : (h == 0 ? 12 : h)), 2);
break;
case 'H':
output += f1('H', (), 2);
break;
case 'i':
output += f1('i', (), 2);
break;
case 's':
output += f1('s', (), 2);
break;
case 'a':
output += () > 11 ? 'pm' : 'am';
break;
case 'A':
output += () > 11 ? 'PM' : 'AM';
break;
case "'":
if (look("'")) {
output += "'";
} else {
literal = true;
}
break;
default:
output += (i);
}
}
}
return output;
};
/**
* Extract a date from a string value with a specified format.
* @param {String} format - Input format.
* @param {String} value - String to parse.
* @param {Object} settings - Settings.
* @return {Date} - Returns the extracted date.
*/
= function (format, value, settings) {
var def = new Date();
if (!format || !value) {
return def;
}
value = (typeof value == 'object' ? () : value + '');
var s = $.extend({}, defaults, settings),
shortYearCutoff = ,
year = (),
month = () + 1,
day = (),
doy = -1,
hours = (),
minutes = (),
seconds = 0, //(),
ampm = -1,
literal = false, // Check whether a format character is doubled
lookAhead = function (match) {
var matches = (iFormat + 1 < && (iFormat + 1) == match);
if (matches) {
iFormat++;
}
return matches;
},
getNumber = function (match) { // Extract a number from the string value
lookAhead(match);
var size = (match == '@' ? 14 : (match == '!' ? 20 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2)))),
digits = new RegExp('^\\d{1,' + size + '}'),
num = (iValue).match(digits);
if (!num) {
return 0;
}
//throw 'Missing number at position ' + iValue;
iValue += num[0].length;
return parseInt(num[0], 10);
},
getName = function (match, s, l) { // Extract a name from the string value and convert to an index
var names = (lookAhead(match) ? l : s),
i;
for (i = 0; i < ; i++) {
if ((iValue, names[i].length).toLowerCase() == names[i].toLowerCase()) {
iValue += names[i].length;
return i + 1;
}
}
return 0;
//throw 'Unknown name at position ' + iValue;
},
checkLiteral = function () {
//if ((iValue) != (iFormat))
//throw 'Unexpected literal at position ' + iValue;
iValue++;
},
iValue = 0,
iFormat;
for (iFormat = 0; iFormat < ; iFormat++) {
if (literal) {
if ((iFormat) == "'" && !lookAhead("'")) {
literal = false;
} else {
checkLiteral();
}
} else {
switch ((iFormat)) {
case 'd':
day = getNumber('d');
break;
case 'D':
getName('D', , );
break;
case 'o':
doy = getNumber('o');
break;
case 'm':
month = getNumber('m');
break;
case 'M':
month = getName('M', , );
break;
case 'y':
year = getNumber('y');
break;
case 'H':
hours = getNumber('H');
break;
case 'h':
hours = getNumber('h');
break;
case 'i':
minutes = getNumber('i');
break;
case 's':
seconds = getNumber('s');
break;
case 'a':
ampm = getName('a', ['am', 'pm'], ['am', 'pm']) - 1;
break;
case 'A':
ampm = getName('A', ['am', 'pm'], ['am', 'pm']) - 1;
break;
case "'":
if (lookAhead("'")) {
checkLiteral();
} else {
literal = true;
}
break;
default:
checkLiteral();
}
}
}
if (year < 100) {
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
(year <= (typeof shortYearCutoff != 'string' ? shortYearCutoff : new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)) ? 0 : -100);
}
if (doy > -1) {
month = 1;
day = doy;
do {
var dim = 32 - new Date(year, month - 1, 32).getDate();
if (day <= dim) {
break;
}
month++;
day -= dim;
} while (true);
}
hours = (ampm == -1) ? hours : ((ampm && hours < 12) ? (hours + 12) : (!ampm && hours == 12 ? 0 : hours));
var date = new Date(year, month - 1, day, hours, minutes, seconds);
if (() != year || () + 1 != month || () != day) {
throw 'Invalid date';
}
return date;
};
})(jQuery);
(function ($) {
$.mobiscroll. = $.extend($.mobiscroll., {
dateFormat: 'yyyy-mm-dd',
dateOrder: 'yymmdd',
dayNames: ['周日', '周一;', '周二;', '周三', '周四', '周五', '周六'],
dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
dayText: '日',
hourText: '时',
minuteText: '分',
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
monthText: '月',
secText: '秒',
timeFormat: 'HH:ii',
timeWheels: 'HHii',
yearText: '年'
});
})(jQuery);
(function ($) {
var theme = {
defaults: {
dateOrder: 'Mddyy',
mode: 'mixed',
rows: 5,
width: 70,
height: 20,
showLabel: true,
useShortLabels: true
}
}
$.['android-ics'] = theme;
$.['android-ics light'] = theme;
})(jQuery);