123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
-
- Namespace.register("U.Boom.A.P.Calen");
- U.Boom.A.P.Calen.A = function (input) {
- var DateJson = ['一', '二', '三', '四', '五', '六', '日'];
-
-
-
- divs = input.parentNode;
- var div = $$('div', { 'class': 'U_BP_Cal-div', 'tabindex': '0' }, divs);
- div.style.left = input.offsetLeft + "px";
- div.style.top = (input.offsetTop + input.offsetHeight) + "px";
- div.input = input;
-
- div.onblur = function () { $(div).remove(); }
- div.focus();
-
- var divTop = $$('div', { 'class': 'U_BP_Cal-Top' }, div);
- var TopTitle = $$('div', { 'class': 'U_BP_Cal-Top-Title' }, divTop);
- var tYear = $$('div', { 'class': 'U_BP_Cal-Top-tYear' }, TopTitle);
- tYear.onclick = function () { U.Boom.A.P.Calen.A.Close(conetY, this, conet, yearText, monthText, conetDB); }
- var yearText = $$('a', { 'class': 'U_BP_Cal-Top-yearText', 'innerHTML': '年份' }, tYear);
- var yearTitle = $$('a', { 'class': 'U_BP_Cal-Top-yearText', 'innerHTML': '年' }, tYear);
- var tMonths = $$('div', { 'class': 'U_BP_Cal-Top-tMonths' }, TopTitle);
- var tMonth = $$('div', { 'class': 'U_BP_Cal-Top-tMonth' }, tMonths);
- tMonth.onclick = function () { U.Boom.A.P.Calen.A.Close(conetM, this, conet, yearText, monthText, conetDB); }
- var monthText = $$('a', { 'class': 'U_BP_Cal-Top-monthText', 'innerHTML': '月份' }, tMonth);
- var monthTitle = $$('a', { 'class': 'U_BP_Cal-Top-monthText', 'innerHTML': '月' }, tMonth);
-
- var conet = $$('div', { 'class': 'U_BP_Cal-conet', 'i': 'U_BP_Cal-conetD' }, div);
- var conetY = $$('div', { 'class': 'U_BP_Cal-conetY', 'style': { 'cssText': 'display:none;'} }, conet);
- var conetM = $$('div', { 'style': { 'cssText': 'display:none' }, 'class': 'U_BP_Cal-conetM' }, conet);
- var conetD = $$('div', { 'class': 'U_BP_Cal-conetD', 'style': { 'cssText': 'display:block'} }, conet);
- var conetDT = $$('div', { 'class': 'U_BP_Cal-conetDT' }, conetD);
- var conetDB = $$('div', { 'class': 'U_BP_Cal-conetDB' }, conetD);
-
- var tMonthLeft = $$('div', { 'class': 'U_BP_Cal-triangleLeft', 'onclick': [U.Boom.A.P.Calen.A.Ontop, [yearText, monthText, conetDB]] }, tMonths);
- var tMonthRight = $$('div', { 'class': 'U_BP_Cal-triangleRight', 'onclick': [U.Boom.A.P.Calen.A.Onbottom, [yearText, monthText, conetDB]] }, tMonths);
-
- var mydate = U.Boom.A.P.Calen.Date();
-
- U.Boom.A.P.Calen.A.couldY(conetY, mydate['year'] - 5, conetM, conet, yearText);
-
- for (i = 1; i < 13; i++) {
- blockM = $$('div', { 'class': 'U_BP_Cal-blockM', 'innerHTML': i + "月" }, conetM);
- blockM.onclick = function () {
- U.Boom.A.P.Calen.A.Open(conetD, this, conet, yearText, monthText, conetDB);
- }
- }
-
- for (i = 0; i < 7; i++) {
- $$('div', { 'class': 'U_BP_Cal-conetDTT', 'innerHTML': DateJson[i] }, conetDT);
- }
- yearText.innerHTML = mydate['year'];
- monthText.innerHTML = mydate['month'];
-
- U.Boom.A.P.Calen.A.nowMonth(U.Boom.A.P.Calen.Mouth(mydate['year'], mydate['month'], mydate['date'], 7, 5), conetDB, monthText.innerHTML, yearText.innerHTML);
- return div;
- }
- U.Boom.A.P.Calen.A.Default = function (div, html) {
- div.innerHTML = html;
- }
- U.Boom.A.P.Calen.A.click = function (div) {
- (div.style.display != "block") ? div.style.display = "block" : div.style.display = "none";
- div.focus();
-
-
- }
- U.Boom.A.P.Calen.Date = function () {
- var myDate = new Date()
-
- var year = myDate.getFullYear();
- var month = myDate.getMonth() + 1;
- var date = myDate.getDate();
- var day = myDate.getDay();
-
- var hours = myDate.getHours();
- var minutes = myDate.getMinutes();
- var seconds = myDate.getSeconds();
-
- if (minutes <= 9) minutes = "0" + minutes;
- if (seconds <= 9) seconds = "0" + seconds;
-
- var days = { 0: "日", 1: "一", 2: "二", 3: "三", 4: "四", 5: "五", 6: "六" }
- return { "year": year, "month": month, "date": date, "day": days[day], "hours": hours, "minutes": minutes, "seconds": seconds }
- }
- U.Boom.A.P.Calen.A.couldY = function (conetY, nowYear, conetM, conet, yearText) {
-
- var blocks, i, j;
-
- conetY.innerHTML = "";
-
- for (i = 0; i < 4; i++) {
- blocks = $$('div', { 'class': 'U_BP_Cal-blocks' }, conetY);
- for (j = 0; j < 3; j++) {
- block = $$('div', { 'class': 'U_BP_Cal-block', 'innerHTML': nowYear++ }, blocks);
- block.onclick = function () {
- U.Boom.A.P.Calen.A.Open(conetM, this, conet, yearText);
- }
- }
- }
-
- var last, year, blocks, block;
- conetY.onmousewheel = function (event) {
- event = event || window.event;
- if (event.wheelDeltaY == -120) {
- last = conetY.firstChild;
- year = parseInt(conetY.lastChild.lastChild.innerHTML);
- last.parentNode.removeChild(last);
- blocks = $$('div', { 'class': 'U_BP_Cal-blocks' }, conetY);
- for (i = 0; i < 3; i++) {
- year = year + 1;
- $$('div', { 'onclick': 'U.Boom.A.P.Calen.conetM,this)', 'class': 'U_BP_Cal-block', 'innerHTML': year }, blocks);
- }
- }
- if (event.wheelDeltaY == 120) {
- last = conetY.lastChild;
- year = parseInt(conetY.firstChild.firstChild.innerHTML);
- last.parentNode.removeChild(last);
- blocks = $('<div class="U_BP_Cal-blocks"></div>')[0];
- conetY.insertBefore(blocks, conetY.childNodes[0]);
- for (i = 0; i < 3; i++) {
- year = year - 1;
- block = $('<div class="U_BP_Cal-block">' + year + '</div>')[0];
- block.onclick = function () {
- U.Boom.A.P.Calen.A.Open(conetM, this, conet, yearText);
- }
- blocks.insertBefore(block, blocks.childNodes[0]);
- }
- }
- }
- }
- U.Boom.A.P.Calen.A.Open = function (div2, thiss, conet, yearText, monthText, conetDB) {
-
- div = thiss.parentNode.parentNode.parentNode.parentNode.getElementsByClassName(conet.i)[0];
-
- if (thiss.className == "U_BP_Cal-block") {
- yearText.innerHTML = parseInt(thiss.innerHTML);
- }
- if (thiss.className == "U_BP_Cal-blockM") {
- monthText.innerHTML = parseInt(thiss.innerHTML);
- U.Boom.A.P.Calen.A.nowMonth(U.Boom.A.P.Calen.Mouth(yearText.innerHTML, parseInt(thiss.innerHTML), 1, 7, 5), conetDB, monthText.innerHTML, yearText.innerHTML);
- }
- conet.i = div2.className;
-
- div.style.cssText += "transition: 0.3s all;transform: scale(1.3);opacity:0;";
-
- setTimeout(function () {
- div.style.cssText += "transition: 0s all;transform: scale(1);opacity:1;display:none;";
- div2.style.cssText += "transition: 0.2s all;transform: scale(0.6);opacity:0;display:block;";
- setTimeout(function () {
- div2.style.cssText += "transition: 0.2s all;transform: scale(1);opacity:1;display:block;";
- }, 200)
- }, 300)
- }
- U.Boom.A.P.Calen.A.Close = function (div2, thiss, conet, yearText, monthText, conetDB) {
-
- div = thiss.parentNode.parentNode.parentNode.parentNode.getElementsByClassName(conet.i)[0];
-
- conet.i = div2.className;
-
- div.style.cssText += "transition: 0.3s all;transform: scale(0.8);opacity:0;display:block;";
-
- setTimeout(function () {
- div.style.cssText += "transition: 0s all;transform: scale(1);opacity:1;display:none;";
- div2.style.cssText += "transition: 0.2s all;transform: scale(0.8);opacity:0;display:block;";
- setTimeout(function () {
- div2.style.cssText += "transition: 0.2s all;transform: scale(1);opacity:1;display:block;";
- }, 150)
- }, 300)
- }
- U.Boom.A.P.Calen.Mouth = function (year, month, nowDate, across, line) {
- var total = across * line;
- var oldDate = new Date(year, month - 1, 0).getDate();
- var newDate = new Date(year, month, 0).getDate();
- var week = new Date(year + "/" + month + "/" + 1).getDay();
-
- var calNum, calInt;
- if (week == 0) week = 7;
- calNum = 0, calFirst = oldDate - week + 1;
-
- calInt = calFirst, myjson = [];
-
-
- for (i = 0; i < total; i++) {
- if (calNum == 0 && calInt <= oldDate) {
- if (calInt == oldDate) {
- calNum++; calInt = 1;
- myjson.push(calInt); continue;
- } else { calInt++; }
- }
- if (calNum == 1 && calInt <= newDate) {
- if (calInt == newDate) {
- calNum++; calInt = 1;
- myjson.push(calInt); continue;
- } else { calInt++; }
- }
- if (calNum == 2 && i < total) calInt++
- myjson.push(calInt);
- }
- return myjson;
- }
- U.Boom.A.P.Calen.A.nowMonth = function (conetDs, conetDB, monthText, yearText) {
- conetDB.innerHTML = "";
- var firstI = 1;
-
- for (i = 0; i < 35; i++) {
- blockD = $$('div', { 'class': 'U_BP_Cal-blockD', 'innerHTML': conetDs[i] }, conetDB);
- if (conetDs[i] == firstI) {
- firstI++;
- blockD.style.color = "#000";
- month = monthText;
- } else {
- if (firstI == 1) {
- (monthText == 1) ? (yearText = yearText - 1, month = 12) : (month = parseInt(monthText) - 1);
- } else {
- (monthText == 12) ? (yearText = yearText + 1, month = parseInt(monthText)) : (month = parseInt(monthText) + 1);
- }
- }
- blockD.month = month
- blockD.year = yearText;
-
- blockD.onclick = function () {
- var thisColor = this.style.color;
- if (thisColor != "rgb(0, 0, 0)") {
- U.alert("此日期不能选择");
- return;
- }
- div = this.parentNode.parentNode.parentNode.parentNode;
-
- input = div.input;
-
- year = $(".U_BP_Cal-Top-yearText")[0].innerHTML;
- month = parseInt(this.month);
- if (month < 10) month = "0" + month;
- day = parseInt(this.innerHTML);
- if (day < 10) day = "0" + day;
- input.innerHTML = year + '-' + month + '-' + day;
- input.value = year + '-' + month + '-' + day;
- div.blur();
- }
- }
- }
- U.Boom.A.P.Calen.A.Ontop = function (yearText, monthText, conetDB) {
-
- if (monthText.innerHTML == 1) {
- yearText = yearText.innerHTML = parseInt(yearText.innerHTML) - 1;
- monthText = monthText.innerHTML = 12;
- } else {
- yearText = parseInt(yearText.innerHTML);
- monthText = monthText.innerHTML = monthText.innerHTML - 1;
- }
- U.Boom.A.P.Calen.A.nowMonth(U.Boom.A.P.Calen.Mouth(yearText, monthText, 1, 7, 5), conetDB, monthText, yearText);
- }
- U.Boom.A.P.Calen.A.Onbottom = function (yearText, monthText, conetDB) {
-
- if (monthText.innerHTML == 12) {
- yearText = yearText.innerHTML = parseInt(yearText.innerHTML) + 1;
- monthText = monthText.innerHTML = 1;
- } else {
- yearText = parseInt(yearText.innerHTML);
- monthText = monthText.innerHTML = parseInt(monthText.innerHTML) + 1;
- }
-
- U.Boom.A.P.Calen.A.nowMonth(U.Boom.A.P.Calen.Mouth(yearText, monthText, 1, 7, 5), conetDB, monthText, yearText);
- }
|