Blame view

app/scripts/controllers/main.js 2.87 KB
c87bc1f33   TRUONG   first commit: ini...
1
2
  define(['app'], function (app) {
  	'use strict';
e0ee74c15   TRUONG   update fix layer ...
3
  	app.controller('MainCtrl', function ($rootScope, $scope, $timeout, $illustration, $t_shirt) {
682a3b12d   TRUONG   fix illustration ...
4
  		$rootScope.API_URL = 'http://domain.com';
c9d8b2fe3   Truong LD   update version
5
  		$scope.designFrameView = 'views/tshirt-design.html?ver='+VERSION;
1d6ddfa62   TRUONG   merge
6
  		$scope.designPartIllustration = 'views/design_part/illustration.html?ver='+VERSION;
19a541686   TRUONG   restruct + fix style
7
8
9
  		$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;
1d6ddfa62   TRUONG   merge
10
  		
422e7837d   DANG   Change color t-shirt
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
  		//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;
  		};
19a541686   TRUONG   restruct + fix style
43
  		$scope.showDesignTab = function(tab){
c8bfdfd96   DANG   event click object
44
45
  			$rootScope.isShowLeftPanel = tab;
  			switch (tab) {
6f105dbd5   Truong LD   add source code i...
46
47
  				case 'illustration': {
  					$scope.IllustrationList = $illustration.getAll();
80ff9bbd4   TRUONG   fix bugs and optimal
48
  					$rootScope.outputImage = false;
6f105dbd5   Truong LD   add source code i...
49
50
  					$scope.illustrationSelectConfig = {
  						allowClear:true
422e7837d   DANG   Change color t-shirt
51
  					};
e0ee74c15   TRUONG   update fix layer ...
52
53
54
55
56
57
  					$timeout(function(){
  						$('.illstration-item').tooltip({
  							animated: 'fade',
  						    placement: 'bottom',
  						    html: true
  						});
80ff9bbd4   TRUONG   fix bugs and optimal
58
  						// console.log('here');
e0ee74c15   TRUONG   update fix layer ...
59
  					},1000);
6f105dbd5   Truong LD   add source code i...
60
61
  					break;
  				}
c8bfdfd96   DANG   event click object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  				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);
6f105dbd5   Truong LD   add source code i...
77
  			}
422e7837d   DANG   Change color t-shirt
78
  		};
6f105dbd5   Truong LD   add source code i...
79

87c93a029   Dang YoungWorld   add modal
80
  		$scope.modalTShirtDesign = function() {
5fe93ca88   Dang YoungWorld   Theme modal
81
82
83
84
85
86
  			$('#tshirt-design').modal(
  				{
  					backdrop: 'static',
  					keyboard: false
  				}
  			);
19a541686   TRUONG   restruct + fix style
87
  			$scope.showDesignTab('default');
5fe93ca88   Dang YoungWorld   Theme modal
88
89
90
  		};
  		$scope.modalClose = function(){
  			$('#tshirt-design').modal('hide');
422e7837d   DANG   Change color t-shirt
91
  		};
c8bfdfd96   DANG   event click object
92

c87bc1f33   TRUONG   first commit: ini...
93
94
  	});
  });