PluginProbe
Survey Maker by AYS / 5.2.4.1
Survey Maker by AYS v5.2.4.1
5.2.4.1 5.2.4.0 5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 All 154 releases
survey-maker / public / js / survey-maker-timepicker.js

survey-maker-timepicker.js in Survey Maker by AYS 5.2.4.1, at public/js/survey-maker-timepicker.js

73 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*!
2 * Bootstrap Timepicker
3 * @author Amir Hussain
4 **/
5 var bstptid = '';
6 !function (t, i) {
7 "function" == typeof define && define.amd ? define(["jquery"], i) : "object" == typeof exports ? module.exports = i(require("jquery")) : t.$ = i(t.jQuery)
8 }(this, function (t) {
9 "use strict";
10 var i = function (t) {
11 return t >= 10 ? t + "" : "0" + t
12 }, e = /^[0-9]{1,2}:[0-9]{1,2}$/, s = {}, n = function () {
13 }, o = new Array(24).fill(null).map(function (t, e) {
14 var s = i(e);
15 return '<li class="cell-2 js-hour-cell" data-val="' + s + '">' + s + "</li>"
16 }).join(""), c = new Array(12).fill(null).map(function (t, e) {
17 var s = i(5 * e);
18 return '<li class="cell-2 js-minute-cell" data-val="' + s + '">' + s + "</li>"
19 }).join(""),
20 l = t('<div class="timepicker">\t\t<div v-show class="title">Select Time <span class="clear-timepicker">X</span></div>\t\t\t<div class="chose-all">\t\t\t\t<div class="handle">\t\t\t\t\t<div class="cell-4"><a class="icon-up js-plus-houer"></a></div>\t\t\t\t\t<div class="cell-2"></div>\t\t\t\t\t<div class="cell-4"><a class="icon-up js-plus-minute"></a></div>\t\t\t\t</div>\t\t\t\t<div class="text">\t\t\t\t\t<div class="cell-4"><a class="js-hour-show" title="选择时"></a></div>\t\t\t\t\t<div class="cell-2">:</div>\t\t\t\t\t<div class="cell-4"><a class="js-minute-show" title="Select Time"></a></div>\t\t\t\t</div>\t\t\t\t<div class="handle">\t\t\t\t\t<div class="cell-4"><a class="icon-down js-minus-houer"></a></div>\t\t\t\t\t<div class="cell-2"></div>\t\t\t\t\t<div class="cell-4"><a class="icon-down js-minus-minute"></a></div>\t\t\t\t</div>\t\t\t</div>\t\t\t<div class="chose-hour">\t\t\t\t<ul class="handle">' + o + '</ul>\t\t\t</div>\t\t\t<div class="chose-minute">\t\t\t\t<ul class="handle">' + c + "</ul>\t\t\t</div>\t\t</div>\t</div>");
21 return l.find("a").attr("href", "javascript:void(0);"), s.content = l, s.title = l.find(".title"), s.choseAll = l.find(".chose-all"), s.choseMinute = l.find(".chose-minute"), s.choseHour = l.find(".chose-hour"), s.hourShow = l.find(".js-hour-show"), s.minuteShow = l.find(".js-minute-show"), s.update = function () {
22 return bstptid.val(i(this.hour) + ":" + i(this.minute)), this.minuteShow.text(i(this.minute)), this.hourShow.text(i(this.hour)), this.inputTarget.$timepickerUpdate(), this
23 }, s.bindEvent = function () {
24 var t = this;
25 t.hasBind || (t.hasBind = !0, this.content.on("click", ".js-minus-minute", function () {
26 t.minute <= 0 ? t.minute = 59 : t.minute--, t.update()
27 }).on("click", ".js-plus-minute", function () {
28 t.minute >= 59 ? t.minute = 0 : t.minute++, t.update()
29 }).on("click" , '.clear-timepicker', function(){
30 var parent = $(this).parents('.ays-survey-question-time-input-box');
31 parent.find('.ays-survey-timepicker').val("");
32 }).on("click", ".js-plus-houer", function () {
33 t.hour >= 23 ? t.hour = 0 : t.hour++, t.update()
34 }).on("click", ".js-minus-houer", function () {
35 t.hour <= 0 ? t.hour = 23 : t.hour--, t.update()
36 }).on("click", ".js-minute-cell", function () {
37 t.minute = +this.getAttribute("data-val"), t.update(), t.choseMinute.hide(), t.choseAll.show(), t.title.text("Select Time"), t.title.append('<span class="clear-timepicker">X</span>')
38 }).on("click", ".js-hour-cell", function () {
39 t.hour = +this.getAttribute("data-val"), t.update(), t.choseHour.hide(), t.choseAll.show(), t.title.text("Select Time"),t.title.append('<span class="clear-timepicker">X</span>')
40 }).on("click", function (t) {
41 t.stopPropagation()
42 }), t.hourShow.on("click", function () {
43 t.choseAll.hide(), t.choseHour.show(), t.title.text("Select Time"),t.title.append('<span class="clear-timepicker">X</span>')
44 }), t.minuteShow.on("click", function () {
45 t.choseAll.hide(), t.choseMinute.show(), t.title.text("Select Time"),t.title.append('<span class="clear-timepicker">X</span>')
46 }))
47 }, t.timepicker = s, t.fn.timepicker = function (i) {
48 var s, o, c = this, l = t.timepicker, u = t("html");
49 if (this[0].nodeName && "INPUT" === this[0].nodeName) return this.$timepickerUpdate = n, this.off("click").on("click", function (i) {
50 var n = this.value;
51 bstptid = $(this);
52 e.test(n) ? (n = n.split(":"), s = +n[0], o = +n[1]) : (n = new Date, s = n.getHours(), o = n.getMinutes());
53 if ($(this).closest('table').length > 0) {
54 var pos = $(this).offset();
55 var h = pos.left + "px", a = pos.top + this.offsetHeight + "px";
56 } else {
57 var h = this.offsetLeft + "px", a = this.offsetTop + this.offsetHeight + "px";
58 }
59 l.inputTarget = c, l.content.appendTo(this.offsetParent).css({
60 left: h,
61 top: a
62 }), l.hour = s, l.minute = o, l.choseAll.show(), l.choseHour.hide(), l.choseMinute.hide(), l.update(), t.timepicker.bindEvent(), i.stopPropagation(), u.one("click", function () {
63 l.content.off().remove(), l.hasBind = !1
64 })
65 }), this.off("keydown").on("keydown", function () {
66 return !1
67 }), this.update = function (i) {
68 t.isFunction(i) ? this.$timepickerUpdate = i : this.$timepickerUpdate = n
69 }, this
70 }, t
71 });
72
73