Click here to Skip to main content
15,891,184 members
Articles / Web Development / HTML5

Property Finder - a Cross-Platform HTML5 Mobile App

Rate me:
Please Sign up or sign in to vote.
5.00/5 (45 votes)
3 Sep 2012CPOL27 min read 134.3K   2.4K   94  
This article describes the development of a cross-platform HTML5 application for Windows Phone and iPhone.
/// <reference path="..//intellisense.js" />

/*global ko, application, ViewModel*/

ViewModel.PropertyViewModel = function () {
  /// <summary>
  /// Represents a single property listing
  /// </summary>
  var titleParts;

  // ----- framework fields
  this.template = "propertyView";
  this.factoryName = "PropertyViewModel";

  // ----- public fields
  this.price = undefined;
  this.bedrooms = undefined;
  this.bathrooms = undefined;
  this.propertyType = undefined;
  this.thumbnailUrl = undefined;
  this.guid = undefined;
  this.summary = undefined;
  this.title = undefined;
  this.isFavourite = ko.observable(false);

  // ----- public functions

  this.initialize = function (property) {
    /// <summary>
    /// Initializes this view model
    /// </summary>

    // copy and format the properties required by the UI
    this.price = property.price;
    this.bedrooms = property.bedrooms;
    this.bathrooms = property.bathrooms;
    this.propertyType = property.propertyType;
    this.thumbnailUrl = property.thumbnailUrl;
    this.guid = property.guid;
    this.summary = property.summary;

    // simplify the title a bit
    if (property.title) {
      titleParts = property.title.split(",");
      if (titleParts.length >= 2) {
        this.title = titleParts[0] + ", " + titleParts[1];
      }
    }
  };

  this.select = function () {
    /// <summary>
    /// Selects this property, navigating to the property view
    /// </summary>
    application.navigateTo(this);
  };

};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Scott Logic
United Kingdom United Kingdom
I am CTO at ShinobiControls, a team of iOS developers who are carefully crafting iOS charts, grids and controls for making your applications awesome.

I am a Technical Architect for Visiblox which have developed the world's fastest WPF / Silverlight and WP7 charts.

I am also a Technical Evangelist at Scott Logic, a provider of bespoke financial software and consultancy for the retail and investment banking, stockbroking, asset management and hedge fund communities.

Visit my blog - Colin Eberhardt's Adventures in .NET.

Follow me on Twitter - @ColinEberhardt

-

Comments and Discussions