Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 0775236

Browse files
jkurzjoshkurz
authored andcommitted
feat(v2): upgrade calendar to v2
Signed-off-by: Josh Kurz <josh.kurz@turner.com>
1 parent 5a1538e commit 0775236

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"dependencies": {
1919
"angular": "~1.2.x",
20-
"jquery": "~2.x",
20+
"moment": "2.5.1",
21+
"jquery": "~1.10.2",
2122
"jquery-ui": "~1.10.3",
2223
"fullcalendar": "~1.x"
2324
},

demo/calendarDemo.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function CalendarCtrl($scope) {
2626
{title: 'Click for Google',start: new Date(y, m, 28),end: new Date(y, m, 29),url: 'http://google.com/'}
2727
];
2828
/* event source that calls a function on every view switch */
29-
$scope.eventsF = function (start, end, callback) {
29+
$scope.eventsF = function (start, end, timezone, callback) {
3030
var s = new Date(start).getTime() / 1000;
3131
var e = new Date(end).getTime() / 1000;
3232
var m = new Date(start).getMonth();
@@ -48,12 +48,12 @@ function CalendarCtrl($scope) {
4848
$scope.alertMessage = (event.title + ' was clicked ');
4949
};
5050
/* alert on Drop */
51-
$scope.alertOnDrop = function(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view){
52-
$scope.alertMessage = ('Event Droped to make dayDelta ' + dayDelta);
51+
$scope.alertOnDrop = function( event, revertFunc, jsEvent, ui, view){
52+
$scope.alertMessage = ('Event Droped on ' + event.start.format());
5353
};
5454
/* alert on Resize */
55-
$scope.alertOnResize = function(event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ){
56-
$scope.alertMessage = ('Event Resized to make dayDelta ' + minuteDelta);
55+
$scope.alertOnResize = function( event, jsEvent, ui, view){
56+
$scope.alertMessage = ('Event end date was moved to ' + event.end.format());
5757
};
5858
/* add and removes an event source of choice */
5959
$scope.addRemoveEventSource = function(sources,source) {

demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<script src="../bower_components/jquery/dist/jquery.js"></script>
1111
<script src="../bower_components/jquery-ui/ui/jquery-ui.js"></script>
12+
<script src="../bower_components/moment/moment.js"></script>
1213

1314
<script src="../bower_components/angular/angular.js"></script>
1415
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.9.0.js"></script>

src/calendar.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ angular.module('ui.calendar', [])
215215
}
216216

217217
scope.destroy = function(){
218+
if(scope.calendar && scope.calendar.fullCalendar){
219+
scope.calendar.fullCalendar('destroy');
220+
}
218221
if(attrs.calendar) {
219222
scope.calendar = scope.$parent[attrs.calendar] = elm.html('');
220223
} else {
@@ -227,8 +230,10 @@ angular.module('ui.calendar', [])
227230
};
228231

229232
eventSourcesWatcher.onAdded = function(source) {
230-
scope.calendar.fullCalendar('addEventSource', source);
231-
sourcesChanged = true;
233+
if(elm.is(':visible')){
234+
scope.calendar.fullCalendar('addEventSource', source);
235+
sourcesChanged = true;
236+
}
232237
};
233238

234239
eventSourcesWatcher.onRemoved = function(source) {
@@ -241,7 +246,9 @@ angular.module('ui.calendar', [])
241246
};
242247

243248
eventsWatcher.onRemoved = function(event) {
244-
scope.calendar.fullCalendar('removeEvents', function(e) { return e === event; });
249+
scope.calendar.fullCalendar('removeEvents', function(e) {
250+
return e.__uiCalId === event.__uiCalId;
251+
});
245252
};
246253

247254
eventsWatcher.onChanged = function(event) {

test/test.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = function (config) {
77
'bower_components/jquery-ui/ui/*.js',
88
'bower_components/angular/angular.js',
99
'bower_components/angular-mocks/angular-mocks.js',
10+
'bower_components/moment/moment.js',
1011
'bower_components/fullcalendar/fullcalendar.js',
1112
'src/calendar.js',
1213
'test/*.spec.js'

0 commit comments

Comments
 (0)