/* global angular, i18n */ 'use strict'; angular.module('DinsorApp', ['DinsorApp.filters', 'DinsorApp.services', 'DinsorApp.directives', 'DinsorApp.controllers', 'ngRoute', 'ngSanitize', 'ngMeta', 'ngCookies' ]) .config(function(ngMetaProvider) { ngMetaProvider.useTitleSuffix(true); ngMetaProvider.setDefaultTitle('Creative Thailand'); //ngMetaProvider.setDefaultTitleSuffix(' | YourSite'); ngMetaProvider.setDefaultTag('device', 'desktop'); }) .config(['$routeProvider', '$httpProvider', '$locationProvider', function($routeProvider, $httpProvider, $locationProvider) { $locationProvider.html5Mode(true) $routeProvider.when('/', { // controller: 'home', templateUrl: '/templates/home.creativethailand', data: { meta: { 'title': '', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/why-thailand', { // controller: 'home', templateUrl: '/templates/pages/why-thailand.creativethailand', data: { meta: { 'title': 'Why Thailand', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/why-thailand/article/:id', { // controller: 'home', templateUrl: '/templates/pages/why-thailand-view.creativethailand', data: { meta: { 'title': 'Why Thailand', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/happening', { // controller: 'home', templateUrl: '/templates/pages/happening.creativethailand', data: { meta: { 'title': 'Happening', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/happening/:id', { // controller: 'home', templateUrl: '/templates/pages/happening-view.creativethailand', data: { meta: { 'title': 'Happening', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/creative-maker', { // controller: 'home', templateUrl: '/templates/pages/creative-maker.creativethailand', data: { meta: { 'title': 'Creative Maker', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/creative-maker/:id', { // controller: 'home', templateUrl: '/templates/pages/creative-maker-view.creativethailand', data: { meta: { 'title': 'Creative Maker', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/creative-hub', { // controller: 'home', templateUrl: '/templates/pages/creative-hub.creativethailand', data: { meta: { 'title': 'Creative Hub', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/creative-hub/:category', { // controller: 'home', templateUrl: '/templates/pages/creative-hub-category.creativethailand', data: { meta: { 'title': 'Creative Hub', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/creative-hub/view/:id', { // controller: 'home', templateUrl: '/templates/pages/creative-hub-view.creativethailand', data: { meta: { 'title': 'Creative Hub', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/service-request/:id', { // controller: 'home', templateUrl: '/templates/pages/service-request.creativethailand', data: { meta: { 'title': 'Service Request', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/service-enquiry', { // controller: 'user', templateUrl: '/templates/pages/service-enquiry.creativethailand', data: { meta: { 'title': 'Service Enquiry', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/creative-solution', { // controller: 'home', templateUrl: '/templates/pages/creative-solution.creativethailand', data: { meta: { 'title': 'Creative Solution', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/creative-solution/:id', { // controller: 'home', templateUrl: '/templates/pages/creative-solution-view.creativethailand', data: { meta: { 'title': 'Creative Solution', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/success-case', { // controller: 'home', templateUrl: '/templates/pages/success-case.creativethailand', data: { meta: { 'title': 'Success Case', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/success-case/:id', { // controller: 'home', templateUrl: '/templates/pages/success-case-view.creativethailand', data: { meta: { 'title': 'Success Case', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/about-us', { // controller: 'home', templateUrl: '/templates/pages/about-us.creativethailand', data: { meta: { 'title': 'About Us', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/contact-us', { // controller: 'home', templateUrl: '/templates/pages/contact-us.creativethailand', data: { meta: { 'title': 'Contact Us', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/search-result', { // controller: 'home', templateUrl: '/templates/pages/search-result.creativethailand', data: { meta: { 'title': 'Search Result', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/signin', { // controller: 'home', templateUrl: '/templates/pages/signin.creativethailand', data: { meta: { 'title': 'Sign in', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/signup', { // controller: 'home', templateUrl: '/templates/pages/signup.creativethailand', data: { meta: { 'title': 'Sign up', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/dashboard', { // controller: 'user', templateUrl: '/templates/pages/dashboard.creativethailand', data: { meta: { 'title': 'Dashboard', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/inquiries/:type/:id', { // controller: 'user', templateUrl: '/templates/pages/inquiries.creativethailand', data: { meta: { 'title': 'Inquiries', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/register-form', { // controller: 'home', templateUrl: '/templates/pages/register-form.creativethailand', data: { meta: { 'title': 'Register Form', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/register-form/:id', { // controller: 'home', templateUrl: '/templates/pages/register-form.creativethailand', data: { meta: { 'title': 'Register Form', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/prelaunch', { // controller: 'home', templateUrl: '/templates/prelaunch.creativethailand', data: { meta: { 'title': '', 'description': '', 'device': 'mobile' } } }); // Th $routeProvider.when('/:language', { // controller: 'home', templateUrl: '/templates/seller/home.creativethailand', data: { meta: { 'title': '', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/about-us/:language', { // controller: 'home', templateUrl: '/templates/pages/about-us-th.creativethailand', data: { meta: { 'title': 'เกี่ยวกับ Creative Thailand', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/how-to-use/:language', { // controller: 'home', templateUrl: '/templates/pages/how-to-use-th.creativethailand', data: { meta: { 'title': 'วิธีการใช้งาน', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/contact-us/:language', { // controller: 'home', templateUrl: '/templates/pages/contact-us-th.creativethailand', data: { meta: { 'title': 'ติดต่อเรา', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/dashboard/:language', { // controller: 'home', templateUrl: '/templates/pages/dashboard-th.creativethailand', data: { meta: { 'title': 'Dashboard', 'description': '', 'device': 'mobile' } } }); $routeProvider.when('/inquiries/:type/:id/:language', { // controller: 'home', templateUrl: '/templates/pages/inquiries-th.creativethailand', data: { meta: { 'title': 'Inquiries', 'description': '', 'device': 'mobile' } } }); $routeProvider.otherwise({ // redirectTo: '/' }); $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; //$httpProvider.defaults.withCredentials = true; //$httpProvider.defaults.useXDomain = true; //delete $httpProvider.defaults.headers.common['X-Requested-With']; var param = function(obj) { var query = '', name, value, fullSubName, subName, subValue, innerObj, i; for (name in obj) { value = obj[name]; if (value instanceof Array) { for (i = 0; i < value.length; ++i) { subValue = value[i]; fullSubName = name + '[' + i + ']'; innerObj = {}; innerObj[fullSubName] = subValue; query += param(innerObj) + '&'; } } else if (value instanceof Object) { for (subName in value) { subValue = value[subName]; fullSubName = name + '[' + subName + ']'; innerObj = {}; innerObj[fullSubName] = subValue; query += param(innerObj) + '&'; } } else if (value !== undefined && value !== null) query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&'; } return query.length ? query.substr(0, query.length - 1) : query; }; $httpProvider.defaults.transformRequest = [function(data) { // return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data; }]; }]) .run(["ngMeta", function (ngMeta) { // ngMeta.init(); }]); Array.prototype.contains = function(obj) { //console.log(obj) return this.indexOf(obj) > -1; };