PageSourceSearch

https://www.pohatcongtwp.org/_Assets/js/angular/app/components/calendar/calendar.controller.js

js pohatcongtwp.org collected 2026-10-04 10:05:55 UTC 6,285 bytes, 191 lines download raw bytes

1app.controller('calendarCtrl', ['$http', '$scope', '$timeout', '$uibModal', 'uiCalendarConfig', 'moment', function ($http, $scope, $timeout, $uibModal, uiCalendarConfig, moment) {
2    $scope.calendarTypeList = [
3        { Value: 'Events', Text: "Events" },
4        { Value: 'Meetings', Text: "Meetings" }
5    ];
6
7    $http.get('/api/data/GetCalendarMeetingType').then(function (response) {
8        $scope.meetingTypeList = response.data;
9    });
10
11    $scope.events = {
12        url: "/api/data/GetCalendarData"
13    };
14
15    $scope.eventsFiltered = [];
16
17    $scope.showMeeting_Type = false;
18
19    $scope.openMeetingComponentModal = function (id) {
20        var modalInstance = $uibModal.open({
21            animation: true,
22            component: 'modalMeetingComponent',
23            resolve: {
24                id: function () {
25                    return id;
26                }
27            }
28        });
29    };
30
31    $scope.openEventComponentModal = function (id) {
32        var modalInstance = $uibMod
32al.open({
33            animation: true,
34            component: 'modalEventComponent',
35            resolve: {
36                id: function () {
37                    return id;
38                }
39            }
40        });
41    };
42
43    /* Change View */
44    $scope.changeView = function (view, calendar) {
45        uiCalendarConfig.calendars[calendar].fullCalendar('changeView', view);
46    };
47
48    /* Change View */
49    $scope.renderCalendar = function (calendar) {
50        $timeout(function () {
51            if (uiCalendarConfig.calendars[calendar]) {
52                uiCalendarConfig.calendars[calendar].fullCalendar('render');
53            }
54        });
55    };
56
57    $scope.OnEventClick = function (event, jsEvent, view) {
58        if (event.className.indexOf('Meeting') >= 0) {
59            $scope.openMeetingComponentModal(event.id);
60        } else {
61            $scope.openEventComponentModal(event.id);
62        }
63    };
64
65    $scope.OnEventLoading = function (bool) {
66        if (bool) {
67            $('#loading').show();
68            $('#calendar').css('visibility', 'hidden');
69        } else {
70            $('#loading').fadeOut('300').delay('200');
71            $('#calendar').hide().css('visibility', 'visible').delay('500').fadeIn(function () {
72                $('#loading').toggle(bool);
73            });
74            $scope.OnEventRenderFiltered();
75        }
76    };
77
78    $scope.OnEventRenderFiltered = function () {
79        if ($scope.Calendar_Type == "Events") {
80            $scope.filterEvents();
81        }
82        if ($scope.Calendar_Type == "Meetings") {
83            if ($scope.Meeting_Type != "") {
84                $scope.filterMeetings($scope.Meeting_Type);
85            } else {
86                $scope.filterMeetings("all");
87            }
88        }
89    };
90
91    /* config object */
92    $scope.uiConfig = {
93        calendar: {
94            editable: false,
95            eventLimit: 4,
96            header: {
97                left: 'prev,next today',
98                center: 'title',
99                right: 'month,basicWeek,basicDay'
100            },
101            eventClick: $scope.OnEventClick,
102            loading: $scope.OnEventLoading
103        }
104    };
105
106    $scope.updateCalendar_Type = function () {
107        switch ($scope.Calendar_Type) {
108            case 'Meetings':
109                $scope.showMeeting_Type = true;
110                $scope.filterMeetings();
111                break;
112            case 'Events':
113                $scope.showMeeting_Type = false;
114                $scope.Meeting_Type = null;
115                $scope.filterEvents();
116                break;
117            default:
118                $scope.showMeeting_Type = false;
119                $scope.getAll();
120                break;
121        }
122    }
123
124    $scope.updateMeeting_Type = function () {
125        if ($scope.Meeting_Type != "") {
126            $scope.filterMeetings($scope.Meeting_Type);
127        } else {
128            $scope.filterMeetings();
129        }
130    };
131
132    $scope.getAll = function () {
133        var view = $('#calendar').fullCalendar('getView');
134        var sDate = view.start.format('MM/DD/YYYY h:mm a');
135        var eDate = view.end.format('MM/DD/YYYY h:mm a');
136
137        uiCalendarConfig.calendars['calendar'].fullCalendar('removeEvents');
138        $http.get('/api/data/GetCalendarData', {
139            params: {
140                start: sDate, end: eDate
141            }
142        }).then(function (response) {
143            var events = response.data;
144            angular.forEach(events, function (data) {
145                $scope.eventsFiltered.push(data);
146            });
147        });
148    };
149
150    $scope.filterEvents = function () {
151        var view = $('#calendar').fullCalendar('getView');
152        var sDate = view.start.format('MM/DD/YYYY h:mm a');
153        var eDate = view.end.format('MM/DD/YYYY h:mm a');
154
155        uiCalendarConfig.calendars['calendar'].fullCalendar('removeEvents');
156        $http.get('/api/data/GetCalendarEvents', {
157            params: {
158                start: sDate, end: eDate
159            }
160        }).then(function (response) {
161            var events = response.data;
162            uiCalendarConfig.calendars['calendar'].fullCalendar('removeEvents');
163            angular.forEach(events, function (data) {
164                $scope.eventsFiltered.push(data);
165            });
166        });
167    };
168
169    $scope.filterMeetings = function (meetingTypeID) {
170        var view = $('#calendar').fullCalendar('getView');
171        var sDate = view.start.format('MM/DD/YYYY h:mm a');
172        var eDate = view.end.format('MM/DD/YYYY h:mm a');
173
174        if (!meetingTypeID)
175            meetingTypeID = "all";
176
177        $http.get('/api/data/GetCalendarMeetings', {
178            params: {
179                start: sDate, end: eDate, meetingTypeID: meetingTypeID
180            }
181        }).then(function (response) {
182            var events = response.data;
183            uiCalendarConfig.calendars['calendar'].fullCalendar('removeEvents');
184            angular.forEach(events, function (data) {
185                $scope.eventsFiltered.push(data);
186            });
187        });
188    };
189
190    $scope.eventSource = [$scope.events, $scope.eventsFiltered];
191}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.