Permalink
Browse files

Added "locate" button to toolbar in Search view.

  • Loading branch information...
1 parent 87f8e2a commit 5fb8c4c532469228d17d71f1f98c86971ac7a010 @CaliLuke committed Apr 29, 2012
Showing with 138 additions and 99 deletions.
  1. +3 −3 CityBarsPlus.xds
  2. +18 −76 app/controller/Search.js
  3. +58 −0 app/view/searchForm.js
  4. +1 −20 metadata/controller/Search
  5. +58 −0 metadata/view/searchForm
View
@@ -1,11 +1,11 @@
{
"name": "CityBarsPlus",
"settings": {
- "urlPrefix": "http://localhost/~_WWW/CityBarsPlus/",
+ "urlPrefix": "http://localhost/~lucacandela/cityPlus/",
"directAPI": "",
"spacesToIndent": 4,
"codeGenFormat": "Class",
- "exportPath": "/Users/luca/Sites/CityBarsPlus",
+ "exportPath": "/Users/lucacandela/Sites/cityPlus",
"extPath": "http://extjs.cachefly.net/touch/sencha-touch-2.0.0/",
"senchaIoKey": "",
"senchaIoPath": "http://extjs.cachefly.net/designer/IO/",
@@ -17,7 +17,7 @@
"mapsAPI": "http://maps.google.com/maps/api/js?sensor=true"
},
"xdsVersion": "2.0.0",
- "xdsBuild": "412",
+ "xdsBuild": "424",
"framework": "touch20",
"topInstanceFileMap": {
"b7340641-b7b1-4104-b24d-3d7be6fbf25a": {
View
@@ -23,9 +23,6 @@ Ext.define('CityBarsPlus.controller.Search', {
},
"#searchButton": {
tap: 'onButtonTap'
- },
- "#inputCity": {
- initialize: 'onComponentInitialize'
}
}
},
@@ -44,94 +41,39 @@ Ext.define('CityBarsPlus.controller.Search', {
},
onButtonTap: function(button, e, options) {
- var me = this;
-
+ var me = this;
var business = me.getApplication().getController('Business');
- //Ext.Viewport.remove(Ext.Viewport.getActiveItem(), true);
Ext.Viewport.add(business.getMainNav());
Ext.Viewport.setActiveItem(1);
Ext.Viewport.setMasked({ message: 'Loading...' });
// get the location, then...
- /*
- me.getLocation(function (location) {
-
- // then use Yelp to get the businesses
-
- me.getBusinesses(location, function (store) {
-
- // then bind data to list and show it
-
- me.getDataList().setStore(store);
- Ext.Viewport.setMasked(false);
- });
- });
-
- */
-
- CityBarsPlus.Init.city = Ext.getCmp('inputCity').getValue();
- CityBarsPlus.Init.term = Ext.getCmp('inputCategory').getValue();
-
- //Ext.getCmp('yelpToolbar').setTitle('Please wait...');
-
- var store = Ext.data.StoreManager.lookup('BusinessStore');
+ CityBarsPlus.Init.city = Ext.getCmp('inputCity').getValue();
+ CityBarsPlus.Init.term = Ext.getCmp('inputCategory').getValue();
- if(!Ext.getCmp('dataList').getStore()){
- Ext.getCmp('dataList').setStore(store);
- } else {
- Ext.getCmp('dataList').getStore().removeAll();
- }
-
- //re-do removeAll later
+ //Ext.getCmp('yelpToolbar').setTitle('Please wait...');
+ var store = Ext.data.StoreManager.lookup('BusinessStore');
- Ext.getCmp('dataList').getStore().load({
- params:{
- ywsid:CityBarsPlus.Init.apiKey,
- term:CityBarsPlus.Init.term,
- location:CityBarsPlus.Init.city
+ if(!Ext.getCmp('dataList').getStore()){
+ Ext.getCmp('dataList').setStore(store);
+ } else {
+ Ext.getCmp('dataList').getStore().removeAll();
}
- });
-
- Ext.Viewport.setMasked(false);
-
- /*
- if (YelpTouch.Init.city && YelpTouch.Init.term) {
- this.setActiveItem(1);}
- */
- },
- onComponentInitialize: function(component, options) {
- if(navigator.geolocation){
+ //re-do removeAll later
- Ext.getCmp('inputCity').setValue('Loading...');
-
- navigator.geolocation.getCurrentPosition(function(pos) {
- var lat = pos.coords.latitude;
- var long = pos.coords.longitude;
- var geocoder = new google.maps.Geocoder();
- var latlng = new google.maps.LatLng(lat, long);
- var city = '';
- var region = '';
-
- geocoder.geocode({'latLng': latlng}, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- console.log(results);
- if(results.length > 0) {
- city = results[0].address_components[2].short_name;
- region = results[0].address_components[4].short_name;
- console.log(city, region);
- Ext.getCmp('inputCity').setValue(city+', '+region);
- }
- } else {
- alert("Could not get your location... sorry!");
- Ext.getCmp('inputCity').setValue('');
- }
- });
+ Ext.getCmp('dataList').getStore().load({
+ params:{
+ ywsid:CityBarsPlus.Init.apiKey,
+ term:CityBarsPlus.Init.term,
+ location:CityBarsPlus.Init.city
+ }
});
- }
+
+ Ext.Viewport.setMasked(false);
}
});
View
@@ -53,10 +53,68 @@ Ext.define('CityBarsPlus.view.searchForm', {
itemId: 'searchButton',
ui: 'confirm',
text: 'Search'
+ },
+ {
+ xtype: 'toolbar',
+ docked: 'top',
+ ui: 'light',
+ title: 'City Bars',
+ layout: {
+ pack: 'end',
+ type: 'hbox'
+ },
+ items: [
+ {
+ xtype: 'button',
+ id: 'geoLocate',
+ itemId: 'mybutton4',
+ iconCls: 'locate',
+ iconMask: true,
+ text: ''
+ }
+ ]
}
]
}
+ ],
+ listeners: [
+ {
+ fn: 'onGeoLocateTap',
+ event: 'tap',
+ delegate: '#geoLocate'
+ }
]
+ },
+
+ onGeoLocateTap: function(button, e, options) {
+ if(navigator.geolocation){
+
+ Ext.getCmp('inputCity').setValue('Loading...');
+
+ navigator.geolocation.getCurrentPosition(function(pos) {
+ var lat = pos.coords.latitude;
+ var long = pos.coords.longitude;
+ var geocoder = new google.maps.Geocoder();
+ var latlng = new google.maps.LatLng(lat, long);
+ var city = '';
+ var region = '';
+
+ geocoder.geocode({'latLng': latlng}, function(results, status) {
+ if (status == google.maps.GeocoderStatus.OK) {
+ console.log(results);
+ if(results.length > 0) {
+ city = results[0].address_components[2].short_name;
+ region = results[0].address_components[4].short_name;
+ console.log(city, region);
+ Ext.getCmp('inputCity').setValue(city+', '+region);
+ }
+ } else {
+ alert("Could not get your location... sorry!");
+ Ext.getCmp('inputCity').setValue('');
+ }
+ });
+ });
+ }
}
});
View
@@ -62,33 +62,14 @@
"codeClass": null,
"userConfig": {
"fn": "onButtonTap",
- "implHandler": "var me = this; \n\nvar business = me.getApplication().getController('Business');\n\n//Ext.Viewport.remove(Ext.Viewport.getActiveItem(), true);\nExt.Viewport.add(business.getMainNav());\nExt.Viewport.setActiveItem(1);\n\nExt.Viewport.setMasked({ message: 'Loading...' });\n// get the location, then...\n\n/*\nme.getLocation(function (location) {\n\n// then use Yelp to get the businesses\n\nme.getBusinesses(location, function (store) {\n\n // then bind data to list and show it\n\n me.getDataList().setStore(store);\n Ext.Viewport.setMasked(false);\n});\n});\n\n*/\n\nCityBarsPlus.Init.city = Ext.getCmp('inputCity').getValue();\nCityBarsPlus.Init.term = Ext.getCmp('inputCategory').getValue();\n\n//Ext.getCmp('yelpToolbar').setTitle('Please wait...');\n\nvar store = Ext.data.StoreManager.lookup('BusinessStore');\n\nif(!Ext.getCmp('dataList').getStore()){\nExt.getCmp('dataList').setStore(store);\n} else {\nExt.getCmp('dataList').getStore().removeAll();\n}\n\n//re-do removeAll later\n\n\nExt.getCmp('dataList').getStore().load({\nparams:{\n ywsid:CityBarsPlus.Init.apiKey,\n term:CityBarsPlus.Init.term,\n location:CityBarsPlus.Init.city\n}\n});\n\nExt.Viewport.setMasked(false);\n\n/* \nif (YelpTouch.Init.city && YelpTouch.Init.term) { \nthis.setActiveItem(1);}\n*/",
+ "implHandler": "var me = this;\nvar business = me.getApplication().getController('Business');\n\nExt.Viewport.add(business.getMainNav());\nExt.Viewport.setActiveItem(1);\n\nExt.Viewport.setMasked({ message: 'Loading...' });\n// get the location, then...\n\nCityBarsPlus.Init.city = Ext.getCmp('inputCity').getValue();\nCityBarsPlus.Init.term = Ext.getCmp('inputCategory').getValue();\n\n//Ext.getCmp('yelpToolbar').setTitle('Please wait...');\n\nvar store = Ext.data.StoreManager.lookup('BusinessStore');\n\nif(!Ext.getCmp('dataList').getStore()){\nExt.getCmp('dataList').setStore(store);\n} else {\nExt.getCmp('dataList').getStore().removeAll();\n}\n\n//re-do removeAll later\n\nExt.getCmp('dataList').getStore().load({\nparams:{\n ywsid:CityBarsPlus.Init.apiKey,\n term:CityBarsPlus.Init.term,\n location:CityBarsPlus.Init.city\n}\n});\n\nExt.Viewport.setMasked(false);",
"name": "tap",
"designer|targetType": "Ext.Button",
"designer|controlQuery": "#searchButton",
"designer|userClassName": "onButtonTap"
},
"customConfigs": [],
"expanded": true
- },
- {
- "id": "ExtBox1-ext-gen10568",
- "type": "controlleraction",
- "reference": {
- "name": "listeners",
- "type": "array"
- },
- "codeClass": null,
- "userConfig": {
- "fn": "onComponentInitialize",
- "implHandler": "if(navigator.geolocation){\n \n Ext.getCmp('inputCity').setValue('Loading...');\n \n navigator.geolocation.getCurrentPosition(function(pos) {\n var lat = pos.coords.latitude;\n var long = pos.coords.longitude;\n var geocoder = new google.maps.Geocoder();\n var latlng = new google.maps.LatLng(lat, long);\n var city = '';\n var region = '';\n \n geocoder.geocode({'latLng': latlng}, function(results, status) {\n if (status == google.maps.GeocoderStatus.OK) {\n console.log(results);\n if(results.length > 0) {\n city = results[0].address_components[2].short_name;\n region = results[0].address_components[4].short_name;\n console.log(city, region);\n Ext.getCmp('inputCity').setValue(city+', '+region);\n }\n } else {\n alert(\"Could not get your location... sorry!\");\n Ext.getCmp('inputCity').setValue('');\n }\n });\n });\n}",
- "name": "initialize",
- "designer|targetType": "Ext.Component",
- "designer|controlQuery": "#inputCity",
- "designer|userClassName": "onComponentInitialize"
- },
- "customConfigs": [],
- "expanded": true
}
]
}
View
@@ -103,6 +103,64 @@
},
"customConfigs": [],
"expanded": true
+ },
+ {
+ "id": "ExtBox1-ext-gen3715",
+ "type": "toolbar",
+ "reference": {
+ "name": "items",
+ "type": "array"
+ },
+ "codeClass": null,
+ "userConfig": {
+ "docked": "top",
+ "ui": "light",
+ "title": "City Bars",
+ "designer|userClassName": "MyToolbar",
+ "container|pack": "end"
+ },
+ "customConfigs": [],
+ "expanded": true,
+ "cn": [
+ {
+ "id": "ExtBox1-ext-gen3960",
+ "type": "button",
+ "reference": {
+ "name": "items",
+ "type": "array"
+ },
+ "codeClass": null,
+ "userConfig": {
+ "id": "geoLocate",
+ "itemId": "mybutton4",
+ "iconCls": "locate",
+ "iconMask": true,
+ "text": "",
+ "designer|userClassName": "MyButton4"
+ },
+ "customConfigs": [],
+ "expanded": true,
+ "cn": [
+ {
+ "id": "ExtBox1-ext-gen5786",
+ "type": "basiceventbinding",
+ "reference": {
+ "name": "listeners",
+ "type": "array"
+ },
+ "codeClass": null,
+ "userConfig": {
+ "fn": "onGeoLocateTap",
+ "implHandler": "if(navigator.geolocation){\n\n Ext.getCmp('inputCity').setValue('Loading...');\n\n navigator.geolocation.getCurrentPosition(function(pos) {\n var lat = pos.coords.latitude;\n var long = pos.coords.longitude;\n var geocoder = new google.maps.Geocoder();\n var latlng = new google.maps.LatLng(lat, long);\n var city = '';\n var region = '';\n\n geocoder.geocode({'latLng': latlng}, function(results, status) {\n if (status == google.maps.GeocoderStatus.OK) {\n console.log(results);\n if(results.length > 0) {\n city = results[0].address_components[2].short_name;\n region = results[0].address_components[4].short_name;\n console.log(city, region);\n Ext.getCmp('inputCity').setValue(city+', '+region);\n }\n } else {\n alert(\"Could not get your location... sorry!\");\n Ext.getCmp('inputCity').setValue('');\n }\n });\n});\n}",
+ "name": "tap",
+ "designer|userClassName": "onGeoLocateTap"
+ },
+ "customConfigs": [],
+ "expanded": true
+ }
+ ]
+ }
+ ]
}
]
}

0 comments on commit 5fb8c4c

Please sign in to comment.