1 var myApp = angular.module('myApp', []);
\r
2 myApp.config(function ($interpolateProvider) {
\r
3 $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
\r
5 myApp.factory('$exceptionHandler', function () {
\r
6 return function (exception, cause) {
\r
7 if (exception.message.contains('leases')) {
\r
8 console.log(exception.message);
\r
10 var tmpScope = angular.element(document.getElementById('SchedulerCtrl')).scope();
\r
11 tmpScope.initSlots(_schedulerCurrentCellPosition, _schedulerCurrentCellPosition + SchedulerTotalVisibleCells);
\r
17 // Create a private execution space for our controller. When
\r
18 // executing this function expression, we're going to pass in
\r
19 // the Angular reference and our application module.
\r
20 (function (ng, app) {
\r
23 // Define our Controller constructor.
\r
24 function Controller($scope) {
\r
26 // Store the scope so we can reference it in our
\r
28 this.scope = $scope;
\r
30 // Set up the default scope value.
\r
31 this.scope.errorMessage = null;
\r
32 this.scope.name = "";
\r
34 this.scope.totalPages = 4;
\r
35 this.scope.curPage = 0;
\r
36 this.scope.pageSize = 25;
\r
38 $scope.resources = SchedulerDataViewData;
\r
39 $scope.slots = SchedulerSlotsViewData;
\r
40 //$scope.msg = "hello";
\r
42 angular.element(document).ready(function() {
\r
43 //console.log('Hello World');
\r
44 //alert('Hello World');
\r
45 //afterAngularRendered();
\r
48 $scope.initSchedulerResources = function (pageSize, filter) {
\r
49 for (var k = 0; k < pageSize; k++) {
\r
50 if ($scope.resources.length < SchedulerData.length)
\r
51 $scope.resources.push(jQuery.extend(true, {}, SchedulerData[k]));
\r
52 $scope.resources[k].leases = [];
\r
54 $scope.pageSize = pageSize;
\r
56 $scope.totalPages = parseInt(Math.ceil(SchedulerData.length / $scope.pageSize));
\r
57 $scope.initSlots(0, SchedulerTotalVisibleCells);
\r
60 $scope.setPage = function(page) {
\r
61 var tmpFrm = $scope.pageSize * page;
\r
62 var tmpTo = tmpFrm + $scope.pageSize;
\r
63 $scope.curPage = page;
\r
64 $scope.resources = [];
\r
65 for (var k = tmpFrm; k < tmpTo; k++) {
\r
66 if ($scope.resources.length < SchedulerData.length)
\r
67 $scope.resources.push(jQuery.extend(true, {}, SchedulerData[k]));
\r
68 $scope.resources[k].leases = [];
\r
70 $scope.initSlots(0, SchedulerTotalVisibleCells);
\r
73 $scope.initSlots = function (from, to) {
\r
77 for (var i = from; i < to; i++) {
\r
78 $scope.slots.push(SchedulerSlots[i]);
\r
79 for (var j = 0; j < $scope.resources.length; j++) {
\r
80 $scope.resources[j].leases.push(SchedulerData[j].leases[i]);
\r
87 $scope.moveFrontSlot = function(from, to) {
\r
88 //$scope.slots.shift();
\r
89 //$scope.slots.push(SchedulerSlots[to]);
\r
90 //for (var j = 0; j < $scope.resources.length; j++) {
\r
91 // $scope.resources[j].leases.shift();
\r
92 // $scope.resources[j].leases.push(SchedulerData[j].leases[to]);
\r
95 // $scope.$digest();
\r
96 // //$scope.$apply();
\r
98 // $scope.initSlots(from, to);
\r
100 $scope.initSlots(from, to);
\r
103 $scope.moveBackSlot = function(from, to) {
\r
104 $scope.$apply(function() {
\r
106 // $scope.slots.pop();
\r
107 // $scope.slots.unshift(SchedulerSlots[from]);
\r
108 // for (var j = 0; j < $scope.resources.length; j++) {
\r
109 // $scope.resources[j].leases.pop();
\r
110 // $scope.resources[j].leases.unshift(SchedulerData[j].leases[from]);
\r
116 $scope.initSlots(from, to);
\r
120 $scope.getTimes = function (n) {
\r
121 return new Array(n);
\r
124 // Return this object reference.
\r
130 // Define the Controller as the constructor function.
\r
131 app.controller("SchedulerCtrl", Controller);
\r