main.js
2.59 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
define(['app'], function (app) {
'use strict';
app.controller('MainCtrl', function ($rootScope, $scope, $illustration, $t_shirt) {
$scope.designFrameView = 'views/tshirt-design.html?ver='+VERSION;
$scope.designPartIllustration = 'views/design_part/illustration.html?ver='+VERSION;
$scope.designPartImage = 'views/design_part/image.html?ver='+VERSION;
$scope.designPartText = 'views/design_part/text.html?ver='+VERSION;
$scope.designPartDefault = 'views/design_part/default.html?ver='+VERSION;
//Action T-Shirt choice color and Back or Front
$scope.tShirtColor = $t_shirt.getTShirtColor(0);
//Set color name default
var tShirtColorFirstKey = 0;
$scope.tShirtChoiceBackFrontKey = 'front';
$scope.tShirtColorKey = tShirtColorFirstKey;
$rootScope.tShirtColorCode = $scope.tShirtColor[tShirtColorFirstKey].code;
$scope.tShirtColorName = $scope.tShirtColor[tShirtColorFirstKey].name;
$scope.tShirtImgFront = $scope.tShirtColor[tShirtColorFirstKey].img.front;
$scope.tShirtImgBack = $scope.tShirtColor[tShirtColorFirstKey].img.back;
$scope.tShirtImg = $scope.tShirtImgFront;
$scope.choiceTShirtColor = function(key) {
$scope.tShirtColorKey = key;
$rootScope.tShirtColorCode = $scope.tShirtColor[key].code;
$scope.tShirtColorName = $scope.tShirtColor[key].name;
$scope.tShirtImgFront = $scope.tShirtColor[key].img.front;
$scope.tShirtImgBack = $scope.tShirtColor[key].img.back;
if($scope.tShirtChoiceBackFrontKey == 'front') {
$scope.tShirtImg = $scope.tShirtImgFront;
} else {
$scope.tShirtImg = $scope.tShirtImgBack;
}
};
$scope.choiceTShirtBackFront = function(choice) {
if(choice == 'front') {
$scope.tShirtImg = $scope.tShirtImgFront;
} else {
$scope.tShirtImg = $scope.tShirtImgBack;
}
$scope.tShirtChoiceBackFrontKey = choice;
};
$scope.showDesignTab = function(tab){
$rootScope.isShowLeftPanel = tab;
switch (tab) {
case 'illustration': {
$scope.IllustrationList = $illustration.getAll();
$scope.illustrationSelectConfig = {
allowClear:true
};
break;
}
case 'text': {
break;
}
}
};
//safeApply
$rootScope.safeApply = function(fn) {
var phase = this.$root.$$phase;
if(phase == '$apply' || phase == '$digest') {
if(fn && (typeof(fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
};
$scope.modalTShirtDesign = function() {
$('#tshirt-design').modal(
{
backdrop: 'static',
keyboard: false
}
);
$scope.showDesignTab('default');
};
$scope.modalClose = function(){
$('#tshirt-design').modal('hide');
};
});
});