diff --git a/include/views/default/crunchbutton/frontend/location.phtml b/include/views/default/crunchbutton/frontend/location.phtml index bbe2faab1..436c896c9 100644 --- a/include/views/default/crunchbutton/frontend/location.phtml +++ b/include/views/default/crunchbutton/frontend/location.phtml @@ -28,7 +28,10 @@
- +
diff --git a/include/views/default/crunchbutton/frontend/restaurants.phtml b/include/views/default/crunchbutton/frontend/restaurants.phtml index f4919434a..0da66d59f 100644 --- a/include/views/default/crunchbutton/frontend/restaurants.phtml +++ b/include/views/default/crunchbutton/frontend/restaurants.phtml @@ -22,7 +22,7 @@
-
+

{{restaurant.name}}

diff --git a/www/assets/js/controllers.js b/www/assets/js/controllers.js index 37172bd8b..d12d138e3 100644 --- a/www/assets/js/controllers.js +++ b/www/assets/js/controllers.js @@ -180,14 +180,6 @@ NGApp.controller( 'RestaurantsCtrl', function ( $scope, $rootScope, $http, $loca $('.content').removeClass('short-meal-list'); } $('.content').removeClass('smaller-width'); - - setTimeout(function() { - $('.meal-item-content').each(function() { - var s = Ladda.create(this); - $(this).data('spinner', s); - $scope.spin = s; - }); - },1); }, // Error @@ -254,7 +246,7 @@ NGApp.controller( 'LocationCtrl', function ($scope, $http, $location, Restaurant }); $scope.$on( 'locationError', function(e, data) { - + spin.stop(); // If the entered address does not have zip code show the enter zip code message #1763 var entered = $scope.location.position.pos().entered(); var isStreet = $scope.location.position.pos().valid( 'order' ); @@ -267,6 +259,7 @@ NGApp.controller( 'LocationCtrl', function ($scope, $http, $location, Restaurant }); $scope.$on( 'locationNotServed', function(e, data) { + spin.stop(); $('.location-address').val('').attr('placeholder','Please include a zip code or city name'); $scope.warningPlaceholder = true; // the user might be typing his login/pass - so blur it @@ -287,6 +280,10 @@ NGApp.controller( 'LocationCtrl', function ($scope, $http, $location, Restaurant // lets eat button $scope.letsEat = function() { + + // Start the spinner + spin.start(); + $scope.location.form.address = $.trim( $scope.location.form.address ); if ( $scope.location.form.address == '' ) { $('.location-address').val('').attr('placeholder',$('
').html('➤ Please enter your address here').text()); @@ -320,6 +317,7 @@ NGApp.controller( 'LocationCtrl', function ($scope, $http, $location, Restaurant }, // Address not ok function() { + spin.stop(); var oopsText = App.isPhoneGap ? 'Oops! Please enter an address' : '☹ Oops! Please enter a street name, number, and city'; $('.location-address').val('').attr('placeholder',$('
').html(oopsText).text()); $scope.warningPlaceholder = true; @@ -345,6 +343,20 @@ NGApp.controller( 'LocationCtrl', function ($scope, $http, $location, Restaurant }); }; + var spin = { + start : function(){ + if( spin.obj ){ + spin.obj.start(); + } + }, + stop : function(){ + if( spin.obj ){ + spin.obj.stop(); + } + } + }; + setTimeout( function(){ spin.obj = $('.button-letseat-form').data('spinner'); }, 500 ); + }); /** diff --git a/www/assets/js/directives.js b/www/assets/js/directives.js index 75bfa866a..54636f052 100644 --- a/www/assets/js/directives.js +++ b/www/assets/js/directives.js @@ -148,6 +148,15 @@ NGApp.directive('ngKeyUp', function () { }; }); +NGApp.directive('ngSpinner', function () { + return { + restrict: 'A', + link: function (scope, elem, attr) { + elem.data( 'spinner', Ladda.create( elem.get(0) ) ); + } + }; +}); + NGApp.directive('ngSimulateReadOnly', function () { return { restrict: 'A',