|
|
|
|
/// <reference path="../Scripts/MicrosoftAjax.js" />
|
|
|
|
|
/// <reference path="../Scripts/jquery.min.js" />
|
|
|
|
|
/// <reference path="jquery.easyui.min.js" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTimeBox = function () {
|
|
|
|
|
this.ApplicationPath = "";
|
|
|
|
|
this.ControlID = "Window_DateTimeBox";
|
|
|
|
|
this.ParentElement = null; //要加入的父容器
|
|
|
|
|
this.Isbgiframe = false;
|
|
|
|
|
var My = this;
|
|
|
|
|
var CalendarID = My.ControlID + "_Calendar";
|
|
|
|
|
var TimespinnerID = My.ControlID + "_Timespinner";
|
|
|
|
|
var cmdSaveID = My.ControlID + "_cmdSave";
|
|
|
|
|
var cmdToDayID = My.ControlID + "_cmdToDay";
|
|
|
|
|
var cmdCloseID = My.ControlID + "_cmdClose";
|
|
|
|
|
var SelectDate = new Date();
|
|
|
|
|
var TextBox = null;
|
|
|
|
|
|
|
|
|
|
//#region 加载
|
|
|
|
|
this.Load = function () {
|
|
|
|
|
Init();
|
|
|
|
|
$(document).click(function () {
|
|
|
|
|
if (window.event.srcElement.id == My.ControlID) return;
|
|
|
|
|
if ($(window.event.srcElement).parents("#" + My.ControlID).length == 0)
|
|
|
|
|
$("#" + My.ControlID, My.ParentElement).hide();
|
|
|
|
|
});
|
|
|
|
|
//选择
|
|
|
|
|
$("#" + cmdSaveID, My.ParentElement).click(function () {
|
|
|
|
|
TextBox.value = SelectDate.localeFormat("yyyy-MM-dd") + " " + $("#" + TimespinnerID).val();
|
|
|
|
|
$("#" + My.ControlID, My.ParentElement).hide();
|
|
|
|
|
});
|
|
|
|
|
//关闭
|
|
|
|
|
$("#" + cmdCloseID, My.ParentElement).click(function () {
|
|
|
|
|
$("#" + My.ControlID, My.ParentElement).hide();
|
|
|
|
|
});
|
|
|
|
|
//今天
|
|
|
|
|
$("#" + cmdToDayID, My.ParentElement).click(function () {
|
|
|
|
|
SelectDate = new Date();
|
|
|
|
|
$("#" + CalendarID, My.ParentElement).calendar("moveTo", new Date());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//#endregion
|
|
|
|
|
//#region 初始化
|
|
|
|
|
function Init() {
|
|
|
|
|
if (My.ParentElement == null) My.ParentElement = $(document.body);
|
|
|
|
|
if ($("#" + My.ControlID, My.ParentElement).length > 0) return;
|
|
|
|
|
var htmlString = new Sys.StringBuilder();
|
|
|
|
|
htmlString.append("<div id='" + My.ControlID + "' style = 'position: absolute;display: none;width:180px;z-index:9999;'>");
|
|
|
|
|
htmlString.append("<table border='1' cellpadding='0' cellspacing='0'>");
|
|
|
|
|
htmlString.append("<tr>");
|
|
|
|
|
htmlString.append("<td><div id='" + CalendarID + "' class='easyui-calendar' style='width:180px;height:180px;'></div></td>");
|
|
|
|
|
htmlString.append("</tr>");
|
|
|
|
|
htmlString.append("<tr>");
|
|
|
|
|
htmlString.append("<td style='text-align: center;background:#e0ecff;'><input id='" + TimespinnerID + "' class='easyui-timespinner' style='width:60px;'></input><input id='" + cmdToDayID + "' type='button' value='今天'></input><input id='" + cmdSaveID + "' type='button' value='确定'></input><input id='" + cmdCloseID + "' type='button' value='关闭'></input></td>");
|
|
|
|
|
htmlString.append("</tr>");
|
|
|
|
|
htmlString.append("</table>");
|
|
|
|
|
htmlString.append("</div>");
|
|
|
|
|
My.ParentElement.append(htmlString.toString());
|
|
|
|
|
$("#" + CalendarID, My.ParentElement).calendar({
|
|
|
|
|
onSelect: function (d) {
|
|
|
|
|
SelectDate = d;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$("#" + TimespinnerID, My.ParentElement).timespinner();
|
|
|
|
|
$("#" + My.ControlID, My.ParentElement).draggable();
|
|
|
|
|
if (My.Isbgiframe == true) $("#" + My.ControlID, My.ParentElement).bgiframe();
|
|
|
|
|
$("#" + TimespinnerID, My.ParentElement).timespinner("setValue", new Date().localeFormat("HH:mm"));
|
|
|
|
|
}
|
|
|
|
|
//#endregion
|
|
|
|
|
//#region 显示
|
|
|
|
|
this.Show = function (obj) {
|
|
|
|
|
TextBox = obj;
|
|
|
|
|
var position = $(TextBox).offset();
|
|
|
|
|
var top=position.top + $(TextBox).height();
|
|
|
|
|
var left=position.left;
|
|
|
|
|
$("#" + My.ControlID, My.ParentElement).css("top", top).css("left", left);
|
|
|
|
|
var value = obj.value;
|
|
|
|
|
if (value.length >= 10) {
|
|
|
|
|
var a = Date.parseInvariant(value.substr(0, 10), "yyyy-MM-dd");
|
|
|
|
|
if (a != null) $("#" + CalendarID, My.ParentElement).calendar("moveTo", a);
|
|
|
|
|
}
|
|
|
|
|
if (value.length == 16) {
|
|
|
|
|
var b = Date.parseInvariant(value.substr(11, 5), "HH:mm");
|
|
|
|
|
if (b == null) {
|
|
|
|
|
$("#" + TimespinnerID, My.ParentElement).timespinner("setValue", new Date().localeFormat("HH:mm"));
|
|
|
|
|
}
|
|
|
|
|
else { $("#" + TimespinnerID, My.ParentElement).timespinner("setValue", value.substr(11, 5)); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$("#" + My.ControlID, My.ParentElement).show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|