Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXTREME 13.1 Demos/DXTravel/DXTravel.Tablet/
Upload File :
Current File : C:/Users/Public/Documents/DXTREME 13.1 Demos/DXTravel/DXTravel.Tablet/App.js

!function() {

    var TabletTripViewModel = DXTravel.BaseTripViewModel.inherit({

        ctor: function(trip) {
            this.callBase(trip);

            this.selectedSection = "summary";

            this.summaryAction = this._createAction("Trip_Summary");
            this.travelersAction = this._createAction("Trip_Travelers");
            this.addTravelersAction = this._createAction("Trip_AddTravelers");
            this.flightsAction = this._createAction("Trip_Flights");
            this.scheduleAction = this._createAction("Trip_Schedule");
            this.attractionsAction = this._createAction("Attractions_List");

            this.hasPendingAppointments = $.grep(trip.appointments || [ ], function(a) { return a.pending }).length > 0;
        },


        addFacebookTravelerAction: function(friendUid) {
            return this._createAction("Trip_AddFacebookTraveler", { uid: friendUid });
        },

        attractionAction: function(attractionIndex) {            
            return this._createAction("Attraction", { id: attractionIndex });
            
        },

        _createAction: function(view, extraParams) {
            return $.extend(
                {
                    view: view,
                    tripId: this.id
                },
                extraParams
            );
        },

        _flightToFlightModel: function(flight) {
            return $.extend({}, flight, {
                fullDateString: Globalize.format(flight.date, "ddd, MMM dd, yyyy h:mm tt")
            });
        },

        _appointmentToAppointmentsModel: function(appointment) {
            return $.extend({}, appointment, {
                fullDateString: Globalize.format(appointment.date, "dddd | h:mm tt")
            });
        },
    });

    var tripModelById = function(id, callback) {
        return DXTravel.tripById(id, function(trip) {
            callback(new DXTravel.TabletTripViewModel(trip));
        });
    };


    $(function() {
        DevExpress.devices.current("iPad");

        var app = DXTravel.app = new DevExpress.framework.html.HtmlApplication({
            namespace: DXTravel,
            defaultLayout: DXTravel.config.defaultLayout,
            navigation: DXTravel.config.navigation,
        });
        $(".dx-viewport").removeClass("dx-theme-ios-typography");

        app.router.register("Trip/:tripId/Facebook/:uid", { view: "Trip_AddFacebookTraveler" });
        app.router.register("Trip/:tripId/:view", { view: "Trip_Summary" });
        app.router.register("Trip/:tripId/:view/:id", { view: "Attraction" });
        app.router.register(":view", { view: "Index" }); // Catch-all route

        app.navigate();
        
    });

    $.extend(DXTravel, {
        TabletTripViewModel: TabletTripViewModel,
        tripModelById: tripModelById,        

        // TODO use uri when UI team delivers it
        back: function() {
            DXTravel.app.navigate('_back')
        },

        selectedTab: ko.observable(0)
    });
}();