Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
thewickedkarma
GitHub Repository: thewickedkarma/blackeye-im
Path: blob/master/sites/bitcoin/js/ui-plugins.js
777 views
1
/*!
2
* FitVids 1.0
3
* Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
4
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
5
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
6
*/
7
(function(a) {
8
a.fn.fitVids = function(b) {
9
var c = {
10
customSelector: null
11
};
12
var e = document.createElement("div"),
13
d = document.getElementsByTagName("base")[0] || document.getElementsByTagName("script")[0];
14
e.className = "fit-vids-style";
15
e.innerHTML = "&shy;<style> .fluid-width-video-wrapper { width: 100%; position: relative; padding: 0; } .fluid-width-video-wrapper iframe, .fluid-width-video-wrapper object, .fluid-width-video-wrapper embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style>";
16
d.parentNode.insertBefore(e, d);
17
if (b) {
18
a.extend(c, b)
19
}
20
return this.each(function() {
21
var f = ["iframe[src*='player.vimeo.com']", "iframe[src*='youtube.com']", "iframe[src*='youtube-nocookie.com']", "iframe[src*='kickstarter.com']", "object", "embed"];
22
if (c.customSelector) {
23
f.push(c.customSelector)
24
}
25
var g = a(this).find(f.join(","));
26
g.each(function() {
27
var l = a(this);
28
if (this.tagName.toLowerCase() === "embed" && l.parent("object").length || l.parent(".fluid-width-video-wrapper").length) {
29
return
30
}
31
var h = (this.tagName.toLowerCase() === "object" || (l.attr("height") && !isNaN(parseInt(l.attr("height"), 10)))) ? parseInt(l.attr("height"), 10) : l.height(),
32
i = !isNaN(parseInt(l.attr("width"), 10)) ? parseInt(l.attr("width"), 10) : l.width(),
33
j = h / i;
34
if (!l.attr("id")) {
35
var k = "fitvid" + Math.floor(Math.random() * 999999);
36
l.attr("id", k)
37
}
38
l.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top", (j * 100) + "%");
39
l.removeAttr("height").removeAttr("width")
40
})
41
})
42
}
43
})(jQuery);
44
/*
45
* jQuery Superfish Menu Plugin - v1.7.4
46
* Copyright (c) 2013 Joel Birch
47
*
48
* Dual licensed under the MIT and GPL licenses:
49
* http://www.opensource.org/licenses/mit-license.php
50
* http://www.gnu.org/licenses/gpl.html
51
*/
52
53
;
54
(function(e) {
55
"use strict";
56
var s = function() {
57
var s = {
58
bcClass: "sf-breadcrumb",
59
menuClass: "sf-js-enabled",
60
anchorClass: "sf-with-ul",
61
menuArrowClass: "sf-arrows"
62
},
63
o = function() {
64
var s = /iPhone|iPad|iPod/i.test(navigator.userAgent);
65
return s && e(window).load(function() {
66
e("body").children().on("click", e.noop)
67
}), s
68
}(),
69
n = function() {
70
var e = document.documentElement.style;
71
return "behavior" in e && "fill" in e && /iemobile/i.test(navigator.userAgent)
72
}(),
73
t = function(e, o) {
74
var n = s.menuClass;
75
o.cssArrows && (n += " " + s.menuArrowClass), e.toggleClass(n)
76
},
77
i = function(o, n) {
78
return o.find("li." + n.pathClass).slice(0, n.pathLevels).addClass(n.hoverClass + " " + s.bcClass).filter(function() {
79
return e(this).children(n.popUpSelector).hide().show().length
80
}).removeClass(n.pathClass)
81
},
82
r = function(e) {
83
e.children("a").toggleClass(s.anchorClass)
84
},
85
a = function(e) {
86
var s = e.css("ms-touch-action");
87
s = "pan-y" === s ? "auto" : "pan-y", e.css("ms-touch-action", s)
88
},
89
l = function(s, t) {
90
var i = "li:has(" + t.popUpSelector + ")";
91
e.fn.hoverIntent && !t.disableHI ? s.hoverIntent(u, p, i) : s.on("mouseenter.superfish", i, u).on("mouseleave.superfish", i, p);
92
var r = "MSPointerDown.superfish";
93
o || (r += " touchend.superfish"), n && (r += " mousedown.superfish"), s.on("focusin.superfish", "li", u).on("focusout.superfish", "li", p).on(r, "a", t, h)
94
},
95
h = function(s) {
96
var o = e(this),
97
n = o.siblings(s.data.popUpSelector);
98
n.length > 0 && n.is(":hidden") && (o.one("click.superfish", !1), "MSPointerDown" === s.type ? o.trigger("focus") : e.proxy(u, o.parent("li"))())
99
},
100
u = function() {
101
var s = e(this),
102
o = d(s);
103
clearTimeout(o.sfTimer), s.siblings().superfish("hide").end().superfish("show")
104
},
105
p = function() {
106
var s = e(this),
107
n = d(s);
108
o ? e.proxy(f, s, n)() : (clearTimeout(n.sfTimer), n.sfTimer = setTimeout(e.proxy(f, s, n), n.delay))
109
},
110
f = function(s) {
111
s.retainPath = e.inArray(this[0], s.$path) > -1, this.superfish("hide"), this.parents("." + s.hoverClass).length || (s.onIdle.call(c(this)), s.$path.length && e.proxy(u, s.$path)())
112
},
113
c = function(e) {
114
return e.closest("." + s.menuClass)
115
},
116
d = function(e) {
117
return c(e).data("sf-options")
118
};
119
return {
120
hide: function(s) {
121
if (this.length) {
122
var o = this,
123
n = d(o);
124
if (!n) return this;
125
var t = n.retainPath === !0 ? n.$path : "",
126
i = o.find("li." + n.hoverClass).add(this).not(t).removeClass(n.hoverClass).children(n.popUpSelector),
127
r = n.speedOut;
128
s && (i.show(), r = 0), n.retainPath = !1, n.onBeforeHide.call(i), i.stop(!0, !0).animate(n.animationOut, r, function() {
129
var s = e(this);
130
n.onHide.call(s)
131
})
132
}
133
return this
134
},
135
show: function() {
136
var e = d(this);
137
if (!e) return this;
138
var s = this.addClass(e.hoverClass),
139
o = s.children(e.popUpSelector);
140
return e.onBeforeShow.call(o), o.stop(!0, !0).animate(e.animation, e.speed, function() {
141
e.onShow.call(o)
142
}), this
143
},
144
destroy: function() {
145
return this.each(function() {
146
var o, n = e(this),
147
i = n.data("sf-options");
148
return i ? (o = n.find(i.popUpSelector).parent("li"), clearTimeout(i.sfTimer), t(n, i), r(o), a(n), n.off(".superfish").off(".hoverIntent"), o.children(i.popUpSelector).attr("style", function(e, s) {
149
return s.replace(/display[^;]+;?/g, "")
150
}), i.$path.removeClass(i.hoverClass + " " + s.bcClass).addClass(i.pathClass), n.find("." + i.hoverClass).removeClass(i.hoverClass), i.onDestroy.call(n), n.removeData("sf-options"), void 0) : !1
151
})
152
},
153
init: function(o) {
154
return this.each(function() {
155
var n = e(this);
156
if (n.data("sf-options")) return !1;
157
var h = e.extend({}, e.fn.superfish.defaults, o),
158
u = n.find(h.popUpSelector).parent("li");
159
h.$path = i(n, h), n.data("sf-options", h), t(n, h), r(u), a(n), l(n, h), u.not("." + s.bcClass).superfish("hide", !0), h.onInit.call(this)
160
})
161
}
162
}
163
}();
164
e.fn.superfish = function(o) {
165
return s[o] ? s[o].apply(this, Array.prototype.slice.call(arguments, 1)) : "object" != typeof o && o ? e.error("Method " + o + " does not exist on jQuery.fn.superfish") : s.init.apply(this, arguments)
166
}, e.fn.superfish.defaults = {
167
popUpSelector: "ul,.sf-mega",
168
hoverClass: "sfHover",
169
pathClass: "overrideThisToUse",
170
pathLevels: 1,
171
delay: 800,
172
animation: {
173
opacity: "show"
174
},
175
animationOut: {
176
opacity: "hide"
177
},
178
speed: "normal",
179
speedOut: "fast",
180
cssArrows: !0,
181
disableHI: !1,
182
onInit: e.noop,
183
onBeforeShow: e.noop,
184
onShow: e.noop,
185
onBeforeHide: e.noop,
186
onHide: e.noop,
187
onIdle: e.noop,
188
onDestroy: e.noop
189
}, e.fn.extend({
190
hideSuperfishUl: s.hide,
191
showSuperfishUl: s.show
192
})
193
})(jQuery);
194
195
/**
196
* jQuery ScrollTo
197
* Copyright (c) 2007-2012 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
198
* Dual licensed under MIT and GPL.
199
* @author Ariel Flesler
200
* @version 1.4.3
201
*/
202
203
;
204
(function($) {
205
var h = $.scrollTo = function(a, b, c) {
206
$(window).scrollTo(a, b, c)
207
};
208
h.defaults = {
209
axis: 'xy',
210
duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1,
211
limit: true
212
};
213
h.window = function(a) {
214
return $(window)._scrollable()
215
};
216
$.fn._scrollable = function() {
217
return this.map(function() {
218
var a = this,
219
isWin = !a.nodeName || $.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1;
220
if (!isWin) return a;
221
var b = (a.contentWindow || a).document || a.ownerDocument || a;
222
return /webkit/i.test(navigator.userAgent) || b.compatMode == 'BackCompat' ? b.body : b.documentElement
223
})
224
};
225
$.fn.scrollTo = function(e, f, g) {
226
if (typeof f == 'object') {
227
g = f;
228
f = 0
229
}
230
if (typeof g == 'function') g = {
231
onAfter: g
232
};
233
if (e == 'max') e = 9e9;
234
g = $.extend({}, h.defaults, g);
235
f = f || g.duration;
236
g.queue = g.queue && g.axis.length > 1;
237
if (g.queue) f /= 2;
238
g.offset = both(g.offset);
239
g.over = both(g.over);
240
return this._scrollable().each(function() {
241
if (!e) return;
242
var d = this,
243
$elem = $(d),
244
targ = e,
245
toff, attr = {},
246
win = $elem.is('html,body');
247
switch (typeof targ) {
248
case 'number':
249
case 'string':
250
if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
251
targ = both(targ);
252
break
253
}
254
targ = $(targ, this);
255
if (!targ.length) return;
256
case 'object':
257
if (targ.is || targ.style) toff = (targ = $(targ)).offset()
258
}
259
$.each(g.axis.split(''), function(i, a) {
260
var b = a == 'x' ? 'Left' : 'Top',
261
pos = b.toLowerCase(),
262
key = 'scroll' + b,
263
old = d[key],
264
max = h.max(d, a);
265
if (toff) {
266
attr[key] = toff[pos] + (win ? 0 : old - $elem.offset()[pos]);
267
if (g.margin) {
268
attr[key] -= parseInt(targ.css('margin' + b)) || 0;
269
attr[key] -= parseInt(targ.css('border' + b + 'Width')) || 0
270
}
271
attr[key] += g.offset[pos] || 0;
272
if (g.over[pos]) attr[key] += targ[a == 'x' ? 'width' : 'height']() * g.over[pos]
273
} else {
274
var c = targ[pos];
275
attr[key] = c.slice && c.slice(-1) == '%' ? parseFloat(c) / 100 * max : c
276
}
277
if (g.limit && /^\d+$/.test(attr[key])) attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
278
if (!i && g.queue) {
279
if (old != attr[key]) animate(g.onAfterFirst);
280
delete attr[key]
281
}
282
});
283
animate(g.onAfter);
284
285
function animate(a) {
286
$elem.animate(attr, f, g.easing, a && function() {
287
a.call(this, e, g)
288
})
289
}
290
}).end()
291
};
292
h.max = function(a, b) {
293
var c = b == 'x' ? 'Width' : 'Height',
294
scroll = 'scroll' + c;
295
if (!$(a).is('html,body')) return a[scroll] - $(a)[c.toLowerCase()]();
296
var d = 'client' + c,
297
html = a.ownerDocument.documentElement,
298
body = a.ownerDocument.body;
299
return Math.max(html[scroll], body[scroll]) - Math.min(html[d], body[d])
300
};
301
302
function both(a) {
303
return typeof a == 'object' ? a : {
304
top: a,
305
left: a
306
}
307
}
308
})(jQuery);
309
/*
310
Plugin Name: Count To
311
Written by: Matt Huggins - https://github.com/mhuggins/jquery-countTo
312
313
*/
314
(function($) {
315
$.fn.countTo = function(options) {
316
options = options || {};
317
318
return $(this).each(function() {
319
// set options for current element
320
var settings = $.extend({}, $.fn.countTo.defaults, {
321
from: $(this).data('from'),
322
to: $(this).data('to'),
323
speed: $(this).data('speed'),
324
refreshInterval: $(this).data('refresh-interval'),
325
decimals: $(this).data('decimals')
326
}, options);
327
328
// how many times to update the value, and how much to increment the value on each update
329
var loops = Math.ceil(settings.speed / settings.refreshInterval),
330
increment = (settings.to - settings.from) / loops;
331
332
// references & variables that will change with each update
333
var self = this,
334
$self = $(this),
335
loopCount = 0,
336
value = settings.from,
337
data = $self.data('countTo') || {};
338
339
$self.data('countTo', data);
340
341
// if an existing interval can be found, clear it first
342
if (data.interval) {
343
clearInterval(data.interval);
344
}
345
data.interval = setInterval(updateTimer, settings.refreshInterval);
346
347
// initialize the element with the starting value
348
render(value);
349
350
function updateTimer() {
351
value += increment;
352
loopCount++;
353
354
render(value);
355
356
if (typeof(settings.onUpdate) == 'function') {
357
settings.onUpdate.call(self, value);
358
}
359
360
if (loopCount >= loops) {
361
// remove the interval
362
$self.removeData('countTo');
363
clearInterval(data.interval);
364
value = settings.to;
365
366
if (typeof(settings.onComplete) == 'function') {
367
settings.onComplete.call(self, value);
368
}
369
}
370
}
371
372
function render(value) {
373
var formattedValue = settings.formatter.call(self, value, settings);
374
$self.html(formattedValue);
375
}
376
});
377
};
378
379
$.fn.countTo.defaults = {
380
from: 0, // the number the element should start at
381
to: 0, // the number the element should end at
382
speed: 1000, // how long it should take to count between the target numbers
383
refreshInterval: 100, // how often the element should be updated
384
decimals: 0, // the number of decimal places to show
385
formatter: formatter, // handler for formatting the value before rendering
386
onUpdate: null, // callback method for every time the element is updated
387
onComplete: null // callback method for when the element finishes updating
388
};
389
390
function formatter(value, settings) {
391
return value.toFixed(settings.decimals);
392
}
393
}(jQuery));
394
395
/*!
396
* Bootstrap-select v1.6.0 (http://silviomoreto.github.io/bootstrap-select/)
397
*
398
* Copyright 2013-2014 bootstrap-select
399
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
400
*/
401
! function(a) {
402
"use strict";
403
a.expr[":"].icontains = function(b, c, d) {
404
return a(b).text().toUpperCase().indexOf(d[3].toUpperCase()) >= 0
405
};
406
var b = function(c, d, e) {
407
e && (e.stopPropagation(), e.preventDefault()), this.$element = a(c), this.$newElement = null, this.$button = null, this.$menu = null, this.$lis = null, this.options = d, null === this.options.title && (this.options.title = this.$element.attr("title")), this.val = b.prototype.val, this.render = b.prototype.render, this.refresh = b.prototype.refresh, this.setStyle = b.prototype.setStyle, this.selectAll = b.prototype.selectAll, this.deselectAll = b.prototype.deselectAll, this.destroy = b.prototype.destroy, this.remove = b.prototype.destroy, this.show = b.prototype.show, this.hide = b.prototype.hide, this.init()
408
};
409
b.VERSION = "1.6.0", b.DEFAULTS = {
410
style: "btn-default",
411
size: "auto",
412
title: null,
413
selectedTextFormat: "values",
414
noneSelectedText: "Nothing selected",
415
noneResultsText: "No results match",
416
countSelectedText: "{0} of {1} selected",
417
maxOptionsText: ["Limit reached ({n} {var} max)", "Group limit reached ({n} {var} max)", ["items", "item"]],
418
width: !1,
419
container: !1,
420
hideDisabled: !1,
421
showSubtext: !1,
422
showIcon: !0,
423
showContent: !0,
424
dropupAuto: !0,
425
header: !1,
426
liveSearch: !1,
427
actionsBox: !1,
428
multipleSeparator: ", ",
429
iconBase: "glyphicon",
430
tickIcon: "glyphicon-ok",
431
maxOptions: !1,
432
mobile: !1
433
}, b.prototype = {
434
constructor: b,
435
init: function() {
436
var b = this,
437
c = this.$element.attr("id");
438
this.$element.hide(), this.multiple = this.$element.prop("multiple"), this.autofocus = this.$element.prop("autofocus"), this.$newElement = this.createView(), this.$element.after(this.$newElement), this.$menu = this.$newElement.find("> .dropdown-menu"), this.$button = this.$newElement.find("> button"), this.$searchbox = this.$newElement.find("input"), void 0 !== c && (this.$button.attr("data-id", c), a('label[for="' + c + '"]').click(function(a) {
439
a.preventDefault(), b.$button.focus()
440
})), this.checkDisabled(), this.clickListener(), this.options.liveSearch && this.liveSearchListener(), this.render(), this.liHeight(), this.setStyle(), this.setWidth(), this.options.container && this.selectPosition(), this.$menu.data("this", this), this.$newElement.data("this", this), this.options.mobile && this.mobile()
441
},
442
createDropdown: function() {
443
var b = this.multiple ? " show-tick" : "",
444
c = this.$element.parent().hasClass("input-group") ? " input-group-btn" : "",
445
d = this.autofocus ? " autofocus" : "",
446
e = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;</button>' + this.options.header + "</div>" : "",
447
f = this.options.liveSearch ? '<div class="bootstrap-select-searchbox"><input type="text" class="input-block-level form-control" autocomplete="off" /></div>' : "",
448
g = this.options.actionsBox ? '<div class="bs-actionsbox"><div class="btn-group btn-block"><button class="actions-btn bs-select-all btn btn-sm btn-default">Select All</button><button class="actions-btn bs-deselect-all btn btn-sm btn-default">Deselect All</button></div></div>' : "",
449
h = '<div class="btn-group bootstrap-select' + b + c + '"><button type="button" class="btn dropdown-toggle selectpicker" data-toggle="dropdown"' + d + '><span class="filter-option pull-left"></span>&nbsp;<span class="caret"></span></button><div class="dropdown-menu open">' + e + f + g + '<ul class="dropdown-menu inner selectpicker" role="menu"></ul></div></div>';
450
return a(h)
451
},
452
createView: function() {
453
var a = this.createDropdown(),
454
b = this.createLi();
455
return a.find("ul").append(b), a
456
},
457
reloadLi: function() {
458
this.destroyLi();
459
var a = this.createLi();
460
this.$menu.find("ul").append(a)
461
},
462
destroyLi: function() {
463
this.$menu.find("li").remove()
464
},
465
createLi: function() {
466
var b = this,
467
c = [],
468
d = "",
469
e = 0;
470
return this.$element.find("option").each(function() {
471
var d = a(this),
472
f = d.attr("class") || "",
473
g = d.attr("style") || "",
474
h = d.data("content") ? d.data("content") : d.html(),
475
i = void 0 !== d.data("subtext") ? '<small class="muted text-muted">' + d.data("subtext") + "</small>" : "",
476
j = void 0 !== d.data("icon") ? '<i class="' + b.options.iconBase + " " + d.data("icon") + '"></i> ' : "";
477
if ("" !== j && (d.is(":disabled") || d.parent().is(":disabled")) && (j = "<span>" + j + "</span>"), d.data("content") || (h = j + '<span class="text">' + h + i + "</span>"), b.options.hideDisabled && (d.is(":disabled") || d.parent().is(":disabled"))) c.push('<a style="min-height: 0; padding: 0"></a>');
478
else if (d.parent().is("optgroup") && d.data("divider") !== !0)
479
if (0 === d.index()) {
480
var k = d.parent().attr("label"),
481
l = void 0 !== d.parent().data("subtext") ? '<small class="muted text-muted">' + d.parent().data("subtext") + "</small>" : "",
482
m = d.parent().data("icon") ? '<i class="' + b.options.iconBase + " " + d.parent().data("icon") + '"></i> ' : "";
483
k = m + '<span class="text">' + k + l + "</span>", e += 1, c.push(0 !== d[0].index ? '<div class="div-contain"><div class="divider"></div></div><dt>' + k + "</dt>" + b.createA(h, "opt " + f, g, e) : "<dt>" + k + "</dt>" + b.createA(h, "opt " + f, g, e))
484
} else c.push(b.createA(h, "opt " + f, g, e));
485
else c.push(d.data("divider") === !0 ? '<div class="div-contain"><div class="divider"></div></div>' : a(this).data("hidden") === !0 ? "<a></a>" : b.createA(h, f, g))
486
}), a.each(c, function(a, b) {
487
var c = "<a></a>" === b ? 'class="hide is-hidden"' : "";
488
d += '<li rel="' + a + '"' + c + ">" + b + "</li>"
489
}), this.multiple || 0 !== this.$element.find("option:selected").length || this.options.title || this.$element.find("option").eq(0).prop("selected", !0).attr("selected", "selected"), a(d)
490
},
491
createA: function(a, b, c, d) {
492
return '<a tabindex="0" class="' + b + '" style="' + c + '"' + ("undefined" != typeof d ? 'data-optgroup="' + d + '"' : "") + ">" + a + '<i class="' + this.options.iconBase + " " + this.options.tickIcon + ' icon-ok check-mark"></i></a>'
493
},
494
render: function(b) {
495
var c = this;
496
b !== !1 && this.$element.find("option").each(function(b) {
497
c.setDisabled(b, a(this).is(":disabled") || a(this).parent().is(":disabled")), c.setSelected(b, a(this).is(":selected"))
498
}), this.tabIndex();
499
var d = this.$element.find("option:selected").map(function() {
500
var b, d = a(this),
501
e = d.data("icon") && c.options.showIcon ? '<i class="' + c.options.iconBase + " " + d.data("icon") + '"></i> ' : "";
502
return b = c.options.showSubtext && d.attr("data-subtext") && !c.multiple ? ' <small class="muted text-muted">' + d.data("subtext") + "</small>" : "", d.data("content") && c.options.showContent ? d.data("content") : void 0 !== d.attr("title") ? d.attr("title") : e + d.html() + b
503
}).toArray(),
504
e = this.multiple ? d.join(this.options.multipleSeparator) : d[0];
505
if (this.multiple && this.options.selectedTextFormat.indexOf("count") > -1) {
506
var f = this.options.selectedTextFormat.split(">"),
507
g = this.options.hideDisabled ? ":not([disabled])" : "";
508
(f.length > 1 && d.length > f[1] || 1 == f.length && d.length >= 2) && (e = this.options.countSelectedText.replace("{0}", d.length).replace("{1}", this.$element.find('option:not([data-divider="true"], [data-hidden="true"])' + g).length))
509
}
510
this.options.title = this.$element.attr("title"), "static" == this.options.selectedTextFormat && (e = this.options.title), e || (e = void 0 !== this.options.title ? this.options.title : this.options.noneSelectedText), this.$button.attr("title", a.trim(a("<div/>").html(e).text()).replace(/\s\s+/g, " ")), this.$newElement.find(".filter-option").html(e)
511
},
512
setStyle: function(a, b) {
513
this.$element.attr("class") && this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|validate\[.*\]/gi, ""));
514
var c = a ? a : this.options.style;
515
"add" == b ? this.$button.addClass(c) : "remove" == b ? this.$button.removeClass(c) : (this.$button.removeClass(this.options.style), this.$button.addClass(c))
516
},
517
liHeight: function() {
518
if (this.options.size !== !1) {
519
var a = this.$menu.parent().clone().find("> .dropdown-toggle").prop("autofocus", !1).end().appendTo("body"),
520
b = a.addClass("open").find("> .dropdown-menu"),
521
c = b.find("li > a").outerHeight(),
522
d = this.options.header ? b.find(".popover-title").outerHeight() : 0,
523
e = this.options.liveSearch ? b.find(".bootstrap-select-searchbox").outerHeight() : 0,
524
f = this.options.actionsBox ? b.find(".bs-actionsbox").outerHeight() : 0;
525
a.remove(), this.$newElement.data("liHeight", c).data("headerHeight", d).data("searchHeight", e).data("actionsHeight", f)
526
}
527
},
528
setSize: function() {
529
var b, c, d, e = this,
530
f = this.$menu,
531
g = f.find(".inner"),
532
h = this.$newElement.outerHeight(),
533
i = this.$newElement.data("liHeight"),
534
j = this.$newElement.data("headerHeight"),
535
k = this.$newElement.data("searchHeight"),
536
l = this.$newElement.data("actionsHeight"),
537
m = f.find("li .divider").outerHeight(!0),
538
n = parseInt(f.css("padding-top")) + parseInt(f.css("padding-bottom")) + parseInt(f.css("border-top-width")) + parseInt(f.css("border-bottom-width")),
539
o = this.options.hideDisabled ? ":not(.disabled)" : "",
540
p = a(window),
541
q = n + parseInt(f.css("margin-top")) + parseInt(f.css("margin-bottom")) + 2,
542
r = function() {
543
c = e.$newElement.offset().top - p.scrollTop(), d = p.height() - c - h
544
};
545
if (r(), this.options.header && f.css("padding-top", 0), "auto" == this.options.size) {
546
var s = function() {
547
var a, h = e.$lis.not(".hide");
548
r(), b = d - q, e.options.dropupAuto && e.$newElement.toggleClass("dropup", c > d && b - q < f.height()), e.$newElement.hasClass("dropup") && (b = c - q), a = h.length + h.find("dt").length > 3 ? 3 * i + q - 2 : 0, f.css({
549
"max-height": b + "px",
550
overflow: "hidden",
551
"min-height": a + j + k + l + "px"
552
}), g.css({
553
"max-height": b - j - k - l - n + "px",
554
"overflow-y": "auto",
555
"min-height": Math.max(a - n, 0) + "px"
556
})
557
};
558
s(), this.$searchbox.off("input.getSize propertychange.getSize").on("input.getSize propertychange.getSize", s), a(window).off("resize.getSize").on("resize.getSize", s), a(window).off("scroll.getSize").on("scroll.getSize", s)
559
} else if (this.options.size && "auto" != this.options.size && f.find("li" + o).length > this.options.size) {
560
var t = f.find("li" + o + " > *").not(".div-contain").slice(0, this.options.size).last().parent().index(),
561
u = f.find("li").slice(0, t + 1).find(".div-contain").length;
562
b = i * this.options.size + u * m + n, e.options.dropupAuto && this.$newElement.toggleClass("dropup", c > d && b < f.height()), f.css({
563
"max-height": b + j + k + l + "px",
564
overflow: "hidden"
565
}), g.css({
566
"max-height": b - n + "px",
567
"overflow-y": "auto"
568
})
569
}
570
},
571
setWidth: function() {
572
if ("auto" == this.options.width) {
573
this.$menu.css("min-width", "0");
574
var a = this.$newElement.clone().appendTo("body"),
575
b = a.find("> .dropdown-menu").css("width"),
576
c = a.css("width", "auto").find("> button").css("width");
577
a.remove(), this.$newElement.css("width", Math.max(parseInt(b), parseInt(c)) + "px")
578
} else "fit" == this.options.width ? (this.$menu.css("min-width", ""), this.$newElement.css("width", "").addClass("fit-width")) : this.options.width ? (this.$menu.css("min-width", ""), this.$newElement.css("width", this.options.width)) : (this.$menu.css("min-width", ""), this.$newElement.css("width", ""));
579
this.$newElement.hasClass("fit-width") && "fit" !== this.options.width && this.$newElement.removeClass("fit-width")
580
},
581
selectPosition: function() {
582
var b, c, d = this,
583
e = "<div />",
584
f = a(e),
585
g = function(a) {
586
f.addClass(a.attr("class").replace(/form-control/gi, "")).toggleClass("dropup", a.hasClass("dropup")), b = a.offset(), c = a.hasClass("dropup") ? 0 : a[0].offsetHeight, f.css({
587
top: b.top + c,
588
left: b.left,
589
width: a[0].offsetWidth,
590
position: "absolute"
591
})
592
};
593
this.$newElement.on("click", function() {
594
d.isDisabled() || (g(a(this)), f.appendTo(d.options.container), f.toggleClass("open", !a(this).hasClass("open")), f.append(d.$menu))
595
}), a(window).resize(function() {
596
g(d.$newElement)
597
}), a(window).on("scroll", function() {
598
g(d.$newElement)
599
}), a("html").on("click", function(b) {
600
a(b.target).closest(d.$newElement).length < 1 && f.removeClass("open")
601
})
602
},
603
mobile: function() {
604
this.$element.addClass("mobile-device").appendTo(this.$newElement), this.options.container && this.$menu.hide()
605
},
606
refresh: function() {
607
this.$lis = null, this.reloadLi(), this.render(), this.setWidth(), this.setStyle(), this.checkDisabled(), this.liHeight()
608
},
609
update: function() {
610
this.reloadLi(), this.setWidth(), this.setStyle(), this.checkDisabled(), this.liHeight()
611
},
612
setSelected: function(b, c) {
613
null == this.$lis && (this.$lis = this.$menu.find("li")), a(this.$lis[b]).toggleClass("selected", c)
614
},
615
setDisabled: function(b, c) {
616
null == this.$lis && (this.$lis = this.$menu.find("li")), c ? a(this.$lis[b]).addClass("disabled").find("a").attr("href", "#").attr("tabindex", -1) : a(this.$lis[b]).removeClass("disabled").find("a").removeAttr("href").attr("tabindex", 0)
617
},
618
isDisabled: function() {
619
return this.$element.is(":disabled")
620
},
621
checkDisabled: function() {
622
var a = this;
623
this.isDisabled() ? this.$button.addClass("disabled").attr("tabindex", -1) : (this.$button.hasClass("disabled") && this.$button.removeClass("disabled"), -1 == this.$button.attr("tabindex") && (this.$element.data("tabindex") || this.$button.removeAttr("tabindex"))), this.$button.click(function() {
624
return !a.isDisabled()
625
})
626
},
627
tabIndex: function() {
628
this.$element.is("[tabindex]") && (this.$element.data("tabindex", this.$element.attr("tabindex")), this.$button.attr("tabindex", this.$element.data("tabindex")))
629
},
630
clickListener: function() {
631
var b = this;
632
this.$newElement.on("touchstart.dropdown", ".dropdown-menu", function(a) {
633
a.stopPropagation()
634
}), this.$newElement.on("click", function() {
635
b.setSize(), b.options.liveSearch || b.multiple || setTimeout(function() {
636
b.$menu.find(".selected a").focus()
637
}, 10)
638
}), this.$menu.on("click", "li a", function(c) {
639
var d = a(this).parent().index(),
640
e = b.$element.val(),
641
f = b.$element.prop("selectedIndex");
642
if (b.multiple && c.stopPropagation(), c.preventDefault(), !b.isDisabled() && !a(this).parent().hasClass("disabled")) {
643
var g = b.$element.find("option"),
644
h = g.eq(d),
645
i = h.prop("selected"),
646
j = h.parent("optgroup"),
647
k = b.options.maxOptions,
648
l = j.data("maxOptions") || !1;
649
if (b.multiple) {
650
if (h.prop("selected", !i), b.setSelected(d, !i), a(this).blur(), k !== !1 || l !== !1) {
651
var m = k < g.filter(":selected").length,
652
n = l < j.find("option:selected").length,
653
o = b.options.maxOptionsText,
654
p = o[0].replace("{n}", k),
655
q = o[1].replace("{n}", l),
656
r = a('<div class="notify"></div>');
657
if (k && m || l && n)
658
if (k && 1 == k) g.prop("selected", !1), h.prop("selected", !0), b.$menu.find(".selected").removeClass("selected"), b.setSelected(d, !0);
659
else if (l && 1 == l) {
660
j.find("option:selected").prop("selected", !1), h.prop("selected", !0);
661
var s = a(this).data("optgroup");
662
b.$menu.find(".selected").has('a[data-optgroup="' + s + '"]').removeClass("selected"), b.setSelected(d, !0)
663
} else o[2] && (p = p.replace("{var}", o[2][k > 1 ? 0 : 1]), q = q.replace("{var}", o[2][l > 1 ? 0 : 1])), h.prop("selected", !1), b.$menu.append(r), k && m && (r.append(a("<div>" + p + "</div>")), b.$element.trigger("maxReached.bs.select")), l && n && (r.append(a("<div>" + q + "</div>")), b.$element.trigger("maxReachedGrp.bs.select")), setTimeout(function() {
664
b.setSelected(d, !1)
665
}, 10), r.delay(750).fadeOut(300, function() {
666
a(this).remove()
667
})
668
}
669
} else g.prop("selected", !1), h.prop("selected", !0), b.$menu.find(".selected").removeClass("selected"), b.setSelected(d, !0);
670
b.multiple ? b.options.liveSearch && b.$searchbox.focus() : b.$button.focus(), (e != b.$element.val() && b.multiple || f != b.$element.prop("selectedIndex") && !b.multiple) && b.$element.change()
671
}
672
}), this.$menu.on("click", "li.disabled a, li dt, li .div-contain, .popover-title, .popover-title :not(.close)", function(a) {
673
a.target == this && (a.preventDefault(), a.stopPropagation(), b.options.liveSearch ? b.$searchbox.focus() : b.$button.focus())
674
}), this.$menu.on("click", ".popover-title .close", function() {
675
b.$button.focus()
676
}), this.$searchbox.on("click", function(a) {
677
a.stopPropagation()
678
}), this.$menu.on("click", ".actions-btn", function(c) {
679
b.options.liveSearch ? b.$searchbox.focus() : b.$button.focus(), c.preventDefault(), c.stopPropagation(), a(this).is(".bs-select-all") ? b.selectAll() : b.deselectAll(), b.$element.change()
680
}), this.$element.change(function() {
681
b.render(!1)
682
})
683
},
684
liveSearchListener: function() {
685
var b = this,
686
c = a('<li class="no-results"></li>');
687
this.$newElement.on("click.dropdown.data-api", function() {
688
b.$menu.find(".active").removeClass("active"), b.$searchbox.val() && (b.$searchbox.val(""), b.$lis.not(".is-hidden").removeClass("hide"), c.parent().length && c.remove()), b.multiple || b.$menu.find(".selected").addClass("active"), setTimeout(function() {
689
b.$searchbox.focus()
690
}, 10)
691
}), this.$searchbox.on("input propertychange", function() {
692
b.$searchbox.val() ? (b.$lis.not(".is-hidden").removeClass("hide").find("a").not(":icontains(" + b.$searchbox.val() + ")").parent().addClass("hide"), b.$menu.find("li").filter(":visible:not(.no-results)").length ? c.parent().length && c.remove() : (c.parent().length && c.remove(), c.html(b.options.noneResultsText + ' "' + b.$searchbox.val() + '"').show(), b.$menu.find("li").last().after(c))) : (b.$lis.not(".is-hidden").removeClass("hide"), c.parent().length && c.remove()), b.$menu.find("li.active").removeClass("active"), b.$menu.find("li").filter(":visible:not(.divider)").eq(0).addClass("active").find("a").focus(), a(this).focus()
693
}), this.$menu.on("mouseenter", "a", function(c) {
694
b.$menu.find(".active").removeClass("active"), a(c.currentTarget).parent().not(".disabled").addClass("active")
695
}), this.$menu.on("mouseleave", "a", function() {
696
b.$menu.find(".active").removeClass("active")
697
})
698
},
699
val: function(a) {
700
return void 0 !== a ? (this.$element.val(a), this.$element.change(), this.render(), this.$element) : this.$element.val()
701
},
702
selectAll: function() {
703
null == this.$lis && (this.$lis = this.$menu.find("li")), this.$element.find("option:enabled").prop("selected", !0), a(this.$lis).not(".disabled").addClass("selected"), this.render(!1)
704
},
705
deselectAll: function() {
706
null == this.$lis && (this.$lis = this.$menu.find("li")), this.$element.find("option:enabled").prop("selected", !1), a(this.$lis).not(".disabled").removeClass("selected"), this.render(!1)
707
},
708
keydown: function(b) {
709
var c, d, e, f, g, h, i, j, k, l, m, n, o = {
710
32: " ",
711
48: "0",
712
49: "1",
713
50: "2",
714
51: "3",
715
52: "4",
716
53: "5",
717
54: "6",
718
55: "7",
719
56: "8",
720
57: "9",
721
59: ";",
722
65: "a",
723
66: "b",
724
67: "c",
725
68: "d",
726
69: "e",
727
70: "f",
728
71: "g",
729
72: "h",
730
73: "i",
731
74: "j",
732
75: "k",
733
76: "l",
734
77: "m",
735
78: "n",
736
79: "o",
737
80: "p",
738
81: "q",
739
82: "r",
740
83: "s",
741
84: "t",
742
85: "u",
743
86: "v",
744
87: "w",
745
88: "x",
746
89: "y",
747
90: "z",
748
96: "0",
749
97: "1",
750
98: "2",
751
99: "3",
752
100: "4",
753
101: "5",
754
102: "6",
755
103: "7",
756
104: "8",
757
105: "9"
758
};
759
if (c = a(this), e = c.parent(), c.is("input") && (e = c.parent().parent()), l = e.data("this"), l.options.liveSearch && (e = c.parent().parent()), l.options.container && (e = l.$menu), d = a("[role=menu] li:not(.divider) a", e), n = l.$menu.parent().hasClass("open"), !n && /([0-9]|[A-z])/.test(String.fromCharCode(b.keyCode)) && (l.options.container ? l.$newElement.trigger("click") : (l.setSize(), l.$menu.parent().addClass("open"), n = !0), l.$searchbox.focus()), l.options.liveSearch && (/(^9$|27)/.test(b.keyCode.toString(10)) && n && 0 === l.$menu.find(".active").length && (b.preventDefault(), l.$menu.parent().removeClass("open"), l.$button.focus()), d = a("[role=menu] li:not(.divider):visible", e), c.val() || /(38|40)/.test(b.keyCode.toString(10)) || 0 === d.filter(".active").length && (d = l.$newElement.find("li").filter(":icontains(" + o[b.keyCode] + ")"))), d.length) {
760
if (/(38|40)/.test(b.keyCode.toString(10))) f = d.index(d.filter(":focus")), h = d.parent(":not(.disabled):visible").first().index(), i = d.parent(":not(.disabled):visible").last().index(), g = d.eq(f).parent().nextAll(":not(.disabled):visible").eq(0).index(), j = d.eq(f).parent().prevAll(":not(.disabled):visible").eq(0).index(), k = d.eq(g).parent().prevAll(":not(.disabled):visible").eq(0).index(), l.options.liveSearch && (d.each(function(b) {
761
a(this).is(":not(.disabled)") && a(this).data("index", b)
762
}), f = d.index(d.filter(".active")), h = d.filter(":not(.disabled):visible").first().data("index"), i = d.filter(":not(.disabled):visible").last().data("index"), g = d.eq(f).nextAll(":not(.disabled):visible").eq(0).data("index"), j = d.eq(f).prevAll(":not(.disabled):visible").eq(0).data("index"), k = d.eq(g).prevAll(":not(.disabled):visible").eq(0).data("index")), m = c.data("prevIndex"), 38 == b.keyCode && (l.options.liveSearch && (f -= 1), f != k && f > j && (f = j), h > f && (f = h), f == m && (f = i)), 40 == b.keyCode && (l.options.liveSearch && (f += 1), -1 == f && (f = 0), f != k && g > f && (f = g), f > i && (f = i), f == m && (f = h)), c.data("prevIndex", f), l.options.liveSearch ? (b.preventDefault(), c.is(".dropdown-toggle") || (d.removeClass("active"), d.eq(f).addClass("active").find("a").focus(), c.focus())) : d.eq(f).focus();
763
else if (!c.is("input")) {
764
var p, q, r = [];
765
d.each(function() {
766
a(this).parent().is(":not(.disabled)") && a.trim(a(this).text().toLowerCase()).substring(0, 1) == o[b.keyCode] && r.push(a(this).parent().index())
767
}), p = a(document).data("keycount"), p++, a(document).data("keycount", p), q = a.trim(a(":focus").text().toLowerCase()).substring(0, 1), q != o[b.keyCode] ? (p = 1, a(document).data("keycount", p)) : p >= r.length && (a(document).data("keycount", 0), p > r.length && (p = 1)), d.eq(r[p - 1]).focus()
768
}
769
/(13|32)/.test(b.keyCode.toString(10)) && n && (/(32)/.test(b.keyCode.toString(10)) || b.preventDefault(), l.options.liveSearch ? /(32)/.test(b.keyCode.toString(10)) || (l.$menu.find(".active a").click(), c.focus()) : a(":focus").click(), a(document).data("keycount", 0)), (/(^9$|27)/.test(b.keyCode.toString(10)) && n && (l.multiple || l.options.liveSearch) || /(27)/.test(b.keyCode.toString(10)) && !n) && (l.$menu.parent().removeClass("open"), l.$button.focus())
770
}
771
},
772
hide: function() {
773
this.$newElement.hide()
774
},
775
show: function() {
776
this.$newElement.show()
777
},
778
destroy: function() {
779
this.$newElement.remove(), this.$element.remove()
780
}
781
}, a.fn.selectpicker = function(c, d) {
782
var e, f = arguments,
783
g = this.each(function() {
784
if (a(this).is("select")) {
785
var g = a(this),
786
h = g.data("selectpicker"),
787
i = "object" == typeof c && c;
788
if (h) {
789
if (i)
790
for (var j in i) i.hasOwnProperty(j) && (h.options[j] = i[j])
791
} else g.data("selectpicker", h = new b(this, a.extend({}, b.DEFAULTS, a.fn.selectpicker.defaults || {}, g.data(), i), d));
792
if ("string" == typeof c) {
793
var k = c;
794
h[k] instanceof Function ? ([].shift.apply(f), e = h[k].apply(h, f)) : e = h.options[k]
795
}
796
}
797
});
798
return "undefined" != typeof e ? e : g
799
}, a.fn.selectpicker.Constructor = b, a(document).data("keycount", 0).on("keydown", ".bootstrap-select [data-toggle=dropdown], .bootstrap-select [role=menu], .bootstrap-select-searchbox input", b.prototype.keydown).on("focusin.modal", ".bootstrap-select [data-toggle=dropdown], .bootstrap-select [role=menu], .bootstrap-select-searchbox input", function(a) {
800
a.stopPropagation()
801
})
802
}(jQuery);
803
804
805
// Bootstrap DatePicker
806
! function($) {
807
function UTCDate() {
808
return new Date(Date.UTC.apply(Date, arguments))
809
}
810
811
function UTCToday() {
812
var today = new Date();
813
return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate())
814
}
815
var Datepicker = function(element, options) {
816
var that = this;
817
this.element = $(element);
818
this.language = options.language || this.element.data('date-language') || "en";
819
this.language = this.language in dates ? this.language : "en";
820
this.isRTL = dates[this.language].rtl || false;
821
this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || 'mm/dd/yyyy');
822
this.isInline = false;
823
this.isInput = this.element.is('input');
824
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
825
this.hasInput = this.component && this.element.find('input').length;
826
if (this.component && this.component.length === 0) this.component = false;
827
this._attachEvents();
828
this.forceParse = true;
829
if ('forceParse' in options) {
830
this.forceParse = options.forceParse
831
} else if ('dateForceParse' in this.element.data()) {
832
this.forceParse = this.element.data('date-force-parse')
833
}
834
this.picker = $(DPGlobal.template).appendTo(this.isInline ? this.element : 'body').on({
835
click: $.proxy(this.click, this),
836
mousedown: $.proxy(this.mousedown, this)
837
});
838
if (this.isInline) {
839
this.picker.addClass('datepicker-inline')
840
} else {
841
this.picker.addClass('datepicker-dropdown dropdown-menu')
842
}
843
if (this.isRTL) {
844
this.picker.addClass('datepicker-rtl');
845
this.picker.find('.prev i, .next i').toggleClass('icon-arrow-left icon-arrow-right')
846
}
847
$(document).on('mousedown', function(e) {
848
if ($(e.target).closest('.datepicker').length === 0) {
849
that.hide()
850
}
851
});
852
this.autoclose = false;
853
if ('autoclose' in options) {
854
this.autoclose = options.autoclose
855
} else if ('dateAutoclose' in this.element.data()) {
856
this.autoclose = this.element.data('date-autoclose')
857
}
858
this.keyboardNavigation = true;
859
if ('keyboardNavigation' in options) {
860
this.keyboardNavigation = options.keyboardNavigation
861
} else if ('dateKeyboardNavigation' in this.element.data()) {
862
this.keyboardNavigation = this.element.data('date-keyboard-navigation')
863
}
864
this.viewMode = this.startViewMode = 0;
865
switch (options.startView || this.element.data('date-start-view')) {
866
case 2:
867
case 'decade':
868
this.viewMode = this.startViewMode = 2;
869
break;
870
case 1:
871
case 'year':
872
this.viewMode = this.startViewMode = 1;
873
break
874
}
875
this.todayBtn = (options.todayBtn || this.element.data('date-today-btn') || false);
876
this.todayHighlight = (options.todayHighlight || this.element.data('date-today-highlight') || false);
877
this.weekStart = ((options.weekStart || this.element.data('date-weekstart') || dates[this.language].weekStart || 0) % 7);
878
this.weekEnd = ((this.weekStart + 6) % 7);
879
this.startDate = -Infinity;
880
this.endDate = Infinity;
881
this.daysOfWeekDisabled = [];
882
this.setStartDate(options.startDate || this.element.data('date-startdate'));
883
this.setEndDate(options.endDate || this.element.data('date-enddate'));
884
this.setDaysOfWeekDisabled(options.daysOfWeekDisabled || this.element.data('date-days-of-week-disabled'));
885
this.fillDow();
886
this.fillMonths();
887
this.update();
888
this.showMode();
889
if (this.isInline) {
890
this.show()
891
}
892
};
893
Datepicker.prototype = {
894
constructor: Datepicker,
895
_events: [],
896
_attachEvents: function() {
897
this._detachEvents();
898
if (this.isInput) {
899
this._events = [
900
[this.element, {
901
focus: $.proxy(this.show, this),
902
keyup: $.proxy(this.update, this),
903
keydown: $.proxy(this.keydown, this)
904
}]
905
]
906
} else if (this.component && this.hasInput) {
907
this._events = [
908
[this.element.find('input'), {
909
focus: $.proxy(this.show, this),
910
keyup: $.proxy(this.update, this),
911
keydown: $.proxy(this.keydown, this)
912
}],
913
[this.component, {
914
click: $.proxy(this.show, this)
915
}]
916
]
917
} else if (this.element.is('div')) {
918
this.isInline = true
919
} else {
920
this._events = [
921
[this.element, {
922
click: $.proxy(this.show, this)
923
}]
924
]
925
}
926
for (var i = 0, el, ev; i < this._events.length; i++) {
927
el = this._events[i][0];
928
ev = this._events[i][1];
929
el.on(ev)
930
}
931
},
932
_detachEvents: function() {
933
for (var i = 0, el, ev; i < this._events.length; i++) {
934
el = this._events[i][0];
935
ev = this._events[i][1];
936
el.off(ev)
937
}
938
this._events = []
939
},
940
show: function(e) {
941
this.picker.show();
942
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
943
this.update();
944
this.place();
945
$(window).on('resize', $.proxy(this.place, this));
946
if (e) {
947
e.stopPropagation();
948
e.preventDefault()
949
}
950
this.element.trigger({
951
type: 'show',
952
date: this.date
953
})
954
},
955
hide: function(e) {
956
if (this.isInline) return;
957
this.picker.hide();
958
$(window).off('resize', this.place);
959
this.viewMode = this.startViewMode;
960
this.showMode();
961
if (!this.isInput) {
962
$(document).off('mousedown', this.hide)
963
}
964
if (this.forceParse && (this.isInput && this.element.val() || this.hasInput && this.element.find('input').val())) this.setValue();
965
this.element.trigger({
966
type: 'hide',
967
date: this.date
968
})
969
},
970
remove: function() {
971
this._detachEvents();
972
this.picker.remove();
973
delete this.element.data().datepicker
974
},
975
getDate: function() {
976
var d = this.getUTCDate();
977
return new Date(d.getTime() + (d.getTimezoneOffset() * 60000))
978
},
979
getUTCDate: function() {
980
return this.date
981
},
982
setDate: function(d) {
983
this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset() * 60000)))
984
},
985
setUTCDate: function(d) {
986
this.date = d;
987
this.setValue()
988
},
989
setValue: function() {
990
var formatted = this.getFormattedDate();
991
if (!this.isInput) {
992
if (this.component) {
993
this.element.find('input').val(formatted)
994
}
995
this.element.data('date', formatted)
996
} else {
997
this.element.val(formatted)
998
}
999
},
1000
getFormattedDate: function(format) {
1001
if (format === undefined) format = this.format;
1002
return DPGlobal.formatDate(this.date, format, this.language)
1003
},
1004
setStartDate: function(startDate) {
1005
this.startDate = startDate || -Infinity;
1006
if (this.startDate !== -Infinity) {
1007
this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language)
1008
}
1009
this.update();
1010
this.updateNavArrows()
1011
},
1012
setEndDate: function(endDate) {
1013
this.endDate = endDate || Infinity;
1014
if (this.endDate !== Infinity) {
1015
this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language)
1016
}
1017
this.update();
1018
this.updateNavArrows()
1019
},
1020
setDaysOfWeekDisabled: function(daysOfWeekDisabled) {
1021
this.daysOfWeekDisabled = daysOfWeekDisabled || [];
1022
if (!$.isArray(this.daysOfWeekDisabled)) {
1023
this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/)
1024
}
1025
this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled, function(d) {
1026
return parseInt(d, 10)
1027
});
1028
this.update();
1029
this.updateNavArrows()
1030
},
1031
place: function() {
1032
if (this.isInline) return;
1033
var zIndex = parseInt(this.element.parents().filter(function() {
1034
return $(this).css('z-index') != 'auto'
1035
}).first().css('z-index')) + 10;
1036
var offset = this.component ? this.component.offset() : this.element.offset();
1037
var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(true);
1038
this.picker.css({
1039
top: offset.top + height,
1040
left: offset.left,
1041
zIndex: zIndex
1042
})
1043
},
1044
update: function() {
1045
var date, fromArgs = false;
1046
if (arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
1047
date = arguments[0];
1048
fromArgs = true
1049
} else {
1050
date = this.isInput ? this.element.val() : this.element.data('date') || this.element.find('input').val()
1051
}
1052
this.date = DPGlobal.parseDate(date, this.format, this.language);
1053
if (fromArgs) this.setValue();
1054
var oldViewDate = this.viewDate;
1055
if (this.date < this.startDate) {
1056
this.viewDate = new Date(this.startDate)
1057
} else if (this.date > this.endDate) {
1058
this.viewDate = new Date(this.endDate)
1059
} else {
1060
this.viewDate = new Date(this.date)
1061
}
1062
if (oldViewDate && oldViewDate.getTime() != this.viewDate.getTime()) {
1063
this.element.trigger({
1064
type: 'changeDate',
1065
date: this.viewDate
1066
})
1067
}
1068
this.fill()
1069
},
1070
fillDow: function() {
1071
var dowCnt = this.weekStart,
1072
html = '<tr>';
1073
while (dowCnt < this.weekStart + 7) {
1074
html += '<th class="dow">' + dates[this.language].daysMin[(dowCnt++) % 7] + '</th>'
1075
}
1076
html += '</tr>';
1077
this.picker.find('.datepicker-days thead').append(html)
1078
},
1079
fillMonths: function() {
1080
var html = '',
1081
i = 0;
1082
while (i < 12) {
1083
html += '<span class="month">' + dates[this.language].monthsShort[i++] + '</span>'
1084
}
1085
this.picker.find('.datepicker-months td').html(html)
1086
},
1087
fill: function() {
1088
var d = new Date(this.viewDate),
1089
year = d.getUTCFullYear(),
1090
month = d.getUTCMonth(),
1091
startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
1092
startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
1093
endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
1094
endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
1095
currentDate = this.date && this.date.valueOf(),
1096
today = new Date();
1097
this.picker.find('.datepicker-days thead th:eq(1)').text(dates[this.language].months[month] + ' ' + year);
1098
this.picker.find('tfoot th.today').text(dates[this.language].today).toggle(this.todayBtn !== false);
1099
this.updateNavArrows();
1100
this.fillMonths();
1101
var prevMonth = UTCDate(year, month - 1, 28, 0, 0, 0, 0),
1102
day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
1103
prevMonth.setUTCDate(day);
1104
prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7) % 7);
1105
var nextMonth = new Date(prevMonth);
1106
nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
1107
nextMonth = nextMonth.valueOf();
1108
var html = [];
1109
var clsName;
1110
while (prevMonth.valueOf() < nextMonth) {
1111
if (prevMonth.getUTCDay() == this.weekStart) {
1112
html.push('<tr>')
1113
}
1114
clsName = '';
1115
if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
1116
clsName += ' old'
1117
} else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
1118
clsName += ' new'
1119
}
1120
if (this.todayHighlight && prevMonth.getUTCFullYear() == today.getFullYear() && prevMonth.getUTCMonth() == today.getMonth() && prevMonth.getUTCDate() == today.getDate()) {
1121
clsName += ' today'
1122
}
1123
if (currentDate && prevMonth.valueOf() == currentDate) {
1124
clsName += ' active'
1125
}
1126
if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate || $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
1127
clsName += ' disabled'
1128
}
1129
html.push('<td class="day' + clsName + '">' + prevMonth.getUTCDate() + '</td>');
1130
if (prevMonth.getUTCDay() == this.weekEnd) {
1131
html.push('</tr>')
1132
}
1133
prevMonth.setUTCDate(prevMonth.getUTCDate() + 1)
1134
}
1135
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
1136
var currentYear = this.date && this.date.getUTCFullYear();
1137
var months = this.picker.find('.datepicker-months').find('th:eq(1)').text(year).end().find('span').removeClass('active');
1138
if (currentYear && currentYear == year) {
1139
months.eq(this.date.getUTCMonth()).addClass('active')
1140
}
1141
if (year < startYear || year > endYear) {
1142
months.addClass('disabled')
1143
}
1144
if (year == startYear) {
1145
months.slice(0, startMonth).addClass('disabled')
1146
}
1147
if (year == endYear) {
1148
months.slice(endMonth + 1).addClass('disabled')
1149
}
1150
html = '';
1151
year = parseInt(year / 10, 10) * 10;
1152
var yearCont = this.picker.find('.datepicker-years').find('th:eq(1)').text(year + '-' + (year + 9)).end().find('td');
1153
year -= 1;
1154
for (var i = -1; i < 11; i++) {
1155
html += '<span class="year' + (i == -1 || i == 10 ? ' old' : '') + (currentYear == year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : '') + '">' + year + '</span>';
1156
year += 1
1157
}
1158
yearCont.html(html)
1159
},
1160
updateNavArrows: function() {
1161
var d = new Date(this.viewDate),
1162
year = d.getUTCFullYear(),
1163
month = d.getUTCMonth();
1164
switch (this.viewMode) {
1165
case 0:
1166
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
1167
this.picker.find('.prev').css({
1168
visibility: 'hidden'
1169
})
1170
} else {
1171
this.picker.find('.prev').css({
1172
visibility: 'visible'
1173
})
1174
}
1175
if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
1176
this.picker.find('.next').css({
1177
visibility: 'hidden'
1178
})
1179
} else {
1180
this.picker.find('.next').css({
1181
visibility: 'visible'
1182
})
1183
}
1184
break;
1185
case 1:
1186
case 2:
1187
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
1188
this.picker.find('.prev').css({
1189
visibility: 'hidden'
1190
})
1191
} else {
1192
this.picker.find('.prev').css({
1193
visibility: 'visible'
1194
})
1195
}
1196
if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
1197
this.picker.find('.next').css({
1198
visibility: 'hidden'
1199
})
1200
} else {
1201
this.picker.find('.next').css({
1202
visibility: 'visible'
1203
})
1204
}
1205
break
1206
}
1207
},
1208
click: function(e) {
1209
e.stopPropagation();
1210
e.preventDefault();
1211
var target = $(e.target).closest('span, td, th');
1212
if (target.length == 1) {
1213
switch (target[0].nodeName.toLowerCase()) {
1214
case 'th':
1215
switch (target[0].className) {
1216
case 'switch':
1217
this.showMode(1);
1218
break;
1219
case 'prev':
1220
case 'next':
1221
var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
1222
switch (this.viewMode) {
1223
case 0:
1224
this.viewDate = this.moveMonth(this.viewDate, dir);
1225
break;
1226
case 1:
1227
case 2:
1228
this.viewDate = this.moveYear(this.viewDate, dir);
1229
break
1230
}
1231
this.fill();
1232
break;
1233
case 'today':
1234
var date = new Date();
1235
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
1236
this.showMode(-2);
1237
var which = this.todayBtn == 'linked' ? null : 'view';
1238
this._setDate(date, which);
1239
break
1240
}
1241
break;
1242
case 'span':
1243
if (!target.is('.disabled')) {
1244
this.viewDate.setUTCDate(1);
1245
if (target.is('.month')) {
1246
var month = target.parent().find('span').index(target);
1247
this.viewDate.setUTCMonth(month);
1248
this.element.trigger({
1249
type: 'changeMonth',
1250
date: this.viewDate
1251
})
1252
} else {
1253
var year = parseInt(target.text(), 10) || 0;
1254
this.viewDate.setUTCFullYear(year);
1255
this.element.trigger({
1256
type: 'changeYear',
1257
date: this.viewDate
1258
})
1259
}
1260
this.showMode(-1);
1261
this.fill()
1262
}
1263
break;
1264
case 'td':
1265
if (target.is('.day') && !target.is('.disabled')) {
1266
var day = parseInt(target.text(), 10) || 1;
1267
var year = this.viewDate.getUTCFullYear(),
1268
month = this.viewDate.getUTCMonth();
1269
if (target.is('.old')) {
1270
if (month === 0) {
1271
month = 11;
1272
year -= 1
1273
} else {
1274
month -= 1
1275
}
1276
} else if (target.is('.new')) {
1277
if (month == 11) {
1278
month = 0;
1279
year += 1
1280
} else {
1281
month += 1
1282
}
1283
}
1284
this._setDate(UTCDate(year, month, day, 0, 0, 0, 0))
1285
}
1286
break
1287
}
1288
}
1289
},
1290
_setDate: function(date, which) {
1291
if (!which || which == 'date') this.date = date;
1292
if (!which || which == 'view') this.viewDate = date;
1293
this.fill();
1294
this.setValue();
1295
this.element.trigger({
1296
type: 'changeDate',
1297
date: this.date
1298
});
1299
var element;
1300
if (this.isInput) {
1301
element = this.element
1302
} else if (this.component) {
1303
element = this.element.find('input')
1304
}
1305
if (element) {
1306
element.change();
1307
if (this.autoclose && (!which || which == 'date')) {
1308
this.hide()
1309
}
1310
}
1311
},
1312
moveMonth: function(date, dir) {
1313
if (!dir) return date;
1314
var new_date = new Date(date.valueOf()),
1315
day = new_date.getUTCDate(),
1316
month = new_date.getUTCMonth(),
1317
mag = Math.abs(dir),
1318
new_month, test;
1319
dir = dir > 0 ? 1 : -1;
1320
if (mag == 1) {
1321
test = dir == -1 ? function() {
1322
return new_date.getUTCMonth() == month
1323
} : function() {
1324
return new_date.getUTCMonth() != new_month
1325
};
1326
new_month = month + dir;
1327
new_date.setUTCMonth(new_month);
1328
if (new_month < 0 || new_month > 11) new_month = (new_month + 12) % 12
1329
} else {
1330
for (var i = 0; i < mag; i++) new_date = this.moveMonth(new_date, dir);
1331
new_month = new_date.getUTCMonth();
1332
new_date.setUTCDate(day);
1333
test = function() {
1334
return new_month != new_date.getUTCMonth()
1335
}
1336
}
1337
while (test()) {
1338
new_date.setUTCDate(--day);
1339
new_date.setUTCMonth(new_month)
1340
}
1341
return new_date
1342
},
1343
moveYear: function(date, dir) {
1344
return this.moveMonth(date, dir * 12)
1345
},
1346
dateWithinRange: function(date) {
1347
return date >= this.startDate && date <= this.endDate
1348
},
1349
keydown: function(e) {
1350
if (this.picker.is(':not(:visible)')) {
1351
if (e.keyCode == 27) this.show();
1352
return
1353
}
1354
var dateChanged = false,
1355
dir, day, month, newDate, newViewDate;
1356
switch (e.keyCode) {
1357
case 27:
1358
this.hide();
1359
e.preventDefault();
1360
break;
1361
case 37:
1362
case 39:
1363
if (!this.keyboardNavigation) break;
1364
dir = e.keyCode == 37 ? -1 : 1;
1365
if (e.ctrlKey) {
1366
newDate = this.moveYear(this.date, dir);
1367
newViewDate = this.moveYear(this.viewDate, dir)
1368
} else if (e.shiftKey) {
1369
newDate = this.moveMonth(this.date, dir);
1370
newViewDate = this.moveMonth(this.viewDate, dir)
1371
} else {
1372
newDate = new Date(this.date);
1373
newDate.setUTCDate(this.date.getUTCDate() + dir);
1374
newViewDate = new Date(this.viewDate);
1375
newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir)
1376
}
1377
if (this.dateWithinRange(newDate)) {
1378
this.date = newDate;
1379
this.viewDate = newViewDate;
1380
this.setValue();
1381
this.update();
1382
e.preventDefault();
1383
dateChanged = true
1384
}
1385
break;
1386
case 38:
1387
case 40:
1388
if (!this.keyboardNavigation) break;
1389
dir = e.keyCode == 38 ? -1 : 1;
1390
if (e.ctrlKey) {
1391
newDate = this.moveYear(this.date, dir);
1392
newViewDate = this.moveYear(this.viewDate, dir)
1393
} else if (e.shiftKey) {
1394
newDate = this.moveMonth(this.date, dir);
1395
newViewDate = this.moveMonth(this.viewDate, dir)
1396
} else {
1397
newDate = new Date(this.date);
1398
newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
1399
newViewDate = new Date(this.viewDate);
1400
newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7)
1401
}
1402
if (this.dateWithinRange(newDate)) {
1403
this.date = newDate;
1404
this.viewDate = newViewDate;
1405
this.setValue();
1406
this.update();
1407
e.preventDefault();
1408
dateChanged = true
1409
}
1410
break;
1411
case 13:
1412
this.hide();
1413
e.preventDefault();
1414
break;
1415
case 9:
1416
this.hide();
1417
break
1418
}
1419
if (dateChanged) {
1420
this.element.trigger({
1421
type: 'changeDate',
1422
date: this.date
1423
});
1424
var element;
1425
if (this.isInput) {
1426
element = this.element
1427
} else if (this.component) {
1428
element = this.element.find('input')
1429
}
1430
if (element) {
1431
element.change()
1432
}
1433
}
1434
},
1435
showMode: function(dir) {
1436
if (dir) {
1437
this.viewMode = Math.max(0, Math.min(2, this.viewMode + dir))
1438
}
1439
this.picker.find('>div').hide().filter('.datepicker-' + DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
1440
this.updateNavArrows()
1441
}
1442
};
1443
$.fn.datepicker = function(option) {
1444
var args = Array.apply(null, arguments);
1445
args.shift();
1446
return this.each(function() {
1447
var $this = $(this),
1448
data = $this.data('datepicker'),
1449
options = typeof option == 'object' && option;
1450
if (!data) {
1451
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults, options))))
1452
}
1453
if (typeof option == 'string' && typeof data[option] == 'function') {
1454
data[option].apply(data, args)
1455
}
1456
})
1457
};
1458
$.fn.datepicker.defaults = {};
1459
$.fn.datepicker.Constructor = Datepicker;
1460
var dates = $.fn.datepicker.dates = {
1461
en: {
1462
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
1463
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
1464
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
1465
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1466
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
1467
today: "Today"
1468
}
1469
};
1470
var DPGlobal = {
1471
modes: [{
1472
clsName: 'days',
1473
navFnc: 'Month',
1474
navStep: 1
1475
}, {
1476
clsName: 'months',
1477
navFnc: 'FullYear',
1478
navStep: 1
1479
}, {
1480
clsName: 'years',
1481
navFnc: 'FullYear',
1482
navStep: 10
1483
}],
1484
isLeapYear: function(year) {
1485
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
1486
},
1487
getDaysInMonth: function(year, month) {
1488
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
1489
},
1490
validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
1491
nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
1492
parseFormat: function(format) {
1493
var separators = format.replace(this.validParts, '\0').split('\0'),
1494
parts = format.match(this.validParts);
1495
if (!separators || !separators.length || !parts || parts.length === 0) {
1496
throw new Error("Invalid date format.");
1497
}
1498
return {
1499
separators: separators,
1500
parts: parts
1501
}
1502
},
1503
parseDate: function(date, format, language) {
1504
if (date instanceof Date) return date;
1505
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)) {
1506
var part_re = /([\-+]\d+)([dmwy])/,
1507
parts = date.match(/([\-+]\d+)([dmwy])/g),
1508
part, dir;
1509
date = new Date();
1510
for (var i = 0; i < parts.length; i++) {
1511
part = part_re.exec(parts[i]);
1512
dir = parseInt(part[1]);
1513
switch (part[2]) {
1514
case 'd':
1515
date.setUTCDate(date.getUTCDate() + dir);
1516
break;
1517
case 'm':
1518
date = Datepicker.prototype.moveMonth.call(Datepicker.prototype, date, dir);
1519
break;
1520
case 'w':
1521
date.setUTCDate(date.getUTCDate() + dir * 7);
1522
break;
1523
case 'y':
1524
date = Datepicker.prototype.moveYear.call(Datepicker.prototype, date, dir);
1525
break
1526
}
1527
}
1528
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0)
1529
}
1530
var parts = date && date.match(this.nonpunctuation) || [],
1531
date = new Date(),
1532
parsed = {},
1533
setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
1534
setters_map = {
1535
yyyy: function(d, v) {
1536
return d.setUTCFullYear(v)
1537
},
1538
yy: function(d, v) {
1539
return d.setUTCFullYear(2000 + v)
1540
},
1541
m: function(d, v) {
1542
v -= 1;
1543
while (v < 0) v += 12;
1544
v %= 12;
1545
d.setUTCMonth(v);
1546
while (d.getUTCMonth() != v) d.setUTCDate(d.getUTCDate() - 1);
1547
return d
1548
},
1549
d: function(d, v) {
1550
return d.setUTCDate(v)
1551
}
1552
},
1553
val, filtered, part;
1554
setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
1555
setters_map['dd'] = setters_map['d'];
1556
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
1557
var fparts = format.parts.slice();
1558
if (parts.length != fparts.length) {
1559
fparts = $(fparts).filter(function(i, p) {
1560
return $.inArray(p, setters_order) !== -1
1561
}).toArray()
1562
}
1563
if (parts.length == fparts.length) {
1564
for (var i = 0, cnt = fparts.length; i < cnt; i++) {
1565
val = parseInt(parts[i], 10);
1566
part = fparts[i];
1567
if (isNaN(val)) {
1568
switch (part) {
1569
case 'MM':
1570
filtered = $(dates[language].months).filter(function() {
1571
var m = this.slice(0, parts[i].length),
1572
p = parts[i].slice(0, m.length);
1573
return m == p
1574
});
1575
val = $.inArray(filtered[0], dates[language].months) + 1;
1576
break;
1577
case 'M':
1578
filtered = $(dates[language].monthsShort).filter(function() {
1579
var m = this.slice(0, parts[i].length),
1580
p = parts[i].slice(0, m.length);
1581
return m == p
1582
});
1583
val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
1584
break
1585
}
1586
}
1587
parsed[part] = val
1588
}
1589
for (var i = 0, s; i < setters_order.length; i++) {
1590
s = setters_order[i];
1591
if (s in parsed && !isNaN(parsed[s])) setters_map[s](date, parsed[s])
1592
}
1593
}
1594
return date
1595
},
1596
formatDate: function(date, format, language) {
1597
var val = {
1598
d: date.getUTCDate(),
1599
D: dates[language].daysShort[date.getUTCDay()],
1600
DD: dates[language].days[date.getUTCDay()],
1601
m: date.getUTCMonth() + 1,
1602
M: dates[language].monthsShort[date.getUTCMonth()],
1603
MM: dates[language].months[date.getUTCMonth()],
1604
yy: date.getUTCFullYear().toString().substring(2),
1605
yyyy: date.getUTCFullYear()
1606
};
1607
val.dd = (val.d < 10 ? '0' : '') + val.d;
1608
val.mm = (val.m < 10 ? '0' : '') + val.m;
1609
var date = [],
1610
seps = $.extend([], format.separators);
1611
for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
1612
if (seps.length) date.push(seps.shift());
1613
date.push(val[format.parts[i]])
1614
}
1615
return date.join('')
1616
},
1617
headTemplate: '<thead>' + '<tr>' + '<th class="prev"><i class="icon-arrow-left"/></th>' + '<th colspan="5" class="switch"></th>' + '<th class="next"><i class="icon-arrow-right"/></th>' + '</tr>' + '</thead>',
1618
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
1619
footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
1620
};
1621
DPGlobal.template = '<div class="datepicker">' + '<div class="datepicker-days">' + '<table class=" table-condensed">' + DPGlobal.headTemplate + '<tbody></tbody>' + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datepicker-months">' + '<table class="table-condensed">' + DPGlobal.headTemplate + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datepicker-years">' + '<table class="table-condensed">' + DPGlobal.headTemplate + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '</div>';
1622
$.fn.datepicker.DPGlobal = DPGlobal
1623
}(window.jQuery);
1624
1625
1626
1627
// Jquery Equal height (http://brm.io/jquery-match-height-demo/)
1628
(function(e) {
1629
var t = -1,
1630
n = -1;
1631
var r = function(t) {
1632
var n = 1,
1633
r = e(t),
1634
s = null,
1635
o = [];
1636
r.each(function() {
1637
var t = e(this),
1638
r = t.offset().top - i(t.css("margin-top")),
1639
u = o.length > 0 ? o[o.length - 1] : null;
1640
if (u === null) {
1641
o.push(t)
1642
} else {
1643
if (Math.floor(Math.abs(s - r)) <= n) {
1644
o[o.length - 1] = u.add(t)
1645
} else {
1646
o.push(t)
1647
}
1648
}
1649
s = r
1650
});
1651
return o
1652
};
1653
var i = function(e) {
1654
return parseFloat(e) || 0
1655
};
1656
var s = function(t) {
1657
var n = {
1658
byRow: true,
1659
remove: false,
1660
property: "height"
1661
};
1662
if (typeof t === "object") {
1663
return e.extend(n, t)
1664
}
1665
if (typeof t === "boolean") {
1666
n.byRow = t
1667
} else if (t === "remove") {
1668
n.remove = true
1669
}
1670
return n
1671
};
1672
var o = e.fn.matchHeight = function(t) {
1673
var n = s(t);
1674
if (n.remove) {
1675
var r = this;
1676
this.css(n.property, "");
1677
e.each(o._groups, function(e, t) {
1678
t.elements = t.elements.not(r)
1679
});
1680
return this
1681
}
1682
if (this.length <= 1) return this;
1683
o._groups.push({
1684
elements: this,
1685
options: n
1686
});
1687
o._apply(this, n);
1688
return this
1689
};
1690
o._groups = [];
1691
o._throttle = 80;
1692
o._maintainScroll = false;
1693
o._beforeUpdate = null;
1694
o._afterUpdate = null;
1695
o._apply = function(t, n) {
1696
var u = s(n),
1697
a = e(t),
1698
f = [a];
1699
var l = e(window).scrollTop(),
1700
c = e("html").outerHeight(true);
1701
var h = a.parents().filter(":hidden");
1702
h.each(function() {
1703
var t = e(this);
1704
t.data("style-cache", t.attr("style"))
1705
});
1706
h.css("display", "block");
1707
if (u.byRow) {
1708
a.each(function() {
1709
var t = e(this),
1710
n = t.css("display") === "inline-block" ? "inline-block" : "block";
1711
t.data("style-cache", t.attr("style"));
1712
t.css({
1713
display: n,
1714
"padding-top": "0",
1715
"padding-bottom": "0",
1716
"margin-top": "0",
1717
"margin-bottom": "0",
1718
"border-top-width": "0",
1719
"border-bottom-width": "0",
1720
height: "100px"
1721
})
1722
});
1723
f = r(a);
1724
a.each(function() {
1725
var t = e(this);
1726
t.attr("style", t.data("style-cache") || "")
1727
})
1728
}
1729
e.each(f, function(t, n) {
1730
var r = e(n),
1731
s = 0;
1732
if (u.byRow && r.length <= 1) {
1733
r.css(u.property, "");
1734
return
1735
}
1736
r.each(function() {
1737
var t = e(this),
1738
n = t.css("display") === "inline-block" ? "inline-block" : "block";
1739
var r = {
1740
display: n
1741
};
1742
r[u.property] = "";
1743
t.css(r);
1744
if (t.outerHeight(false) > s) s = t.outerHeight(false);
1745
t.css("display", "")
1746
});
1747
r.each(function() {
1748
var t = e(this),
1749
n = 0;
1750
if (t.css("box-sizing") !== "border-box") {
1751
n += i(t.css("border-top-width")) + i(t.css("border-bottom-width"));
1752
n += i(t.css("padding-top")) + i(t.css("padding-bottom"))
1753
}
1754
t.css(u.property, s - n)
1755
})
1756
});
1757
h.each(function() {
1758
var t = e(this);
1759
t.attr("style", t.data("style-cache") || null)
1760
});
1761
if (o._maintainScroll) e(window).scrollTop(l / c * e("html").outerHeight(true));
1762
return this
1763
};
1764
o._applyDataApi = function() {
1765
var t = {};
1766
e("[data-match-height], [data-mh]").each(function() {
1767
var n = e(this),
1768
r = n.attr("data-match-height") || n.attr("data-mh");
1769
if (r in t) {
1770
t[r] = t[r].add(n)
1771
} else {
1772
t[r] = n
1773
}
1774
});
1775
e.each(t, function() {
1776
this.matchHeight(true)
1777
})
1778
};
1779
var u = function(t) {
1780
if (o._beforeUpdate) o._beforeUpdate(t, o._groups);
1781
e.each(o._groups, function() {
1782
o._apply(this.elements, this.options)
1783
});
1784
if (o._afterUpdate) o._afterUpdate(t, o._groups)
1785
};
1786
o._update = function(r, i) {
1787
if (i && i.type === "resize") {
1788
var s = e(window).width();
1789
if (s === t) return;
1790
t = s
1791
}
1792
if (!r) {
1793
u(i)
1794
} else if (n === -1) {
1795
n = setTimeout(function() {
1796
u(i);
1797
n = -1
1798
}, o._throttle)
1799
}
1800
};
1801
e(o._applyDataApi);
1802
e(window).bind("load", function(e) {
1803
o._update(false, e)
1804
});
1805
e(window).bind("resize orientationchange", function(e) {
1806
o._update(true, e)
1807
})
1808
})(jQuery);
1809