Run though jslint to clean up

This commit is contained in:
Trent Richardson 2010-11-10 13:33:43 -05:00
parent 23f19b76c3
commit 0c56593fb4

View file

@ -19,7 +19,7 @@
(function($) { (function($) {
function Timepicker(singleton) { function Timepicker(singleton) {
if(typeof(singleton) === 'boolean' && singleton == true) { if(typeof(singleton) === 'boolean' && singleton === true) {
this.regional = []; // Available regional settings, indexed by language code this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings this.regional[''] = { // Default regional settings
currentText: 'Now', currentText: 'Now',
@ -60,7 +60,7 @@
this.defaults = $.extend({}, $.timepicker.defaults); this.defaults = $.extend({}, $.timepicker.defaults);
} }
}; }
Timepicker.prototype = { Timepicker.prototype = {
$input: null, $input: null,
@ -84,7 +84,7 @@
addTimePicker: function(dp_inst) { addTimePicker: function(dp_inst) {
var tp_inst = this; var tp_inst = this;
var currDT; var currDT;
if ((this.$altInput) && this.$altInput != null) if ((this.$altInput) && this.$altInput !== null)
{ {
currDT = this.$input.val() + ' ' + this.$altInput.val(); currDT = this.$input.val() + ' ' + this.$altInput.val();
} }
@ -191,6 +191,7 @@
var hourGridSize = 0; var hourGridSize = 0;
var minuteGridSize = 0; var minuteGridSize = 0;
var secondGridSize = 0; var secondGridSize = 0;
var size = 0;
if (opts.showHour && opts.hourGrid > 0) if (opts.showHour && opts.hourGrid > 0)
{ {
@ -203,21 +204,28 @@
hourGridSize++; hourGridSize++;
var tmph = h; var tmph = h;
if (opts.ampm && h > 12) if (opts.ampm && h > 12){
tmph = h - 12; tmph = h - 12;
else }
else{
tmph = h; tmph = h;
}
if (tmph < 10)
if (tmph < 10){
tmph = '0' + tmph; tmph = '0' + tmph;
}
if (opts.ampm) if (opts.ampm)
{ {
if (h == 0) if (h === 0){
tmph = 12 + 'a'; tmph = 12 + 'a';
else if (h < 12) }
else if (h < 12){
tmph += 'a'; tmph += 'a';
else }
else{
tmph += 'p'; tmph += 'p';
}
} }
html += '<td>' + tmph + '</td>'; html += '<td>' + tmph + '</td>';
} }
@ -249,7 +257,7 @@
} }
else else
{ {
html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_inst.id + '"' + ((opts.showMinute) ? '' : noDisplay) + '></dd>' html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_inst.id + '"' + ((opts.showMinute) ? '' : noDisplay) + '></dd>';
} }
html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_inst.id + '"' + ((opts.showSecond) ? '' : noDisplay) + '>' + opts.secondText + '</dt>'; html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_inst.id + '"' + ((opts.showSecond) ? '' : noDisplay) + '>' + opts.secondText + '</dt>';
@ -332,7 +340,7 @@
// Add grid functionality // Add grid functionality
if (opts.showHour && opts.hourGrid > 0) if (opts.showHour && opts.hourGrid > 0)
{ {
var size = 100 * hourGridSize * opts.hourGrid / (hourMax - opts.hourMin); size = 100 * hourGridSize * opts.hourGrid / (hourMax - opts.hourMin);
$tp.find(".ui_tpicker_hour table").css({ $tp.find(".ui_tpicker_hour table").css({
'width': size + "%", 'width': size + "%",
@ -349,18 +357,24 @@
if (opts.ampm) if (opts.ampm)
{ {
var ap = h.substring(2).toLowerCase(); var ap = h.substring(2).toLowerCase();
var aph = new Number(h.substring(0, 2)); var aph = parseInt(h.substring(0, 2), 10);
if (ap == 'a') if (ap == 'a')
{ {
if (aph == 12) if (aph == 12){
h = 0; h = 0;
else h = aph; }
else{
h = aph;
}
} else } else
{ {
if (aph == 12) if (aph == 12){
h = 12; h = 12;
else h = aph + 12; }
else{
h = aph + 12;
}
} }
} }
tp_inst.hour_slider.slider("option", "value", h); tp_inst.hour_slider.slider("option", "value", h);
@ -379,7 +393,7 @@
if (opts.showMinute && opts.minuteGrid > 0) if (opts.showMinute && opts.minuteGrid > 0)
{ {
var size = 100 * minuteGridSize * opts.minuteGrid / (minMax - opts.minuteMin); size = 100 * minuteGridSize * opts.minuteGrid / (minMax - opts.minuteMin);
$tp.find(".ui_tpicker_minute table").css({ $tp.find(".ui_tpicker_minute table").css({
'width': size + "%", 'width': size + "%",
@ -408,7 +422,7 @@
if (opts.showSecond && opts.secondGrid > 0) if (opts.showSecond && opts.secondGrid > 0)
{ {
var size = 100 * secondGridSize * opts.secondGrid / (secMax - opts.secondMin); size = 100 * secondGridSize * opts.secondGrid / (secMax - opts.secondMin);
$tp.find(".ui_tpicker_second table").css({ $tp.find(".ui_tpicker_second table").css({
'width': size + "%", 'width': size + "%",
@ -462,7 +476,7 @@
// If the update was done in the input field, this field should not be updated. // If the update was done in the input field, this field should not be updated.
// If the update was done using the sliders, update the input field. // If the update was done using the sliders, update the input field.
if (tp_inst.hour != hour || tp_inst.minute != minute || tp_inst.second != second || (tp_inst.ampm.length > 0 && tp_inst.ampm != ampm) || (force != undefined && force == true)) { if (tp_inst.hour != hour || tp_inst.minute != minute || tp_inst.second != second || (tp_inst.ampm.length > 0 && tp_inst.ampm != ampm) || (force !== undefined && force === true)) {
hasChanged = true; hasChanged = true;
} }
@ -472,9 +486,10 @@
tp_inst.ampm = ampm; tp_inst.ampm = ampm;
tp_inst.formatTime(tp_inst); tp_inst.formatTime(tp_inst);
if(tp_inst.$timeObj) if(tp_inst.$timeObj){
tp_inst.$timeObj.text(tp_inst.formattedTime); tp_inst.$timeObj.text(tp_inst.formattedTime);
}
if (hasChanged) { if (hasChanged) {
tp_inst.updateDateTime(dp_inst, tp_inst); tp_inst.updateDateTime(dp_inst, tp_inst);
tp_inst.timeDefined = true; tp_inst.timeDefined = true;
@ -532,7 +547,7 @@
formattedDateTime = this.formattedTime; formattedDateTime = this.formattedTime;
} }
else if (this.defaults.timeOnly !== true && (this.defaults.alwaysSetTime || timeAvailable)) { else if (this.defaults.timeOnly !== true && (this.defaults.alwaysSetTime || timeAvailable)) {
if ((this.$altInput) && this.$altInput != null) if ((this.$altInput) && this.$altInput !== null)
{ {
this.$altInput.val(this.formattedTime); this.$altInput.val(this.formattedTime);
} }
@ -563,12 +578,15 @@
if(typeof(o) == 'string') if(typeof(o) == 'string')
{ {
if(o == 'setDate') if(o == 'setDate'){
return input.datepicker(o, arguments[1]); return input.datepicker(o, arguments[1]);
if(o == 'options' && typeof(arguments[1]) == 'string') }
if(o == 'options' && typeof(arguments[1]) == 'string'){
return input.datepicker(o, arguments[1], arguments[2]); return input.datepicker(o, arguments[1], arguments[2]);
if(o == 'dialog') }
if(o == 'dialog'){
return input.datepicker(o, arguments[1], arguments[2], arguments[3], arguments[4]); return input.datepicker(o, arguments[1], arguments[2], arguments[3], arguments[4]);
}
return input.datepicker(o); return input.datepicker(o);
} }
@ -593,8 +611,9 @@
tp.second = tp.defaults.second; tp.second = tp.defaults.second;
tp.ampm = ''; tp.ampm = '';
tp.$input = $(input); tp.$input = $(input);
if(opts.altField != undefined && opts.altField != '') if(opts.altField !== undefined && opts.altField != ''){
tp.$altInput = $($.datepicker._get(inst, 'altField')); tp.$altInput = $($.datepicker._get(inst, 'altField'));
}
tp.inst = inst; tp.inst = inst;
tp.addTimePicker(inst); tp.addTimePicker(inst);
if ($.isFunction(opts.beforeShow)) { if ($.isFunction(opts.beforeShow)) {
@ -620,7 +639,7 @@
}; };
// make the alt field trigger the picker if its set // make the alt field trigger the picker if its set
if ((opts.altField) && opts.altField != null){ if ((opts.altField) && opts.altField !== null){
var me = $(opts.altField); var me = $(opts.altField);
me.css({ 'cursor': 'pointer' }); me.css({ 'cursor': 'pointer' });
@ -644,8 +663,9 @@
// shorthand just to use timepicker.. // shorthand just to use timepicker..
//######################################################################## //########################################################################
jQuery.fn.timepicker = function(opts) { jQuery.fn.timepicker = function(opts) {
if(typeof opts == 'object') if(typeof opts == 'object'){
opts = $.extend(opts, { timeOnly: true }); opts = $.extend(opts, { timeOnly: true });
}
return $(this).datetimepicker(opts, arguments[1], arguments[2], arguments[3], arguments[4]); return $(this).datetimepicker(opts, arguments[1], arguments[2], arguments[3], arguments[4]);
}; };
@ -729,13 +749,13 @@
var inst = $.datepicker._getInst(event.target); var inst = $.datepicker._getInst(event.target);
var tp_inst = $.datepicker._get(inst, 'timepicker'); var tp_inst = $.datepicker._get(inst, 'timepicker');
if (tp_inst != null) { if (tp_inst !== null) {
if (tp_inst.defaults.timeOnly && (inst.input.val() != inst.lastVal)) { if (tp_inst.defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
try { try {
$.datepicker._updateDatepicker(inst); $.datepicker._updateDatepicker(inst);
} }
catch (event) { catch (err) {
$.datepicker.log(event); $.datepicker.log(err);
} }
} }
} }
@ -832,11 +852,13 @@
//####################################################################################### //#######################################################################################
function extendRemove(target, props) { function extendRemove(target, props) {
$.extend(target, props); $.extend(target, props);
for (var name in props) for (var name in props){
if (props[name] == null || props[name] == undefined) if (props[name] === null || props[name] === undefined){
target[name] = props[name]; target[name] = props[name];
}
}
return target; return target;
}; }
$.timepicker = new Timepicker(true); // singleton instance $.timepicker = new Timepicker(true); // singleton instance
})(jQuery); })(jQuery);