Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = angular.module('myapp', ['ui.bootstrap', 'ui', 'ngResource', 'ui.directives']);
- app.factory('dealerService', ['$resource', '$http', '$rootScope', function($resource, $http, $rootScope) {
- return {
- // PHP backend wird aufgerufen
- all: $resource('files/framework/dealerall/:token', {}),
- api: $resource('files/framework/dealer/:id/:token', {}),
- message: $resource('files/framework/dealermessage/:id', {})
- };
- }]);
- app.directive("mySlider", function() {
- return {
- restrict: 'E',
- replace: true,
- scope: true,
- template: '<ul class="sliderclass"><li check-last ng-repeat="image in dealerdetails.images"><img ng-src="{{image}}" alt="" /></li></ul>'
- };
- });
- app.directive('checkLast', function() {
- return function(scope, element, attrs) {
- if (scope.$last === true) {
- // jQuery Script triggern
- // AngularJS: jQuery(selector) = element.
- element.ready(function() {
- jQuery('.sliderclass').bxSlider({
- mode: 'fade',
- pager: false
- });
- });
- }
- };
- });
- app.directive('addscroller', function() {
- return function(scope, element, attrs) {
- // jQuery Script triggern
- // AngularJS: jQuery(selector) = element.
- setTimeout(function() {
- jQuery(".nano").nanoScroller();
- if (scope.$last === true) {}
- }, 0);
- };
- });
- // Routing Definitionen
- app.config(['$routeProvider', function($routeProvider) {
- $routeProvider.
- when('/dealer/:id', {
- templateUrl: 'files/tpl/dealer-details.html?52',
- controller: 'DealerDetailsCtrl',
- activetab: 'details'
- }).
- when('/dealermessage/:id', {
- templateUrl: 'files/tpl/dealer-message.html?150',
- controller: 'DealerMessageCtrl',
- activetab: 'message'
- }).
- when('/dealersendmessage/:id', {
- templateUrl: 'files/tpl/dealer-details.html?10',
- controller: 'DealerDetailsCtrl',
- activetab: 'details'
- }).
- otherwise({
- redirectTo: '/dealer'
- });
- }]);
- // MainCtrl
- app.controller('MainCtrl', function($scope, $rootScope, $location, $route, $http) {
- $scope.loading = true;
- $scope.typeOptions = [{
- name: 'DE',
- value: 'DE'
- }, {
- name: 'AT',
- value: 'AT'
- }, {
- name: 'CH',
- value: 'CH'
- }];
- $scope.countryLookup = $scope.typeOptions[0].value;
- $scope.setupCountrySelect = {
- minimumResultsForSearch: 20,
- dropdownCssClass: 'dropsort_drop',
- containerCssClass: 'dropcountry'
- };
- $scope.setupFilterSelect = {
- containerCssClass: 'dropsort',
- minimumResultsForSearch: 20,
- dropdownCssClass: 'dropsort_drop'
- };
- $rootScope.details = {
- show: false
- };
- $scope.updateDealer = function(zip, country) {
- if (zip) {
- $rootScope.alldealer = {
- show: false
- };
- $http.get('files/framework/dealer/near/' + zip + '/' + country + '/' + $rootScope.token + '').success(function(data) {
- $rootScope.details = close();
- if (!data) {
- $rootScope.error = {
- showerror: true
- };
- $rootScope.details = close();
- } else {
- $rootScope.error = {
- showerror: false
- };
- $location.path('/dealer/' + data.id);
- $rootScope.details = {
- show: true
- };
- $scope.active_marker = {
- show: data.id
- };
- }
- });
- } else {
- $scope.dealer = $scope.loadall();
- $rootScope.details = close();
- }
- };
- $scope.updateToken = function(token) {
- $rootScope.token = token;
- $http.get('files/framework/dealerall/' + token).success(function(data) {
- $scope.dealerall = data;
- $scope.loading = false;
- });
- };
- $scope.loadall = function() {
- $http.get('files/framework/dealer/near/45525/DE/' + $rootScope.token + '').success(function(data) {
- $rootScope.details = close();
- if (!data) {
- $rootScope.error = {
- showerror: true
- };
- $rootScope.details = close();
- } else {
- $rootScope.error = {
- showerror: false
- };
- $location.path('/dealer/' + data.id);
- $rootScope.details = {
- show: true
- };
- $rootScope.active_marker = {
- show: data.id
- };
- }
- });
- $http.get('files/framework/dealerall/').success(function(data) {
- // Händler werden an das scope.dealerall übergeben um diese im Frontend darzustellen
- $scope.dealer = data;
- });
- $scope.orderProp = 'name';
- };
- $scope.$route = $route;
- $rootScope.active_marker = {
- show: false
- };
- //Marker Overlay reload
- $scope.toggle = function(marker) {
- $rootScope.active_marker = {
- show: marker.id
- };
- $rootScope.details = {
- show: false
- };
- return $rootScope.active_marker.show;
- };
- });
- app.controller('DealerDetailsCtrl', function($scope, $rootScope, $routeParams, dealerService) {
- $scope.loading = true;
- $rootScope.dealerdetails = dealerService.api.get({
- id: $routeParams.id,
- token: $scope.token
- });
- $rootScope.dealercoord = $scope.dealerdetails;
- $scope.issend = $rootScope.issend;
- $rootScope.issend = false;
- $scope.loading = false;
- $rootScope.close = function() {
- $rootScope.marker = {
- show: false
- };
- $rootScope.details = {
- show: false
- };
- $rootScope.alldealer = {
- show: false
- };
- $rootScope.active_marker = null;
- };
- });
- app.controller('DealerMessageCtrl', function($scope, $rootScope, $http, $routeParams, $location, dealerService) {
- $scope.dealer = dealerService.message.get({
- id: $routeParams.id
- });
- $scope.$invalid = false;
- //Sende Nachricht
- $scope.sendMessage = function(form) {
- $http({
- method: 'POST',
- url: 'files/framework/dealersendmessage/' + $routeParams.id,
- data: $scope.user,
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- }).success(function(data) {
- $location.url('/dealer/' + $routeParams.id);
- $rootScope.issend = data;
- });
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement