Skip to content

Instantly share code, notes, and snippets.

@rmoura-92
Created July 9, 2013 16:01
Show Gist options
  • Save rmoura-92/5958600 to your computer and use it in GitHub Desktop.
Save rmoura-92/5958600 to your computer and use it in GitHub Desktop.
define([
'jquery',
'underscore',
'backbone',
'router',
'collections/voos',
'collections/hoteis',
'collections/ferias',
'collections/escapadinhas',
'views/shared/common',
'views/shared/navigation',
'views/home',
'views/voos',
'views/hoteis',
'views/ferias',
'views/escapadinhas'
], function(
$, _, Backbone, Router,
VoosCollection, HoteisCollection, FeriasCollection, EscapadinhasCollection,
CommonView, NavigationView, HomeView, VooView, HotelView, FeriasView, EscapadinhaView
) {
var initialize = function() {
_.mixin({
price: function(price) {
var formatedprice = parseInt(price.replace(',','.'));
return formatedprice.toFixed(0);
return price;
},
priceFlights: function(price) {
return price.toFixed(0);
},
myescape: function(string) {
return string;
},
imgCompanhiaAerea: function(string) {
return string.replace('|*SIZE_OF_THUMB*|','90X26');
},
horaUnix: function(timestamp) {
timestamp = timestamp.match(/([0-9]+)/);
var a = new Date(parseInt(timestamp[0]));
var hour = a.getHours();
var min = a.getMinutes();
var time = hour+':'+min;
return time;
},
dataUnix: function(timestamp) {
timestamp = timestamp.match(/([0-9]+)/);
var a = new Date(parseInt(timestamp[0]));
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var month = months[a.getMonth()];
var date = a.getDate();
var time = date+' '+month;
return time;
},
weekdayUnix: function(timestamp) {
timestamp = timestamp.match(/([0-9]+)/);
var a = new Date(parseInt(timestamp[0]));
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var weekdays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'];
var month = months[a.getMonth()];
var day = weekdays[a.getDay()];
var time = month+' '+day;
return time;
},
dayUnix: function(timestamp) {
timestamp = timestamp.match(/([0-9]+)/);
var a = new Date(parseInt(timestamp[0]));
var date = a.getDate();
return date;
}
}); // underscore mixins
// initialize collections
Application.Collections = {
Voos: new VoosCollection(),
Hoteis: new HoteisCollection(),
Ferias: new FeriasCollection(),
Escapadinhas: new EscapadinhasCollection()
};
// initialize views
Application.Views = {
//Section: new Section(),
//Mais: new Mais(),
Common: new CommonView(),
Navigation: new NavigationView(),
Home: new HomeView(),
//Voos: new VooView({model:Application.Collections.Voos}),
//Hoteis: new HotelView({model:Application.Collections.Hoteis}),
//Ferias: new FeriasView({model:Application.Collections.Ferias}),
//Escapadinhas: new EscapadinhaView({model:Application.Collections.Escapadinhas}),
};
Application.Router = new Router();
Backbone.emulateJSON = true;
//Backbone.emulateHTTP = true;
Backbone.history.start();
}
return {
initialize:initialize,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment