Skip to content

Instantly share code, notes, and snippets.

@aguimaraes
Last active December 11, 2015 03:38
Show Gist options
  • Save aguimaraes/4538675 to your computer and use it in GitHub Desktop.
Save aguimaraes/4538675 to your computer and use it in GitHub Desktop.
Ext.define('LG.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
pag: 'pag',
categories: 'categories',
//companylist: 'companylist',
//search: 'search',
},
control: {
'pag list': {
itemtap: 'showPost'
},
'#searchBtn': {
tap: 'searchTap'
},
'#categoryBtn': {
tap: 'categoryTap'
},
'categories': {
itemtap: 'showCompany'
}/*,
'companylist list': {
itemtap: 'showCompanyDetails'
},
'search list': {
itemtap: 'showCompanySearch'
}*/
}
},
/* Visar detaljsida för event */
showPost: function(list, index, element, record) {
this.getPag().push({
xtype: 'panel',
title: 'Event',
html: '<strong><a href="http://www.facebook.com/sharer.php?s=100&p[url]=http://www.lillagula.se&p[images][0]=http://www.lillagula.se/Content/images/lilla_gula_top.png&p[title]=' + record.get('EventName') + '&p[summary]=' + record.get('Description') + '">Dela event p&aring; Facebook</a></strong><br><br><strong>' + record.get('EventName') + '</strong><br><br><strong>B&ouml;rjar:</strong> ' + record.get('StartDate') + '<br><br><strong>Slutar:</strong> ' + record.get('EndDate') + '<br><br><strong>Arrang&ouml;r:</strong> ' + record.get('ArrangedBy') + '<br><br><strong>Var:</strong> ' + record.get('Where') + '<br><br>' + record.get('Description'),
scrollable: true,
styleHtmlContent: true
});
},
/* Öppnar search.js */
searchTap: function(){
//var value = searchqueryfield.getValue();
//console.log(value);
Ext.Viewport.setActiveItem(Ext.create('LG.view.search'));
},
/* Öppnar categories.js */
categoryTap: function(){
Ext.Viewport.setActiveItem(Ext.create('LG.view.categories'));
},
/* */
showCompany: function(list, index, element, record) {
var YrkesId = record.get('YrkesId');
console.log('id:' + YrkesId);
//Ext.Viewport.setActiveItem(Ext.create('LG.view.companylist'));
/*var proxy = Ext.create('Ext.data.AjaxProxy', {
timeout: 10000,
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries',
},
afterRequest: function(request, success) {
}
});
proxy.url = 'http://api.lillagula.se/API.mvc/GetLillaGulaKunderByYrkeId/' + YrkesId + '?apikey=f87c21f3-3c14-4661-9c9a-add5d7c7988c';
console.log(proxy);
list.stores.Location.setProxy(proxy);*/
var companylistView = Ext.create('LG.view.companylist');
var store = companyListView().getStore();
if (store) {
var proxy = store.getProxy();
console.log(proxy);
if (proxy) {
proxy.setUrl('http://api.lillagula.se/API.mvc/GetLillaGulaKunderByYrkeId/' + YrkesId + '?apikey=f87c21f3-3c14-4661-9c9a-add5d7c7988');
store.load();
}
}
});
}/*,
showCompanyDetails: function(list, index, element, record) {
this.getCompanylist().push({
xtype: 'panel',
title: record.get('KNamn'),
html: '<p style="border:solid 1px red;"><a href="tel:' + record.get('PhoneNumber') + '">' + record.get('KNamn') + '<br>' + record.get('PhoneNumber') + '</a><p><p style="border:solid 1px green;"><a href="rmaps:ll=63.288303,18.70905">' + record.get('KAdress') + '<br>' + record.get('KPostNr') + ' ' + record.get('KOrt') + '</a><p>',
scrollable: true,
styleHtmlContent: true
});
},
showCompanySearch: function(list, index, element, record) {
this.getSearch().push({
xtype: 'panel',
title: record.get('KNamn'),
html: '<p style="border:solid 1px red;"><a href="tel:' + record.get('PhoneNumber') + '">' + record.get('KNamn') + '<br>' + record.get('PhoneNumber') + '</a><p><p style="border:solid 1px green;"><a href="rmaps:ll=63.288303,18.70905">' + record.get('KAdress') + '<br>' + record.get('KPostNr') + ' ' + record.get('KOrt') + '</a><p>',
scrollable: true,
styleHtmlContent: true
})
}*/
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment