This commit is contained in:
Daniel Camargo 2013-09-26 13:48:42 -03:00
parent e5908c0f1d
commit e2fbdce386
4 changed files with 35 additions and 11 deletions

View File

@ -28,7 +28,10 @@
</form>
</div>
<div class="divider"></div>
<button ng-show="!locationError" class="button-letseat-form button-bottom" ng-click="letsEat()"><div>Find Restaurants!</div></button>
<button ng-show="!locationError" ng-spinner class="button-letseat-form button-bottom ladda-button" data-style="zoom-out" data-spinner-color="#FFFFFF" ng-click="letsEat()">
<div class="ladda-label">Find Restaurants!</div>
<span class="ladda-spinner"></span>
</button>
<div class="error-location" ng-show="locationError">

View File

@ -22,7 +22,7 @@
<div ng-click="display($event)" ng-class="{'meal-item-closed': restaurant._open==false}" class="meal-item" data-id_restaurant="{{restaurant.id_restaurant}}" data-permalink="{{restaurant.permalink}}" ng-repeat="restaurant in restaurants">
<div class="meal-item-content ladda-button" data-style="zoom-out" data-spinner-color="#333333">
<div class="meal-item-content ladda-button" ng-spinner data-style="zoom-out" data-spinner-color="#333333">
<div class="ladda-label">
<div class="meal-pic" style="background: url({{restaurant.img64}});"></div>
<h2 class="meal-restaurant">{{restaurant.name}}</h2>

View File

@ -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',$('<div>').html('&#10148; 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' : '&#9785; Oops! Please enter a street name, number, and city';
$('.location-address').val('').attr('placeholder',$('<div>').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 );
});
/**

View File

@ -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',