From 44890c934ca3f0bf33907dbf567d36da42195af0 Mon Sep 17 00:00:00 2001 From: Daniel Camargo Date: Mon, 7 Oct 2013 15:37:50 -0300 Subject: [PATCH] partial #1922 - removed unnecessary (exported) properties at byRange method - removed unnecessary code - fixed interval issue at snap.js --- include/library/Crunchbutton/Restaurant.php | 35 ++++++++++++++++----- www/assets/js/app.js | 2 -- www/assets/js/controllers.js | 13 -------- www/assets/js/snap.js | 2 ++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/include/library/Crunchbutton/Restaurant.php b/include/library/Crunchbutton/Restaurant.php index 16ce47f91..8d31832c5 100644 --- a/include/library/Crunchbutton/Restaurant.php +++ b/include/library/Crunchbutton/Restaurant.php @@ -1012,13 +1012,22 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { */ public function exports($ignore = [], $where = []) { - $out = $this->properties(); - $out['_open'] = $this->open(); + // method ByRand doesnt need all the properties + if( $out['type'] && $out['type'] == 'byrange' ){ + $_ignore = [ 'type', 'credit','address','max_items','tax','active','phone','fee_restaurant','fee_customer','delivery_min','delivery_min_amt','notes_todo','pickup_estimated_time','delivery_fee','delivery_estimated_time','notes_owner','confirmation','zip','customer_receipt','cash','giftcard','email','notes','balanced_id','balanced_bank','fee_on_subtotal','payment_method','id_restaurant_pay_another_restaurant','charge_credit_fee','waive_fee_first_month','pay_promotions','pay_apology_credits','check_address','contact_name','summary_fax','summary_email','summary_frequency','legal_name_payment','tax_id','community','_preset','id_community', '_hoursFormat', 'loc_long', 'lat_lat', 'id_community' ]; + foreach ( $_ignore as $property ) { + $ignore[ $property ] = true; + } + } + + $out = $this->properties(); + $out['_open'] = $this->open(); $out['_closesIn'] = $this->closesIn(); $out['_weight'] = $this->weight(); $out['_minimumTime'] = 15; // Min minutes to show the hurry message // $out['_openIn'] = $this->openIn(); - + + if( $out['_closesIn'] == 0 ){ $out['_open'] = false; $out['_closesIn'] = false; @@ -1078,14 +1087,25 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { } } - foreach ($this->hours(true) as $hours) { - $out['_hoursFormat'][$hours->day][] = [$hours->time_open, $hours->time_close]; + if (!$ignore['_hoursFormat']) { + foreach ($this->hours(true) as $hours) { + $out['_hoursFormat'][$hours->day][] = [$hours->time_open, $hours->time_close]; + } } + foreach ($this->hours() as $hours) { $out['_hours'][$hours->day][] = [$hours->time_open, $hours->time_close]; } - if ($this->preset()->count()) { - $out['_preset'] = $this->preset()->get(0)->exports(); + + if (!$ignore['_preset']) { + if ($this->preset()->count()) { + $out['_preset'] = $this->preset()->get(0)->exports(); + } + } + + // Remove ignored methods + foreach ( $ignore as $property => $val ) { + unset( $out[ $property ] ); } $out['id_community'] = $this->community()->id_community; @@ -1218,6 +1238,7 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { $query = ' SELECT count(*) as _weight, + "byrange" type, ((ACOS(SIN('.$params['lat'].' * PI() / 180) * SIN(loc_lat * PI() / 180) + COS('.$params['lat'].' * PI() / 180) * COS(loc_lat * PI() / 180) * COS(('.$params['lon'].' - loc_long) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS `distance`, restaurant.* FROM `restaurant` diff --git a/www/assets/js/app.js b/www/assets/js/app.js index 97cbcc1b7..a2fe81c1e 100644 --- a/www/assets/js/app.js +++ b/www/assets/js/app.js @@ -310,8 +310,6 @@ NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootS App.scrollTop(); },1); - clearInterval($rootScope.updateOpen); - if (App.isPhoneGap && !App.splashHidden && navigator.splashscreen) { App.splashHidden = true; setTimeout(function() { diff --git a/www/assets/js/controllers.js b/www/assets/js/controllers.js index 2f77b2857..63bd84a70 100644 --- a/www/assets/js/controllers.js +++ b/www/assets/js/controllers.js @@ -51,19 +51,6 @@ NGApp.controller('HomeCtrl', function ($scope, $http, $location, RestaurantsServ // just force the location to the food-delivery page. if we dont have a loc it sends us back to location anyway $location.path( '/' + restaurants.permalink ); return; - - /* - restaurants.list( - // Success - function(){ - $location.path( '/' + restaurants.permalink ); - }, - // Error - function(){ - $location.path( '/location' ); - } - ); - */ }); diff --git a/www/assets/js/snap.js b/www/assets/js/snap.js index 039f23cdc..d2b2b7649 100644 --- a/www/assets/js/snap.js +++ b/www/assets/js/snap.js @@ -208,6 +208,8 @@ utils.dispatchEvent('animating'); }, 1); + clearInterval(cache.animatingInterval); + utils.events.addEvent(settings.element, utils.transitionCallback(), action.translate.easeCallback); action.translate.x(n); }