Skip to content

Commit e795b3e

Browse files
committed
Remove unused variables, fix validation warnings
1 parent 9b57a88 commit e795b3e

File tree

1 file changed

+51
-57
lines changed

1 file changed

+51
-57
lines changed

jquery-ui-timepicker-addon.js

+51-57
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* By: Trent Richardson [http://trentrichardson.com]
44
* Version 1.0.0-dev
55
* Last Modified: 02/05/2012
6-
*
6+
*
77
* Copyright 2012 Trent Richardson
88
* Dual licensed under the MIT and GPL licenses.
99
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
1010
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
11-
*
11+
*
1212
* HERES THE CSS:
1313
* .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
1414
* .ui-timepicker-div dl { text-align: left; }
@@ -133,7 +133,7 @@ $.extend(Timepicker.prototype, {
133133
_newInst: function($input, o) {
134134
var tp_inst = new Timepicker(),
135135
inlineSettings = {};
136-
136+
137137
for (var attrName in this._defaults) {
138138
var attrValue = $input.attr('time:' + attrName);
139139
if (attrValue) {
@@ -163,8 +163,8 @@ $.extend(Timepicker.prototype, {
163163
},
164164
timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
165165
});
166-
tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase() });
167-
tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase() });
166+
tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase(); });
167+
tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase(); });
168168

169169
if (tp_inst._defaults.timezoneList === null) {
170170
var timezoneList = [];
@@ -188,7 +188,7 @@ $.extend(Timepicker.prototype, {
188188
tp_inst.$altInput = $(o.altField)
189189
.css({ cursor: 'pointer' })
190190
.focus(function(){ $input.trigger("focus"); });
191-
191+
192192
if(tp_inst._defaults.minDate==0 || tp_inst._defaults.minDateTime==0)
193193
{
194194
tp_inst._defaults.minDate=new Date();
@@ -197,7 +197,7 @@ $.extend(Timepicker.prototype, {
197197
{
198198
tp_inst._defaults.maxDate=new Date();
199199
}
200-
200+
201201
// datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
202202
if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
203203
tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
@@ -215,7 +215,7 @@ $.extend(Timepicker.prototype, {
215215
//########################################################################
216216
_addTimePicker: function(dp_inst) {
217217
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
218-
this.$input.val() + ' ' + this.$altInput.val() :
218+
this.$input.val() + ' ' + this.$altInput.val() :
219219
this.$input.val();
220220

221221
this.timeDefined = this._parseTime(currDT);
@@ -249,7 +249,7 @@ $.extend(Timepicker.prototype, {
249249
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
250250
regstr = '^.{' + dp_dateFormat.length + ',}?' + this._defaults.separator.replace(specials, "\\$&") + regstr;
251251
}
252-
252+
253253
treg = timeString.match(new RegExp(regstr, 'i'));
254254

255255
if (treg) {
@@ -297,7 +297,7 @@ $.extend(Timepicker.prototype, {
297297
}
298298
this.timezone = tz;
299299
}
300-
300+
301301
return true;
302302

303303
}
@@ -314,7 +314,7 @@ $.extend(Timepicker.prototype, {
314314
$.merge(markers, o.amNames);
315315
if (o.pmNames)
316316
$.merge(markers, o.pmNames);
317-
markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&') });
317+
markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&'); });
318318
return '(' + markers.join('|') + ')?';
319319
},
320320

@@ -364,7 +364,7 @@ $.extend(Timepicker.prototype, {
364364
minuteGridSize = 0,
365365
secondGridSize = 0,
366366
millisecGridSize = 0,
367-
size;
367+
size = null;
368368

369369
// Hours
370370
html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' +
@@ -472,7 +472,7 @@ $.extend(Timepicker.prototype, {
472472
}
473473
});
474474

475-
475+
476476
// Updated by Peter Medeiros:
477477
// - Pass in Event and UI instance into slide function
478478
this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
@@ -634,7 +634,7 @@ $.extend(Timepicker.prototype, {
634634
this.minute_slider.bind('slidestop',onSelectDelegate);
635635
this.second_slider.bind('slidestop',onSelectDelegate);
636636
this.millisec_slider.bind('slidestop',onSelectDelegate);
637-
637+
638638
// slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
639639
if (this._defaults.addSliderAccess){
640640
var sliderAccessArgs = this._defaults.sliderAccessArgs;
@@ -651,15 +651,15 @@ $.extend(Timepicker.prototype, {
651651
oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
652652
newWidth = oldWidth - sliderAccessWidth,
653653
newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
654-
654+
655655
$g.css({ width: newWidth, marginLeft: newMarginLeft });
656656
});
657657
}
658658
}
659659
},0);
660660
}
661661
// end slideAccess integration
662-
662+
663663
}
664664
},
665665

@@ -770,7 +770,7 @@ $.extend(Timepicker.prototype, {
770770

771771
},
772772

773-
773+
774774
//########################################################################
775775
// when a slider moves, set the internal time...
776776
// on time change is also called when the time is updated in the text field
@@ -803,30 +803,30 @@ $.extend(Timepicker.prototype, {
803803
|| (this.ampm.length > 0
804804
&& (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
805805
|| timezone != this.timezone);
806-
806+
807807
if (hasChanged) {
808808

809809
if (hour !== false)this.hour = hour;
810810
if (minute !== false) this.minute = minute;
811811
if (second !== false) this.second = second;
812812
if (millisec !== false) this.millisec = millisec;
813813
if (timezone !== false) this.timezone = timezone;
814-
814+
815815
if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
816-
816+
817817
this._limitMinMaxDateTime(this.inst, true);
818818
}
819819
if (o.ampm) this.ampm = ampm;
820-
820+
821821
//this._formatTime();
822822
this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
823823
if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix);
824824
this.timeDefined = true;
825825
if (hasChanged) this._updateDateTime();
826826
},
827-
827+
828828
//########################################################################
829-
// call custom onSelect.
829+
// call custom onSelect.
830830
// bind to sliders slidestop, and grid click.
831831
//########################################################################
832832
_onSelectHandler: function() {
@@ -845,7 +845,7 @@ $.extend(Timepicker.prototype, {
845845
var tmptime = (format || this._defaults.timeFormat).toString();
846846

847847
tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);
848-
848+
849849
if (arguments.length) return tmptime;
850850
else this.formattedTime = tmptime;
851851
},
@@ -883,7 +883,7 @@ $.extend(Timepicker.prototype, {
883883
} else {
884884
this.$input.val(formattedDateTime);
885885
}
886-
886+
887887
this.$input.trigger("change");
888888
}
889889

@@ -909,13 +909,12 @@ $.fn.extend({
909909
//########################################################################
910910
datetimepicker: function(o) {
911911
o = o || {};
912-
var $input = this,
913912
tmp_args = arguments;
914913

915914
if (typeof(o) == 'string'){
916-
if(o == 'getDate')
915+
if(o == 'getDate')
917916
return $.fn.datepicker.apply($(this[0]), tmp_args);
918-
else
917+
else
919918
return this.each(function() {
920919
var $t = $(this);
921920
$t.datepicker.apply($t, tmp_args);
@@ -930,7 +929,7 @@ $.fn.extend({
930929
});
931930

932931
//########################################################################
933-
// format the time all pretty...
932+
// format the time all pretty...
934933
// format = string format of the time
935934
// time = a {}, not a Date() for timezones
936935
// options = essentially the regional[].. amNames, pmNames, ampm
@@ -939,7 +938,7 @@ $.datepicker.formatTime = function(format, time, options) {
939938
options = options || {};
940939
options = $.extend($.timepicker._defaults, options);
941940
time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time);
942-
941+
943942
var tmptime = format;
944943
var ampmName = options['amNames'][0];
945944

@@ -975,7 +974,7 @@ $.datepicker.formatTime = function(format, time, options) {
975974

976975
tmptime = $.trim(tmptime);
977976
return tmptime;
978-
}
977+
};
979978

980979
//########################################################################
981980
// the bad hack :/ override datepicker so it doesnt close on select
@@ -1015,9 +1014,9 @@ $.datepicker._updateDatepicker = function(inst) {
10151014
}
10161015

10171016
if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
1018-
1017+
10191018
this._base_updateDatepicker(inst);
1020-
1019+
10211020
// Reload the time control when changing something in the input text field.
10221021
var tp_inst = this._get(inst, 'timepicker');
10231022
if(tp_inst) tp_inst._addTimePicker(inst);
@@ -1055,7 +1054,7 @@ $.datepicker._doKeyPress = function(event) {
10551054
return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
10561055
}
10571056
}
1058-
1057+
10591058
return $.datepicker._base_doKeyPress(event);
10601059
};
10611060

@@ -1102,7 +1101,7 @@ $.datepicker._gotoToday = function(id) {
11021101
tp_inst.timezone_select.val(tzoffset);
11031102
}
11041103
this._setTime(inst, now);
1105-
$( '.ui-datepicker-today', $dp).click();
1104+
$( '.ui-datepicker-today', $dp).click();
11061105
};
11071106

11081107
//#######################################################################################
@@ -1245,14 +1244,11 @@ $.datepicker.parseDate = function(format, value, settings) {
12451244
//#######################################################################################
12461245
// override formatDate to set date with time to the input
12471246
//#######################################################################################
1248-
$.datepicker._base_formatDate=$.datepicker._formatDate;
1247+
$.datepicker._base_formatDate = $.datepicker._formatDate;
12491248
$.datepicker._formatDate = function(inst, day, month, year){
12501249
var tp_inst = this._get(inst, 'timepicker');
1251-
if(tp_inst)
1252-
{
1253-
if(day)
1254-
var b = this._base_formatDate(inst, day, month, year);
1255-
tp_inst._updateDateTime(inst);
1250+
if(tp_inst) {
1251+
tp_inst._updateDateTime(inst);
12561252
return tp_inst.$input.val();
12571253
}
12581254
return this._base_formatDate(inst);
@@ -1266,16 +1262,16 @@ $.datepicker._optionDatepicker = function(target, name, value) {
12661262
var inst = this._getInst(target),
12671263
tp_inst = this._get(inst, 'timepicker');
12681264
if (tp_inst) {
1269-
var min,max,onselect;
1265+
var min = null, max = null, onselect = null;
12701266
if (typeof name == 'string') { // if min/max was set with the string
1271-
if (name==='minDate' || name==='minDateTime' )
1267+
if (name === 'minDate' || name === 'minDateTime' )
12721268
min = value;
1273-
else if (name==='maxDate' || name==='maxDateTime')
1269+
else if (name === 'maxDate' || name === 'maxDateTime')
12741270
max = value;
1275-
else if (name==='onSelect')
1276-
onselect=value;
1271+
else if (name === 'onSelect')
1272+
onselect = value;
12771273
} else if (typeof name == 'object') { //if min/max was set with the JSON
1278-
if(name.minDate)
1274+
if (name.minDate)
12791275
min = name.minDate;
12801276
else if (name.minDateTime)
12811277
min = name.minDateTime;
@@ -1284,24 +1280,23 @@ $.datepicker._optionDatepicker = function(target, name, value) {
12841280
else if (name.maxDateTime)
12851281
max = name.maxDateTime;
12861282
}
1287-
if(min){ //if min was set
1288-
if(min==0)
1289-
min=new Date();
1283+
if(min) { //if min was set
1284+
if (min == 0)
1285+
min = new Date();
12901286
else
1291-
min= new Date(min);
1292-
1287+
min = new Date(min);
1288+
12931289
tp_inst._defaults.minDate = min;
12941290
tp_inst._defaults.minDateTime = min;
1295-
} else if (max){ //if max was set
1291+
} else if (max) { //if max was set
12961292
if(max==0)
12971293
max=new Date();
12981294
else
12991295
max= new Date(max);
13001296
tp_inst._defaults.maxDate = max;
13011297
tp_inst._defaults.maxDateTime = max;
1302-
}
1303-
else if (onselect)
1304-
tp_inst._defaults.onSelect=onselect;
1298+
} else if (onselect)
1299+
tp_inst._defaults.onSelect = onselect;
13051300
}
13061301
if (value === undefined)
13071302
return this._base_optionDatepicker(target, name);
@@ -1323,4 +1318,3 @@ $.timepicker = new Timepicker(); // singleton instance
13231318
$.timepicker.version = "1.0.0";
13241319

13251320
})(jQuery);
1326-

0 commit comments

Comments
 (0)