-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrollers.js
74 lines (61 loc) · 1.91 KB
/
controllers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function MainCtrl($scope, $compile, ImagesDataSvc, AdorSvc){
$scope.imagesDataSvc = ImagesDataSvc;
$scope.adors = AdorSvc;
$scope.months = [
{ador:'jan_image', text:'January'},
{ador:'feb_image', text:'February'},
{ador:'mar_image', text:'March'},
{ador:'apr_image', text:'April'},
{ador:'may_image', text:'May'},
{ador:'jun_image', text:'June'},
{ador:'jul_image', text:'July'},
{ador:'aug_image', text:'August'},
{ador:'sep_image', text:'September'},
{ador:'oct_image', text:'October'},
{ador:'nov_image', text:'November'},
{ador:'dec_image', text:'December'}
];
$scope.selectedMonth = $scope.months[0];
$scope.selectedFilter = 'spring';
$scope.images = $scope.imagesDataSvc.query({},function(){
/** Bind the ADOR inputs to the service **/
$(document).find('input.FormField').each(function(){
/** Find the associated FieldLabel and get the text **/
var label = $.trim($(this).closest('tr').find('.FormLabel').text());
/** Save any current value before binding **/
var tmp = $(this).val();
/** Bind input element using ng-model **/
$(this).attr('ng-model','adors.'+label);
var x = $compile($(this));
x($scope);
/** Reassign saved value **/
$scope.adors[ label ] = tmp;
});
angular.forEach($scope.months, function(m){
var id = $scope.adors[ m.ador ];
angular.forEach($scope.images, function(i){
if (i.id == id)
m.img = i;
});
});
});
$scope.selectImage = function(image, $event){
$event.preventDefault();
$event.stopPropagation();
$scope.selectedMonth.img = image.id;
$scope.adors[ $scope.selectedMonth.ador ] = image.id;
};
$scope.selectMonth = function(month){
$scope.selectedMonth = month;
};
$scope.isSubmitDisabled = function(){
for (var m in $scope.months) {
if (!$scope.months[m].img)
return true;
}
return false;
};
$scope.submitOrder = function(){
// GO TO THE NEXT PAGE
};
}