<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Scott Logic</title>
	<atom:link href="http://www.scottlogic.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scottlogic.co.uk</link>
	<description>Financial Software Development</description>
	<lastBuildDate>Sat, 18 May 2013 01:09:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>HTML5 – It Just Got Real – Slides</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2013/05/html5-it-just-got-real-slides-and-photos/</link>
		<comments>http://www.scottlogic.co.uk/blog/colin/2013/05/html5-it-just-got-real-slides-and-photos/#comments</comments>
		<pubDate>Thu, 16 May 2013 14:54:15 +0000</pubDate>
		<dc:creator>Colin Eberhardt</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=2417</guid>
		<description><![CDATA[TweetA couple of days ago we hosted a one-day conference, HTML5 &#8211; It Just Got Real, at the Royal Society buildings in London. I&#8217;m happy to say that the event was a great success, and that the Q&#38;A session that followed our talks was very lively! As promised, we have made all of our presentations [...]]]></description>
				<content:encoded><![CDATA[<div id="tweetbutton2417" class="tw_button" style=""><a href="http://twitter.com/share?url=http%3A%2F%2Fwww.scottlogic.co.uk%2Fblog%2Fcolin%2F2013%2F05%2Fhtml5-it-just-got-real-slides-and-photos%2F&amp;text=HTML5%20%26%238211%3B%20It%20Just%20Got%20Real%20%26%238211%3B%20Slides&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fwww.scottlogic.co.uk%2Fblog%2Fcolin%2F2013%2F05%2Fhtml5-it-just-got-real-slides-and-photos%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://www.scottlogic.co.uk/blog/colin/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><p>A couple of days ago we hosted a one-day conference, <a href="http://html5-it-just-got-real.com/">HTML5 &#8211; It Just Got Real</a>, at the Royal Society buildings in London. I&#8217;m happy to say that the event was a great success, and that the Q&#038;A session that followed our talks was very lively!</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/03/html5-just-got-real.png" alt="html5-just-got-real" width="495" height="269" class="aligncenter size-full wp-image-2376" /></p>
<p>As promised, we have made all of our presentations available online. The first three presentations have all been created using HTML5, whilst the last uses PowerPoint.</p>
<h2>Attention!</h2>
<p>These presentation were designed to work with the Chrome browser, and are navigated using the left and right arrow keys. They are not intended to be a demonstration of cross-browser HTML5, on the contrary! They illustrate the fact that HTML5 has not solved the need to consider specific browsers and browser-versions when writing code.</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/05/keys.png" alt="keys" width="600" height="213" class="aligncenter size-full wp-image-2436" /></p>
<h2>HTML5 Revolution</h2>
<p> &#8211; by <a href="http://www.scottlogic.co.uk/blog/colin/">Colin Eberhardt</a>, you can <a href="http://colineberhardt.github.io/html5-revolution/">view the presentation in your browser</a>, and view the <a href="https://github.com/ColinEberhardt/html5-revolution">sourcecode on github</a>.</p>
<p><a href="http://colineberhardt.github.io/html5-revolution/"><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/05/html5-revolution.png" alt="html5-it-just-got-real" width="600" height="384" class="aligncenter size-full wp-image-2419" /></a></p>
<p><br/><br/><br/></p>
<h2>HTML5 &#8211; It Just Got Real</h2>
<p> &#8211; by <a href="http://www.scottlogic.co.uk/blog/chris/">Chris Price</a>, you can <a href="http://chrisprice.github.io/html5-it-just-got-real/">view the presentation in your browser</a>, and view the <a href="https://github.com/chrisprice/html5-it-just-got-real">sourcecode on github</a>.</p>
<p><a href="http://chrisprice.github.io/html5-it-just-got-real/"><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/05/html5-it-just-got-real.png" alt="html5-it-just-got-real" width="600" height="384" class="aligncenter size-full wp-image-2419" /></a></p>
<p><br/><br/><br/></p>
<h2>Designing the Future</h2>
<p> &#8211; by <a href="http://www.scottlogic.co.uk/blog/graham/">Graham Odds</a>, you can <a href="http://godds.github.io/designing-the-future/">view the presentation in your browser</a>, and view the <a href="https://github.com/godds/designing-the-future">sourcecode on github</a>.</p>
<p><a href="http://godds.github.io/designing-the-future/"><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/05/designing-the-future.png" alt="designing-the-future" width="600" height="384" class="aligncenter size-full wp-image-2421" /></a></p>
<p><br/><br/><br/></p>
<h2>Cross-Platform Mobile Development</h2>
<p> &#8211; by <a href="http://www.scottlogic.co.uk/blog/colin/">Colin Eberhardt</a>, this presentation is <a href="http://www.slideshare.net/colineberhardt/cross-platform-mobile-development-you-tube-videos">hosted on slideshare</a>, with videos made available via YouTube.</p>
<p><a href="http://www.slideshare.net/colineberhardt/cross-platform-mobile-development-you-tube-videos"><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/05/cross-platform.jpg" alt="cross-platform" width="600" height="384" class="aligncenter size-full wp-image-2427" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/colin/2013/05/html5-it-just-got-real-slides-and-photos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Scott Logic judges Newcastle University poster competition</title>
		<link>http://www.scottlogic.co.uk/2013/05/scott-logic-judges-newcastle-university-poster-competition/</link>
		<comments>http://www.scottlogic.co.uk/2013/05/scott-logic-judges-newcastle-university-poster-competition/#comments</comments>
		<pubDate>Thu, 09 May 2013 15:01:15 +0000</pubDate>
		<dc:creator>Natalie Jolly</dc:creator>
				<category><![CDATA[Awards]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Latest News Widget]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=185381</guid>
		<description><![CDATA[For the second year running Scott Logic sponsored and judged the final year Computer and Information Science poster competition at Newcastle University. ]]></description>
				<content:encoded><![CDATA[<p>For the second year running Scott Logic sponsored and judged the final year Computer and Information Science poster competition at Newcastle University. Colleagues from marketing and technical teams were dispatched to judge 6 entrants from each discipline. Two worthy winners (Edward Jenkins and Daniel O’Keeffe) were chosen and both received a cash prize alongside a Scott Logic goodie bag!</p>
<p>Natalie Jolly, Communications Manager, said:</p>
<p>“The quality of submission was particularly high and made for a very difficult decision. Everyone participating did extraordinarily well and the principles and disciplines behind each entry was fascinating to listen to. We wish every student involved all the best with their continued studies.”</p>
<p>Whilst there the team also took the opportunity to talk to students about career opportunities at Scott Logic as well as demoing the latest version of the <a href="http://shinobicontrols.com">ShinobiControls</a> app ‘ShinobiPlay’.</p>
<p><a href="http://www.scottlogic.co.uk/wp-content/uploads/2013/05/ISWinner.jpg"><img class="alignnone size-medium wp-image-185380" alt="ISWinner" src="http://www.scottlogic.co.uk/wp-content/uploads/2013/05/ISWinner-225x300.jpg" width="225" height="300" /></a><a href="http://www.scottlogic.co.uk/wp-content/uploads/2013/05/CSWinner.jpg"><img class="alignnone size-medium wp-image-185379" alt="CSWinner" src="http://www.scottlogic.co.uk/wp-content/uploads/2013/05/CSWinner-225x300.jpg" width="225" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2013/05/scott-logic-judges-newcastle-university-poster-competition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Senior Developer</title>
		<link>http://www.scottlogic.co.uk/2013/05/senior-developer/</link>
		<comments>http://www.scottlogic.co.uk/2013/05/senior-developer/#comments</comments>
		<pubDate>Tue, 07 May 2013 15:39:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Vacancies]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=185235</guid>
		<description><![CDATA[C++, Java or C# developer to cross-train to Objective C
Competitive salary + bonus + benefits; Bristol]]></description>
				<content:encoded><![CDATA[<p>Scott Logic are currently looking for someone with a passion for software development and either a strong background in OO development looking to gain Objective C exposure, or for a developer with solid iOS mobile experience.</p>
<p>The position is based in the ShinobiControls team <a href="http://www.shinobicontrols.com/">(shinobicontrols.com)</a>, a product team based in our central Bristol offices, within easy walking distance of the railway station. The team is building a suite of fully customizable controls including Grids and Charts, in order to enable third-party application developers to build apps using innovative, enhanced UI controls. With over four hundred clients, they are now looking to augment the team with a senior developer who has at least five years of OO development experience or experience of ObjectiveC.</p>
<p>Essential:</p>
<ul>
<li>Language expert (C++/ Java / C#)</li>
<li>OO design skills, including design patterns</li>
<li>Exposure to the full software development lifecycle</li>
<li>Exposure to Agile/Scrum methodology</li>
<li>Team player and self-motivated individual</li>
</ul>
<p>Desirable:</p>
<ul>
<li>Objective C</li>
<li>Mobile experience</li>
<li>Product development experience</li>
</ul>
<p>ScottLogic offer a highly competitive salary and benefits package, including:</p>
<ul>
<li>Performance and profit-related bonus scheme</li>
<li>25 days holiday per year, growing with length of service</li>
<li>Life assurance</li>
<li>Contributory pension scheme</li>
</ul>
<p>In addition, we can offer the following:</p>
<ul>
<li>Office location in central Bristol</li>
<li>A wide variety of technologies and platforms</li>
<li>The opportunity to work with pro-active, smart developers</li>
</ul>
<p>A CV and covering letter specifying your areas of expertise and interest, along with your salary expectations, should be sent to <a ref="mailto:applications@scottlogic.co.uk">applications@scottlogic.co.uk</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2013/05/senior-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>User Experience Designer</title>
		<link>http://www.scottlogic.co.uk/2013/04/user-experience-designer/</link>
		<comments>http://www.scottlogic.co.uk/2013/04/user-experience-designer/#comments</comments>
		<pubDate>Thu, 18 Apr 2013 14:15:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Vacancies]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=184365</guid>
		<description><![CDATA[Competitive salary + bonus + benefits; Edinburgh]]></description>
				<content:encoded><![CDATA[<p><strong>User Experience Designer position available in our Edinburgh office</strong></p>
<p>Scott Logic is a software consultancy that provides the very best in bespoke software across web, mobile and desktop.  Our consultancy work is complemented by two product brands, ShinobiControls (www.shinobicontrols.com) and Visiblox (www.visiblox.com).  The ever-growing significance of user experience design in both our consultancy and product work means we are looking to grow our UX Practice.</p>
<p>While the job title hopefully already tells you a lot, here are more specifics about what we are looking for and why you should want to join us:<br />
You share our core beliefs about user experience design, namely that:</p>
<ul>
<li>Research and exploration form the foundations of our designs, since problems can only be solved effectively once they are understood.</li>
<li>Our collaborative approach focuses on delivering the end product with minimal waste, and empowers stakeholders, users and developers alike.</li>
<li>Short cycles leading to analysis and feedback improve designs and maintain project focus.</li>
<li>We create effective, beautiful interfaces because we recognise the importance of every design decision, not just those relating to aesthetics.</li>
</ul>
<p>You want to design functionally rich applications across web, mobile and desktop, rather than just another website.</p>
<p>You want to be part of a team, producing high quality, innovative end products that effectively marry user needs and business goals.</p>
<p>You live, sleep and breathe user-centred design, and don’t mind extolling about both the theory and practicalities of it to anyone who will listen.</p>
<p>Coding doesn’t scare or alienate you, and you’re as happy to learn about it as you are educating developers about design.</p>
<p>As if that wasn’t enough, we also offer a great remuneration and benefits package, including:</p>
<ul>
<li>Performance and profit related bonus scheme</li>
<li>25 days holiday per year, growing with length of service up to 30 days</li>
<li>Life assurance</li>
<li>Pension Scheme</li>
<li>Childcare vouchers</li>
<li>Cycle to Work Scheme</li>
<li>Referral programme – payable to anyone who refers a successful candidate</li>
</ul>
<p>To apply, please email your CV, portfolio and a brief cover note to <a ref="mailto:applications@scottlogic.co.uk">applications@scottlogic.co.uk</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2013/04/user-experience-designer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enhanced Windows Phone 8 Map Gestures</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2013/04/enhanced-windows-phone-8-map-gestures/</link>
		<comments>http://www.scottlogic.co.uk/blog/colin/2013/04/enhanced-windows-phone-8-map-gestures/#comments</comments>
		<pubDate>Mon, 15 Apr 2013 09:34:19 +0000</pubDate>
		<dc:creator>Colin Eberhardt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[codeproject]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=2405</guid>
		<description><![CDATA[TweetThis blog post describes the addition of a two-finger rotation and three-finger pitch gesture to the Windows Phone 8 Map control. You can see these gesture in action below: The WP8 release replaced the image-tile based Bing maps with a fully vector-rendered map from Nokia. Being vector-based, this map can be panned, zoomed, rotated and [...]]]></description>
				<content:encoded><![CDATA[<div id="tweetbutton2405" class="tw_button" style=""><a href="http://twitter.com/share?url=http%3A%2F%2Fwww.scottlogic.co.uk%2Fblog%2Fcolin%2F2013%2F04%2Fenhanced-windows-phone-8-map-gestures%2F&amp;text=Enhanced%20Windows%20Phone%208%20Map%20Gestures&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fwww.scottlogic.co.uk%2Fblog%2Fcolin%2F2013%2F04%2Fenhanced-windows-phone-8-map-gestures%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://www.scottlogic.co.uk/blog/colin/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><p><em>This blog post describes the addition of a two-finger rotation and three-finger pitch gesture to the Windows Phone 8 Map control.</em></p>
<p>You can see these gesture in action below:</p>
<p><iframe width="640" height="480" src="http://www.youtube.com/embed/XunJ9sTXfH0" frameborder="0" allowfullscreen></iframe></p>
<p>The WP8 release replaced the image-tile based Bing maps with a fully vector-rendered map from Nokia. Being vector-based, this map can be panned, zoomed, rotated and rendered at an angle (i.e. pitched). However, much of this new functionality is not offered to the end user!</p>
<p>The WP8 supports the same gestures that the Bing WP7 map did, i.e. a single-fingered pan gesture and two-fingered pinch to zoom. What about rotation and pitch? Why not allow the user to modify these via gestures?</p>
<p>The key here is to add some new gestures that complement the existing one. I opted for the following:</p>
<ul>
<li><strong>Two-finger rotate</strong> – When the user places two fingers on the map this is currently used to zoom the display via a ‘spreading’ motion. However, if the user instead rotates the two touch points around the centre, the map should be rotated.</li>
<li><strong>Three-finger pitch</strong> – When the user places three fingers on the map, if they drag up or down, the map should adjust its pitch accordingly.</li>
</ul>
<p>These gestures are enabled simply by creating them with a reference to the map:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">new</span> MapRotationGesture<span style="color: #008000;">&#40;</span>map<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">new</span> MapPitchGesture<span style="color: #008000;">&#40;</span>map<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>If you don’t care how this all works, just <a href="https://github.com/ColinEberhardt/WP8-MapGestures">head over to github</a> and grab the code. If you want to find out more, read on …</p>
<h2>Suppressing The Existing Gestures</h2>
<p>In order to add these new gestures to the map, there needs to be a mechanism in place to suppress the existing gestures so that they do not interfere.</p>
<p>The technique I used is similar to a technique I demonstrated previously for <a href="http://www.scottlogic.co.uk/blog/colin/2011/11/suppressing-zoom-and-scroll-interactions-in-the-windows-phone-7-browser-control/" title="Suppressing Zoom and Scroll interactions in the Windows Phone 7 WebBrowser Control">suppressing pinch and scroll in the Windows Phone Browser control</a>. Both the Map and <code>WebBrowser </code>controls have a visual tree containing a number of user interface elements. The inner structure of the <code>Map</code> is shown below:</p>
<pre>
Microsoft.Phone.Maps.Controls.Map
  System.Windows.Controls.Border
    System.Windows.Controls.Border
      Microsoft.Phone.Maps.Controls.MapPresentationContainer
        MS.Internal.ExternalInputContainer
          System.Windows.Controls.Grid
            MS.Internal.TileHostV2
            Microsoft.Phone.Maps.Controls.RootMapLayer
</pre>
<p>The technique for suppressing interactions is quite simple, just add a <code>ManipulationDelta</code> event handler to each one of these elements, setting the event to handled. The complete code is show below:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// A base class for map gestures, which allows them to suppress the built-in map gestures.</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> MapGestureBase
<span style="color: #008000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">/// Gets or sets whether to suppress the existing gestures/</span>
  <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> SuppressMapGestures <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">protected</span> Map Map <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> MapGestureBase<span style="color: #008000;">&#40;</span>Map map<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    Map <span style="color: #008000;">=</span> map<span style="color: #008000;">;</span>
    map<span style="color: #008000;">.</span><span style="color: #0000FF;">Loaded</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">&#40;</span>s,e<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> CrawlTree<span style="color: #008000;">&#40;</span>Map<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> CrawlTree<span style="color: #008000;">&#40;</span>FrameworkElement el<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    el<span style="color: #008000;">.</span><span style="color: #0000FF;">ManipulationDelta</span> <span style="color: #008000;">+=</span> MapElement_ManipulationDelta<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> c <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> c <span style="color: #008000;">&lt;</span> VisualTreeHelper<span style="color: #008000;">.</span><span style="color: #0000FF;">GetChildrenCount</span><span style="color: #008000;">&#40;</span>el<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> c<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
      CrawlTree<span style="color: #008000;">&#40;</span>VisualTreeHelper<span style="color: #008000;">.</span><span style="color: #0000FF;">GetChild</span><span style="color: #008000;">&#40;</span>el, c<span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">as</span> FrameworkElement<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> MapElement_ManipulationDelta<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, ManipulationDeltaEventArgs e<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>SuppressMapGestures<span style="color: #008000;">&#41;</span>
      e<span style="color: #008000;">.</span><span style="color: #0000FF;">Handled</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>If you create an instance of this class and associate it with a map you can turn gestures on and off via the <code>SuppressMapGestures </code>property:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">var</span> gestureBase <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MapGestureBase<span style="color: #008000;">&#40;</span>map<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
gestureBase<span style="color: #008000;">.</span><span style="color: #0000FF;">SuppressMapGestures</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>NOTE: Unfortunately this doesn’t solve the ‘map in a pivot’ or ‘map in a panorama’ problem that many Windows Phone developers have struggled with – the gestures that are handled are not propagated to a parent control.</p>
<h2>A Rotation Gesture</h2>
<p>The user can rotate the map by placing two fingers on the screen then rotating them around their central point. Because two fingers are also used for the pinch-to-zoom gesture, a suitable threshold needs to be introduced. I have found that disabling rotation until the user has rotated by 10 degrees feels about right.</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/04/RotationGesture.jpg" alt="RotationGesture" width="282" height="480" class="aligncenter size-full wp-image-2406" /></p>
<p>The code that implements the rotation is really quite simple, the <code>MapGestureBase </code> subclass is shown in its entirety below:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// Adds a two-finger rotation gesture to a Map control.</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> MapRotationGesture <span style="color: #008000;">:</span> MapGestureBase
<span style="color: #008000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">/// Gets or sets the minimuum rotation that the user must apply in order to initiate this gesture.</span>
  <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">double</span> MinimumRotation <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">double</span><span style="color: #008000;">?</span> _previousAngle<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> _isRotating<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> MapRotationGesture<span style="color: #008000;">&#40;</span>Map map<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span>map<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    MinimumRotation <span style="color: #008000;">=</span> <span style="color: #FF0000;">10.0</span><span style="color: #008000;">;</span>
    Touch<span style="color: #008000;">.</span><span style="color: #0000FF;">FrameReported</span> <span style="color: #008000;">+=</span> Touch_FrameReported<span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> Touch_FrameReported<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, TouchFrameEventArgs e<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">var</span> touchPoints <span style="color: #008000;">=</span> e<span style="color: #008000;">.</span><span style="color: #0000FF;">GetTouchPoints</span><span style="color: #008000;">&#40;</span>Map<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>touchPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
      <span style="color: #008080; font-style: italic;">// for the initial touch, record the angle between the fingers</span>
      <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>_previousAngle<span style="color: #008000;">.</span><span style="color: #0000FF;">HasValue</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
        _previousAngle <span style="color: #008000;">=</span> AngleBetweenPoints<span style="color: #008000;">&#40;</span>touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span>, touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">// should we rotate?</span>
      <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>_isRotating<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">double</span> angle <span style="color: #008000;">=</span> AngleBetweenPoints<span style="color: #008000;">&#40;</span>touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span>, touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">double</span> delta <span style="color: #008000;">=</span> angle <span style="color: #008000;">-</span> _previousAngle<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Value</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Abs</span><span style="color: #008000;">&#40;</span>delta<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&gt;</span> MinimumRotation<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
          _isRotating <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
          SuppressMapGestures <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">// rotate me</span>
      <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_isRotating<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">double</span> angle <span style="color: #008000;">=</span> AngleBetweenPoints<span style="color: #008000;">&#40;</span>touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span>, touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">double</span> delta <span style="color: #008000;">=</span> angle <span style="color: #008000;">-</span> _previousAngle<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Value</span><span style="color: #008000;">;</span>
        Map<span style="color: #008000;">.</span><span style="color: #0000FF;">Heading</span> <span style="color: #008000;">-=</span> delta<span style="color: #008000;">;</span>
        _previousAngle <span style="color: #008000;">=</span> angle<span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">else</span>
    <span style="color: #008000;">&#123;</span>
      _previousAngle <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
      _isRotating <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
      SuppressMapGestures <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">double</span> AngleBetweenPoints<span style="color: #008000;">&#40;</span>TouchPoint p1, TouchPoint p2<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Atan2</span><span style="color: #008000;">&#40;</span>p1<span style="color: #008000;">.</span><span style="color: #0000FF;">Position</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span> <span style="color: #008000;">-</span> p2<span style="color: #008000;">.</span><span style="color: #0000FF;">Position</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span>, p1<span style="color: #008000;">.</span><span style="color: #0000FF;">Position</span><span style="color: #008000;">.</span><span style="color: #0000FF;">X</span> <span style="color: #008000;">-</span> p2<span style="color: #008000;">.</span><span style="color: #0000FF;">Position</span><span style="color: #008000;">.</span><span style="color: #0000FF;">X</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">*</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">180</span> <span style="color: #008000;">/</span> Math<span style="color: #008000;">.</span><span style="color: #0000FF;">PI</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Touch gestures are detected via the <code>Touch.FrameReported</code> event. When two fingers are placed on the screen the initial rotation angle is recorded. When the minimum rotation is exceeded, the <code>Map.Heading</code> is updated with each ‘delta’ reported. Really simple code, but a fantastic feature for the user!</p>
<h2>A Pitch Gesture</h2>
<p>You get a real feel for the vector-nature of the maps when you set the ‘pitch’, a style of rendering that is often used on satnavs.</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/04/PitchGesture.jpg" alt="PitchGesture" width="282" height="483" class="aligncenter size-full wp-image-2407" /></p>
<p>I initially considered using a two finger pull-down gesture, which is similar to the one which Google Maps on Android uses, but found it very hard to coordinate the three gestures, zoom, rotate, pitch, which all use the same two-fingers! So instead, I opted for a three-finger pull-down gesture to increase the pitch of the map.</p>
<p>The code follows a very similar pattern to the rotate gesture:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// Adds a three-finger pitch gesture to a Map control.</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> MapPitchGesture <span style="color: #008000;">:</span> MapGestureBase
<span style="color: #008000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">/// Gets or sets the sensitivity of this gesture</span>
  <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">double</span> Sensitivity <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">double</span><span style="color: #008000;">?</span> _initialPitchYLocation<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> MapPitchGesture<span style="color: #008000;">&#40;</span>Map map<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span>map<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    Sensitivity <span style="color: #008000;">=</span> <span style="color: #FF0000;">0.5</span><span style="color: #008000;">;</span>
    Touch<span style="color: #008000;">.</span><span style="color: #0000FF;">FrameReported</span> <span style="color: #008000;">+=</span> Touch_FrameReported<span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> Touch_FrameReported<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, TouchFrameEventArgs e<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">var</span> touchPoints <span style="color: #008000;">=</span> e<span style="color: #008000;">.</span><span style="color: #0000FF;">GetTouchPoints</span><span style="color: #008000;">&#40;</span>Map<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    SuppressMapGestures <span style="color: #008000;">=</span> touchPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">3</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>touchPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>_initialPitchYLocation<span style="color: #008000;">.</span><span style="color: #0000FF;">HasValue</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
        _initialPitchYLocation <span style="color: #008000;">=</span> touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Position</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span><span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #6666cc; font-weight: bold;">double</span> delta <span style="color: #008000;">=</span> touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Position</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span> <span style="color: #008000;">-</span> _initialPitchYLocation<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Value</span><span style="color: #008000;">;</span>
      <span style="color: #6666cc; font-weight: bold;">double</span> newPitch <span style="color: #008000;">=</span> Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Max</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, Math<span style="color: #008000;">.</span><span style="color: #0000FF;">Min</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">75</span>, <span style="color: #008000;">&#40;</span>Map<span style="color: #008000;">.</span><span style="color: #0000FF;">Pitch</span> <span style="color: #008000;">+</span> delta <span style="color: #008000;">*</span> Sensitivity<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
      Map<span style="color: #008000;">.</span><span style="color: #0000FF;">Pitch</span> <span style="color: #008000;">=</span> newPitch<span style="color: #008000;">;</span>
      _initialPitchYLocation <span style="color: #008000;">=</span> touchPoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Position</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">else</span>
    <span style="color: #008000;">&#123;</span>
      _initialPitchYLocation <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>As soon as three fingers are placed on the screen, the gesture becomes active. The movement of the first finger is used to determine the delta to apply to the <code>Pitch </code>property. Again, nice and simple!</p>
<p>The sourcecode for these gesture, plus a demo app is <a href="https://github.com/ColinEberhardt/WP8-MapGestures">available via github</a>. Please let me know if you use this code in any of your apps.</p>
<p>Regards, Colin E. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/colin/2013/04/enhanced-windows-phone-8-map-gestures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Comparing KendoUI and Knockout (with a bit of jQueryMobile on the side)</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/</link>
		<comments>http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#comments</comments>
		<pubDate>Mon, 08 Apr 2013 10:43:31 +0000</pubDate>
		<dc:creator>Colin Eberhardt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[codeproject]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=2380</guid>
		<description><![CDATA[TweetThis blog post compares the same twitter search application written with both Knockout and Kendo in order to highlight the strengths and weaknesses of each framework. Introduction I&#8217;ve always been a big fan of Knockout, most likely because it reminds me of Silverlight (rest in peace). For my thoughts on how Silverlight and Knockout compare, [...]]]></description>
				<content:encoded><![CDATA[<div id="tweetbutton2380" class="tw_button" style=""><a href="http://twitter.com/share?url=http%3A%2F%2Fwww.scottlogic.co.uk%2Fblog%2Fcolin%2F2013%2F04%2Fcomparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side%2F&amp;text=Comparing%20KendoUI%20and%20Knockout%20%28with%20a%20bit%20of%20jQueryMobile%20on%20the%20side%29&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fwww.scottlogic.co.uk%2Fblog%2Fcolin%2F2013%2F04%2Fcomparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://www.scottlogic.co.uk/blog/colin/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><p>This blog post compares the same twitter search application written with both Knockout and Kendo in order to highlight the strengths and weaknesses of each framework.</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/04/knockout-vs-kendo.png" alt="knockout-vs-kendo" width="400" height="175" class="aligncenter size-full wp-image-2402" /></p>
<h2>Introduction</h2>
<p>I’ve always been a big fan of Knockout, most likely because it reminds me of Silverlight (rest in peace).</p>
<blockquote><p>For my thoughts on how Silverlight and Knockout compare, head over to codeproject where I wrote <a href="http://www.codeproject.com/Articles/365120/KnockoutJS-vs-Silverlight">quite a lengthy article on the subject</a>.</p></blockquote>
<p>More recently I have been dabbling with the use of Knockout for writing mobile applications. Because Knockout is an MVVM framework and doesn’t have any UI components of its own, I used a combination of jQuery Mobile (jQM) and Knockout. I must admit, the integration of these two frameworks <a href="http://www.scottlogic.co.uk/blog/colin/2012/10/integrating-knockout-and-jquerymobile/">wasn’t entirely painless</a>!.</p>
<p>It is the integration pain I experienced with jQM and Knockout that has resulted in my interest in KendoUI. </p>
<p>KendoUI (<a href="http://www.kendoui.com/">www.kendoui.com</a>) is a commercial JavaScript framework that includes web and mobile UI widgets together with an MVVM framework, which, on initial inspection, closely resembles Knockout. The promise of an MVVM framework and mobile widgets that play nicely together is quite appealing!</p>
<p>In order to compare Kendo with Knockout + jQM I re-implemented the twitter-search application that <a href="http://www.scottlogic.co.uk/blog/colin/2012/10/integrating-knockout-and-jquerymobile/">I blogged about a few months ago</a>. The rest of this blog post is a collection of thoughts, commentary on the differences and personal opinions.</p>
<p>The two version of the code are available on github:</p>
<ul>
<li><a href="https://github.com/ColinEberhardt/Knockout-jQueryMobile">https://github.com/ColinEberhardt/Knockout-jQueryMobile</a></li>
<li><a href="https://github.com/ColinEberhardt/KendoUI-TwitterSearch">https://github.com/ColinEberhardt/KendoUI-TwitterSearch</a></li>
</ul>
<p>And you can see working examples at the following locations:</p>
<ul>
<li><a href="http://colineberhardt.github.io/Knockout-jQueryMobile/">Knockout + jQuery Mobile</a></li>
<li><a href="http://colineberhardt.github.io/KendoUI-TwitterSearch/">KendoUI</a></li>
</ul>
<p>It is worth viewing the above on your phone.</p>
<h2>From Knockout to KendoUI</h2>
<ul>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#magic_properties">Knockout has magic properties, Kendo has magic objects!</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#construction">Knockout is more flexible regarding view model construction</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#intellisense">Kendo requires a little effort to make it work with Intellisense</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#hierarchies">Knockout supports view model hierarchies</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#bindings">Kendo bindings are not JavaScript!</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#data">Kendo lacks a $data binding</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#widgets">Kendo has its own UI widgets</a>!</li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#dom">Kendo UI does not mangle the DOM</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#styles">jQM has a more extensive set of styles</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/themes">Kendo supports multiple mobile themes</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#datasource">Kendo has a datasource concept</a></li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/#money">Knockout is open source, Kendo costs $$$</a></li>
</ul>
<h3><a id="magic_properties"></a>Knockout has magic properties, Kendo has magic objects!</h3>
<p>JavaScript does not support the notion of change-notification when you change the value of an object’s properties. This is a vital feature for supporting binding within an MVVM framework, so both Kendo and Knockout have to provide this missing change notification.</p>
<p>With Knockout change notification is provided via observable properties:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> knockoutViewModel <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  name <span style="color: #339933;">:</span> ko.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;john&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>When a property has been created via <code>ko.observable</code> you can subscribe to change notifications for that property.</p>
<p>With Kendo change notification is provided via observable objects:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> kendoViewModel <span style="color: #339933;">=</span> kendo.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  name <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;john&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And as a result you can subscribe to change notifications on the object..</p>
<p>Neither Kendo or Knockout are able to detect when a property is set directly, instead, you must set the property value via a function. With Knockout, your property is actually a function which you can set as follows:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">knockoutViewModel.<span style="color: #660066;">name</span><span style="color: #009900;">&#40;</span>“john smith”<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span></pre></td></tr></table></div>

<p>Whereas with Kendo you set the property via the owning object:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">kendoViewModel.<span style="color: #000066; font-weight: bold;">set</span><span style="color: #009900;">&#40;</span>“name”<span style="color: #339933;">,</span> “john smith”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Both Kendo and Knockout support the concept of dependant properties, where you construct a property by composing one or more of the other objects properties, with change notifications happening automatically.</p>
<p>Both Kendo’s object-centic and Knockout’s property-centric approaches seem quite reasonable, but as we shall see later this small difference has an impact on many aspects of each framework.</p>
<h3><a id="construction"></a>Knockout is more flexible regarding view model construction</h3>
<p>Because Knockout performs its ‘magic’ at the property level, it does not place any restrictions on the way in which you construct your view models. You can use the literal syntax:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> knockoutViewModel <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  name <span style="color: #339933;">:</span> ko.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;john&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Or define a constructor:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">function</span> KnockoutViewModel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">name</span> <span style="color: #339933;">=</span> ko.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;john&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">var</span> viewModel <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> KnockoutViewModel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Personally I like the second approach because it gives you a view model ‘factory’, i.e. you can create multiple instances of the same view model, and it also allows you to define both public and private functions:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">function</span> KnockoutViewModel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">name</span> <span style="color: #339933;">=</span> ko.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;john&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  saveState <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// do something here</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">update</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    saveState<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In the code above the <code>saveState </code>function is private – for more information on this pattern I&#8217;d recommend reading <a href="http://javascript.crockford.com/private.html">Private Members in JavaScript</a> by Douglas Crockford.</p>
<p>All of the Kendo examples create view model using a literal syntax:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> kendoViewModel <span style="color: #339933;">=</span> kendo.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  name <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;john&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Initially I was under the impression that it wasn’t possible to create Kendo view models using constructor functions, furthermore, one of the nice guys from the Kendo support rather <a href="http://www.kendoui.com/forums/framework/mvvm/can-you-create-view-models-as-functions-.aspx">apologetically told me</a> “I am afraid that it is not possible to emulate Knockout style of view model creation via functions. Kendo MVVM supports only the literal style.”.</p>
<p>However, after a little bit of thought, I realised that it is possible if you explicitly return an observable as follows:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">function</span> KendoViewModel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">name</span> <span style="color: #339933;">=</span> “john”<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">return</span> kendo.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">var</span> viewModel <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> KendoViewModel <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>However, things are not quite so straightforward – if you need to capture the reference to ‘this’ you must ensure that the reference is to the observable object, as follows:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">function</span> KendoViewModel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">name</span> <span style="color: #339933;">=</span> “john”<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">function</span> saveState <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>that<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">update</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    saveState<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">var</span> that <span style="color: #339933;">=</span> kendo.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> that<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">var</span> viewModel <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> KendoViewModel <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In the above code the variable, <code>that</code>, is always going to refer to the observable object regardless of what, <code>this</code>, refers to.</p>
<h3><a id="intellisense"></a>Kendo requires a little effort to make it work with Intellisense</h3>
<p>Following on from the previous point, because the Kendo ‘magic’ is at the object level, Visual Studio Intellisense becomes flummoxed. Now I know that Visual Studio is perhaps not the best tool for JavaScript, but I can bet that quite a few Knockout and Kendo developers use it!</p>
<p>Visual Studio uses pseudo-execution of your JavaScript code to provide Intellisense. With Knockout this works well out-of-the-box &#8211; see the image below where the update function, together with its ‘summary’ text, are picked up by Intellisense:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/04/ko_intellisense.png" alt="ko_intellisense" width="424" height="407" class="aligncenter size-full wp-image-2382" /></p>
<p>Whereas with Kendo, in order for Visual Studio to be able to execute your code it needs to be aware of the Kendo and jQuery JavaScript files. This can be done by adding a ‘reference’ comment, as shown below:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/04/kendo_intellisense.png" alt="kendo_intellisense" width="475" height="448" class="aligncenter size-full wp-image-2383" /></p>
<p>Note that you can also see the other functions that are present on observable objects.</p>
<h3><a id="hierarchies"></a>Knockout supports view model hierarchies</h3>
<p>One particularly elegant feature of Knockout is that it supports view model hierarchies. When binding collections of objects, Knockout creates a child binding context that refers to the nested view model data. You can also explicitly set the binding-context of an element via the ‘with’ binding. This approach allows you to create complex nested view models.</p>
<p>With Kendo, when binding a collection of objects the ‘context’ for each item is the parent view model, which means that any event bindings are sent to the owning view model. This is clearly due to the way that Kendo uses observable objects rather than observable properties.</p>
<p>Whilst this is not a significant limitation, I do miss the binding-context concept when working with Kendo. The lack of this feature does mean that view models can become bloated.</p>
<h3><a id="bindings"></a>Kendo bindings are not JavaScript!</h3>
<p>With Knockout, bindings are JavaScript, which means you can have bindings which contain logic. For example:</p>
<pre>
data-bind="enable: searchTerm().length > 0 && isSearching() == false,
           click: search"
</pre>
<p>Kendo bindings are not JavaScript!</p>
<p>A simple way to achieve equivalent functionality is to move the JavaScript in the binding into a dependant property:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">searchButtonDisabled<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066; font-weight: bold;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;searchTerm&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">===</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066; font-weight: bold;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;isSearching&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Which is bound as follows:</p>
<pre>
data-bind="click: executeSearch, { disabled: searchButtonDisabled }"
</pre>
<p>I do not see this as a significant limitation of Kendo. I do use this feature quite often with Knockout, it feels a little like the Silverlight / WPF concept of value-converters. However, I can see how it could be abused, hiding JavaScript logic within bindings isn’t terribly good for testing or maintenance!</p>
<h3><a id="data"></a>Kendo lacks a $data binding</h3>
<p>With Knockout, if you create a ‘foreach’ binding to an array of strings, the template that renders each string can make use of the <code>$data</code> binding:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">data-bind</span>=<span style="color: #ff0000;">&quot;text: $data&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The above is needed because the binding-context of the above span element is a string – we want to bind to the object itself rather than a property of the object.</p>
<p>I could not find an equivalent feature with Kendo, so had to create an object as a container for the string:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">recentSearches</span>.<span style="color: #660066;">unshift</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> searchString<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">searchTerm</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And bind it as follows:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">data-bind</span>=<span style="color: #ff0000;">&quot;text:searchString&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Again, a pretty minor limitation.</p>
<h3><a id="widgets"></a>Kendo has its own UI widgets!</h3>
<p>So far much of my discussion has focussed on Knockout features which Kendo does not support. However, Kendo is much more than just an MVVM framework, it includes a large number of web and mobile UI widgets.</p>
<p>In the context of this comparison, I integrated jQM with Knockout to create my mobile UI – and as I mentioned earlier, <a href="http://www.scottlogic.co.uk/blog/colin/2012/10/integrating-knockout-and-jquerymobile/">this integration was pretty painful</a>. In contrast, the Kendo UI Mobile framework integrates seamlessly with the Kendo MVVM framework – as you might expected!</p>
<h3><a id="dom"></a>Kendo UI does not mangle the DOM</h3>
<p>While we are on the subject of the UI, one of the features of jQM that I really disliked is the way that it totally mangles the DOM.</p>
<p>In order to support the jQM styling it requires a large number of ‘supporting’ elements. As an example a button is transformed from this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;button</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">data-bind</span>=<span style="color: #ff0000;">&quot;enable: isSearchEnabled,</span>
<span style="color: #009900;">                                 click: executeSearch&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Go<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/button<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>To this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn ui-btn-inline ui-btn-corner-all ui-shadow ui-btn-up-c&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn-inner ui-btn-corner-all&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn-text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Go<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn-hidden&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Go&quot;</span></span>
<span style="color: #009900;">                  <span style="color: #000066;">data-bind</span>=<span style="color: #ff0000;">&quot;enable: isSearchEnabled, </span>
<span style="color: #009900;">                                    click: executeSearch&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This causes all kinds of headaches when trying to use jQM with an MVVM or MVC framework. </p>
<p>In contrast, with Kendo when you create a button:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;button&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">data-bind</span>=<span style="color: #ff0000;">&quot;click: executeSearch, { disabled: searchButtonDisabled }&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Go<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>It adds very little supporting structure:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot; km-button&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">data-bind</span>=<span style="color: #ff0000;">&quot;click: executeSearch, { disabled: searchButtonDisabled }&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;km-text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Go<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>And in many cases it leaves the DOM structure unaltered. </p>
<h3><a id="styles"></a>jQM has a more extensive set of styles</h3>
<p>The jQuery Mobile framework is more extensive than Kendo. As a quick example, jQM nicely styles your list items:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/04/jqm_list.png" alt="jqm_list" width="425" height="276" class="aligncenter size-full wp-image-2385" /></p>
<p>With Kendo, you have to put in a bit of extra effort to style the list:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/04/kendo_list.png" alt="kendo_list" width="422" height="447" class="aligncenter size-full wp-image-2384" /></p>
<p>This is just one example of many – jQM is a <em>big</em> framework.</p>
<h3><a id="themes"></a>Kendo supports multiple mobile themes</h3>
<p>The jQM UI is designed to look at home on iOS devices, which is just fine for the ~30% of people who own an iPhone. However, this UI just looks plain wrong on an Android or Windows Phone. </p>
<p>There are a few open source Android themes for jQM, but I didn’t get a satisfactory result with any of them. Also, Microsoft have <a href="http://www.scottlogic.co.uk/blog/colin/2012/04/introducing-the-jquery-mobile-metro-theme/">contributed a Metro theme to jQM, but it is rather ugly</a>!</p>
<p>In contrast, Kendo supports iOS, Android, BlackBerry and Windows Phone, <a href="http://demos.kendoui.com/mobile/overview/index.html#/">as shown on their online demo</a>. This is pretty neat!</p>
<h3><a id="datasource"></a>Kendo has a datasource concept</h3>
<p>With the Knockout + jQM application I wrote a very simple <code>TwitterSearchService</code> which acts as a datasource. The Kendo framework has a <a href="http://docs.kendoui.com/getting-started/framework/datasource/overview"><code>DataSource</code> component</a> which makes integrating with services such as Twitter much easier, you typically provide configuration to the <code>DataSource </code>and it does the rest. Also, the UI components like the <code>ListView </code>integrate directly with the <code>DataSource</code>, with features like pull-to-load-more available out-of-the-box.</p>
<h3><a id="money"></a>Knockout is open source, Kendo costs $$$</h3>
<p>This one is pretty obvious really …</p>
<p>Knockout is open source, and as a result doesn’t cost you anything to use it. For an open source project it is very well documented and there are many blog posts that provide tutorials and solutions to problems. The <a href="http://learn.knockoutjs.com/">interactive tutorial</a> is a particularly fantastic idea.</p>
<p>Kendo will cost you a few hundred dollars to buy (http://www.kendoui.com/purchase.aspx). Considering that Kendo is a UI widget framework, MVVM framework and mobile framework, I would say that the price is very reasonable. Also, the documentation is of a similar quantity and quality to that of Knockout.</p>
<h2>Conclusions</h2>
<p>This article has been a mixed-bag of observations, thoughts and opinions and it is not intended to be an exhaustive comparison. Despite that, I hope it will be useful for others.</p>
<p>I certainly prefer the Knockout implementation of MVVM, I find it more powerful and flexible than the Kendo equivalent. However, Kendo’s MVVM framework is certainly adequate.</p>
<p>When it comes to building mobile applications, the fully integrated Kendo solution has some pretty big advantages over Knockout and jQuery Mobile.</p>
<p>Regards, Colin E.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/colin/2013/04/comparing-kendoui-and-knockout-with-a-bit-of-jquerymobile-on-the-side/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Scott Logic sponsors “HTML5 – It Just Got Real”</title>
		<link>http://www.scottlogic.co.uk/2013/03/scott-logic-sponsors-html5-it-just-got-real/</link>
		<comments>http://www.scottlogic.co.uk/2013/03/scott-logic-sponsors-html5-it-just-got-real/#comments</comments>
		<pubDate>Thu, 28 Mar 2013 15:47:19 +0000</pubDate>
		<dc:creator>Natalie Jolly</dc:creator>
				<category><![CDATA[Latest News Widget]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Press Releases]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=183348</guid>
		<description><![CDATA[Scott Logic is proud to announce sponsorship of  HTML5 – It Just Got Real, a one day conference for IT Leaders focusing on strategic decisions around HTML5.]]></description>
				<content:encoded><![CDATA[<p>Scott Logic is proud to announce sponsorship of  <a href="http://html5-it-just-got-real.com/">HTML5 – It Just Got Real</a>, a one day conference for IT Leaders focusing on strategic decisions around HTML5. Featuring a keynote speech from <a href="http://www.adam-hart-davis.org/">Adam Hart-Davis</a> alongside other industry experts, this event will take place on 14<sup>th</sup> May 2013 at the Royal Society, London. <a href="http://html5-it-just-got-real.com/">Click here</a> for more information and to register your attendance.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2013/03/scott-logic-sponsors-html5-it-just-got-real/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 – It Just Got Real – A One-day Conference in London 14th May</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2013/03/html5-it-just-got-real-a-one-day-conference-in-london-14th-may/</link>
		<comments>http://www.scottlogic.co.uk/blog/colin/2013/03/html5-it-just-got-real-a-one-day-conference-in-london-14th-may/#comments</comments>
		<pubDate>Thu, 28 Mar 2013 14:04:57 +0000</pubDate>
		<dc:creator>Colin Eberhardt</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=2375</guid>
		<description><![CDATA[Announcing a one-day conference at the Royal Society, London UK, on the 14th of May. Just a few years back I wrote a white paper titled "Flex, Silverlight or HTML5? Time to decide..." with the help of a couple of my colleagues, comparing the strengths and weaknesses of the three competing technologies. This paper [...]]]></description>
				<content:encoded><![CDATA[<div id="tweetbutton2375" class="tw_button" style=""><a href="http://twitter.com/share?url=http%3A%2F%2Fwww.scottlogic.co.uk%2Fblog%2Fcolin%2F2013%2F03%2Fhtml5-it-just-got-real-a-one-day-conference-in-london-14th-may%2F&amp;text=HTML5%20%E2%80%93%20It%20Just%20Got%20Real%20%E2%80%93%20A%20One-day%20Conference%20in%20London%2014th%20May&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fwww.scottlogic.co.uk%2Fblog%2Fcolin%2F2013%2F03%2Fhtml5-it-just-got-real-a-one-day-conference-in-london-14th-may%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://www.scottlogic.co.uk/blog/colin/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><p><em>Announcing a one-day conference at the Royal Society, London UK, on the 14th of May.</em></p>
<p><a href="http://html5-it-just-got-real.com/"><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2013/03/html5-just-got-real.png" alt="html5-just-got-real" width="495" height="269" class="aligncenter size-full wp-image-2376" /></a></p>
<p>Just a few years back I wrote a white paper titled <a href="http://www.scottlogic.co.uk/blog/colin/2011/05/flex-silverlight-html5-time-to-decide/">“Flex, Silverlight or HTML5? Time to decide …”</a> with the help of a couple of my colleagues, comparing the strengths and weaknesses of the three competing technologies. This paper was aimed at helping developers make an informed choice when faced with developing an interactive web site or complex web app.</p>
<p>Don’t bother reading that white paper now!  It was only written two years ago, but is now so out-of-date that it might as well have been written ten years ago.</p>
<p>Here’s the penultimate paragraph:</p>
<blockquote><p>“It is very difficult to predict where we will be in a few years’ time and whether there will be some technology casualties along the way. Can all three technologies co-exist? Or will one or more be relegated to the internet history books like Java Applets and ActiveX?”</p></blockquote>
<p>Yes, there have been some casualties, <a href="http://www.scottlogic.co.uk/blog/colin/2011/11/the-untimely-demise-of-the-plugin-and-how-lob-developments-will-suffer/">both Silverlight … and Flex</a>!</p>
<p>The rise of smartphones and tablets has accelerated HTML5 adoption to the point where plugins are considered a legacy technology. Invest in them at your peril!</p>
<p>The problem is that enterprise-scale HTML5 development is far from easy. With Flex and Silverlight you have the comfort of working within a shrink-wrapped development environment, whereas HTML5 is like the Wild West; assembling a workable set of tools, framework and processes is not an easy task.</p>
<p>This is why we decided to stage our own conference – we want to talk about the challenges of enterprise scale HTML5 development, and how to tackle them.</p>
<p>If you are interested, and are thinking of signing up, take a look at the conference website &#8211; <a href="http://html5-it-just-got-real.com/">html5-it-just-got-real.com</a> – there will be talks on a range of subjects, ranging from practical and insightful to radical and fun (we have a BBC presenter and a guitar-wielding JavaScript rockstar). </p>
<p>Regards, Colin E.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/colin/2013/03/html5-it-just-got-real-a-one-day-conference-in-london-14th-may/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java / Web Developer</title>
		<link>http://www.scottlogic.co.uk/2013/03/java-web-developer-various-levels/</link>
		<comments>http://www.scottlogic.co.uk/2013/03/java-web-developer-various-levels/#comments</comments>
		<pubDate>Fri, 22 Mar 2013 08:35:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Vacancies]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=182933</guid>
		<description><![CDATA[Very competitive salary + bonus + benefits; Bristol, Edinburgh or Newcastle Upon Tyne]]></description>
				<content:encoded><![CDATA[<p><strong>Developer, Senior Developer and Lead Developer positions available in our Newcastle, Edinburgh and Bristol offices</strong></p>
<p>Scott Logic Ltd is a growing technology consultancy which provides the very best in bespoke software solutions across a variety of market sectors. Our clients demand that we stay at the cutting-edge: we design complex business-critical systems, ranging from sophisticated graphical research analysis tools through to back-office settlement platforms.</p>
<p>Our development roles are very hands-on and at least 90% of your time will be spent developing software. We can give you the opportunity to get involved in full life-cycle development, working in collaboration with our clients, from our office locations in Newcastle, Bristol and Edinburgh.</p>
<p>Our offices are in city centre locations enabling an easy, car-free commute.</p>
<p>Essential:</p>
<ul>
<li>A relevant degree (involving some computer science) from a reputable university</li>
<li>Commercial experience in an OO environment</li>
<li>Experienced developing enterprise scale applications using Java EE</li>
<li>Experienced in enterprise scale web development, specifically using HTML5 and JavaScript frameworks (jQuery / Knockout etc.)</li>
</ul>
<p>Desirable:</p>
<ul>
<li>Consultancy experience</li>
</ul>
<p>Scott Logic offers a highly competitive salary and benefits package, including:</p>
<ul>
<li>Bonus scheme</li>
<li>25 days holiday per year, growing with length of service up to 30 days</li>
<li>Life assurance</li>
<li>Childcare vouchers</li>
<li>Cycle to Work Scheme</li>
<li>Professional development opportunities</li>
</ul>
<p>In addition, we can offer the following:</p>
<ul>
<li>Occasional travel to clients in London, New York and Europe</li>
<li>A wide variety of technologies and platforms including web and mobile</li>
<li>The opportunity to work with some of the best developers in the region</li>
</ul>
<p>A CV and covering letter specifying your area of expertise,  interest and preferred location, along with your salary expectations, should be sent to <a href="mailto:applications@scottlogic.co.uk">applications@scottlogic.co.uk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2013/03/java-web-developer-various-levels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Knockout.js + Node.js = What.js?</title>
		<link>http://www.scottlogic.co.uk/2013/03/knockout-js-node-js-what-js/</link>
		<comments>http://www.scottlogic.co.uk/2013/03/knockout-js-node-js-what-js/#comments</comments>
		<pubDate>Fri, 08 Mar 2013 16:01:44 +0000</pubDate>
		<dc:creator>Chris Price</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Latest News Widget]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=182071</guid>
		<description><![CDATA[Recently I contributed a change to Knockout which allows it to run without hacks in a non-browser JavaScript environment. My original intention was to allow Knockout.js to be used with [...]]]></description>
				<content:encoded><![CDATA[<p><a style="float: right; margin-left: 16px;" href="http://www.scottlogic.co.uk/blog/chris/"><img class="aligncenter size-full wp-image-145833" style="border: 1px solid black;" title="Chris Price" alt="" src="http://www.scottlogic.co.uk/wp-content/uploads/2012/03/me1.png" /></a><em>Recently I contributed a change to Knockout which allows it to run without hacks in a non-browser JavaScript environment. My original intention was to allow Knockout.js to be used with Titanium for the <a href="http://www.propertycross.com">PropertyCross</a> project however, a convenient side-effect is that it now also runs in Node. In this post I’ll run through what is and isn’t supported, and some ways you might want to use it..</em></p>
<h3>Getting Started</h3>
<p>The changes are targeted for the 2.3.0 release which means the only way of working with them currently (official npm package <a href="https://github.com/SteveSanderson/knockout/pull/866">due soon</a>) is to checkout the project from GitHub and build it yourself, luckily this is a relatively painless experience if you have git setup -</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">git clone git<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//github.com/SteveSanderson/knockout.git</span>
cd knockout
.<span style="color: #339933;">/</span>build<span style="color: #339933;">/</span>build.<span style="color: #660066;">sh</span></pre></td></tr></table></div>

<p>The output files are located in the build/output folder, knockout-latest-debug.js is the one you’ll want for Node, unless you have a strange compulsion for minified code! Let’s quickly put together a hello world example based on the example from the <a href="http://knockoutjs.com/examples/helloWorld.html">Knockout website</a> -</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> ko <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'build/output/knockout-latest.debug.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Here's my data model</span>
<span style="color: #000066; font-weight: bold;">var</span> ViewModel <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>first<span style="color: #339933;">,</span> last<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">firstName</span> <span style="color: #339933;">=</span> ko.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span>first<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">lastName</span> <span style="color: #339933;">=</span> ko.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span>last<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">fullName</span> <span style="color: #339933;">=</span> ko.<span style="color: #660066;">computed</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName.</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">firstName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">lastName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// create an instance of the ViewModel</span>
<span style="color: #000066; font-weight: bold;">var</span> vm <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> ViewModel<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Planet'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Earth'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// subscribe to fullName changes</span>
<span style="color: #000066; font-weight: bold;">var</span> subscription <span style="color: #339933;">=</span> vm.<span style="color: #660066;">fullName</span>.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// log the current value</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>vm.<span style="color: #660066;">fullName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// trigger a change</span>
vm.<span style="color: #660066;">lastName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Mars'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// dispose of the subscription</span>
subscription.<span style="color: #660066;">dispose</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Sticking the above in a file (hello-world.js) in the root of the knockout project and then running it through Node (node hello-world.js) gives us -</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">Planet Earth
Planet Mars</pre></td></tr></table></div>

<p>So far so good but that’s a lot of boilerplate code, what’s happened to ko.applyBindings and the corresponding template? Well at this point it’s worth going back and reviewing the spec runner for Node to get a better idea of exactly which bits of Knockout are expected to work.</p>
<h3>What works? What doesn&#8217;t?</h3>
<p>The following table lists the test specs for Node, taken from spec/runner.node.js, against the Knockout methods they exercise -</p>
<table>
<tbody>
<tr>
<td>arrayEditDetectionBehaviors</td>
<td>ko.utils.compareArrays(a, b)</td>
</tr>
<tr>
<td>asyncBehaviors</td>
<td>ko.observable().extend({ throttle: a })</td>
</tr>
<tr>
<td>dependentObservableBehaviors</td>
<td>ko.dependentObservable/computed()</td>
</tr>
<tr>
<td>expressionRewritingBehaviors</td>
<td>ko.expressionRewriting.*</td>
</tr>
<tr>
<td>extenderBehaviors</td>
<td>ko.extenders.*</td>
</tr>
<tr>
<td>mappingHelperBehaviors</td>
<td>ko.toJS, ko.toJSON</td>
</tr>
<tr>
<td>observableArrayBehaviors</td>
<td>ko.observableArray()</td>
</tr>
<tr>
<td>observableBehaviors</td>
<td>ko.observable()</td>
</tr>
<tr>
<td>subscribableBehaviors</td>
<td>ko.subscribable()</td>
</tr>
</tbody>
</table>
<p>There’s a lot of observable related goodness there but glaring omissions around the DOM and templating functionality, which means no ko.applyBindings. However, taking a step back, you’ll probably have noticed that there isn’t much of a UI layer to Node, so even if those methods were there, what would they do?</p>
<p>Philosophy aside, where does this leave us? What can we do now that we couldn’t do previously?</p>
<h3>Faster view model testing</h3>
<p>As long as your view models aren’t making any direct use of the DOM or templating functionality, then you can now run your test specs through Node instead of something like Phantom.js. Your milage will vary but in the case of the Knockout test cases, the Node test specs run in a quarter of the time (0.5s) of the Phantom test specs (2s).</p>
<p>This isn’t a perfect example as the only a subset of the Phantom test specs are run by Node but in this case it does make enough of a difference to mean that the tests could now comfortably be run by a file-system watcher.</p>
<h3>Potential to integrate with non-browser, JavaScript powered UIs</h3>
<p>This was my original aim when making these changes, in my case it was to re-use the view models from an HTML5 app in a Titanium app. I ended up hacking a fake DOM in to keep the old code happy but if I were to try it again now, I could just include vanilla Knockout.</p>
<p>As well as simply being able to use Knockout, I hope that these changes will encourage people to create their own templating system for the non-browser UI elements, which in turn will make it even easier to use Knockout.</p>
<h3>Crazy, pointless, Node-based view model fun!</h3>
<p>Let&#8217;s say we create a view model like this -</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> viewModel <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  ticks<span style="color: #339933;">:</span> ko.<span style="color: #660066;">observable</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  tick<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ticks</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ticks</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  bars<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">function</span> createBar<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> count<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> ko.<span style="color: #660066;">computed</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> viewModel.<span style="color: #660066;">ticks</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>count <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> <span style="">Math</span>.<span style="color: #660066;">abs</span><span style="color: #009900;">&#40;</span>a <span style="color: #339933;">-</span> count <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> <span style="">Math</span>.<span style="color: #660066;">abs</span><span style="color: #009900;">&#40;</span>index <span style="color: #339933;">-</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> c <span style="color: #339933;">/</span> count<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">-</span> d<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>e <span style="color: #339933;">*</span> e <span style="color: #339933;">*</span> e<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toFixed</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> count <span style="color: #339933;">=</span> <span style="color: #CC0000;">6</span><span style="color: #339933;">;</span> index <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> count<span style="color: #339933;">;</span> index<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  viewModel.<span style="color: #660066;">bars</span><span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> createBar<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> count<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Then combine it with an npm module called <a href="https://github.com/rwldrn/johnny-five">johnny-five</a> and a bit of view binding code -</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> five <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;johnny-five&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">new</span> five.<span style="color: #660066;">Board</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ready'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">11</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">forEach</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>pin<span style="color: #339933;">,</span> index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">var</span> led <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> five.<span style="color: #660066;">Led</span><span style="color: #009900;">&#40;</span>pin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    viewModel.<span style="color: #660066;">bars</span><span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      led.<span style="color: #660066;">brightness</span><span style="color: #009900;">&#40;</span><span style="">Math</span>.<span style="color: #660066;">round</span><span style="color: #009900;">&#40;</span>value <span style="color: #339933;">*</span> <span style="color: #CC0000;">255</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  setInterval<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    viewModel.<span style="color: #660066;">tick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Finally, attach an arduino and what do you get?</p>
<p><iframe src="http://www.youtube.com/embed/OHQp_1wcFDU" height="400" width="690" allowfullscreen="" frameborder="0"></iframe></p>
<p>The worlds first KnightRider LED effect powered by a Knockout view model (I think)! If anyone fancies making their own, the code is all available on <a href="https://github.com/chrisprice/knightrider">GitHub</a></p>
<p><a class="twitter-share-button" href="https://twitter.com/share" data-via="100pxls">Tweet</a><br />
<script type="text/javascript">// <![CDATA[
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
// ]]&gt;</script></p>
<div class="g-plusone" data-annotation="inline" data-width="300"></div>
<p><script type="text/javascript">// <![CDATA[
(function() {     var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;     po.src = 'https://apis.google.com/js/plusone.js';     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);   })();
// ]]&gt;</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2013/03/knockout-js-node-js-what-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
