Skip to content

Commit 2c250cb

Browse files
committed
Merge branch 'develop' of https://github.com/dalelotts/angular-bootstrap-datetimepicker into release/0.3.4
2 parents 23b8330 + 01f4a17 commit 2c250cb

File tree

2 files changed

+46
-42
lines changed

2 files changed

+46
-42
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Native AngularJS datetime picker directive styled by Twitter Bootstrap 3
1313

1414
# Upgrading to 0.3.x
1515

16-
<code>weekStart</code> has bee removed. This directive uses the locale aware
16+
<code>weekStart</code> has been removed. This directive uses the locale aware
1717
[moment.js day of week](http://momentjs.com/docs/#/get-set/weekday/) to
1818
determine which day is the first day of the week. If you would like a first
1919
day of week that is not standard for the locale you can create a
@@ -177,7 +177,8 @@ The increment used to build the hour view. A button is created for each <code>mi
177177

178178
When used within a Bootstrap dropdown and jQuery, the selector specified in dropdownSelector will toggle the dropdown when a date/time is selected.
179179

180-
**NOTE:** dropdownSelector **requires** jquery and bootstrap.js. If do not have these available do not specify this option, it will cause an exception.
180+
**NOTE:** dropdownSelector **requires** jquery and bootstrap.js. If do not have these available do not specify this option. If you do, an error will
181+
be logged and this option will be removed.
181182

182183

183184
## Working with ng-model

src/js/datetimepicker.js

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -74,40 +74,50 @@ angular.module('ui.bootstrap.datetimepicker', [])
7474
if (configuration.dropdownSelector !== null && !angular.isString(configuration.dropdownSelector)) {
7575
throw ("dropdownSelector must be a string");
7676
}
77+
78+
if (configuration.dropdownSelector != null) {
79+
/* istanbul ignore next */
80+
if ((typeof jQuery === 'undefined') || (typeof jQuery().dropdown !== 'function')) {
81+
$log.error("Please DO NOT specify the dropdownSelector option unless you are using jQuery AND Bootstrap.js. " +
82+
"Please include jQuery AND Bootstrap.js, or write code to close the dropdown in the on-set-time callback. \n\n" +
83+
"The dropdownSelector configuration option is being removed because it will not function properly.");
84+
delete configuration.dropdownSelector;
85+
}
86+
}
7787
};
7888

7989
return {
8090
restrict: 'E',
8191
require: 'ngModel',
8292
template: "<div class='datetimepicker table-responsive'>" +
83-
"<table class='table table-striped'>" +
84-
" <thead>" +
85-
" <tr>" +
86-
" <th class='left' data-ng-click='changeView(data.currentView, data.leftDate, $event)' data-ng-show='data.leftDate.selectable'><i class='glyphicon glyphicon-arrow-left'/></th>" +
87-
" <th class='switch' colspan='5' data-ng-show='data.currentDate.selectable' data-ng-click='changeView(data.previousView, data.currentDate, $event)'>{{ data.currentDate.display }}</th>" +
88-
" <th class='right' data-ng-click='changeView(data.currentView, data.rightDate, $event)' data-ng-show='data.rightDate.selectable'><i class='glyphicon glyphicon-arrow-right'/></th>" +
89-
" </tr>" +
90-
" <tr>" +
91-
" <th class='dow' data-ng-repeat='day in data.dayNames' >{{ day }}</th>" +
92-
" </tr>" +
93-
" </thead>" +
94-
" <tbody>" +
95-
" <tr data-ng-if='data.currentView !== \"day\"' >" +
96-
" <td colspan='7' >" +
97-
" <span class='{{ data.currentView }}' " +
98-
" data-ng-repeat='dateObject in data.dates' " +
99-
" data-ng-class='{active: dateObject.active, past: dateObject.past, future: dateObject.future, disabled: !dateObject.selectable}' " +
100-
" data-ng-click=\"changeView(data.nextView, dateObject, $event)\">{{ dateObject.display }}</span> " +
101-
" </td>" +
102-
" </tr>" +
103-
" <tr data-ng-if='data.currentView === \"day\"' data-ng-repeat='week in data.weeks'>" +
104-
" <td data-ng-repeat='dateObject in week.dates' " +
105-
" data-ng-click='changeView(data.nextView, dateObject, $event)'" +
106-
" class='day' " +
107-
" data-ng-class='{active: dateObject.active, past: dateObject.past, future: dateObject.future, disabled: !dateObject.selectable}' >{{ dateObject.display }}</td>" +
108-
" </tr>" +
109-
" </tbody>" +
110-
"</table></div>",
93+
"<table class='table table-striped'>" +
94+
" <thead>" +
95+
" <tr>" +
96+
" <th class='left' data-ng-click='changeView(data.currentView, data.leftDate, $event)' data-ng-show='data.leftDate.selectable'><i class='glyphicon glyphicon-arrow-left'/></th>" +
97+
" <th class='switch' colspan='5' data-ng-show='data.currentDate.selectable' data-ng-click='changeView(data.previousView, data.currentDate, $event)'>{{ data.currentDate.display }}</th>" +
98+
" <th class='right' data-ng-click='changeView(data.currentView, data.rightDate, $event)' data-ng-show='data.rightDate.selectable'><i class='glyphicon glyphicon-arrow-right'/></th>" +
99+
" </tr>" +
100+
" <tr>" +
101+
" <th class='dow' data-ng-repeat='day in data.dayNames' >{{ day }}</th>" +
102+
" </tr>" +
103+
" </thead>" +
104+
" <tbody>" +
105+
" <tr data-ng-if='data.currentView !== \"day\"' >" +
106+
" <td colspan='7' >" +
107+
" <span class='{{ data.currentView }}' " +
108+
" data-ng-repeat='dateObject in data.dates' " +
109+
" data-ng-class='{active: dateObject.active, past: dateObject.past, future: dateObject.future, disabled: !dateObject.selectable}' " +
110+
" data-ng-click=\"changeView(data.nextView, dateObject, $event)\">{{ dateObject.display }}</span> " +
111+
" </td>" +
112+
" </tr>" +
113+
" <tr data-ng-if='data.currentView === \"day\"' data-ng-repeat='week in data.weeks'>" +
114+
" <td data-ng-repeat='dateObject in week.dates' " +
115+
" data-ng-click='changeView(data.nextView, dateObject, $event)'" +
116+
" class='day' " +
117+
" data-ng-class='{active: dateObject.active, past: dateObject.past, future: dateObject.future, disabled: !dateObject.selectable}' >{{ dateObject.display }}</td>" +
118+
" </tr>" +
119+
" </tbody>" +
120+
"</table></div>",
111121
scope: {
112122
ngModel: "=",
113123
onSetTime: "&",
@@ -220,7 +230,7 @@ angular.module('ui.bootstrap.datetimepicker', [])
220230
}
221231

222232
for (var i = 0; i < 6; i++) {
223-
var week = { dates: [] };
233+
var week = {dates: []};
224234
for (var j = 0; j < 7; j++) {
225235
var monthMoment = moment.utc(startDate).add((i * 7) + j, 'days');
226236
var dateValue = {
@@ -306,17 +316,10 @@ angular.module('ui.bootstrap.datetimepicker', [])
306316
scope.ngModel = newDate;
307317

308318
if (configuration.dropdownSelector) {
309-
310-
/* istanbul ignore else */
311-
if (typeof jQuery !== 'undefined') {
312-
jQuery(configuration.dropdownSelector).dropdown('toggle');
313-
} else {
314-
$log.error("Please DO NOT specify the dropdownSelector option unless you are using jQuery. " +
315-
"Please include jQuery or write code to close the dropdown in the on-set-time callback. ");
316-
}
319+
jQuery(configuration.dropdownSelector).dropdown('toggle');
317320
}
318321

319-
scope.onSetTime({ newDate: scope.ngModel, oldDate: oldDate });
322+
scope.onSetTime({newDate: scope.ngModel, oldDate: oldDate});
320323

321324
return dataFactory[configuration.startView](unixDate);
322325
}
@@ -359,10 +362,10 @@ angular.module('ui.bootstrap.datetimepicker', [])
359362
}
360363
};
361364

362-
scope.changeView(configuration.startView, new DateObject({ dateValue: getUTCTime(), selectable: true }));
365+
scope.changeView(configuration.startView, new DateObject({dateValue: getUTCTime(), selectable: true}));
363366

364367
scope.$watch('ngModel', function () {
365-
scope.changeView(scope.data.currentView, new DateObject({ dateValue: getUTCTime() }));
368+
scope.changeView(scope.data.currentView, new DateObject({dateValue: getUTCTime()}));
366369
});
367370
}
368371
};

0 commit comments

Comments
 (0)