], function (_, Backbone, $, BookModel) { 'use strict'; var $$ = Framework7.$; var Utils = require('common'); var userId = Utils.userId(); var hotelId = Arg("hotelid"); var price = Arg("price"); var roomtype = Arg("roomtype"); var paySuccessTemplate = require('../hbs/paysuccess.hbs'); var BookView = Backbone.View.extend({ el: ".page-content", initialize: function (option) { this.render(); this.model = new BookModel(); this.listenTo(this.model, "sync", this.renderBookingSuccess); var createBookHandler = _.bind(this.createBook, this); setTimeout(createBookHandler, 3000); }, render: function () { this.$el.html("<h2>Paying ...</h2>") }, renderBookingSuccess: function (result) { console.log(result.toJSON()); var $html = $(paySuccessTemplate(result.toJSON())); var navigationToHotelHandler = _.bind(this.navigationToHotel, this); $html.find("#navigate-btn").click(navigationToHotelHandler); this.$el.html($html); }, createBook: function () { this.model.save({ userId: userId, hotelId: hotelId, price: price, roomType: roomtype }); }, navigationToHotel: function () { var that = this; if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { var pos = { lat: position.coords.latitude, lng: position.coords.longitude }; that.currentPosition = pos; that.trigger("event_get_position_finish"); var from = pos.lat + "," + pos.lng; var to = that.model.get("hotel").latitude + "," + that.model.get("hotel").longitude; window.location.href = "https://maps.google.com/?saddr=" + from + "&daddr=" + to + "&zoom=20&views=transit"; }, function () { console.log("Error: The Geolocation service failed."); return null; }); } else { // Browser doesn't support Geolocation console.log("Error: Your browser doesn\'t support geolocation."); return null; } } }); return BookView; });
'use strict'; import 'framework7/dist/js/framework7.js'; import 'framework7/dist/css/framework7.ios.css'; import 'framework7/dist/css/framework7.ios.colors.css'; import 'font-awesome/css/font-awesome.css'; import '../../less/travaler.less'; var Utils = require('common'); var userId = Utils.userId(); $$(".link").on('click', function () { window.location.href = $$(this).attr("href"); }); var $$ = Framework7.$; $$(document).on('pageInit', function (e) { }); var myApp = null; if (userId) { myApp = new Framework7(); }