📄 zptime-utils.js
字号:
// $Id: zptime-utils.js 6651 2007-03-19 10:15:22Z slip $/** * * Copyright (c) 2004-2006 by Zapatec, Inc. * http://www.zapatec.com * 1700 MLK Way, Berkeley, California, * 94709, U.S.A. * All rights reserved. *//** * Parses given DOM element to save references into objects properties. * All the elements to be saved as a reference had to have a word starting * with 'area' in there class name. So for example an element with class name * areaTitle will be parsed into this.title property and those className will * be removed. * @param el [HTML element] - element to parse; * @return - true if success, otherwise false; */Zapatec.TimeSelect.prototype.parseDom = function(el) { var classes = ""; //the el needs to be a DOM HTML element if (!Zapatec.isHtmlElement(el)) { return false; } //seeks the elements with the className starting with word 'area', //extracts the rest part of this class name, creates the reference //(a property of the object) with such name, removes this class. //I didn't knew which way to mark the elements which needed to have reference //in our object, and decided (by advise) to use className starting with 'area'. //Example: 'areaContent', 'areaTitle', etc. will create this.content, this.title, etc. if (el.className) { classes = el.className.match(/area(\w+)/); //this way we mark all the elements which belong to the widget with a reference to it. el.win = true; if (classes) { el.id = "zpTime" + this.id + classes[1]; classes[1] = classes[1].charAt(0).toLowerCase() + classes[1].substring(1); if (!Zapatec.isArray(this[classes[1]])) { this.createProperty(this, classes[1], el); } else { this[classes[1]].push(el); } Zapatec.Utils.removeClass(el, classes[0]); } } //to go through all the childs we use recursive calls of this function for every child. var child = el.firstChild; while(child) { this.parseDom(child); child = child.nextSibling; } return true;};/** * Shows the specified button of the window. * @param button {string} string pointing to button name. */Zapatec.TimeSelect.prototype.showButton = function(button) { this.restorer.restoreProp(button + ".getContainer().parentNode.style.display");};/** * Hides the specified button of the window. * @param button {string} string pointing to button name. */Zapatec.TimeSelect.prototype.hideButton = function(button) { this.restorer.saveProp(button + ".getContainer().parentNode.style.display"); this[button].getContainer().parentNode.style.display = "none";};/** * Shows the given control. * @param control {string} string representing control. */Zapatec.TimeSelect.prototype.showControl = function(control) { this.showButton(control + "Select"); this.showButton(control + "Up"); this.showButton(control + "Down");};/** * Hides the given control. * @param control {string} string representing control. */Zapatec.TimeSelect.prototype.hideControl = function(control) { this.hideButton(control + "Select"); this.hideButton(control + "Up"); this.hideButton(control + "Down");};/** * Reconfigurating the object due to the config options. */Zapatec.TimeSelect.prototype.reconfig = function() { if (!this.fireOnState("loaded", function() {this.reconfig();})) { return; } var config = this.getConfiguration(); //filling separators var separators = Zapatec.Array(this.separators); separators.each(function(index, separator) { separator.innerHTML = config.separator; }); //hiding buttons if needed, otherwise showing them //hours controls if (config.showHours) { this.showControl("hours"); } else { this.hideControl("hours"); } //minutes controls if (config.showMinutes) { this.showControl("minutes"); } else { this.hideControl("minutes"); } //seconds controls if (config.showSeconds) { this.showControl("seconds"); } else { this.hideControl("seconds"); } //ampm select if (config.timeFormat == "12") { this.showButton("ampmSelect"); this.restorer.restoreProp("emptySeparator.style.display"); } else { this.hideButton("ampmSelect"); this.restorer.saveProp("emptySeparator.style.display"); this.emptySeparator.style.display = "none"; } //toggling separators if ((config.showHours && config.showMinutes) || (config.showHours && config.showSeconds)) { this.restorer.restoreProp("separators[0].style.display"); } else { this.restorer.saveProp("separators[0].style.display"); this.separators[0].style.display = "none"; } if (config.showMinutes && config.showSeconds) { this.restorer.restoreProp("separators[1].style.display"); } else { this.restorer.saveProp("separators[1].style.display"); this.separators[1].style.display = "none"; }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -