Permalink
Browse files

only use setSelectionRange if supported

fixes #75
  • Loading branch information...
1 parent 455371e commit a896120fd03cbe925d9f1ec3ce7b0b45f7b39dca @jdewit committed Feb 17, 2013
Showing with 32 additions and 24 deletions.
  1. +1 −1 composer.json
  2. +30 −22 js/bootstrap-timepicker.js
  3. +1 −1 js/bootstrap-timepicker.min.js
View
@@ -1,5 +1,5 @@
{
- "name" : "eternicode/bootstrap-timepicker",
+ "name" : "jdewit/bootstrap-timepicker",
"description" : "A simple timepicker component for Twitter Bootstrap.",
"version" : "0.1.2",
"license" : "MIT",
View
@@ -436,49 +436,57 @@
},
highlightHour: function() {
- var $element = this.$element;
+ var $element = this.$element.get(0);
this.highlightedUnit = 'hour';
- setTimeout(function() {
- $element.get(0).setSelectionRange(0,2);
- }, 0);
+ if ($element.setSelectionRange) {
+ setTimeout(function() {
+ $element.setSelectionRange(0,2);
+ }, 0);
+ }
},
highlightMinute: function() {
- var $element = this.$element;
+ var $element = this.$element.get(0);
this.highlightedUnit = 'minute';
- setTimeout(function() {
- $element.get(0).setSelectionRange(3,5);
- }, 0);
+ if ($element.setSelectionRange) {
+ setTimeout(function() {
+ $element.setSelectionRange(3,5);
+ }, 0);
+ }
},
highlightSecond: function() {
- var $element = this.$element;
+ var $element = this.$element.get(0);
this.highlightedUnit = 'second';
- setTimeout(function() {
- $element.get(0).setSelectionRange(6,8);
- }, 0);
+ if ($element.setSelectionRange) {
+ setTimeout(function() {
+ $element.setSelectionRange(6,8);
+ }, 0);
+ }
},
highlightMeridian: function() {
- var $element = this.$element;
+ var $element = this.$element.get(0);
this.highlightedUnit = 'meridian';
- if (this.showSeconds) {
- setTimeout(function() {
- $element.get(0).setSelectionRange(9,11);
- }, 0);
- } else {
- setTimeout(function() {
- $element.get(0).setSelectionRange(6,8);
- }, 0);
- }
+ if ($element.setSelectionRange) {
+ if (this.showSeconds) {
+ setTimeout(function() {
+ $element.setSelectionRange(9,11);
+ }, 0);
+ } else {
+ setTimeout(function() {
+ $element.setSelectionRange(6,8);
+ }, 0);
+ }
+ }
},
incrementHour: function() {
Oops, something went wrong.

0 comments on commit a896120

Please sign in to comment.