Blame view
app/scripts/controllers/main.js
2.94 KB
|
c87bc1f33
|
1 2 |
define(['app'], function (app) {
'use strict';
|
|
3ca9f7356
|
3 |
app.controller('MainCtrl', function ($rootScope, $scope, $timeout, $illustration, $t_shirt, $routeParams) {
|
|
2f4c31749
|
4 |
// console.log($('nav').width());
|
|
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; |
|
1d6ddfa62
|
11 |
|
|
422e7837d
|
12 |
//Action T-Shirt choice color and Back or Front |
|
3ca9f7356
|
13 14 15 16 17 18 |
var currentTShirtKey = 0; var _routeParams = $routeParams; if(typeof _routeParams.tShirt != 'undefined') currentTShirtKey = _routeParams.tShirt - 1; $scope.tShirtColor = $t_shirt.getTShirtColor(currentTShirtKey); |
|
422e7837d
|
19 20 21 22 23 24 25 26 27 |
//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; |
|
83f7186e9
|
28 |
|
|
422e7837d
|
29 |
|
|
2f4c31749
|
30 |
//review design set position |
|
360081503
|
31 32 33 34 35 36 37 38 39 40 41 |
function setSizePreViewDesign() {
var _widthPreviewDesign = $('#preview-design').width();
var _widthTShirtImage = $('.tshirt-image').width();
var leftReviewDesign = _widthTShirtImage/2 - (_widthPreviewDesign/2);
$('#preview-design').css({left: leftReviewDesign});
}
setSizePreViewDesign();
//event resize window
$(window).resize(function () {
setSizePreViewDesign();
});
|
|
2f4c31749
|
42 |
|
|
422e7837d
|
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
$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;
};
|
|
c8bfdfd96
|
63 64 65 66 67 68 69 70 71 |
//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
|
72 |
} |
|
422e7837d
|
73 |
}; |
|
6f105dbd5
|
74 |
|
|
87c93a029
|
75 |
$scope.modalTShirtDesign = function() {
|
|
5fe93ca88
|
76 77 78 79 80 81 |
$('#tshirt-design').modal(
{
backdrop: 'static',
keyboard: false
}
);
|
|
2f4c31749
|
82 |
|
|
5fe93ca88
|
83 84 85 |
};
$scope.modalClose = function(){
$('#tshirt-design').modal('hide');
|
|
422e7837d
|
86 |
}; |
|
c87bc1f33
|
87 88 |
}); }); |