diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 17dc752..736d1ea 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -1,33 +1,46 @@ define(['app'], function (app) { 'use strict'; app.controller('MainCtrl', function ($rootScope, $scope, $timeout, $illustration, $t_shirt, $routeParams) { - // console.log($('nav').width()); + //Define and init var $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 var currentTShirtKey = 0; + var placeTShirt; + var tShirtColorFirstKey = 0; + $scope.tShirtChoiceBackFrontKey = 'front'; + $scope.tShirtColorKey = tShirtColorFirstKey; + + /** + * Get param route + * @type {any} + * @private + */ var _routeParams = $routeParams; if(typeof _routeParams.tShirt != 'undefined') currentTShirtKey = _routeParams.tShirt - 1; + if(typeof _routeParams.place != 'undefined') + placeTShirt = _routeParams.place; + + /** + * Get all info TShirt + * @param: id + * @return: object + */ $scope.tShirtColor = $t_shirt.getTShirtColor(currentTShirtKey); - //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 + /** + * Set preview size and position + */ function setSizePreViewDesign() { var _widthPreviewDesign = $('#preview-design').width(); var _widthTShirtImage = $('.tshirt-image').width(); @@ -35,23 +48,30 @@ define(['app'], function (app) { $('#preview-design').css({left: leftReviewDesign}); } setSizePreViewDesign(); - //event resize window $(window).resize(function () { setSizePreViewDesign(); }); - + /** + * Choice color t-shirt + * @param key + */ $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; + var tShirtColor = $scope.tShirtColor[key]; + $rootScope.tShirtColorCode = tShirtColor.code; + $scope.tShirtColorName = tShirtColor.name; + $scope.tShirtImgFront = tShirtColor.img.front; + $scope.tShirtImgBack = tShirtColor.img.back; if($scope.tShirtChoiceBackFrontKey == 'front') { $scope.tShirtImg = $scope.tShirtImgFront; } else { $scope.tShirtImg = $scope.tShirtImgBack; } }; + /** + * Choice back or front t-shirt + * @param choice + */ $scope.choiceTShirtBackFront = function(choice) { if(choice == 'front') { $scope.tShirtImg = $scope.tShirtImgFront; @@ -72,7 +92,9 @@ define(['app'], function (app) { this.$apply(fn); } }; - + /** + * Open modal design + */ $scope.modalTShirtDesign = function() { $('#tshirt-design').modal( { @@ -82,6 +104,9 @@ define(['app'], function (app) { ); }; + /** + * Close modal design + */ $scope.modalClose = function(){ $('#tshirt-design').modal('hide'); }; diff --git a/app/scripts/routes.js b/app/scripts/routes.js index fe8dd8c..f6e0ef4 100644 --- a/app/scripts/routes.js +++ b/app/scripts/routes.js @@ -3,7 +3,7 @@ define([], function(){ return { defaultRoutePaths: '/1', routes: { - '/:tShirt': { + '/:tShirt/:place': { templateUrl: 'views/main.html', dependencies: [ 'scripts/controllers/main.js', diff --git a/app/scripts/services/tshirt.js b/app/scripts/services/tshirt.js index 799d156..1405329 100644 --- a/app/scripts/services/tshirt.js +++ b/app/scripts/services/tshirt.js @@ -11,7 +11,20 @@ define(['app'], function (app) { gender: '', image: '' }, - place_design: {}, + place_design: { + 'place_1' : { + 'face' : 'front', + 'place' : 't_shirt_p_1' + }, + 'place_2' : { + 'face' : 'front', + 'place' : 't_shirt_p_2' + }, + 'place_3' : { + 'face' : 'front', + 'place' : 't_shirt_p_3' + } + }, color: [ { name: 'color: 2E GRAY', @@ -132,6 +145,12 @@ define(['app'], function (app) { } return DATA[key]['color']; }, + getTShirtPlace : function(key, place) { + if(typeof DATA[key].place_design.place == 'undefined' || typeof DATA[key].place_design.place == 'null') + return []; + + return DATA[key].place_design.place; + }, getAll: function(){ return DATA;