[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
simpeg
/
zapatec
/
zptime
/
zptime
/
jsdocs
/
[
Home
]
File: overview-summary-zptime-controlling.js.html
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"> <html> <head> <title> Zapatec Time Overview </title> <link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <script> function asd() { parent.document.title="zptime-controlling.js Overview"; } </script> </head> <body bgcolor="white" onload="asd();"> <!-- ========== START OF NAVBAR ========== --> <a name="navbar_top"><!-- --></a> <table border="0" width="100%" cellpadding="1" cellspacing="0"> <tr> <td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1"> <a name="navbar_top_firstrow"><!-- --></a> <table border="0" cellpadding="0" cellspacing="3"> <tr align="center" valign="top"> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td> <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td> </tr> </table> </td> <td bgcolor="#EEEEFF" align="right" valign="top"> <em> <b>Zapatec Time</b></em> </td> </tr> <tr> <td bgcolor="white" class="NavBarCell2"><font size="-2"> PREV NEXT</font></td> <td bgcolor="white" class="NavBarCell2"><font size="-2"> <a href="index.html" target="_top"><b>FRAMES</b></a> <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> <script> <!-- if(window==top) { document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--> </script> <noscript> <a href="allclasses-noframe.html" target=""><b>All Classes</b></a> </noscript> </font></td> </tr> </table> <!-- =========== END OF NAVBAR =========== --> <hr> <center> <h2>zptime-controlling.js</h2> </center> <h4>Summary</h4> <p> No overview generated for 'zptime-controlling.js'<BR/><BR/> </p> <hr> <!-- ========== METHOD SUMMARY =========== --> <!-- ========== END METHOD SUMMARY =========== --> <pre class="sourceview"><span class="comment">//$Id: zptime-controlling.js 6651 2007-03-19 10:15:22Z slip $</span> <span class="comment">/** * Sets the time from the given date and * replaces config.date with it if copy * parameter is false. * <span class="attrib">@param</span> date {object} date object. * <span class="attrib">@param</span> replace {boolean} should we replace * date object or just copy time. * <span class="attrib">@return</span> {boolean} true if success, otherwise false. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.setTime = <span class="reserved">function</span>(date, replace) { <span class="comment">//geting configuration</span> var config = <span class="reserved">this</span>.getConfiguration(); <span class="comment">//if not date passed taking one from the config</span> <span class="reserved">if</span> (!Zapatec.isDate(date)) { date = config.date; } <span class="comment">//rounding time to time interval</span> <span class="reserved">this</span>._roundDate(date); <span class="comment">//checking the availability of the date</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkDate(date) == <span class="literal">"disabled"</span>) { <span class="reserved">return</span> false; } <span class="reserved">if</span> (replace) { <span class="comment">//replacing date</span> config.date = date; } <span class="reserved">else</span> { <span class="comment">//copying time</span> config.date.setHours(date.getHours()); config.date.setMinutes(date.getMinutes()); config.date.setSeconds(date.getSeconds()); } <span class="comment">//updating time view</span> <span class="reserved">this</span>._updateTime(); <span class="comment">//updating controls(some of them may become disabled)</span> <span class="reserved">this</span>._updateControls(); <span class="comment">//toggling shift button if the mouse pointer is over some select</span> <span class="reserved">this</span>._toggleShift(); <span class="comment">//firing onTimeChange event</span> <span class="reserved">this</span>.fireEvent(<span class="literal">"onTimeChange"</span>, config.date); <span class="comment">//returning success</span> <span class="reserved">return</span> true; }; <span class="comment">/** * Sets the first enabled time. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.setFirstEnabledTime = <span class="reserved">function</span>() { <span class="comment">//getting configuration</span> var config = <span class="reserved">this</span>.getConfiguration(), <span class="comment">//copying date</span> date = new Date(config.date), i = 0; <span class="comment">//if can not set config time then starting loop</span> <span class="reserved">if</span> (!<span class="reserved">this</span>.setTime()) { <span class="comment">//reseting time</span> date.setHours(0); date.setMinutes(0); date.setSeconds(0); <span class="comment">//looping through one day</span> <span class="reserved">for</span>(i = 1; i < 288; ++i) { <span class="comment">//if can set then stop the loop</span> <span class="reserved">if</span> (<span class="reserved">this</span>.setTime(date)) { break; } <span class="comment">//taking next time with 5 minute interval</span> date.setTime(date.getTime() + 300000); } } }; <span class="comment">/** * Sets hours of our date object and updates view. * <span class="attrib">@param</span> hours {number} the number to be set as new hours. * <span class="attrib">@return</span> {boolean} true if success, otherwise false. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.setHours = <span class="reserved">function</span>(hours) { <span class="comment">//getting configuration</span> var config = <span class="reserved">this</span>.getConfiguration(); <span class="comment">//copying date object</span> var date = new Date(config.date); <span class="comment">//setting hours in it</span> date.setHours(hours); <span class="comment">//setting new time</span> <span class="reserved">return</span> <span class="reserved">this</span>.setTime(date); }; <span class="comment">/** * Sets minutes of our date object and updates view. * <span class="attrib">@param</span> minutes {number} the number to be set as new minutes. * <span class="attrib">@return</span> {boolean} true if success, otherwise false. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.setMinutes = <span class="reserved">function</span>(minutes) { <span class="comment">//getting configuration</span> var config = <span class="reserved">this</span>.getConfiguration(); <span class="comment">//copying date object</span> var date = new Date(config.date); <span class="comment">//setting minutes in it</span> date.setMinutes(minutes); <span class="comment">//setting new time</span> <span class="reserved">return</span> <span class="reserved">this</span>.setTime(date); }; <span class="comment">/** * Sets seconds of our date object and updates view. * <span class="attrib">@param</span> seconds {number} the number to be set as new seconds. * <span class="attrib">@return</span> {boolean} true if success, otherwise false. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.setSeconds = <span class="reserved">function</span>(seconds) { <span class="comment">//getting configuration</span> var config = <span class="reserved">this</span>.getConfiguration(); <span class="comment">//copying date object</span> var date = new Date(config.date); <span class="comment">//setting seconds in it</span> date.setSeconds(seconds); <span class="comment">//setting new time</span> <span class="reserved">return</span> <span class="reserved">this</span>.setTime(date); }; <span class="comment">/** * Gets hours selected. * <span class="attrib">@return</span> {number} hours. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.getHours = <span class="reserved">function</span>() { <span class="reserved">return</span> <span class="reserved">this</span>.getConfiguration().date.getHours(); }; <span class="comment">/** * Gets minutes selected. * <span class="attrib">@return</span> {number} hours. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.getMinutes = <span class="reserved">function</span>() { <span class="reserved">return</span> <span class="reserved">this</span>.getConfiguration().date.getMinutes(); }; <span class="comment">/** * Gets seconds selected. * <span class="attrib">@return</span> {number} hours. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.getSeconds = <span class="reserved">function</span>() { <span class="reserved">return</span> <span class="reserved">this</span>.getConfiguration().date.getSeconds(); }; <span class="comment">/** * Update the time displayed. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>._updateTime = <span class="reserved">function</span>() { <span class="reserved">if</span> (!<span class="reserved">this</span>.fireOnState(<span class="literal">"loaded"</span>, <span class="reserved">function</span>() {<span class="reserved">this</span>._updateTime();})) { <span class="reserved">return</span>; } <span class="comment">//getting configuration</span> var config = <span class="reserved">this</span>.getConfiguration(); var val = null, hours = minutes = seconds = 0, pm = false; <span class="comment">//updating hours</span> <span class="reserved">if</span> (config.showHours) { <span class="comment">//trying to handle hours format</span> hours = config.date.getHours(); <span class="reserved">if</span> (config.timeFormat == <span class="literal">"12"</span>) { pm = (hours > 11); <span class="reserved">if</span> (pm && hours != 12) {hours -= 12;} <span class="reserved">if</span> (!pm && hours === 0) {hours = 12;} <span class="comment">//if it is 12 hour format we need to update ampm control</span> <span class="reserved">this</span>.ampmSelect.setText(pm ? <span class="literal">"PM"</span> : <span class="literal">"AM"</span>); } <span class="comment">//setting hours</span> val = (hours > 9) ? hours : <span class="literal">"0"</span> + hours; <span class="reserved">this</span>.hoursSelect.setText(val); } <span class="comment">//updating minutes</span> <span class="reserved">if</span> (config.showMinutes) { minutes = config.date.getMinutes(); val = (minutes > 9) ? minutes : <span class="literal">"0"</span> + minutes; <span class="reserved">this</span>.minutesSelect.setText(val); } <span class="comment">//updating seconds</span> <span class="reserved">if</span> (config.showSeconds) { seconds = config.date.getSeconds(); val = (seconds > 9) ? seconds : <span class="literal">"0"</span> + seconds; <span class="reserved">this</span>.secondsSelect.setText(val); } }; <span class="comment">/** * Updates controls, meaning that it will * toggle(disable or enable) all controls * due to timeStatus and timeInterval. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>._updateControls = <span class="reserved">function</span>() { <span class="reserved">if</span> (!<span class="reserved">this</span>.fireOnState(<span class="literal">"loaded"</span>, <span class="reserved">function</span>() {<span class="reserved">this</span>._updateControls();})) { <span class="reserved">return</span>; } <span class="comment">//getting configuration</span> var config = <span class="reserved">this</span>.getConfiguration(); var self = <span class="reserved">this</span>; <span class="comment">//function to toggle control</span> <span class="reserved">function</span> toggleControl(control) { var date = new Date(config.date); <span class="comment">//making capital letter value</span> var cont = control.charAt(0).toUpperCase() + control.slice(1); <span class="comment">//getting part date value</span> var val = self[<span class="literal">"get"</span> + cont](); <span class="comment">//taking select</span> var select = self[control + <span class="literal">"Select"</span>]; <span class="comment">//checking plus step</span> date[<span class="literal">"set"</span> + cont](val + 1); select.noShiftEnabled = (self.checkDate(date) == <span class="literal">"disabled"</span>) ? false : true; <span class="comment">//renewing the date</span> date = new Date(config.date); <span class="comment">//checking minus step</span> date[<span class="literal">"set"</span> + cont](val - 1); select.shiftEnabled = (self.checkDate(date) == <span class="literal">"disabled"</span>) ? false : true; <span class="comment">//taking arrows</span> var upArrow = self[control + <span class="literal">"Up"</span>]; var downArrow = self[control + <span class="literal">"Down"</span>]; <span class="comment">//getting step</span> var step = self._getStep(control, <span class="literal">"plus"</span>); <span class="comment">//renewing the date</span> date = new Date(config.date); <span class="comment">//toggling up arrow</span> date[<span class="literal">"set"</span> + cont](val + step); <span class="reserved">if</span> (self.checkDate(date) == <span class="literal">"disabled"</span>) { upArrow.disable(); } <span class="reserved">else</span> { upArrow.enable(); } <span class="comment">//getting step</span> step = self._getStep(control, <span class="literal">"minus"</span>); <span class="comment">//renewing the date</span> date = new Date(config.date); <span class="comment">//toggling down arrow</span> date[<span class="literal">"set"</span> + cont](val - step); <span class="reserved">if</span> (self.checkDate(date) == <span class="literal">"disabled"</span>) { downArrow.disable(); } <span class="reserved">else</span> { downArrow.enable(); } } <span class="comment">//no status function - no action</span> <span class="reserved">if</span> (config.timeStatus) { <span class="comment">//togling seconds</span> <span class="reserved">if</span> (config.showSeconds) { toggleControl(<span class="literal">"seconds"</span>); } <span class="comment">//toggling minutes</span> <span class="reserved">if</span> (config.showMinutes) { toggleControl(<span class="literal">"minutes"</span>); } <span class="comment">//toggling hours</span> <span class="reserved">if</span> (config.showHours) { toggleControl(<span class="literal">"hours"</span>); } } <span class="reserved">if</span> (config.timeInterval) { <span class="comment">//disable controlling of seconds</span> <span class="reserved">this</span>.secondsSelect.shiftEnabled = false; <span class="reserved">this</span>.secondsSelect.noShiftEnabled = false; <span class="reserved">this</span>.secondsUp.disable(); <span class="reserved">this</span>.secondsDown.disable(); <span class="comment">//disabling minutes select</span> <span class="reserved">this</span>.minutesSelect.shiftEnabled = false; <span class="reserved">this</span>.minutesSelect.noShiftEnabled = false; <span class="reserved">if</span> (config.timeInterval >= 60) { <span class="comment">//disabling minutes arrow control</span> <span class="reserved">this</span>.minutesUp.disable(); <span class="reserved">this</span>.minutesDown.disable(); <span class="comment">//disabling hours select</span> <span class="reserved">this</span>.hoursSelect.shiftEnabled = false; <span class="reserved">this</span>.hoursSelect.noShiftEnabled = false; } } }; <span class="comment">/** * Rounds the date due to the timeInterval. * Affects the object itself, so does not * returns anything. * <span class="attrib">@param</span> date {object} date object to round. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>._roundDate = <span class="reserved">function</span>(date) { <span class="comment">//taking interval</span> var timeInterval = <span class="reserved">this</span>.getConfiguration().timeInterval; <span class="comment">//no interval no rounding</span> <span class="reserved">if</span> (!timeInterval) { <span class="reserved">return</span>; } <span class="comment">//calculating overcome</span> var MINUTE = 60000; var interval = MINUTE * timeInterval; var overcome = (date.getTime() % interval); <span class="comment">//rounding date</span> date.setTime(date.getTime() - overcome + (overcome ? interval : 0)); }; <span class="comment">/** * Gets the step for the given part arrow. * Other buttons can not have step. * <span class="attrib">@param</span> part {string} string identifying part. * <span class="attrib">@param</span> direction {string} string "plus" or "minus" * <span class="attrib">@return</span> {number} step for this part. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>._getStep = <span class="reserved">function</span>(part, direction) { <span class="comment">//taking interval</span> var timeInterval = <span class="reserved">this</span>.getConfiguration().timeInterval; switch (part) { <span class="comment">//hours step</span> case <span class="literal">"hours"</span> : { <span class="reserved">if</span> (timeInterval && timeInterval >= 60) { <span class="reserved">return</span> timeInterval / 60; } <span class="reserved">else</span> { <span class="reserved">return</span> 1; } } <span class="comment">//minutes step</span> case <span class="literal">"minutes"</span> : { <span class="reserved">if</span> (!timeInterval) { var diff = <span class="reserved">this</span>.getMinutes() % 5; <span class="reserved">if</span> (direction == <span class="literal">"plus"</span>) { <span class="reserved">return</span> 5 - diff; } <span class="reserved">else</span> { <span class="reserved">return</span> diff || 5; } } <span class="reserved">else</span> { <span class="reserved">if</span> (timeInterval < 60) { <span class="reserved">return</span> timeInterval; } <span class="reserved">else</span> { <span class="reserved">return</span> null; } } } <span class="comment">//seconds step</span> case <span class="literal">"seconds"</span> : { <span class="reserved">if</span> (!timeInterval) { var diff = <span class="reserved">this</span>.getSeconds() % 5; <span class="reserved">if</span> (direction == <span class="literal">"plus"</span>) { <span class="reserved">return</span> 5 - diff; } <span class="reserved">else</span> { <span class="reserved">return</span> diff || 5; } } <span class="reserved">else</span> { <span class="reserved">return</span> null; } } } }; <span class="comment">/** * Checks the status of the given date. * <span class="attrib">@param</span> date {object} date object to check. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>.checkDate = <span class="reserved">function</span>(date) { var config = <span class="reserved">this</span>.getConfiguration(); <span class="reserved">if</span> (!config.timeStatus) { <span class="reserved">return</span> true; } <span class="reserved">return</span> config.timeStatus(date, date.getHours(), date.getMinutes(), date.getSeconds()); }; <span class="comment">/** * Toggles shift and hilighting. */</span> Zapatec.TimeSelect.<span class="reserved">prototype</span>._toggleShift = <span class="reserved">function</span>() { <span class="comment">//the mouse pointer should be over some select</span> <span class="reserved">if</span> (!<span class="reserved">this</span>.state.overSelect) { <span class="reserved">return</span>; } <span class="comment">//getting select</span> var select = <span class="reserved">this</span>.state.overSelect; <span class="comment">//getting shift state</span> var shift = <span class="reserved">this</span>.state.shiftKey; <span class="comment">//checking if current state is disabled</span> <span class="reserved">if</span> ((!select.shiftEnabled && shift) || (!select.noShiftEnabled && !shift)) { select.disable(); Zapatec.Utils.removeClass(select.getInternalContainer(), <span class="literal">"zpTimeSelectHovered"</span>); } <span class="reserved">else</span> { select.enable(); Zapatec.Utils.addClass(select.getInternalContainer(), <span class="literal">"zpTimeSelectHovered"</span>); } };</pre> <hr> <!-- ========== START OF NAVBAR ========== --> <a name="navbar_top"><!-- --></a> <table border="0" width="100%" cellpadding="1" cellspacing="0"> <tr> <td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1"> <a name="navbar_top_firstrow"><!-- --></a> <table border="0" cellpadding="0" cellspacing="3"> <tr align="center" valign="top"> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td> <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td> </tr> </table> </td> <td bgcolor="#EEEEFF" align="right" valign="top"><em> <b>Zapatec Time</b></em> </td> </tr> <tr> <td bgcolor="white" class="NavBarCell2"><font size="-2"> PREV NEXT</font></td> <td bgcolor="white" class="NavBarCell2"><font size="-2"> <a href="index.html" target="_top"><b>FRAMES</b></a> <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> <script> <!-- if(window==top) { document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--> </script> <noscript> <a href="allclasses-noframe.html" target=""><b>All Classes</b></a> </noscript> </font></td> </tr> </table> <!-- =========== END OF NAVBAR =========== --> <hr> <font size="-1"> </font> <div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu Aug 16 12:19:05 2007</div> </body> </html>