define(['app'], function (app) { 'use strict'; app.controller('MainCtrl', function ($rootScope, $scope, $timeout, $illustration, $t_shirt) { // console.log($('nav').width()); $rootScope.API_URL = 'http://domain.com'; $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; //review design set position 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(); }); $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; }; //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.modalClose = function(){ $('#tshirt-design').modal('hide'); }; }); });