Initial commit
191
modules/chat/datepicker/css/datepicker.css
Normal file
|
@ -0,0 +1,191 @@
|
|||
div.datepicker {
|
||||
position: relative;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
width: 196px;
|
||||
height: 147px;
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: none;
|
||||
}
|
||||
.datepickerContainer {
|
||||
background: #121212;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
}
|
||||
.datepickerBorderT {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
height: 10px;
|
||||
background: url(../images/datepicker_t.png);
|
||||
}
|
||||
.datepickerBorderB {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
bottom: 0;
|
||||
right: 10px;
|
||||
height: 10px;
|
||||
background: url(../images/datepicker_b.png);
|
||||
}
|
||||
.datepickerBorderL {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 10px;
|
||||
top: 10px;
|
||||
width: 10px;
|
||||
background: url(../images/datepicker_l.png);
|
||||
}
|
||||
.datepickerBorderR {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 10px;
|
||||
top: 10px;
|
||||
width: 10px;
|
||||
background: url(../images/datepicker_r.png);
|
||||
}
|
||||
.datepickerBorderTL {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: url(../images/datepicker_tl.png);
|
||||
}
|
||||
.datepickerBorderTR {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: url(../images/datepicker_tr.png);
|
||||
}
|
||||
.datepickerBorderBL {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: url(../images/datepicker_bl.png);
|
||||
}
|
||||
.datepickerBorderBR {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: url(../images/datepicker_br.png);
|
||||
}
|
||||
.datepickerHidden {
|
||||
display: none;
|
||||
}
|
||||
div.datepicker table {
|
||||
border-collapse:collapse;
|
||||
}
|
||||
div.datepicker a {
|
||||
color: #eee;
|
||||
text-decoration: none;
|
||||
cursor: default;
|
||||
outline: none;
|
||||
}
|
||||
div.datepicker table td {
|
||||
text-align: right;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
div.datepicker th {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-weight: normal;
|
||||
}
|
||||
div.datepicker tbody th {
|
||||
text-align: left;
|
||||
}
|
||||
div.datepicker tbody a {
|
||||
display: block;
|
||||
}
|
||||
.datepickerDays a {
|
||||
width: 20px;
|
||||
line-height: 16px;
|
||||
height: 16px;
|
||||
padding-right: 2px;
|
||||
}
|
||||
.datepickerYears a,
|
||||
.datepickerMonths a{
|
||||
width: 44px;
|
||||
line-height: 36px;
|
||||
height: 36px;
|
||||
text-align: center;
|
||||
}
|
||||
td.datepickerNotInMonth a {
|
||||
color: #666;
|
||||
}
|
||||
tbody.datepickerDays td.datepickerSelected{
|
||||
background: #136A9F;
|
||||
}
|
||||
tbody.datepickerDays td.datepickerNotInMonth.datepickerSelected {
|
||||
background: #17384d;
|
||||
}
|
||||
tbody.datepickerYears td.datepickerSelected,
|
||||
tbody.datepickerMonths td.datepickerSelected{
|
||||
background: #17384d;
|
||||
}
|
||||
div.datepicker a:hover,
|
||||
div.datepicker a:hover {
|
||||
color: #88c5eb;
|
||||
}
|
||||
div.datepicker td.datepickerNotInMonth a:hover {
|
||||
color: #999;
|
||||
}
|
||||
div.datepicker tbody th {
|
||||
text-align: left;
|
||||
}
|
||||
.datepickerSpace div {
|
||||
width: 20px;
|
||||
}
|
||||
.datepickerGoNext a,
|
||||
.datepickerGoPrev a,
|
||||
.datepickerMonth a {
|
||||
text-align: center;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.datepickerGoNext a {
|
||||
float: right;
|
||||
width: 20px;
|
||||
}
|
||||
.datepickerGoPrev a {
|
||||
float: left;
|
||||
width: 20px;
|
||||
}
|
||||
table.datepickerViewDays tbody.datepickerMonths,
|
||||
table.datepickerViewDays tbody.datepickerYears {
|
||||
display: none;
|
||||
}
|
||||
table.datepickerViewMonths tbody.datepickerDays,
|
||||
table.datepickerViewMonths tbody.datepickerYears,
|
||||
table.datepickerViewMonths tr.datepickerDoW {
|
||||
display: none;
|
||||
}
|
||||
table.datepickerViewYears tbody.datepickerDays,
|
||||
table.datepickerViewYears tbody.datepickerMonths,
|
||||
table.datepickerViewYears tr.datepickerDoW {
|
||||
display: none;
|
||||
}
|
||||
td.datepickerDisabled a,
|
||||
td.datepickerDisabled.datepickerNotInMonth a{
|
||||
color: #333;
|
||||
}
|
||||
td.datepickerDisabled a:hover {
|
||||
color: #333;
|
||||
}
|
||||
td.datepickerSpecial a {
|
||||
background: #700;
|
||||
}
|
||||
td.datepickerSpecial.datepickerSelected a {
|
||||
background: #a00;
|
||||
}
|
150
modules/chat/datepicker/css/layout.css
Normal file
|
@ -0,0 +1,150 @@
|
|||
|
||||
#colorSelector {
|
||||
position: relative;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: url(../images/select.png);
|
||||
}
|
||||
#colorSelector div {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
left: 3px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background: url(../images/select.png) center;
|
||||
}
|
||||
#colorSelector2 {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: url(../images/select2.png);
|
||||
}
|
||||
#colorSelector2 div {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 4px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background: url(../images/select2.png) center;
|
||||
}
|
||||
#colorpickerHolder2 {
|
||||
top: 32px;
|
||||
left: 0;
|
||||
width: 356px;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker {
|
||||
background-image: url(../images/custom_background.png);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_hue div {
|
||||
background-image: url(../images/custom_indic.gif);
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_hex {
|
||||
background-image: url(../images/custom_hex.png);
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_rgb_r {
|
||||
background-image: url(../images/custom_rgb_r.png);
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_rgb_g {
|
||||
background-image: url(../images/custom_rgb_g.png);
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_rgb_b {
|
||||
background-image: url(../images/custom_rgb_b.png);
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_hsb_s {
|
||||
background-image: url(../images/custom_hsb_s.png);
|
||||
display: none;
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_hsb_h {
|
||||
background-image: url(../images/custom_hsb_h.png);
|
||||
display: none;
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_hsb_b {
|
||||
background-image: url(../images/custom_hsb_b.png);
|
||||
display: none;
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker_submit {
|
||||
background-image: url(../images/custom_submit.png);
|
||||
}
|
||||
#colorpickerHolder2 .colorpicker input {
|
||||
color: #778398;
|
||||
}
|
||||
#customWidget {
|
||||
position: relative;
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
input.inputDate {
|
||||
border: 1px solid #999;
|
||||
padding: 4px;
|
||||
border-bottom-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
width: 65px;
|
||||
}
|
||||
#widget {
|
||||
position: relative;
|
||||
}
|
||||
#widgetField {
|
||||
width: 290px;
|
||||
height: 26px;
|
||||
background: url(../images/field.png);
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
#widgetField a {
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
top: 0;
|
||||
right: 0;
|
||||
text-decoration: none;
|
||||
text-indent: -3000px;
|
||||
}
|
||||
#widgetField span {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
left: 5px;
|
||||
width: 250px;
|
||||
text-align: center;
|
||||
}
|
||||
#widgetCalendar {
|
||||
position: absolute;
|
||||
top: 26px;
|
||||
left: 0;
|
||||
height: 0px;
|
||||
overflow: hidden;
|
||||
width: 588px;
|
||||
background: #B9B9B9;
|
||||
}
|
||||
#widgetCalendar .datepicker {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
top: auto;
|
||||
}
|
||||
#widgetCalendar .datepickerContainer,
|
||||
#widgetCalendar .datepickerBorderT,
|
||||
#widgetCalendar .datepickerBorderB,
|
||||
#widgetCalendar .datepickerBorderL,
|
||||
#widgetCalendar .datepickerBorderR,
|
||||
#widgetCalendar .datepickerBorderTL,
|
||||
#widgetCalendar .datepickerBorderTR,
|
||||
#widgetCalendar .datepickerBorderBL,
|
||||
#widgetCalendar .datepickerBorderBR {
|
||||
background: transparent !important;
|
||||
}
|
||||
#widgetCalendar .datepicker a:hover{
|
||||
color: #b6f063;
|
||||
}
|
BIN
modules/chat/datepicker/images/custom_b.png
Normal file
After Width: | Height: | Size: 179 B |
BIN
modules/chat/datepicker/images/custom_bl.png
Normal file
After Width: | Height: | Size: 213 B |
BIN
modules/chat/datepicker/images/custom_br.png
Normal file
After Width: | Height: | Size: 227 B |
BIN
modules/chat/datepicker/images/custom_l.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
modules/chat/datepicker/images/custom_r.png
Normal file
After Width: | Height: | Size: 165 B |
BIN
modules/chat/datepicker/images/custom_t.png
Normal file
After Width: | Height: | Size: 159 B |
BIN
modules/chat/datepicker/images/custom_tl.png
Normal file
After Width: | Height: | Size: 165 B |
BIN
modules/chat/datepicker/images/custom_tr.png
Normal file
After Width: | Height: | Size: 222 B |
BIN
modules/chat/datepicker/images/datepicker_b.png
Normal file
After Width: | Height: | Size: 135 B |
BIN
modules/chat/datepicker/images/datepicker_bl.png
Normal file
After Width: | Height: | Size: 211 B |
BIN
modules/chat/datepicker/images/datepicker_br.png
Normal file
After Width: | Height: | Size: 208 B |
BIN
modules/chat/datepicker/images/datepicker_l.png
Normal file
After Width: | Height: | Size: 131 B |
BIN
modules/chat/datepicker/images/datepicker_r.png
Normal file
After Width: | Height: | Size: 132 B |
BIN
modules/chat/datepicker/images/datepicker_t.png
Normal file
After Width: | Height: | Size: 140 B |
BIN
modules/chat/datepicker/images/datepicker_tl.png
Normal file
After Width: | Height: | Size: 209 B |
BIN
modules/chat/datepicker/images/datepicker_tr.png
Normal file
After Width: | Height: | Size: 240 B |
BIN
modules/chat/datepicker/images/field.png
Normal file
After Width: | Height: | Size: 767 B |
259
modules/chat/datepicker/index.html
Normal file
|
@ -0,0 +1,259 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
|
||||
<link rel="stylesheet" media="screen" type="text/css" href="css/layout.css" />
|
||||
<title>DatePicker - jQuery plugin</title>
|
||||
<script type="text/javascript" src="js/jquery.js"></script>
|
||||
<script type="text/javascript" src="js/datepicker.js"></script>
|
||||
<script type="text/javascript" src="js/eye.js"></script>
|
||||
<script type="text/javascript" src="js/utils.js"></script>
|
||||
<script type="text/javascript" src="js/layout.js?ver=1.0.2"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<h1>Date Picker - jQuery plugin</h1>
|
||||
<ul class="navigationTabs">
|
||||
<li><a href="#about" rel="about">About</a></li>
|
||||
<li><a href="#download" rel="download">Download</a></li>
|
||||
<li><a href="#implement" rel="implement">Implement</a></li>
|
||||
</ul>
|
||||
<div class="tabsContent">
|
||||
<div class="tab">
|
||||
<h2>About</h2>
|
||||
<p>Date Picker component with a lot of options and easy to fit in your web application.</p>
|
||||
<h3>Last update</h3>
|
||||
<p>22.05.2009 - Check Download tab</p>
|
||||
<h3>Features</h3>
|
||||
<ul>
|
||||
<li>Flat mode - as element in page</li>
|
||||
<li>Multiple calendars in the component</li>
|
||||
<li>Allows single, multiple or range selection</li>
|
||||
<li>Mark dates as special, weekends, special days</li>
|
||||
<li>Easy to customize the look by changing CSS</li>
|
||||
<li>Localiation for months' and days' names</li>
|
||||
<li>Custom day to start the week</li>
|
||||
<li>Fits into the viewport</li>
|
||||
</ul>
|
||||
<h3>License</h3>
|
||||
<p>Dual licensed under the MIT and GPL licenses.</p>
|
||||
<h3>Examples</h3>
|
||||
<p id="date"></p>
|
||||
<p>Flat mode, single selection, the week start monday.</p>
|
||||
<pre>$('#date').DatePicker({
|
||||
flat: true,
|
||||
date: '2008-07-31',
|
||||
current: '2008-07-31',
|
||||
calendars: 1,
|
||||
starts: 1
|
||||
});</pre>
|
||||
<p>Flat mode, multiple selection, disabled dates, special day, the week start sunday.</p>
|
||||
<p id="date2"></p>
|
||||
<pre>$('#date2').DatePicker({
|
||||
flat: true,
|
||||
date: ['2008-07-31', '2008-07-28'],
|
||||
current: '2008-07-31',
|
||||
format: 'Y-m-d',
|
||||
calendars: 1,
|
||||
mode: 'multiple',
|
||||
onRender: function(date) {
|
||||
return {
|
||||
disabled: (date.valueOf() < now.valueOf()),
|
||||
className: date.valueOf() == now2.valueOf() ? 'datepickerSpecial' : false
|
||||
}
|
||||
},
|
||||
starts: 0
|
||||
});</pre>
|
||||
<p><a href="#" id="clearSelection">Clear selection</a></p>
|
||||
<pre>$('#date3').DatePickerClear();</pre>
|
||||
<p>Flat mode, range selection, 3 calendars.</p>
|
||||
<p id="date3"></p>
|
||||
<pre>$('#date3').DatePicker({
|
||||
flat: true,
|
||||
date: ['2008-07-28','2008-07-31'],
|
||||
current: '2008-07-31',
|
||||
calendars: 3,
|
||||
mode: 'range',
|
||||
starts: 1
|
||||
});</pre>
|
||||
<p>Attached to an text field and usign callbacks to update the date selection with the value from the field.</p>
|
||||
<p>
|
||||
<input class="inputDate" id="inputDate" value="06/14/2008" />
|
||||
<label id="closeOnSelect"><input type="checkbox" /> Close on selection</label>
|
||||
</p>
|
||||
<pre>$('#inputDate').DatePicker({
|
||||
format:'m/d/Y',
|
||||
date: $('#inputDate').val(),
|
||||
current: $('#inputDate').val(),
|
||||
starts: 1,
|
||||
position: 'r',
|
||||
onBeforeShow: function(){
|
||||
$('#inputDate').DatePickerSetDate($('#inputDate').val(), true);
|
||||
},
|
||||
onChange: function(formated, dates){
|
||||
$('#inputDate').val(formated);
|
||||
if ($('#closeOnSelect input').attr('checked')) {
|
||||
$('#inputDate').DatePickerHide();
|
||||
}
|
||||
}
|
||||
});</pre>
|
||||
<p>Flat mode, inside a custom widget and with custom design.</p>
|
||||
<div id="widget">
|
||||
<div id="widgetField">
|
||||
<span>28 July, 2008 ÷ 31 July, 2008</span>
|
||||
<a href="#">Select date range</a>
|
||||
</div>
|
||||
<div id="widgetCalendar">
|
||||
</div>
|
||||
</div>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<div class="tab">
|
||||
<h2>Download</h2>
|
||||
<p><a href="datepicker.zip">datepicker.zip (50 kb)</a>: jQuery, Javscript files, CSS files, images, examples and instructions.</p>
|
||||
<h3>Changelog</h3>
|
||||
<dl>
|
||||
<dt>22.05.2009</dt>
|
||||
<dd>added: close on selection example</dd>
|
||||
<dd>added: onChange has new parameter: reference to related element</dd>
|
||||
<dd>added: start view days, months, years</dd>
|
||||
<dd>added: clear selection in multiple and range mode</dd>
|
||||
<dd>fixed: datepicker hide and show methods</dd>
|
||||
<dd>fixed: january selection (tahns to Konstantin Zavialov)</dd>
|
||||
<dd>fixed: working with jQuery 1.3</dd>
|
||||
<dd>fixed: deselecting a date in multiple mode (thanks to Geelen Sebastien)</dd>
|
||||
<dt>22.08.2008</dt>
|
||||
<dd>Fixed bug: where some events were not canceled right on Safari</dd>
|
||||
<dd>Fixed bug: where teh view port was not detected right on Safari</dd>
|
||||
<dt>31.07.2008</dt>
|
||||
<dd>Added new method: 'DatePickerGetDate'</dd>
|
||||
<dd>Minor speed improvement</dd>
|
||||
<dt>30.07.2008</dt>
|
||||
<dd>The first release.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="tab">
|
||||
<h2>Implement</h2>
|
||||
<p>Attach the Javascript and CSS files to your document. Edit CSS file and fix the paths to images and change colors to fit your site theme.</p>
|
||||
<pre>
|
||||
<link rel="stylesheet" media="screen" type="text/css" href="css/datepicker.css" />
|
||||
<script type="text/javascript" src="js/datepicker.js"></script>
|
||||
</pre>
|
||||
<h3>Invocation code</h3>
|
||||
<p>All you have to do is to select the elements in a jQuery way and call the plugin.</p>
|
||||
<pre>
|
||||
$('input').DatePicker(options);
|
||||
</pre>
|
||||
<h3>Options</h3>
|
||||
<p>A hash of parameters. All parameters are optional.</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td><strong>eventName</strong></td>
|
||||
<td>string</td>
|
||||
<td>The desired event to trigger the date picker. Default: 'click'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>date</strong></td>
|
||||
<td>String, Date or array</td>
|
||||
<td>The selected date(s) as string (will be converted to Date object based on teh format suplied) and Date object for single selection, as Array of strings or Date objects</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>flat</strong></td>
|
||||
<td>boolean</td>
|
||||
<td>Whatever if the date picker is appended to the element or triggered by an event. Default false</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>start</strong></td>
|
||||
<td>integer</td>
|
||||
<td>The day week start. Default 1 (monday)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>prev</strong></td>
|
||||
<td>string</td>
|
||||
<td>HTML inserted to previous links. Default '◀' (UNICODE black left arrow)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>next</strong></td>
|
||||
<td>string</td>
|
||||
<td>HTML inserted to next links. Default '▶' (UNICODE black right arrow)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>mode</strong></td>
|
||||
<td>string ['single'|'multiple'|'range']</td>
|
||||
<td>Date selection mode. Default 'single'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>view</strong></td>
|
||||
<td>string ['days'|'months'|'years']</td>
|
||||
<td>Start view mode. Default 'days'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>calendars</strong></td>
|
||||
<td>integer</td>
|
||||
<td>Number of calendars to render inside the date picker. Default 1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>format</strong></td>
|
||||
<td>string</td>
|
||||
<td>Date format. Default 'Y-m-d'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>position</strong></td>
|
||||
<td>string ['top'|'left'|'right'|'bottom']</td>
|
||||
<td>Date picker's position relative to the trigegr element (non flat mode only). Default 'bottom'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>locale</strong></td>
|
||||
<td>hash</td>
|
||||
<td>Location: provide a hash with keys 'days', 'daysShort', 'daysMin', 'months', 'monthsShort', 'week'. Default english</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>onShow</strong></td>
|
||||
<td>function</td>
|
||||
<td>Callback function triggered when the date picker is shown</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>onBeforeShow</strong></td>
|
||||
<td>function</td>
|
||||
<td>Callback function triggered before the date picker is shown</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>onHide</strong></td>
|
||||
<td>function</td>
|
||||
<td>Callback function triggered when the date picker is hidden</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>onChange</strong></td>
|
||||
<td>function</td>
|
||||
<td>Callback function triggered when the date is changed</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>onRender</strong></td>
|
||||
<td>function</td>
|
||||
<td>Callback function triggered when the date is rendered inside a calendar. It should return and hash with keys: 'selected' to select the date, 'disabled' to disable the date, 'className' for additional CSS class</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3>Set date</h3>
|
||||
<p>If you want to set a diferent date selection.</p>
|
||||
<pre>$('input').DatePickerSetDate(date, shiftTo);</pre>
|
||||
<p>The 'date' argument is the same format as the option 'date' and the 'shiftTo' argument (boolean) moves the curent month view to the date selection provided.</p>
|
||||
<h3>Get date</h3>
|
||||
<p>Get date selection.</p>
|
||||
<pre>$('input').DatePickerGetDate(formated);</pre>
|
||||
<p>Set 'formated' to true if you whant to get teh selection formated.</p>
|
||||
<h3>Show and hide date picker</h3>
|
||||
<p>Show or hide a date picker.</p>
|
||||
<pre>$('input').DatePickerShow();</pre>
|
||||
<pre>$('input').DatePickerHide();</pre>
|
||||
<h3>Clear multiple selection</h3>
|
||||
<p>Clear selection in multiple and range mode</p>
|
||||
<pre>$('#datepicker').DatePickerClear();</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
891
modules/chat/datepicker/js/datepicker.js
Normal file
|
@ -0,0 +1,891 @@
|
|||
/**
|
||||
*
|
||||
* Date picker
|
||||
* Author: Stefan Petre www.eyecon.ro
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses
|
||||
*
|
||||
*/
|
||||
(function ($) {
|
||||
var DatePicker = function () {
|
||||
var ids = {},
|
||||
views = {
|
||||
years: 'datepickerViewYears',
|
||||
moths: 'datepickerViewMonths',
|
||||
days: 'datepickerViewDays'
|
||||
},
|
||||
tpl = {
|
||||
wrapper: '<div class="datepicker"><div class="datepickerBorderT" /><div class="datepickerBorderB" /><div class="datepickerBorderL" /><div class="datepickerBorderR" /><div class="datepickerBorderTL" /><div class="datepickerBorderTR" /><div class="datepickerBorderBL" /><div class="datepickerBorderBR" /><div class="datepickerContainer"><table cellspacing="0" cellpadding="0"><tbody><tr></tr></tbody></table></div></div>',
|
||||
head: [
|
||||
'<td>',
|
||||
'<table cellspacing="0" cellpadding="0">',
|
||||
'<thead>',
|
||||
'<tr>',
|
||||
'<th class="datepickerGoPrev"><a href="#"><span><%=prev%></span></a></th>',
|
||||
'<th colspan="6" class="datepickerMonth"><a href="#"><span></span></a></th>',
|
||||
'<th class="datepickerGoNext"><a href="#"><span><%=next%></span></a></th>',
|
||||
'</tr>',
|
||||
'<tr class="datepickerDoW">',
|
||||
'<th><span><%=week%></span></th>',
|
||||
'<th><span><%=day1%></span></th>',
|
||||
'<th><span><%=day2%></span></th>',
|
||||
'<th><span><%=day3%></span></th>',
|
||||
'<th><span><%=day4%></span></th>',
|
||||
'<th><span><%=day5%></span></th>',
|
||||
'<th><span><%=day6%></span></th>',
|
||||
'<th><span><%=day7%></span></th>',
|
||||
'</tr>',
|
||||
'</thead>',
|
||||
'</table></td>'
|
||||
],
|
||||
space : '<td class="datepickerSpace"><div></div></td>',
|
||||
days: [
|
||||
'<tbody class="datepickerDays">',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[0].week%></span></a></th>',
|
||||
'<td class="<%=weeks[0].days[0].classname%>"><a href="#"><span><%=weeks[0].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[1].classname%>"><a href="#"><span><%=weeks[0].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[2].classname%>"><a href="#"><span><%=weeks[0].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[3].classname%>"><a href="#"><span><%=weeks[0].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[4].classname%>"><a href="#"><span><%=weeks[0].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[5].classname%>"><a href="#"><span><%=weeks[0].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[6].classname%>"><a href="#"><span><%=weeks[0].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[1].week%></span></a></th>',
|
||||
'<td class="<%=weeks[1].days[0].classname%>"><a href="#"><span><%=weeks[1].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[1].classname%>"><a href="#"><span><%=weeks[1].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[2].classname%>"><a href="#"><span><%=weeks[1].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[3].classname%>"><a href="#"><span><%=weeks[1].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[4].classname%>"><a href="#"><span><%=weeks[1].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[5].classname%>"><a href="#"><span><%=weeks[1].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[6].classname%>"><a href="#"><span><%=weeks[1].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[2].week%></span></a></th>',
|
||||
'<td class="<%=weeks[2].days[0].classname%>"><a href="#"><span><%=weeks[2].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[1].classname%>"><a href="#"><span><%=weeks[2].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[2].classname%>"><a href="#"><span><%=weeks[2].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[3].classname%>"><a href="#"><span><%=weeks[2].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[4].classname%>"><a href="#"><span><%=weeks[2].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[5].classname%>"><a href="#"><span><%=weeks[2].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[6].classname%>"><a href="#"><span><%=weeks[2].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[3].week%></span></a></th>',
|
||||
'<td class="<%=weeks[3].days[0].classname%>"><a href="#"><span><%=weeks[3].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[1].classname%>"><a href="#"><span><%=weeks[3].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[2].classname%>"><a href="#"><span><%=weeks[3].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[3].classname%>"><a href="#"><span><%=weeks[3].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[4].classname%>"><a href="#"><span><%=weeks[3].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[5].classname%>"><a href="#"><span><%=weeks[3].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[6].classname%>"><a href="#"><span><%=weeks[3].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[4].week%></span></a></th>',
|
||||
'<td class="<%=weeks[4].days[0].classname%>"><a href="#"><span><%=weeks[4].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[1].classname%>"><a href="#"><span><%=weeks[4].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[2].classname%>"><a href="#"><span><%=weeks[4].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[3].classname%>"><a href="#"><span><%=weeks[4].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[4].classname%>"><a href="#"><span><%=weeks[4].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[5].classname%>"><a href="#"><span><%=weeks[4].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[6].classname%>"><a href="#"><span><%=weeks[4].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[5].week%></span></a></th>',
|
||||
'<td class="<%=weeks[5].days[0].classname%>"><a href="#"><span><%=weeks[5].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[1].classname%>"><a href="#"><span><%=weeks[5].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[2].classname%>"><a href="#"><span><%=weeks[5].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[3].classname%>"><a href="#"><span><%=weeks[5].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[4].classname%>"><a href="#"><span><%=weeks[5].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[5].classname%>"><a href="#"><span><%=weeks[5].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[6].classname%>"><a href="#"><span><%=weeks[5].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'</tbody>'
|
||||
],
|
||||
months: [
|
||||
'<tbody class="<%=className%>">',
|
||||
'<tr>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[0]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[1]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[2]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[3]%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[4]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[5]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[6]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[7]%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[8]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[9]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[10]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[11]%></span></a></td>',
|
||||
'</tr>',
|
||||
'</tbody>'
|
||||
]
|
||||
},
|
||||
defaults = {
|
||||
flat: false,
|
||||
starts: 1,
|
||||
prev: '◀',
|
||||
next: '▶',
|
||||
lastSel: false,
|
||||
mode: 'single',
|
||||
view: 'days',
|
||||
calendars: 1,
|
||||
format: 'Y-m-d',
|
||||
position: 'bottom',
|
||||
eventName: 'click',
|
||||
onRender: function(){return {};},
|
||||
onChange: function(){return true;},
|
||||
onShow: function(){return true;},
|
||||
onBeforeShow: function(){return true;},
|
||||
onHide: function(){return true;},
|
||||
locale: {
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
weekMin: 'wk'
|
||||
}
|
||||
},
|
||||
fill = function(el) {
|
||||
var options = $(el).data('datepicker');
|
||||
var cal = $(el);
|
||||
var currentCal = Math.floor(options.calendars/2), date, data, dow, month, cnt = 0, week, days, indic, indic2, html, tblCal;
|
||||
cal.find('td>table tbody').remove();
|
||||
for (var i = 0; i < options.calendars; i++) {
|
||||
date = new Date(options.current);
|
||||
date.addMonths(-currentCal + i);
|
||||
tblCal = cal.find('table').eq(i+1);
|
||||
switch (tblCal[0].className) {
|
||||
case 'datepickerViewDays':
|
||||
dow = formatDate(date, 'B, Y');
|
||||
break;
|
||||
case 'datepickerViewMonths':
|
||||
dow = date.getFullYear();
|
||||
break;
|
||||
case 'datepickerViewYears':
|
||||
dow = (date.getFullYear()-6) + ' - ' + (date.getFullYear()+5);
|
||||
break;
|
||||
}
|
||||
tblCal.find('thead tr:first th:eq(1) span').text(dow);
|
||||
dow = date.getFullYear()-6;
|
||||
data = {
|
||||
data: [],
|
||||
className: 'datepickerYears'
|
||||
}
|
||||
for ( var j = 0; j < 12; j++) {
|
||||
data.data.push(dow + j);
|
||||
}
|
||||
html = tmpl(tpl.months.join(''), data);
|
||||
date.setDate(1);
|
||||
data = {weeks:[], test: 10};
|
||||
month = date.getMonth();
|
||||
var dow = (date.getDay() - options.starts) % 7;
|
||||
date.addDays(-(dow + (dow < 0 ? 7 : 0)));
|
||||
week = -1;
|
||||
cnt = 0;
|
||||
while (cnt < 42) {
|
||||
indic = parseInt(cnt/7,10);
|
||||
indic2 = cnt%7;
|
||||
if (!data.weeks[indic]) {
|
||||
week = date.getWeekNumber();
|
||||
data.weeks[indic] = {
|
||||
week: week,
|
||||
days: []
|
||||
};
|
||||
}
|
||||
data.weeks[indic].days[indic2] = {
|
||||
text: date.getDate(),
|
||||
classname: []
|
||||
};
|
||||
if (month != date.getMonth()) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerNotInMonth');
|
||||
}
|
||||
if (date.getDay() == 0) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerSunday');
|
||||
}
|
||||
if (date.getDay() == 6) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerSaturday');
|
||||
}
|
||||
var fromUser = options.onRender(date);
|
||||
var val = date.valueOf();
|
||||
if (fromUser.selected || options.date == val || $.inArray(val, options.date) > -1 || (options.mode == 'range' && val >= options.date[0] && val <= options.date[1])) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerSelected');
|
||||
}
|
||||
if (fromUser.disabled) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerDisabled');
|
||||
}
|
||||
if (fromUser.className) {
|
||||
data.weeks[indic].days[indic2].classname.push(fromUser.className);
|
||||
}
|
||||
data.weeks[indic].days[indic2].classname = data.weeks[indic].days[indic2].classname.join(' ');
|
||||
cnt++;
|
||||
date.addDays(1);
|
||||
}
|
||||
html = tmpl(tpl.days.join(''), data) + html;
|
||||
data = {
|
||||
data: options.locale.monthsShort,
|
||||
className: 'datepickerMonths'
|
||||
};
|
||||
html = tmpl(tpl.months.join(''), data) + html;
|
||||
tblCal.append(html);
|
||||
}
|
||||
},
|
||||
parseDate = function (date, format) {
|
||||
if (date.constructor == Date) {
|
||||
return new Date(date);
|
||||
}
|
||||
var parts = date.split(/\W+/);
|
||||
var against = format.split(/\W+/), d, m, y, h, min, now = new Date();
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
switch (against[i]) {
|
||||
case 'd':
|
||||
case 'e':
|
||||
d = parseInt(parts[i],10);
|
||||
break;
|
||||
case 'm':
|
||||
m = parseInt(parts[i], 10)-1;
|
||||
break;
|
||||
case 'Y':
|
||||
case 'y':
|
||||
y = parseInt(parts[i], 10);
|
||||
y += y > 100 ? 0 : (y < 29 ? 2000 : 1900);
|
||||
break;
|
||||
case 'H':
|
||||
case 'I':
|
||||
case 'k':
|
||||
case 'l':
|
||||
h = parseInt(parts[i], 10);
|
||||
break;
|
||||
case 'P':
|
||||
case 'p':
|
||||
if (/pm/i.test(parts[i]) && h < 12) {
|
||||
h += 12;
|
||||
} else if (/am/i.test(parts[i]) && h >= 12) {
|
||||
h -= 12;
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
min = parseInt(parts[i], 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new Date(
|
||||
y === undefined ? now.getFullYear() : y,
|
||||
m === undefined ? now.getMonth() : m,
|
||||
d === undefined ? now.getDate() : d,
|
||||
h === undefined ? now.getHours() : h,
|
||||
min === undefined ? now.getMinutes() : min,
|
||||
0
|
||||
);
|
||||
},
|
||||
formatDate = function(date, format) {
|
||||
var m = date.getMonth();
|
||||
var d = date.getDate();
|
||||
var y = date.getFullYear();
|
||||
var wn = date.getWeekNumber();
|
||||
var w = date.getDay();
|
||||
var s = {};
|
||||
var hr = date.getHours();
|
||||
var pm = (hr >= 12);
|
||||
var ir = (pm) ? (hr - 12) : hr;
|
||||
var dy = date.getDayOfYear();
|
||||
if (ir == 0) {
|
||||
ir = 12;
|
||||
}
|
||||
var min = date.getMinutes();
|
||||
var sec = date.getSeconds();
|
||||
var parts = format.split(''), part;
|
||||
for ( var i = 0; i < parts.length; i++ ) {
|
||||
part = parts[i];
|
||||
switch (parts[i]) {
|
||||
case 'a':
|
||||
part = date.getDayName();
|
||||
break;
|
||||
case 'A':
|
||||
part = date.getDayName(true);
|
||||
break;
|
||||
case 'b':
|
||||
part = date.getMonthName();
|
||||
break;
|
||||
case 'B':
|
||||
part = date.getMonthName(true);
|
||||
break;
|
||||
case 'C':
|
||||
part = 1 + Math.floor(y / 100);
|
||||
break;
|
||||
case 'd':
|
||||
part = (d < 10) ? ("0" + d) : d;
|
||||
break;
|
||||
case 'e':
|
||||
part = d;
|
||||
break;
|
||||
case 'H':
|
||||
part = (hr < 10) ? ("0" + hr) : hr;
|
||||
break;
|
||||
case 'I':
|
||||
part = (ir < 10) ? ("0" + ir) : ir;
|
||||
break;
|
||||
case 'j':
|
||||
part = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy;
|
||||
break;
|
||||
case 'k':
|
||||
part = hr;
|
||||
break;
|
||||
case 'l':
|
||||
part = ir;
|
||||
break;
|
||||
case 'm':
|
||||
part = (m < 9) ? ("0" + (1+m)) : (1+m);
|
||||
break;
|
||||
case 'M':
|
||||
part = (min < 10) ? ("0" + min) : min;
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
part = pm ? "PM" : "AM";
|
||||
break;
|
||||
case 's':
|
||||
part = Math.floor(date.getTime() / 1000);
|
||||
break;
|
||||
case 'S':
|
||||
part = (sec < 10) ? ("0" + sec) : sec;
|
||||
break;
|
||||
case 'u':
|
||||
part = w + 1;
|
||||
break;
|
||||
case 'w':
|
||||
part = w;
|
||||
break;
|
||||
case 'y':
|
||||
part = ('' + y).substr(2, 2);
|
||||
break;
|
||||
case 'Y':
|
||||
part = y;
|
||||
break;
|
||||
}
|
||||
parts[i] = part;
|
||||
}
|
||||
return parts.join('');
|
||||
},
|
||||
extendDate = function(options) {
|
||||
if (Date.prototype.tempDate) {
|
||||
return;
|
||||
}
|
||||
Date.prototype.tempDate = null;
|
||||
Date.prototype.months = options.months;
|
||||
Date.prototype.monthsShort = options.monthsShort;
|
||||
Date.prototype.days = options.days;
|
||||
Date.prototype.daysShort = options.daysShort;
|
||||
Date.prototype.getMonthName = function(fullName) {
|
||||
return this[fullName ? 'months' : 'monthsShort'][this.getMonth()];
|
||||
};
|
||||
Date.prototype.getDayName = function(fullName) {
|
||||
return this[fullName ? 'days' : 'daysShort'][this.getDay()];
|
||||
};
|
||||
Date.prototype.addDays = function (n) {
|
||||
this.setDate(this.getDate() + n);
|
||||
this.tempDate = this.getDate();
|
||||
};
|
||||
Date.prototype.addMonths = function (n) {
|
||||
if (this.tempDate == null) {
|
||||
this.tempDate = this.getDate();
|
||||
}
|
||||
this.setDate(1);
|
||||
this.setMonth(this.getMonth() + n);
|
||||
this.setDate(Math.min(this.tempDate, this.getMaxDays()));
|
||||
};
|
||||
Date.prototype.addYears = function (n) {
|
||||
if (this.tempDate == null) {
|
||||
this.tempDate = this.getDate();
|
||||
}
|
||||
this.setDate(1);
|
||||
this.setFullYear(this.getFullYear() + n);
|
||||
this.setDate(Math.min(this.tempDate, this.getMaxDays()));
|
||||
};
|
||||
Date.prototype.getMaxDays = function() {
|
||||
var tmpDate = new Date(Date.parse(this)),
|
||||
d = 28, m;
|
||||
m = tmpDate.getMonth();
|
||||
d = 28;
|
||||
while (tmpDate.getMonth() == m) {
|
||||
d ++;
|
||||
tmpDate.setDate(d);
|
||||
}
|
||||
return d - 1;
|
||||
};
|
||||
Date.prototype.getFirstDay = function() {
|
||||
var tmpDate = new Date(Date.parse(this));
|
||||
tmpDate.setDate(1);
|
||||
return tmpDate.getDay();
|
||||
};
|
||||
Date.prototype.getWeekNumber = function() {
|
||||
var tempDate = new Date(this);
|
||||
tempDate.setDate(tempDate.getDate() - (tempDate.getDay() + 6) % 7 + 3);
|
||||
var dms = tempDate.valueOf();
|
||||
tempDate.setMonth(0);
|
||||
tempDate.setDate(4);
|
||||
return Math.round((dms - tempDate.valueOf()) / (604800000)) + 1;
|
||||
};
|
||||
Date.prototype.getDayOfYear = function() {
|
||||
var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
|
||||
var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
|
||||
var time = now - then;
|
||||
return Math.floor(time / 24*60*60*1000);
|
||||
};
|
||||
},
|
||||
layout = function (el) {
|
||||
var options = $(el).data('datepicker');
|
||||
var cal = $('#' + options.id);
|
||||
if (!options.extraHeight) {
|
||||
var divs = $(el).find('div');
|
||||
options.extraHeight = divs.get(0).offsetHeight + divs.get(1).offsetHeight;
|
||||
options.extraWidth = divs.get(2).offsetWidth + divs.get(3).offsetWidth;
|
||||
}
|
||||
var tbl = cal.find('table:first').get(0);
|
||||
var width = tbl.offsetWidth;
|
||||
var height = tbl.offsetHeight;
|
||||
cal.css({
|
||||
width: width + options.extraWidth + 'px',
|
||||
height: height + options.extraHeight + 'px'
|
||||
}).find('div.datepickerContainer').css({
|
||||
width: width + 'px',
|
||||
height: height + 'px'
|
||||
});
|
||||
},
|
||||
click = function(ev) {
|
||||
if ($(ev.target).is('span')) {
|
||||
ev.target = ev.target.parentNode;
|
||||
}
|
||||
var el = $(ev.target);
|
||||
if (el.is('a')) {
|
||||
ev.target.blur();
|
||||
if (el.hasClass('datepickerDisabled')) {
|
||||
return false;
|
||||
}
|
||||
var options = $(this).data('datepicker');
|
||||
var parentEl = el.parent();
|
||||
var tblEl = parentEl.parent().parent().parent();
|
||||
var tblIndex = $('table', this).index(tblEl.get(0)) - 1;
|
||||
var tmp = new Date(options.current);
|
||||
var changed = false;
|
||||
var fillIt = false;
|
||||
if (parentEl.is('th')) {
|
||||
if (parentEl.hasClass('datepickerWeek') && options.mode == 'range' && !parentEl.next().hasClass('datepickerDisabled')) {
|
||||
var val = parseInt(parentEl.next().text(), 10);
|
||||
tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
|
||||
if (parentEl.next().hasClass('datepickerNotInMonth')) {
|
||||
tmp.addMonths(val > 15 ? -1 : 1);
|
||||
}
|
||||
tmp.setDate(val);
|
||||
options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
|
||||
tmp.setHours(23,59,59,0);
|
||||
tmp.addDays(6);
|
||||
options.date[1] = tmp.valueOf();
|
||||
fillIt = true;
|
||||
changed = true;
|
||||
options.lastSel = false;
|
||||
} else if (parentEl.hasClass('datepickerMonth')) {
|
||||
tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
|
||||
switch (tblEl.get(0).className) {
|
||||
case 'datepickerViewDays':
|
||||
tblEl.get(0).className = 'datepickerViewMonths';
|
||||
el.find('span').text(tmp.getFullYear());
|
||||
break;
|
||||
case 'datepickerViewMonths':
|
||||
tblEl.get(0).className = 'datepickerViewYears';
|
||||
el.find('span').text((tmp.getFullYear()-6) + ' - ' + (tmp.getFullYear()+5));
|
||||
break;
|
||||
case 'datepickerViewYears':
|
||||
tblEl.get(0).className = 'datepickerViewDays';
|
||||
el.find('span').text(formatDate(tmp, 'B, Y'));
|
||||
break;
|
||||
}
|
||||
} else if (parentEl.parent().parent().is('thead')) {
|
||||
switch (tblEl.get(0).className) {
|
||||
case 'datepickerViewDays':
|
||||
options.current.addMonths(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
|
||||
break;
|
||||
case 'datepickerViewMonths':
|
||||
options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
|
||||
break;
|
||||
case 'datepickerViewYears':
|
||||
options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -12 : 12);
|
||||
break;
|
||||
}
|
||||
fillIt = true;
|
||||
}
|
||||
} else if (parentEl.is('td') && !parentEl.hasClass('datepickerDisabled')) {
|
||||
switch (tblEl.get(0).className) {
|
||||
case 'datepickerViewMonths':
|
||||
options.current.setMonth(tblEl.find('tbody.datepickerMonths td').index(parentEl));
|
||||
options.current.setFullYear(parseInt(tblEl.find('thead th.datepickerMonth span').text(), 10));
|
||||
options.current.addMonths(Math.floor(options.calendars/2) - tblIndex);
|
||||
tblEl.get(0).className = 'datepickerViewDays';
|
||||
break;
|
||||
case 'datepickerViewYears':
|
||||
options.current.setFullYear(parseInt(el.text(), 10));
|
||||
tblEl.get(0).className = 'datepickerViewMonths';
|
||||
break;
|
||||
default:
|
||||
var val = parseInt(el.text(), 10);
|
||||
tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
|
||||
if (parentEl.hasClass('datepickerNotInMonth')) {
|
||||
tmp.addMonths(val > 15 ? -1 : 1);
|
||||
}
|
||||
tmp.setDate(val);
|
||||
switch (options.mode) {
|
||||
case 'multiple':
|
||||
val = (tmp.setHours(0,0,0,0)).valueOf();
|
||||
if ($.inArray(val, options.date) > -1) {
|
||||
$.each(options.date, function(nr, dat){
|
||||
if (dat == val) {
|
||||
options.date.splice(nr,1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
options.date.push(val);
|
||||
}
|
||||
break;
|
||||
case 'range':
|
||||
if (!options.lastSel) {
|
||||
options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
|
||||
}
|
||||
val = (tmp.setHours(23,59,59,0)).valueOf();
|
||||
if (val < options.date[0]) {
|
||||
options.date[1] = options.date[0] + 86399000;
|
||||
options.date[0] = val - 86399000;
|
||||
} else {
|
||||
options.date[1] = val;
|
||||
}
|
||||
options.lastSel = !options.lastSel;
|
||||
break;
|
||||
default:
|
||||
options.date = tmp.valueOf();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
fillIt = true;
|
||||
changed = true;
|
||||
}
|
||||
if (fillIt) {
|
||||
fill(this);
|
||||
}
|
||||
if (changed) {
|
||||
options.onChange.apply(this, prepareDate(options));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
prepareDate = function (options) {
|
||||
var tmp;
|
||||
if (options.mode == 'single') {
|
||||
tmp = new Date(options.date);
|
||||
return [formatDate(tmp, options.format), tmp, options.el];
|
||||
} else {
|
||||
tmp = [[],[], options.el];
|
||||
$.each(options.date, function(nr, val){
|
||||
var date = new Date(val);
|
||||
tmp[0].push(formatDate(date, options.format));
|
||||
tmp[1].push(date);
|
||||
});
|
||||
return tmp;
|
||||
}
|
||||
},
|
||||
getViewport = function () {
|
||||
var m = document.compatMode == 'CSS1Compat';
|
||||
return {
|
||||
l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
||||
t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
|
||||
w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
|
||||
h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
|
||||
};
|
||||
},
|
||||
isChildOf = function(parentEl, el, container) {
|
||||
if (parentEl == el) {
|
||||
return true;
|
||||
}
|
||||
if (parentEl.contains) {
|
||||
return parentEl.contains(el);
|
||||
}
|
||||
if ( parentEl.compareDocumentPosition ) {
|
||||
return !!(parentEl.compareDocumentPosition(el) & 16);
|
||||
}
|
||||
var prEl = el.parentNode;
|
||||
while(prEl && prEl != container) {
|
||||
if (prEl == parentEl)
|
||||
return true;
|
||||
prEl = prEl.parentNode;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
show = function (ev) {
|
||||
var cal = $('#' + $(this).data('datepickerId'));
|
||||
if (!cal.is(':visible')) {
|
||||
var calEl = cal.get(0);
|
||||
fill(calEl);
|
||||
var options = cal.data('datepicker');
|
||||
options.onBeforeShow.apply(this, [cal.get(0)]);
|
||||
var pos = $(this).offset();
|
||||
var viewPort = getViewport();
|
||||
var top = pos.top;
|
||||
var left = pos.left;
|
||||
var oldDisplay = $.curCSS(calEl, 'display');
|
||||
cal.css({
|
||||
visibility: 'hidden',
|
||||
display: 'block'
|
||||
});
|
||||
layout(calEl);
|
||||
switch (options.position){
|
||||
case 'top':
|
||||
top -= calEl.offsetHeight;
|
||||
break;
|
||||
case 'left':
|
||||
left -= calEl.offsetWidth;
|
||||
break;
|
||||
case 'right':
|
||||
left += this.offsetWidth;
|
||||
break;
|
||||
case 'bottom':
|
||||
top += this.offsetHeight;
|
||||
break;
|
||||
}
|
||||
if (top + calEl.offsetHeight > viewPort.t + viewPort.h) {
|
||||
top = pos.top - calEl.offsetHeight;
|
||||
}
|
||||
if (top < viewPort.t) {
|
||||
top = pos.top + this.offsetHeight + calEl.offsetHeight;
|
||||
}
|
||||
if (left + calEl.offsetWidth > viewPort.l + viewPort.w) {
|
||||
left = pos.left - calEl.offsetWidth;
|
||||
}
|
||||
if (left < viewPort.l) {
|
||||
left = pos.left + this.offsetWidth
|
||||
}
|
||||
cal.css({
|
||||
visibility: 'visible',
|
||||
display: 'block',
|
||||
top: top + 'px',
|
||||
left: left + 'px'
|
||||
});
|
||||
if (options.onShow.apply(this, [cal.get(0)]) != false) {
|
||||
cal.show();
|
||||
}
|
||||
$(document).bind('mousedown', {cal: cal, trigger: this}, hide);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
hide = function (ev) {
|
||||
if (ev.target != ev.data.trigger && !isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
|
||||
if (ev.data.cal.data('datepicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
||||
ev.data.cal.hide();
|
||||
}
|
||||
$(document).unbind('mousedown', hide);
|
||||
}
|
||||
};
|
||||
return {
|
||||
init: function(options){
|
||||
options = $.extend({}, defaults, options||{});
|
||||
extendDate(options.locale);
|
||||
options.calendars = Math.max(1, parseInt(options.calendars,10)||1);
|
||||
options.mode = /single|multiple|range/.test(options.mode) ? options.mode : 'single';
|
||||
return this.each(function(){
|
||||
if (!$(this).data('datepicker')) {
|
||||
options.el = this;
|
||||
if (options.date.constructor == String) {
|
||||
options.date = parseDate(options.date, options.format);
|
||||
options.date.setHours(0,0,0,0);
|
||||
}
|
||||
if (options.mode != 'single') {
|
||||
if (options.date.constructor != Array) {
|
||||
options.date = [options.date.valueOf()];
|
||||
if (options.mode == 'range') {
|
||||
options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < options.date.length; i++) {
|
||||
options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
|
||||
}
|
||||
if (options.mode == 'range') {
|
||||
options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
options.date = options.date.valueOf();
|
||||
}
|
||||
if (!options.current) {
|
||||
options.current = new Date();
|
||||
} else {
|
||||
options.current = parseDate(options.current, options.format);
|
||||
}
|
||||
options.current.setDate(1);
|
||||
options.current.setHours(0,0,0,0);
|
||||
var id = 'datepicker_' + parseInt(Math.random() * 1000), cnt;
|
||||
options.id = id;
|
||||
$(this).data('datepickerId', options.id);
|
||||
var cal = $(tpl.wrapper).attr('id', id).bind('click', click).data('datepicker', options);
|
||||
if (options.className) {
|
||||
cal.addClass(options.className);
|
||||
}
|
||||
var html = '';
|
||||
for (var i = 0; i < options.calendars; i++) {
|
||||
cnt = options.starts;
|
||||
if (i > 0) {
|
||||
html += tpl.space;
|
||||
}
|
||||
html += tmpl(tpl.head.join(''), {
|
||||
week: options.locale.weekMin,
|
||||
prev: options.prev,
|
||||
next: options.next,
|
||||
day1: options.locale.daysMin[(cnt++)%7],
|
||||
day2: options.locale.daysMin[(cnt++)%7],
|
||||
day3: options.locale.daysMin[(cnt++)%7],
|
||||
day4: options.locale.daysMin[(cnt++)%7],
|
||||
day5: options.locale.daysMin[(cnt++)%7],
|
||||
day6: options.locale.daysMin[(cnt++)%7],
|
||||
day7: options.locale.daysMin[(cnt++)%7]
|
||||
});
|
||||
}
|
||||
cal
|
||||
.find('tr:first').append(html)
|
||||
.find('table').addClass(views[options.view]);
|
||||
fill(cal.get(0));
|
||||
if (options.flat) {
|
||||
cal.appendTo(this).show().css('position', 'relative');
|
||||
layout(cal.get(0));
|
||||
} else {
|
||||
cal.appendTo(document.body);
|
||||
$(this).bind(options.eventName, show);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
showPicker: function() {
|
||||
return this.each( function () {
|
||||
if ($(this).data('datepickerId')) {
|
||||
show.apply(this);
|
||||
}
|
||||
});
|
||||
},
|
||||
hidePicker: function() {
|
||||
return this.each( function () {
|
||||
if ($(this).data('datepickerId')) {
|
||||
$('#' + $(this).data('datepickerId')).hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
setDate: function(date, shiftTo){
|
||||
return this.each(function(){
|
||||
if ($(this).data('datepickerId')) {
|
||||
var cal = $('#' + $(this).data('datepickerId'));
|
||||
var options = cal.data('datepicker');
|
||||
options.date = date;
|
||||
if (options.date.constructor == String) {
|
||||
options.date = parseDate(options.date, options.format);
|
||||
options.date.setHours(0,0,0,0);
|
||||
}
|
||||
if (options.mode != 'single') {
|
||||
if (options.date.constructor != Array) {
|
||||
options.date = [options.date.valueOf()];
|
||||
if (options.mode == 'range') {
|
||||
options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < options.date.length; i++) {
|
||||
options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
|
||||
}
|
||||
if (options.mode == 'range') {
|
||||
options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
options.date = options.date.valueOf();
|
||||
}
|
||||
if (shiftTo) {
|
||||
options.current = new Date (options.mode != 'single' ? options.date[0] : options.date);
|
||||
}
|
||||
fill(cal.get(0));
|
||||
}
|
||||
});
|
||||
},
|
||||
getDate: function(formated) {
|
||||
if (this.size() > 0) {
|
||||
return prepareDate($('#' + $(this).data('datepickerId')).data('datepicker'))[formated ? 0 : 1];
|
||||
}
|
||||
},
|
||||
clear: function(){
|
||||
return this.each(function(){
|
||||
if ($(this).data('datepickerId')) {
|
||||
var cal = $('#' + $(this).data('datepickerId'));
|
||||
var options = cal.data('datepicker');
|
||||
if (options.mode != 'single') {
|
||||
options.date = [];
|
||||
fill(cal.get(0));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
fixLayout: function(){
|
||||
return this.each(function(){
|
||||
if ($(this).data('datepickerId')) {
|
||||
var cal = $('#' + $(this).data('datepickerId'));
|
||||
var options = cal.data('datepicker');
|
||||
if (options.flat) {
|
||||
layout(cal.get(0));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
$.fn.extend({
|
||||
DatePicker: DatePicker.init,
|
||||
DatePickerHide: DatePicker.hidePicker,
|
||||
DatePickerShow: DatePicker.showPicker,
|
||||
DatePickerSetDate: DatePicker.setDate,
|
||||
DatePickerGetDate: DatePicker.getDate,
|
||||
DatePickerClear: DatePicker.clear,
|
||||
DatePickerLayout: DatePicker.fixLayout
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
(function(){
|
||||
var cache = {};
|
||||
|
||||
this.tmpl = function tmpl(str, data){
|
||||
// Figure out if we're getting a template, or if we need to
|
||||
// load the template - and be sure to cache the result.
|
||||
var fn = !/\W/.test(str) ?
|
||||
cache[str] = cache[str] ||
|
||||
tmpl(document.getElementById(str).innerHTML) :
|
||||
|
||||
// Generate a reusable function that will serve as a template
|
||||
// generator (and which will be cached).
|
||||
new Function("obj",
|
||||
"var p=[],print=function(){p.push.apply(p,arguments);};" +
|
||||
|
||||
// Introduce the data as local variables using with(){}
|
||||
"with(obj){p.push('" +
|
||||
|
||||
// Convert the template into pure JavaScript
|
||||
str
|
||||
.replace(/[\r\t\n]/g, " ")
|
||||
.split("<%").join("\t")
|
||||
.replace(/((^|%>)[^\t]*)'/g, "$1\r")
|
||||
.replace(/\t=(.*?)%>/g, "',$1,'")
|
||||
.split("\t").join("');")
|
||||
.split("%>").join("p.push('")
|
||||
.split("\r").join("\\'")
|
||||
+ "');}return p.join('');");
|
||||
|
||||
// Provide some basic currying to the user
|
||||
return data ? fn( data ) : fn;
|
||||
};
|
||||
})();
|
34
modules/chat/datepicker/js/eye.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
*
|
||||
* Zoomimage
|
||||
* Author: Stefan Petre www.eyecon.ro
|
||||
*
|
||||
*/
|
||||
(function($){
|
||||
var EYE = window.EYE = function() {
|
||||
var _registered = {
|
||||
init: []
|
||||
};
|
||||
return {
|
||||
init: function() {
|
||||
$.each(_registered.init, function(nr, fn){
|
||||
fn.call();
|
||||
});
|
||||
},
|
||||
extend: function(prop) {
|
||||
for (var i in prop) {
|
||||
if (prop[i] != undefined) {
|
||||
this[i] = prop[i];
|
||||
}
|
||||
}
|
||||
},
|
||||
register: function(fn, type) {
|
||||
if (!_registered[type]) {
|
||||
_registered[type] = [];
|
||||
}
|
||||
_registered[type].push(fn);
|
||||
}
|
||||
};
|
||||
}();
|
||||
$(EYE.init);
|
||||
})(jQuery);
|
4376
modules/chat/datepicker/js/jquery.js
vendored
Normal file
106
modules/chat/datepicker/js/layout.js
Normal file
|
@ -0,0 +1,106 @@
|
|||
(function($){
|
||||
var initLayout = function() {
|
||||
var hash = window.location.hash.replace('#', '');
|
||||
var currentTab = $('ul.navigationTabs a')
|
||||
.bind('click', showTab)
|
||||
.filter('a[rel=' + hash + ']');
|
||||
if (currentTab.size() == 0) {
|
||||
currentTab = $('ul.navigationTabs a:first');
|
||||
}
|
||||
showTab.apply(currentTab.get(0));
|
||||
$('#date').DatePicker({
|
||||
flat: true,
|
||||
date: '2008-07-31',
|
||||
current: '2008-07-31',
|
||||
calendars: 1,
|
||||
starts: 1,
|
||||
view: 'years'
|
||||
});
|
||||
var now = new Date();
|
||||
now.addDays(-10);
|
||||
var now2 = new Date();
|
||||
now2.addDays(-5);
|
||||
now2.setHours(0,0,0,0);
|
||||
$('#date2').DatePicker({
|
||||
flat: true,
|
||||
date: ['2008-07-31', '2008-07-28'],
|
||||
current: '2008-07-31',
|
||||
format: 'Y-m-d',
|
||||
calendars: 1,
|
||||
mode: 'multiple',
|
||||
onRender: function(date) {
|
||||
return {
|
||||
disabled: (date.valueOf() < now.valueOf()),
|
||||
className: date.valueOf() == now2.valueOf() ? 'datepickerSpecial' : false
|
||||
}
|
||||
},
|
||||
onChange: function(formated, dates) {
|
||||
},
|
||||
starts: 0
|
||||
});
|
||||
$('#clearSelection').bind('click', function(){
|
||||
$('#date3').DatePickerClear();
|
||||
return false;
|
||||
});
|
||||
$('#date3').DatePicker({
|
||||
flat: true,
|
||||
date: ['2009-12-28','2010-01-23'],
|
||||
current: '2010-01-01',
|
||||
calendars: 3,
|
||||
mode: 'range',
|
||||
starts: 1
|
||||
});
|
||||
$('.inputDate').DatePicker({
|
||||
format:'m/d/Y',
|
||||
date: $('#inputDate').val(),
|
||||
current: $('#inputDate').val(),
|
||||
starts: 1,
|
||||
position: 'right',
|
||||
onBeforeShow: function(){
|
||||
$('#inputDate').DatePickerSetDate($('#inputDate').val(), true);
|
||||
},
|
||||
onChange: function(formated, dates){
|
||||
$('#inputDate').val(formated);
|
||||
if ($('#closeOnSelect input').attr('checked')) {
|
||||
$('#inputDate').DatePickerHide();
|
||||
}
|
||||
}
|
||||
});
|
||||
var now3 = new Date();
|
||||
now3.addDays(-4);
|
||||
var now4 = new Date()
|
||||
$('#widgetCalendar').DatePicker({
|
||||
flat: true,
|
||||
format: 'd B, Y',
|
||||
date: [new Date(now3), new Date(now4)],
|
||||
calendars: 3,
|
||||
mode: 'range',
|
||||
starts: 1,
|
||||
onChange: function(formated) {
|
||||
$('#widgetField span').get(0).innerHTML = formated.join(' ÷ ');
|
||||
}
|
||||
});
|
||||
var state = false;
|
||||
$('#widgetField>a').bind('click', function(){
|
||||
$('#widgetCalendar').stop().animate({height: state ? 0 : $('#widgetCalendar div.datepicker').get(0).offsetHeight}, 500);
|
||||
state = !state;
|
||||
return false;
|
||||
});
|
||||
$('#widgetCalendar div.datepicker').css('position', 'absolute');
|
||||
};
|
||||
|
||||
var showTab = function(e) {
|
||||
var tabIndex = $('ul.navigationTabs a')
|
||||
.removeClass('active')
|
||||
.index(this);
|
||||
$(this)
|
||||
.addClass('active')
|
||||
.blur();
|
||||
$('div.tab')
|
||||
.hide()
|
||||
.eq(tabIndex)
|
||||
.show();
|
||||
};
|
||||
|
||||
EYE.register(initLayout, 'init');
|
||||
})(jQuery)
|
252
modules/chat/datepicker/js/utils.js
Normal file
|
@ -0,0 +1,252 @@
|
|||
/**
|
||||
*
|
||||
* Utilities
|
||||
* Author: Stefan Petre www.eyecon.ro
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
EYE.extend({
|
||||
getPosition : function(e, forceIt)
|
||||
{
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var es = e.style;
|
||||
var restoreStyles = false;
|
||||
if (forceIt && jQuery.curCSS(e,'display') == 'none') {
|
||||
var oldVisibility = es.visibility;
|
||||
var oldPosition = es.position;
|
||||
restoreStyles = true;
|
||||
es.visibility = 'hidden';
|
||||
es.display = 'block';
|
||||
es.position = 'absolute';
|
||||
}
|
||||
var el = e;
|
||||
if (el.getBoundingClientRect) { // IE
|
||||
var box = el.getBoundingClientRect();
|
||||
x = box.left + Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) - 2;
|
||||
y = box.top + Math.max(document.documentElement.scrollTop, document.body.scrollTop) - 2;
|
||||
} else {
|
||||
x = el.offsetLeft;
|
||||
y = el.offsetTop;
|
||||
el = el.offsetParent;
|
||||
if (e != el) {
|
||||
while (el) {
|
||||
x += el.offsetLeft;
|
||||
y += el.offsetTop;
|
||||
el = el.offsetParent;
|
||||
}
|
||||
}
|
||||
if (jQuery.browser.safari && jQuery.curCSS(e, 'position') == 'absolute' ) {
|
||||
x -= document.body.offsetLeft;
|
||||
y -= document.body.offsetTop;
|
||||
}
|
||||
el = e.parentNode;
|
||||
while (el && el.tagName.toUpperCase() != 'BODY' && el.tagName.toUpperCase() != 'HTML')
|
||||
{
|
||||
if (jQuery.curCSS(el, 'display') != 'inline') {
|
||||
x -= el.scrollLeft;
|
||||
y -= el.scrollTop;
|
||||
}
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
if (restoreStyles == true) {
|
||||
es.display = 'none';
|
||||
es.position = oldPosition;
|
||||
es.visibility = oldVisibility;
|
||||
}
|
||||
return {x:x, y:y};
|
||||
},
|
||||
getSize : function(e)
|
||||
{
|
||||
var w = parseInt(jQuery.curCSS(e,'width'), 10);
|
||||
var h = parseInt(jQuery.curCSS(e,'height'), 10);
|
||||
var wb = 0;
|
||||
var hb = 0;
|
||||
if (jQuery.curCSS(e, 'display') != 'none') {
|
||||
wb = e.offsetWidth;
|
||||
hb = e.offsetHeight;
|
||||
} else {
|
||||
var es = e.style;
|
||||
var oldVisibility = es.visibility;
|
||||
var oldPosition = es.position;
|
||||
es.visibility = 'hidden';
|
||||
es.display = 'block';
|
||||
es.position = 'absolute';
|
||||
wb = e.offsetWidth;
|
||||
hb = e.offsetHeight;
|
||||
es.display = 'none';
|
||||
es.position = oldPosition;
|
||||
es.visibility = oldVisibility;
|
||||
}
|
||||
return {w:w, h:h, wb:wb, hb:hb};
|
||||
},
|
||||
getClient : function(e)
|
||||
{
|
||||
var h, w;
|
||||
if (e) {
|
||||
w = e.clientWidth;
|
||||
h = e.clientHeight;
|
||||
} else {
|
||||
var de = document.documentElement;
|
||||
w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
|
||||
h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
|
||||
}
|
||||
return {w:w,h:h};
|
||||
},
|
||||
getScroll : function (e)
|
||||
{
|
||||
var t=0, l=0, w=0, h=0, iw=0, ih=0;
|
||||
if (e && e.nodeName.toLowerCase() != 'body') {
|
||||
t = e.scrollTop;
|
||||
l = e.scrollLeft;
|
||||
w = e.scrollWidth;
|
||||
h = e.scrollHeight;
|
||||
} else {
|
||||
if (document.documentElement) {
|
||||
t = document.documentElement.scrollTop;
|
||||
l = document.documentElement.scrollLeft;
|
||||
w = document.documentElement.scrollWidth;
|
||||
h = document.documentElement.scrollHeight;
|
||||
} else if (document.body) {
|
||||
t = document.body.scrollTop;
|
||||
l = document.body.scrollLeft;
|
||||
w = document.body.scrollWidth;
|
||||
h = document.body.scrollHeight;
|
||||
}
|
||||
if (typeof pageYOffset != 'undefined') {
|
||||
t = pageYOffset;
|
||||
l = pageXOffset;
|
||||
}
|
||||
iw = self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0;
|
||||
ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0;
|
||||
}
|
||||
return { t: t, l: l, w: w, h: h, iw: iw, ih: ih };
|
||||
},
|
||||
getMargins : function(e, toInteger)
|
||||
{
|
||||
var t = jQuery.curCSS(e,'marginTop') || '';
|
||||
var r = jQuery.curCSS(e,'marginRight') || '';
|
||||
var b = jQuery.curCSS(e,'marginBottom') || '';
|
||||
var l = jQuery.curCSS(e,'marginLeft') || '';
|
||||
if (toInteger)
|
||||
return {
|
||||
t: parseInt(t, 10)||0,
|
||||
r: parseInt(r, 10)||0,
|
||||
b: parseInt(b, 10)||0,
|
||||
l: parseInt(l, 10)
|
||||
};
|
||||
else
|
||||
return {t: t, r: r, b: b, l: l};
|
||||
},
|
||||
getPadding : function(e, toInteger)
|
||||
{
|
||||
var t = jQuery.curCSS(e,'paddingTop') || '';
|
||||
var r = jQuery.curCSS(e,'paddingRight') || '';
|
||||
var b = jQuery.curCSS(e,'paddingBottom') || '';
|
||||
var l = jQuery.curCSS(e,'paddingLeft') || '';
|
||||
if (toInteger)
|
||||
return {
|
||||
t: parseInt(t, 10)||0,
|
||||
r: parseInt(r, 10)||0,
|
||||
b: parseInt(b, 10)||0,
|
||||
l: parseInt(l, 10)
|
||||
};
|
||||
else
|
||||
return {t: t, r: r, b: b, l: l};
|
||||
},
|
||||
getBorder : function(e, toInteger)
|
||||
{
|
||||
var t = jQuery.curCSS(e,'borderTopWidth') || '';
|
||||
var r = jQuery.curCSS(e,'borderRightWidth') || '';
|
||||
var b = jQuery.curCSS(e,'borderBottomWidth') || '';
|
||||
var l = jQuery.curCSS(e,'borderLeftWidth') || '';
|
||||
if (toInteger)
|
||||
return {
|
||||
t: parseInt(t, 10)||0,
|
||||
r: parseInt(r, 10)||0,
|
||||
b: parseInt(b, 10)||0,
|
||||
l: parseInt(l, 10)||0
|
||||
};
|
||||
else
|
||||
return {t: t, r: r, b: b, l: l};
|
||||
},
|
||||
traverseDOM : function(nodeEl, func)
|
||||
{
|
||||
func(nodeEl);
|
||||
nodeEl = nodeEl.firstChild;
|
||||
while(nodeEl){
|
||||
EYE.traverseDOM(nodeEl, func);
|
||||
nodeEl = nodeEl.nextSibling;
|
||||
}
|
||||
},
|
||||
getInnerWidth : function(el, scroll) {
|
||||
var offsetW = el.offsetWidth;
|
||||
return scroll ? Math.max(el.scrollWidth,offsetW) - offsetW + el.clientWidth:el.clientWidth;
|
||||
},
|
||||
getInnerHeight : function(el, scroll) {
|
||||
var offsetH = el.offsetHeight;
|
||||
return scroll ? Math.max(el.scrollHeight,offsetH) - offsetH + el.clientHeight:el.clientHeight;
|
||||
},
|
||||
getExtraWidth : function(el) {
|
||||
if($.boxModel)
|
||||
return (parseInt($.curCSS(el, 'paddingLeft'))||0)
|
||||
+ (parseInt($.curCSS(el, 'paddingRight'))||0)
|
||||
+ (parseInt($.curCSS(el, 'borderLeftWidth'))||0)
|
||||
+ (parseInt($.curCSS(el, 'borderRightWidth'))||0);
|
||||
return 0;
|
||||
},
|
||||
getExtraHeight : function(el) {
|
||||
if($.boxModel)
|
||||
return (parseInt($.curCSS(el, 'paddingTop'))||0)
|
||||
+ (parseInt($.curCSS(el, 'paddingBottom'))||0)
|
||||
+ (parseInt($.curCSS(el, 'borderTopWidth'))||0)
|
||||
+ (parseInt($.curCSS(el, 'borderBottomWidth'))||0);
|
||||
return 0;
|
||||
},
|
||||
isChildOf: function(parentEl, el, container) {
|
||||
if (parentEl == el) {
|
||||
return true;
|
||||
}
|
||||
if (!el || !el.nodeType || el.nodeType != 1) {
|
||||
return false;
|
||||
}
|
||||
if (parentEl.contains && !$.browser.safari) {
|
||||
return parentEl.contains(el);
|
||||
}
|
||||
if ( parentEl.compareDocumentPosition ) {
|
||||
return !!(parentEl.compareDocumentPosition(el) & 16);
|
||||
}
|
||||
var prEl = el.parentNode;
|
||||
while(prEl && prEl != container) {
|
||||
if (prEl == parentEl)
|
||||
return true;
|
||||
prEl = prEl.parentNode;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
centerEl : function(el, axis)
|
||||
{
|
||||
var clientScroll = EYE.getScroll();
|
||||
var size = EYE.getSize(el);
|
||||
if (!axis || axis == 'vertically')
|
||||
$(el).css(
|
||||
{
|
||||
top: clientScroll.t + ((Math.min(clientScroll.h,clientScroll.ih) - size.hb)/2) + 'px'
|
||||
}
|
||||
);
|
||||
if (!axis || axis == 'horizontally')
|
||||
$(el).css(
|
||||
{
|
||||
left: clientScroll.l + ((Math.min(clientScroll.w,clientScroll.iw) - size.wb)/2) + 'px'
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
if (!$.easing.easeout) {
|
||||
$.easing.easeout = function(p, n, firstNum, delta, duration) {
|
||||
return -delta * ((n=n/duration-1)*n*n*n - 1) + firstNum;
|
||||
};
|
||||
}
|
||||
|
||||
})(jQuery);
|