Skip to content

Commit

Permalink
v0.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasalvarez87 committed Jan 27, 2014
1 parent 32a7693 commit 4b47c1f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nan-timepicker",
"version": "0.1.8",
"version": "0.1.9",
"main": "dist/nan-timepicker.js",
"ignore": [
"**/.*",
Expand Down
33 changes: 23 additions & 10 deletions dist/nan-timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
}

var _baseDate = _generateBaseDate();
var _baseId = 0;
var _ONE_DAY = 86400;
var _defaults = {
var _defaults = {
id: 'nan-timepicker-',
className: null,
minTime: null,
maxTime: null,
Expand All @@ -42,8 +44,6 @@
hrs: 'hrs'
};

var $elCache = null;

var methods = {

init: function(options) {
Expand All @@ -66,7 +66,8 @@
self = input;
}

var settings = $.extend({}, _defaults);
_baseId++;
var settings = $.extend({}, _defaults, { id: _defaults.id + _baseId });

if (options) {
settings = $.extend(settings, options);
Expand All @@ -78,6 +79,7 @@

settings = _parseSettings(settings);

self.data('timepicker-id', settings.id);
self.data('timepicker-settings', settings);
self.prop('autocomplete', 'off');
self.on('click.timepicker focus.timepicker', methods.show);
Expand Down Expand Up @@ -108,7 +110,7 @@

// check if list needs to be rendered
if (!list || list.length === 0 || typeof settings.durationTime === 'function') {
$elCache = _render(self);
_render(self);
list = self.data('timepicker-list');
}

Expand Down Expand Up @@ -195,8 +197,16 @@
return self;
},

get: function() {
return $elCache;
getInput: function() {
return $(this);
},

getTimepicker: function () {
return $(this).data('timepicker-list');
},

getTimepickerId: function () {
return $(this).data('timepicker-id');
},

getSecondsFromMidnight: function() {
Expand All @@ -215,9 +225,8 @@
_setTimeValue(self, prettyTime);
},

remove: function() {
remove: function(timepickerId) {
var self = this;
$elCache = null;

// check if this element is a timepicker
if (!self.hasClass('ui-timepicker-input')) {
Expand All @@ -232,6 +241,9 @@
// timepicker-list won't be present unless the user has interacted with this timepicker
if (self.data('timepicker-list')) {
self.data('timepicker-list').remove();
} else {
// Ensures the timepicker html is removed
$('#' + timepickerId).remove();
}

self.removeData('timepicker-list');
Expand Down Expand Up @@ -310,6 +322,7 @@
list = $('<ul />', { 'class': 'ui-timepicker-list' });

var wrapped_list = $('<div />', { 'class': 'ui-timepicker-wrapper', 'tabindex': -1 });
wrapped_list.attr('id', settings.id);
wrapped_list.css({'display':'none', 'position': 'absolute' }).append(list);


Expand Down Expand Up @@ -721,7 +734,7 @@
var timeValue = null;

var cursor = list.find('.ui-timepicker-selected');
self.trigger('time-pressed', [ $(cursor) ] );
self.trigger('timePressed', [ $(cursor) ] );

if (cursor.hasClass('ui-timepicker-disabled')) {
return false;
Expand Down
Loading

0 comments on commit 4b47c1f

Please sign in to comment.