Blame view
app/scripts/controllers/main.js
3.26 KB
c87bc1f33
|
1 2 |
define(['app'], function (app) { 'use strict'; |
3ca9f7356
|
3 |
app.controller('MainCtrl', function ($rootScope, $scope, $timeout, $illustration, $t_shirt, $routeParams) { |
4d7dab16f
|
4 |
//Define and init var |
682a3b12d
|
5 |
$rootScope.API_URL = 'http://domain.com'; |
c9d8b2fe3
|
6 |
$scope.designFrameView = 'views/tshirt-design.html?ver='+VERSION; |
1d6ddfa62
|
7 |
$scope.designPartIllustration = 'views/design_part/illustration.html?ver='+VERSION; |
19a541686
|
8 9 10 |
$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; |
3ca9f7356
|
11 |
var currentTShirtKey = 0; |
4d7dab16f
|
12 13 14 15 16 17 18 19 20 21 |
var placeTShirt; var tShirtColorFirstKey = 0; $scope.tShirtChoiceBackFrontKey = 'front'; $scope.tShirtColorKey = tShirtColorFirstKey; /** * Get param route * @type {any} * @private */ |
3ca9f7356
|
22 23 24 |
var _routeParams = $routeParams; if(typeof _routeParams.tShirt != 'undefined') currentTShirtKey = _routeParams.tShirt - 1; |
4d7dab16f
|
25 26 |
if(typeof _routeParams.place != 'undefined') placeTShirt = _routeParams.place; |
3ca9f7356
|
27 |
|
4d7dab16f
|
28 29 30 31 32 |
/** * Get all info TShirt * @param: id * @return: object */ |
3ca9f7356
|
33 |
$scope.tShirtColor = $t_shirt.getTShirtColor(currentTShirtKey); |
422e7837d
|
34 35 36 37 38 |
$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; |
4d7dab16f
|
39 40 41 |
/** * Set preview size and position */ |
360081503
|
42 43 44 45 46 47 48 |
function setSizePreViewDesign() { var _widthPreviewDesign = $('#preview-design').width(); var _widthTShirtImage = $('.tshirt-image').width(); var leftReviewDesign = _widthTShirtImage/2 - (_widthPreviewDesign/2); $('#preview-design').css({left: leftReviewDesign}); } setSizePreViewDesign(); |
360081503
|
49 50 51 |
$(window).resize(function () { setSizePreViewDesign(); }); |
4d7dab16f
|
52 53 54 55 |
/** * Choice color t-shirt * @param key */ |
422e7837d
|
56 57 |
$scope.choiceTShirtColor = function(key) { $scope.tShirtColorKey = key; |
4d7dab16f
|
58 59 60 61 62 |
var tShirtColor = $scope.tShirtColor[key]; $rootScope.tShirtColorCode = tShirtColor.code; $scope.tShirtColorName = tShirtColor.name; $scope.tShirtImgFront = tShirtColor.img.front; $scope.tShirtImgBack = tShirtColor.img.back; |
422e7837d
|
63 64 65 66 67 68 |
if($scope.tShirtChoiceBackFrontKey == 'front') { $scope.tShirtImg = $scope.tShirtImgFront; } else { $scope.tShirtImg = $scope.tShirtImgBack; } }; |
4d7dab16f
|
69 70 71 72 |
/** * Choice back or front t-shirt * @param choice */ |
422e7837d
|
73 74 75 76 77 78 79 80 |
$scope.choiceTShirtBackFront = function(choice) { if(choice == 'front') { $scope.tShirtImg = $scope.tShirtImgFront; } else { $scope.tShirtImg = $scope.tShirtImgBack; } $scope.tShirtChoiceBackFrontKey = choice; }; |
c8bfdfd96
|
81 82 83 84 85 86 87 88 89 |
//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
|
90 |
} |
422e7837d
|
91 |
}; |
4d7dab16f
|
92 93 94 |
/** * Open modal design */ |
87c93a029
|
95 |
$scope.modalTShirtDesign = function() { |
5fe93ca88
|
96 97 98 99 100 101 |
$('#tshirt-design').modal( { backdrop: 'static', keyboard: false } ); |
2f4c31749
|
102 |
|
5fe93ca88
|
103 |
}; |
4d7dab16f
|
104 105 106 |
/** * Close modal design */ |
5fe93ca88
|
107 108 |
$scope.modalClose = function(){ $('#tshirt-design').modal('hide'); |
422e7837d
|
109 |
}; |
c87bc1f33
|
110 111 |
}); }); |