?? calendar-core.js
字號:
hc.appendChild(h); if (h.histDate.dateEqualsTo(cal.date)) Zapatec.Utils.addClass(h, "active"); } } cd = cal.activeDiv; s = hc.style; s.display = "block"; s.left = Math.floor(cd.offsetLeft + (cd.offsetWidth-hc.offsetWidth)/2) + "px"; s.top = (cd.offsetTop + cd.offsetHeight) + "px"; cal.updateWCH(hc); cal.bEventShowHistory=true; // Set state the we DID enter History event};/** * Displays the years combo box for the active calendar. The "fwd" parameter * tells it if it should display future (right) or past (left) years. * * @param fwd [boolean] true if it's for the right combo (future), false * otherwise. */Zapatec.Calendar.showYearsCombo = function (fwd) { var cal = Zapatec.Calendar._C; if (!cal) { return false; } var cd = cal.activeDiv; var yc = cal.yearsCombo; if (cal.hilitedYear) { Zapatec.Utils.removeClass(cal.hilitedYear, "hilite"); } if (cal.activeYear) { Zapatec.Utils.removeClass(cal.activeYear, "active"); } cal.activeYear = null; var Y = cal.date.getFullYear() + (fwd ? 1 : -1); var yr = yc.firstChild; var show = false; for (var i = 12; i > 0; --i) { if (Y >= cal.minYear && Y <= cal.maxYear) { yr.firstChild.data = Y; yr.year = Y; yr.style.display = "block"; show = true; } else { yr.style.display = "none"; } yr = yr.nextSibling; Y += fwd ? cal.yearStep : -cal.yearStep; } if (show) { var s = yc.style; s.display = "block"; if (cd.navtype < 0) s.left = cd.offsetLeft + "px"; else { var ycw = yc.offsetWidth; if (typeof ycw == "undefined") // Konqueror brain-dead techniques ycw = 50; s.left = (cd.offsetLeft + cd.offsetWidth - ycw) + "px"; } s.top = (cd.offsetTop + cd.offsetHeight) + "px"; } cal.updateWCH(yc);};// event handlers/** * This is an event handler that gets called when the mouse button is released * upon the document. The name (tableMouseUp) is because of historic reasons * (in the initial calendar versions this event was triggered by the calendar * table, but now it's the document who does it). * * This function does a number of things. It determines which is the element * that was actually clicked. Note that the "mouseup" event usually means * "something was clicked"; it's "mouseup" who fires the "onclick" event, not * "mousedown" ;-). So, if the clicked element is a member of one of the combo * boxes such as month, year or history, then the appropriate action is taken * (switch month, year or go to history date). * * Also, the Zapatec.Calendar.cellClick() function is called, which further * examines the target element and might do other things. * * Finally, this handler deregisters itself (it's automatically enabled at * "mousedown" on document), stops the event propagation, sets the static _C * variable to \em null (meaning "no calendar is currently in use"). * * @param ev [Event] the event object * @return false */Zapatec.Calendar.tableMouseUp = function(ev) { var cal = Zapatec.Calendar._C; if (!cal) { return false; } if (cal.timeout) { clearTimeout(cal.timeout); } var el = cal.activeDiv; if (!el) { return false; } var target = Zapatec.Utils.getTargetElement(ev); if (typeof(el.navtype) == "undefined") { while(target && !target.calendar) { target = target.parentNode; } } ev || (ev = window.event); Zapatec.Utils.removeClass(el, "active"); if (target == el || target.parentNode == el) { Zapatec.Calendar.cellClick(el, ev); } var mon = Zapatec.Calendar.findMonth(target); var date = null; if (mon) { if (!mon.disabled) { date = new Date(cal.date); if (mon.month != date.getMonth()) { date.setMonth(mon.month); cal.setDate(date, true); cal.dateClicked = false; cal.callHandler(); } } } else { var year = Zapatec.Calendar.findYear(target); if (year) { date = new Date(cal.date); if (year.year != date.getFullYear()) { date.setFullYear(year.year); cal.setDate(date, true); cal.dateClicked = false; cal.callHandler(); } } else { var hist = Zapatec.Calendar.findHist(target); if (hist && !hist.histDate.dateEqualsTo(cal.date)) { //(date = new Date(cal.date)).setDateOnly(hist.histDate); date = new Date(hist.histDate); cal._init(cal.firstDayOfWeek, cal.date = date); cal.dateClicked = false; cal.callHandler(); cal.updateHistory(); } } } Zapatec.Utils.removeEvent(window.document, "mouseup", Zapatec.Calendar.tableMouseUp); Zapatec.Utils.removeEvent(window.document, "mouseover", Zapatec.Calendar.tableMouseOver); Zapatec.Utils.removeEvent(window.document, "mousemove", Zapatec.Calendar.tableMouseOver); cal._hideCombos(); Zapatec.Calendar._C = null; return Zapatec.Utils.stopEvent(ev);};/** * Event handler that gets called when the end-user moves the mouse over the * document. * * This function is pretty complicated too. It adds hover/active state class * to elements that are highlighted and/or clicked. It determines whether one * is trying to modify the time by "drag'n'drop" (the original interface * implemented by the calendar). Finally, it determines if the * mouse is over combo box items, also adding/removing hover states and setting * some calendar variables with reference to the element involved. * * @param ev * */Zapatec.Calendar.tableMouseOver = function (ev) { var cal = Zapatec.Calendar._C; if (!cal) { return; } var el = cal.activeDiv; var target = Zapatec.Utils.getTargetElement(ev); if (target == el || target.parentNode == el) { Zapatec.Utils.addClass(el, "hilite active"); Zapatec.Utils.addClass(el.parentNode, "rowhilite"); } else { if (typeof el.navtype == "undefined" || (el.navtype != 50 && ((el.navtype == 0 && !cal.histCombo) || Math.abs(el.navtype) > 2))) Zapatec.Utils.removeClass(el, "active"); Zapatec.Utils.removeClass(el, "hilite"); Zapatec.Utils.removeClass(el.parentNode, "rowhilite"); } ev || (ev = window.event); if (el.navtype == 50 && target != el) { var pos = Zapatec.Utils.getAbsolutePos(el); var w = el.offsetWidth; var x = ev.clientX; var dx; var decrease = true; if (x > pos.x + w) { dx = x - pos.x - w; decrease = false; } else dx = pos.x - x; if (dx < 0) dx = 0; var range = el._range; var current = el._current; var date = cal.currentDate; var pm = (date.getHours() >= 12); var old = el.firstChild.data; // old value of the element var count = Math.floor(dx / 10) % range.length; for (var i = range.length; --i >= 0;) if (range[i] == current) break; while (count-- > 0) if (decrease) { if (--i < 0) { i = range.length - 1; } } else if ( ++i >= range.length ) { i = 0; } //ALLOWED TIME CHECK if (cal.getDateStatus) { //Current time is changing, check with the callback to see if it's in range of allowed times // Fills the "minute" and "hour" variables with the time that user wants to set, to pass them to the dateStatusHandler for verification. // As the script passes hours in 24 format, we need to convert input values if they are not in the needed format. var minute = null; // minutes to be passed var hour = null; // hours to be passed var new_date = new Date(date); // as we pass date element to the handler, we need to create new one and fill it with new minutes or hours (depending on what had changed) // if "ampm" was clicked if (el.className.indexOf("ampm", 0) != -1) { minute = date.getMinutes(); // minutes didn't change // if the "ampm" value has changed we need to correct hours (add 12 or exclude 12 or set it to zero) if (old != range[i]) { hour = (range[i] == Zapatec.Calendar.i18n("pm", "ampm")) ? ((date.getHours() == 0) ? (12) : (date.getHours() + 12)) : (date.getHours() - 12); } else { hour = date.getHours(); } // updates our new Date object that will be passed to the handler new_date.setHours(hour); } // if hours were clicked if (el.className.indexOf("hour", 0) != -1) { minute = date.getMinutes(); // minutes didn't change hour = (!cal.time24) ? ((pm) ? ((range[i] != 12) ? (parseInt(range[i], 10) + 12) : (12)) : ((range[i] != 12) ? (range[i]) : (0))) : (range[i]); // new value of hours new_date.setHours(hour); } // if minutes were clicked if (el.className.indexOf("minute", 0) != -1) { hour = date.getHours(); // hours didn't change minute = range[i]; // new value of minutes new_date.setMinutes(minute); } } var status = false; // if the handler is set, we pass new values and retrieve result in "status" variable if (cal.getDateStatus) { status = cal.getDateStatus(new_date, date.getFullYear(), date.getMonth(), date.getDate(), parseInt(hour, 10), parseInt(minute, 10)); } // if time is enabled, we set new value if (status == false) { if ( !((!cal.time24) && (range[i] == Zapatec.Calendar.i18n("pm", "ampm")) && (hour > 23)) ) { el.firstChild.data = range[i]; } } cal.onUpdateTime(); //END OF ALLOWED TIME CHECK } var mon = Zapatec.Calendar.findMonth(target); if (mon) { if (!mon.disabled) { if (mon.month != cal.date.getMonth()) { if (cal.hilitedMonth) { Zapatec.Utils.removeClass(cal.hilitedMonth, "hilite"); } Zapatec.Utils.addClass(mon, "hilite"); cal.hilitedMonth = mon; } else if (cal.hilitedMonth) { Zapatec.Utils.removeClass(cal.hilitedMonth, "hilite"); } } } else { if (cal.hilitedMonth) { Zapatec.Utils.removeClass(cal.hilitedMonth, "hilite"); } var year = Zapatec.Calendar.findYear(target); if (year) { if (year.year != cal.date.getFullYear()) { if (cal.hilitedYear) { Zapatec.Utils.removeClass(cal.hilitedYear, "hilite"); } Zapatec.Utils.addClass(year, "hilite"); cal.hilitedYear = year; } else if (cal.hilitedYear) { Zapatec.Utils.removeClass(cal.hilitedYear, "hilite"); } } else { if (cal.hilitedYear) { Zapatec.Utils.removeClass(cal.hilitedYear, "hilite"); } var hist = Zapatec.Calendar.findHist(target); if (hist) { if (!hist.histDate.dateEqualsTo(cal.date)) { if (cal.hilitedHist) { Zapatec.Utils.removeClass(cal.hilitedHist, "hilite"); } Zapatec.Utils.addClass(hist, "hilite"); cal.hilitedHist = hist; } else if (cal.hilitedHist) { Zapatec.Utils.removeClass(cal.hilitedHist, "hilite"); } } else if (cal.hilitedHist) { Zapatec.Utils.removeClass(cal.hilitedHist, "hilite"); } } } return Zapatec.Utils.stopEvent(ev);};/** * This is a simple function that stops a "mousedown" related to the calendar's * table element. This helps avoiding text selection in certain browsers (most * notably, Safari, since Mozilla already has a better way). * * @param ev [Event] the Event object * @return false */Zapatec.Calendar.tableMouseDown = function (ev) { if (Zapatec.Utils.getTargetElement(ev) == Zapatec.Utils.getElement(ev)) { return Zapatec.Utils.stopEvent(ev); }};/** * \defgroup dndmove Drag'n'drop (move calendar) functions * * Contains some functions that implement calendar "drag'n'drop" facility which * allows one to move the calendar around the browser's view. *///@{/** * Called at mouseover and/or mousemove on document, this function repositions * the calendar according to the current mouse position. * * @param ev [Event] The Event object * @return false */Zapatec.Calendar.calDragIt = function (ev) { ev || (ev = window.event); var cal = Zapatec.Calendar._C; if (!cal) { Zapatec.Calendar.calDragEnd(); } if (!cal.disableDrag) { if (!(cal && cal.dragging)) { return false; } var posX = ev.clientX + window.document.body.scrollLeft; var posY = ev.clientY + window.document.body.scrollTop; cal.hideShowCovered(); var st = cal.element.style, L = posX - cal.xOffs, T = posY - cal.yOffs; st.left = L + "px"; st.top = T + "px"; Zapatec.Utils.setupWCH(cal.WCH, L, T); } return Zapatec.Utils.stopEvent(ev);};/** * Gets called when the drag and drop operation is finished; thus, at * "onmouseup". This function unregisters D'n'D event handlers and calls * Zapatec.Calendar.hideShowCovered() which repaints as appropriate any * "windowed controls" that might have been hidden by the end user moving the
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -