Commit 758c4469 by Chris Dodge

wip on setting date/times on subsection page

parent 3b38070d
from django.conf import settings
from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore
'''
cdodge: for a given Xmodule, return the course that it belongs to
NOTE: This makes a lot of assumptions about the format of the course location
Also we have to assert that this module maps to only one course item - it'll throw an
assert if not
'''
def get_course_location_for_item(location):
'''
cdodge: for a given Xmodule, return the course that it belongs to
NOTE: This makes a lot of assumptions about the format of the course location
Also we have to assert that this module maps to only one course item - it'll throw an
assert if not
'''
item_loc = Location(location)
# check to see if item is already a course, if so we can skip this
......@@ -29,3 +30,18 @@ def get_course_location_for_item(location):
location = courses[0].location
return location
def get_lms_link_for_item(item):
if settings.LMS_BASE is not None:
lms_link = "{lms_base}/courses/{course_id}/jump_to/{location}".format(
lms_base=settings.LMS_BASE,
# TODO: These will need to be changed to point to the particular instance of this problem in the particular course
course_id = modulestore().get_containing_courses(item.location)[0].id,
location=item.location,
)
else:
lms_link = None
return lms_link
......@@ -43,7 +43,7 @@ from cache_toolbox.core import set_cached_content, get_cached_content, del_cache
from auth.authz import is_user_in_course_group_role, get_users_in_course_group_by_role
from auth.authz import get_user_by_email, add_user_to_course_group, remove_user_from_course_group
from auth.authz import ADMIN_ROLE_NAME, EDITOR_ROLE_NAME
from .utils import get_course_location_for_item
from .utils import get_course_location_for_item, get_lms_link_for_item
from xmodule.templates import all_templates
......@@ -143,13 +143,18 @@ def edit_subsection(request, location):
item = modulestore().get_item(location)
lms_link = get_lms_link_for_item(item)
# make sure that location references a 'sequential', otherwise return BadRequest
if item.location.category != 'sequential':
return HttpResponseBadRequest
logging.debug('Start = {0}'.format(item.start))
return render_to_response('edit_subsection.html',
{'subsection': item,
'create_new_unit_template': Location('i4x', 'edx', 'templates', 'vertical', 'Empty')
'create_new_unit_template': Location('i4x', 'edx', 'templates', 'vertical', 'Empty'),
'lms_link': lms_link
})
@login_required
......@@ -167,15 +172,7 @@ def edit_unit(request, location):
item = modulestore().get_item(location)
if settings.LMS_BASE is not None:
lms_link = "{lms_base}/courses/{course_id}/jump_to/{location}".format(
lms_base=settings.LMS_BASE,
# TODO: These will need to be changed to point to the particular instance of this problem in the particular course
course_id = modulestore().get_containing_courses(item.location)[0].id,
location=item.location,
)
else:
lms_link = None
lms_link = get_lms_link_for_item(item)
component_templates = defaultdict(list)
......
......@@ -31,6 +31,11 @@ $(document).ready(function() {
$('.sortable-unit-list').sortable();
$('.sortable-unit-list').disableSelection();
$('.sortable-unit-list').bind('sortstop', onUnitReordered);
// expand/collapse methods for optional date setters
$('.set-date').bind('click', showDateSetter);
$('.remove-date').bind('click', removeDateSetter);
});
// This method only changes the ordering of the child objects in a subsection
......@@ -198,8 +203,22 @@ function hideHistoryModal(e) {
$modalCover.hide();
}
function showDateSetter(e) {
e.preventDefault();
var $block = $(this).closest('.due-date-input');
$(this).hide();
$block.find('.date-setter').show();
}
function removeDateSetter(e) {
e.preventDefault();
var $block = $(this).closest('.due-date-input');
$block.find('.date-setter').hide();
$block.find('.set-date').show();
// clear out the values
$block.find('.date').val('');
$block.find('.time').val('');
}
<%inherit file="base.html" />
<%!
import time
import dateutil.parser
from datetime import datetime
now = datetime.now()
%>
<%! from django.core.urlresolvers import reverse %>
<%block name="bodyclass">subsection</%block>
<%block name="title">CMS Subsection</%block>
<%namespace name="units" file="widgets/units.html" />
<%namespace name='static' file='static_content.html'/>
<%namespace name='datetime' module='datetime'/>
<%block name="content">
<div class="main-wrapper">
......@@ -15,8 +25,8 @@
<input type="text" value="${subsection.metadata['display_name']}" class="subsection-display-name-input" data-metadata-name="display_name"/>
</div>
<div>
<label>Subtitle:</label>
<input type="text" value="${subsection.metadata['subtitle'] if 'subtitle' in subsection.metadata else ''}" class="unit-subtitle" data-metadata-name="subtitle"/>
<label>Format:</label>
<input type="text" value="${subsection.metadata['format'] if 'format' in subsection.metadata else ''}" class="unit-subtitle" data-metadata-name="subtitle"/>
</div>
<div class="unit-list">
<label>Units:</label>
......@@ -35,31 +45,38 @@
<div class="window-contents">
<div class="scheduled-date-input row">
<label>Release date:<!-- <span class="description">Determines when this subsection and the units within it will be released publicly.</span>--></label>
<div class="date-setter">
<input type="text" value="10/22/2012" class="date-input" />
<input type="text" value="6:00 am" class="time-input" />
<div class="datepair" data-language="javascript">
<input type="text" value="${subsection.start.strftime('%Y-%m-%d') if subsection.start is not None else ''}" placeholder="MM/DD/YYYY" class="date" size='15'/>
<input type="text" value="${subsection.start.strftime('%H:%M') if subsection.start is not None else ''}" placeholder="HH:MM" class="time" size='10'/>
</div>
<p class="notice">The date above differs from the release date of Week 1 – 10/10/2012 at 12:00 am. <a href="#" class="sync-date">Sync to Week 1.</a></p>
</div>
<div class="due-date-input row">
<label>Due date:</label>
<a href="#" class="set-date">Set a due date</a>
<div class="date-setter">
<p class="date-description"><input type="text" value="10/20/2012" class="date-input" /> <input type="text" value="6:00 am" class="time-input" />
<div class="datepair date-setter">
<p class="date-description">
<%
due_date = dateutil.parser.parse(subsection.metadata.get('get')) if 'due' in subsection.metadata else None
%>
<input type="text" value="${due_date.strftime('%Y-%m-%d') if due_date is not None else ''}" placeholder="MM/DD/YYYY" class="date" size='15' />
<input type="text" value="${due_date.strftime('%H:%M') if due_date is not None else ''}" placeholder="HH:MM" class="time" size='10' />
<a href="#" class="remove-date">Remove due date</a>
</p>
</div>
</div>
<div class="visibility row">
<label>Visibility:<!-- <span class="description">Shows or hides this subsection and the units within it.</span>--></label>
<a href="#" class="toggle-off">hide</a><a href="#" class="large-toggle"></a><a href="#" class="toggle-on">show</a>
</div>
<div class="row unit-actions">
<a href="#" class="save-button save-subsection" data-id="${subsection.location}">Save</a>
<a href="preview.html" target="_blank" class="preview-button">Preview</a>
<a href="${lms_link}" target="_blank" class="preview-button">Preview</a>
</div>
</div>
</div>
</div>
</div>
</%block>
<%block name="jsextra">
<link rel="stylesheet" type="text/css" href="${static.url('js/vendor/timepicker/jquery.timepicker.css')}" />
<script src="${static.url('js/vendor/timepicker/jquery.timepicker.js')}"></script>
<script src="${static.url('js/vendor/timepicker/datepair.js')}"></script>
</%block>
$(function() {
$('.datepair input.date').each(function(){
var $this = $(this);
$this.datepicker({ 'dateFormat': 'm/d/yy' });
if ($this.hasClass('start') || $this.hasClass('end')) {
$this.on('changeDate change', doDatepair);
}
});
$('.datepair input.time').each(function() {
var $this = $(this);
var opts = { 'showDuration': true, 'timeFormat': 'g:ia', 'scrollDefaultNow': true };
if ($this.hasClass('start') || $this.hasClass('end')) {
opts.onSelect = doDatepair;
}
$this.timepicker(opts);
});
$('.datepair').each(initDatepair);
function initDatepair()
{
var container = $(this);
var startDateInput = container.find('input.start.date');
var endDateInput = container.find('input.end.date');
var dateDelta = 0;
if (startDateInput.length && endDateInput.length) {
var startDate = new Date(startDateInput.val());
var endDate = new Date(endDateInput.val());
dateDelta = endDate.getTime() - startDate.getTime();
container.data('dateDelta', dateDelta);
}
var startTimeInput = container.find('input.start.time');
var endTimeInput = container.find('input.end.time');
if (startTimeInput.length && endTimeInput.length) {
var startInt = startTimeInput.timepicker('getSecondsFromMidnight');
var endInt = endTimeInput.timepicker('getSecondsFromMidnight');
container.data('timeDelta', endInt - startInt);
if (dateDelta < 86400000) {
endTimeInput.timepicker('option', 'minTime', startInt);
}
}
}
function doDatepair()
{
var target = $(this);
if (target.val() == '') {
return;
}
var container = target.closest('.datepair');
if (target.hasClass('date')) {
updateDatePair(target, container);
} else if (target.hasClass('time')) {
updateTimePair(target, container);
}
}
function updateDatePair(target, container)
{
var start = container.find('input.start.date');
var end = container.find('input.end.date');
if (!start.length || !end.length) {
return;
}
var startDate = new Date(start.val());
var endDate = new Date(end.val());
var oldDelta = container.data('dateDelta');
if (oldDelta && target.hasClass('start')) {
var newEnd = new Date(startDate.getTime()+oldDelta);
end.val(newEnd.format('m/d/Y'));
end.datepicker('update');
return;
} else {
var newDelta = endDate.getTime() - startDate.getTime();
if (newDelta < 0) {
newDelta = 0;
if (target.hasClass('start')) {
end.val(startDate.format('m/d/Y'));
end.datepicker('update');
} else if (target.hasClass('end')) {
start.val(endDate.format('m/d/Y'));
start.datepicker('update');
}
}
if (newDelta < 86400000) {
var startTimeVal = container.find('input.start.time').val();
if (startTimeVal) {
container.find('input.end.time').timepicker('option', {'minTime': startTimeVal});
}
} else {
container.find('input.end.time').timepicker('option', {'minTime': null});
}
container.data('dateDelta', newDelta);
}
}
function updateTimePair(target, container)
{
var start = container.find('input.start.time');
var end = container.find('input.end.time');
if (!start.length || !end.length) {
return;
}
var startInt = start.timepicker('getSecondsFromMidnight');
var endInt = end.timepicker('getSecondsFromMidnight');
var oldDelta = container.data('timeDelta');
var dateDelta = container.data('dateDelta');
if (target.hasClass('start') && (!dateDelta || dateDelta < 86400000)) {
end.timepicker('option', 'minTime', startInt);
}
var endDateAdvance = 0;
var newDelta;
if (oldDelta && target.hasClass('start')) {
// lock the duration and advance the end time
var newEnd = (startInt+oldDelta)%86400;
if (newEnd < 0) {
newEnd += 86400;
}
end.timepicker('setTime', newEnd);
newDelta = newEnd - startInt;
} else if (startInt !== null && endInt !== null) {
newDelta = endInt - startInt;
} else {
return;
}
container.data('timeDelta', newDelta);
if (newDelta < 0 && (!oldDelta || oldDelta > 0)) {
// overnight time span. advance the end date 1 day
var endDateAdvance = 86400000;
} else if (newDelta > 0 && oldDelta < 0) {
// switching from overnight to same-day time span. decrease the end date 1 day
var endDateAdvance = -86400000;
}
var startInput = container.find('.start.date');
var endInput = container.find('.end.date');
if (startInput.val() && !endInput.val()) {
endInput.val(startInput.val());
endInput.datepicker('update');
dateDelta = 0;
container.data('dateDelta', 0);
}
if (endDateAdvance != 0) {
if (dateDelta || dateDelta === 0) {
var endDate = new Date(endInput.val());
var newEnd = new Date(endDate.getTime() + endDateAdvance);
endInput.val(newEnd.format('m/d/Y'));
endInput.datepicker('update');
container.data('dateDelta', dateDelta + endDateAdvance);
}
}
}
});
// Simulates PHP's date function
Date.prototype.format=function(format){var returnStr='';var replace=Date.replaceChars;for(var i=0;i<format.length;i++){var curChar=format.charAt(i);if(replace[curChar]){returnStr+=replace[curChar].call(this);}else{returnStr+=curChar;}}return returnStr;};Date.replaceChars={shortMonths:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],longMonths:['January','February','March','April','May','June','July','August','September','October','November','December'],shortDays:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],longDays:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d:function(){return(this.getDate()<10?'0':'')+this.getDate();},D:function(){return Date.replaceChars.shortDays[this.getDay()];},j:function(){return this.getDate();},l:function(){return Date.replaceChars.longDays[this.getDay()];},N:function(){return this.getDay()+1;},S:function(){return(this.getDate()%10==1&&this.getDate()!=11?'st':(this.getDate()%10==2&&this.getDate()!=12?'nd':(this.getDate()%10==3&&this.getDate()!=13?'rd':'th')));},w:function(){return this.getDay();},z:function(){return"Not Yet Supported";},W:function(){return"Not Yet Supported";},F:function(){return Date.replaceChars.longMonths[this.getMonth()];},m:function(){return(this.getMonth()<9?'0':'')+(this.getMonth()+1);},M:function(){return Date.replaceChars.shortMonths[this.getMonth()];},n:function(){return this.getMonth()+1;},t:function(){return"Not Yet Supported";},L:function(){return(((this.getFullYear()%4==0)&&(this.getFullYear()%100!=0))||(this.getFullYear()%400==0))?'1':'0';},o:function(){return"Not Supported";},Y:function(){return this.getFullYear();},y:function(){return(''+this.getFullYear()).substr(2);},a:function(){return this.getHours()<12?'am':'pm';},A:function(){return this.getHours()<12?'AM':'PM';},B:function(){return"Not Yet Supported";},g:function(){return this.getHours()%12||12;},G:function(){return this.getHours();},h:function(){return((this.getHours()%12||12)<10?'0':'')+(this.getHours()%12||12);},H:function(){return(this.getHours()<10?'0':'')+this.getHours();},i:function(){return(this.getMinutes()<10?'0':'')+this.getMinutes();},s:function(){return(this.getSeconds()<10?'0':'')+this.getSeconds();},e:function(){return"Not Yet Supported";},I:function(){return"Not Supported";},O:function(){return(-this.getTimezoneOffset()<0?'-':'+')+(Math.abs(this.getTimezoneOffset()/60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()/60))+'00';},P:function(){return(-this.getTimezoneOffset()<0?'-':'+')+(Math.abs(this.getTimezoneOffset()/60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()/60))+':'+(Math.abs(this.getTimezoneOffset()%60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()%60));},T:function(){var m=this.getMonth();this.setMonth(0);var result=this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/,'$1');this.setMonth(m);return result;},Z:function(){return-this.getTimezoneOffset()*60;},c:function(){return this.format("Y-m-d")+"T"+this.format("H:i:sP");},r:function(){return this.toString();},U:function(){return this.getTime()/1000;}};
\ No newline at end of file
.ui-timepicker-list {
overflow-y: auto;
height: 150px;
width: 6.5em;
background: #fff;
border: 1px solid #ddd;
margin: 0;
padding: 0;
list-style: none;
-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);
-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);
box-shadow:0 5px 10px rgba(0,0,0,0.2);
outline: none;
z-index: 10001;
}
.ui-timepicker-list.ui-timepicker-with-duration {
width: 11em;
}
.ui-timepicker-duration {
margin-left: 5px; color: #888;
}
.ui-timepicker-list:hover .ui-timepicker-duration {
color: #888;
}
.ui-timepicker-list li {
padding: 3px 0 3px 5px;
cursor: pointer;
white-space: nowrap;
color: #000;
list-style: none;
margin: 0;
}
.ui-timepicker-list:hover .ui-timepicker-selected {
background: #fff; color: #000;
}
li.ui-timepicker-selected,
.ui-timepicker-list li:hover,
.ui-timepicker-list:hover .ui-timepicker-selected:hover {
background: #1980EC; color: #fff;
}
li.ui-timepicker-selected .ui-timepicker-duration,
.ui-timepicker-list li:hover .ui-timepicker-duration {
color: #ccc;
}
!function(e){function o(t){var r=t.data("timepicker-settings"),i=t.data("timepicker-list");i&&i.length&&(i.remove(),t.data("timepicker-list",!1)),i=e("<ul />"),i.attr("tabindex",-1),i.addClass("ui-timepicker-list"),r.className&&i.addClass(r.className),i.css({display:"none",position:"absolute"}),r.minTime!==null&&r.showDuration&&i.addClass("ui-timepicker-with-duration");var s=r.durationTime!==null?r.durationTime:r.minTime,o=r.minTime!==null?r.minTime:0,u=r.maxTime!==null?r.maxTime:o+n-1;u<=o&&(u+=n);for(var f=o;f<=u;f+=r.step*60){var l=f%n,d=e("<li />");d.data("time",l),d.text(p(l,r.timeFormat));if(r.minTime!==null&&r.showDuration){var v=e("<span />");v.addClass("ui-timepicker-duration"),v.text(" ("+h(f-s)+")"),d.append(v)}i.append(d)}i.data("timepicker-input",t),t.data("timepicker-list",i),e("body").append(i),a(t,i),i.delegate("li","click",{timepicker:t},function(n){t.addClass("ui-timepicker-hideme"),t[0].focus(),i.find("li").removeClass("ui-timepicker-selected"),e(this).addClass("ui-timepicker-selected"),c(t),i.hide()})}function u(t,n,r){if(!r&&r!==0)return!1;var i=t.data("timepicker-settings"),s=!1;return n.find("li").each(function(t,n){var o=e(n);if(Math.abs(o.data("time")-r)<=i.step*30)return s=o,!1}),s}function a(e,t){var n=d(e.val()),r=u(e,t,n);r&&r.addClass("ui-timepicker-selected")}function f(){if(this.value=="")return;var t=e(this),n=p(d(this.value),t.data("timepicker-settings").timeFormat);t.val(n)}function l(t){var n=e(this),r=n.data("timepicker-list");if(!r.is(":visible")){if(t.keyCode!=40)return!0;n.focus()}switch(t.keyCode){case 13:return c(n),s.hide.apply(this),t.preventDefault(),!1;case 38:var i=r.find(".ui-timepicker-selected");if(!i.length){var i;r.children().each(function(t,n){if(e(n).position().top>0)return i=e(n),!1}),i.addClass("ui-timepicker-selected")}else i.is(":first-child")||(i.removeClass("ui-timepicker-selected"),i.prev().addClass("ui-timepicker-selected"),i.prev().position().top<i.outerHeight()&&r.scrollTop(r.scrollTop()-i.outerHeight()));break;case 40:var i=r.find(".ui-timepicker-selected");if(i.length==0){var i;r.children().each(function(t,n){if(e(n).position().top>0)return i=e(n),!1}),i.addClass("ui-timepicker-selected")}else i.is(":last-child")||(i.removeClass("ui-timepicker-selected"),i.next().addClass("ui-timepicker-selected"),i.next().position().top+2*i.outerHeight()>r.outerHeight()&&r.scrollTop(r.scrollTop()+i.outerHeight()));break;case 27:r.find("li").removeClass("ui-timepicker-selected"),r.hide();break;case 9:case 16:case 17:case 18:case 19:case 20:case 33:case 34:case 35:case 36:case 37:case 39:case 45:return;default:r.find("li").removeClass("ui-timepicker-selected");return}}function c(e){var t=e.data("timepicker-settings"),n=e.data("timepicker-list"),r=null,i=n.find(".ui-timepicker-selected");if(i.length)var r=i.data("time");else if(e.val()){var r=d(e.val());a(e,n)}if(r!==null){var s=p(r,t.timeFormat);e.attr("value",s)}e.trigger("change").trigger("changeTime")}function h(e){var t=Math.round(e/60),n;if(t<60)n=[t,i.mins];else if(t==60)n=["1",i.hr];else{var r=(t/60).toFixed(1);i.decimal!="."&&(r=r.replace(".",i.decimal)),n=[r,i.hrs]}return n.join(" ")}function p(e,n){var r=new Date(t.valueOf()+e*1e3),i="";for(var s=0;s<n.length;s++){var o=n.charAt(s);switch(o){case"a":i+=r.getHours()>11?"pm":"am";break;case"A":i+=r.getHours()>11?"PM":"AM";break;case"g":var u=r.getHours()%12;i+=u==0?"12":u;break;case"G":i+=r.getHours();break;case"h":var u=r.getHours()%12;u!=0&&u<10&&(u="0"+u),i+=u==0?"12":u;break;case"H":var u=r.getHours();i+=u>9?u:"0"+u;break;case"i":var a=r.getMinutes();i+=a>9?a:"0"+a;break;case"s":var e=r.getSeconds();i+=e>9?e:"0"+e;break;default:i+=o}}return i}function d(e){if(e=="")return null;if(e+0==e)return e;typeof e=="object"&&(e=e.getHours()+":"+e.getMinutes());var t=new Date(0),n=e.toLowerCase().match(/(\d+)(?::(\d\d))?\s*([pa]?)/);if(!n)return null;var r=parseInt(n[1]*1);if(n[3])if(r==12)var i=n[3]=="p"?12:0;else var i=r+(n[3]=="p"?12:0);else var i=r;var s=n[2]*1||0;return i*3600+s*60}var t=new Date;t.setHours(0),t.setMinutes(0),t.setSeconds(0);var n=86400,r={className:null,minTime:null,maxTime:null,durationTime:null,step:30,showDuration:!1,timeFormat:"g:ia",scrollDefaultNow:!1,scrollDefaultTime:!1,selectOnBlur:!1},i={decimal:".",mins:"mins",hr:"hr",hrs:"hrs"},s={init:function(t){return this.each(function(){var n=e(this);if(n[0].tagName=="SELECT"){var o=e("<input />"),u={type:"text",value:n.val()},a=n[0].attributes;for(var c=0;c<a.length;c++)u[a[c].nodeName]=a[c].nodeValue;o.attr(u),n.replaceWith(o),n=o}var h=e.extend({},r);t&&(h=e.extend(h,t)),h.minTime&&(h.minTime=d(h.minTime)),h.maxTime&&(h.maxTime=d(h.maxTime)),h.durationTime&&(h.durationTime=d(h.durationTime)),h.lang&&(i=e.extend(i,h.lang)),n.data("timepicker-settings",h),n.attr("autocomplete","off"),n.click(s.show).focus(s.show).blur(f).keydown(l),n.addClass("ui-timepicker-input");if(n.val()){var v=p(d(n.val()),h.timeFormat);n.val(v)}e("body").attr("tabindex",-1).focusin(function(t){e(t.target).closest(".ui-timepicker-input").length==0&&e(t.target).closest(".ui-timepicker-list").length==0&&s.hide()})})},show:function(t){var n=e(this),r=n.data("timepicker-list");if(!r||r.length==0)o(n),r=n.data("timepicker-list");if(n.hasClass("ui-timepicker-hideme")){n.removeClass("ui-timepicker-hideme"),r.hide();return}if(r.is(":visible"))return;s.hide();var i=parseInt(n.css("marginTop").slice(0,-2));i||(i=0),n.offset().top+n.outerHeight(!0)+r.outerHeight()>e(window).height()+e(window).scrollTop()?r.css({left:n.offset().left,top:n.offset().top+i-r.outerHeight()}):r.css({left:n.offset().left,top:n.offset().top+i+n.outerHeight()}),r.show();var a=n.data("timepicker-settings"),f=r.find(".ui-timepicker-selected");f.length||(n.val()?f=u(n,r,d(n.val())):a.minTime===null&&a.scrollDefaultNow?f=u(n,r,d(new Date)):a.scrollDefaultTime!==!1&&(f=u(n,r,d(a.scrollDefaultTime))));if(f&&f.length){var l=r.scrollTop()+f.position().top-f.outerHeight();r.scrollTop(l)}else r.scrollTop(0);n.trigger("showTimepicker")},hide:function(t){e(".ui-timepicker-list:visible").each(function(){var t=e(this),n=t.data("timepicker-input"),r=n.data("timepicker-settings");r.selectOnBlur&&c(n),t.hide(),n.trigger("hideTimepicker")})},option:function(t,n){var r=e(this),i=r.data("timepicker-settings"),s=r.data("timepicker-list");if(typeof t=="object")i=e.extend(i,t);else if(typeof t=="string"&&typeof n!="undefined")i[t]=n;else if(typeof t=="string")return i[t];i.minTime&&(i.minTime=d(i.minTime)),i.maxTime&&(i.maxTime=d(i.maxTime)),i.durationTime&&(i.durationTime=d(i.durationTime)),r.data("timepicker-settings",i),s&&(s.remove(),r.data("timepicker-list",!1))},getSecondsFromMidnight:function(){return d(e(this).val())},getTime:function(){return new Date(t.valueOf()+d(e(this).val())*1e3)},setTime:function(t){var n=e(this),r=p(d(t),n.data("timepicker-settings").timeFormat);n.val(r)}};e.fn.timepicker=function(t){if(s[t])return s[t].apply(this,Array.prototype.slice.call(arguments,1));if(typeof t=="object"||!t)return s.init.apply(this,arguments);e.error("Method "+t+" does not exist on jQuery.timepicker")}}(jQuery)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment