File: D:/HostingSpaces/SBogers10/topswtwmobile.komma.pro/wwwroot/js/app/angularConfig.js
/*define(['app/checkout/cartController.ng',
'app/checkout/productController.ng',
'app/checkout/productSessionService.ng',
'app/checkout/smallAfterCommaFilter.ng',
'app/checkout/discountModule.ng',
'app/checkout/checkoutCart.ng'
],*/
define([
'app/checkout/checkout.ng',
'app/checkout/checkoutCart.ng',
'app/checkout/discountModule.ng',
'app/customer/customer.ng',
'app/searchbar/searchbar.ng',
'app/modules/productOverviewItemController.ng',
'app/pages/pages.ng.js'
],
function (checkout, checkoutCart, discountModule, customer, searchbar, productOverviewItemController, pages) {
var app = angular.module('shop', ['ngSanitize', 'checkout', 'customer', 'checkoutCart', 'discountModule', 'pages', 'searchbar', 'ui.bootstrap']);
app.directive('jsonData', [function () {
return {
restrict: 'A',
link: function (scope, element, attributes, controller) {
//Check if the string contains more then whitespaces
if (/\S/.test(element.html())) {
scope[attributes.ngModel] = JSON.parse(element.html())
}
}
};
}]);
/**
* This service will load a translation via Ajax
* And collects an item with the get function
*
*/
app.service('translationsService',['$http','$location', function ($http, $location) {
//set the translation array
var translations = [];
lang_url = '/ajax/translations';
var url_parts = window.location.pathname.split('/')
if(url_parts[1].match(/[a-z]{2}/gi)){
lang_url = '/'+url_parts[1] + lang_url;
}
//load the translations external (with lang)
$http.get(lang_url).success(function (data) {
//If the load is succesfull add the data to the translations var
translations = data;
}).error(function () {
//The load faild return '', so that the script doesn't break
return '';
});
//the path is an string with . to seperate the parts
this.get = function (path) {
//Split the parts in to an array
var pathParts = path.split('.');
var translationLevel = translations;
for (var pathPart in pathParts) {
pathPart = pathParts[pathPart];
//Chekc if the pathpart exits in the translationLevel
if (translationLevel[pathPart]) {
//set the translationlevel to the found level and repeat (till the deepest part)
translationLevel = translationLevel[pathPart];
}
}
//Check if translationLevel is an string, if not it can mean no all the parts are found in de tranlation object
if (typeof translationLevel === 'string' || translationLevel instanceof String) {
return translationLevel;
}
//nothing found return '', so the script doesn't break
return '';
};
}]);
/*
app.factory('productSessionService', productSessionService);
app.filter('smallAfterCommaFilter', smallAfterCommaFilter);
app.controller('cartController', cartController);
*/
app.controller('productOverviewItemController', productOverviewItemController);
}
);