Friday, December 5, 2014

Swift from Scratch: Introduction

Mootor, an HTML5 Framework for Mobile Development

In this tutorial, we’ll look at the Mootor Framework, an HTML 5 framework for developing mobile applications. It’s reasonably new (March 2014) and lacks the flurry of development some similar frameworks have, but it’s always worth taking a look.


Source code from this tutorial is available on GitHub.


Getting started


We’ll be using the angular seed project to set up a local server for the Mootor project. So first clone the angular seed project and install the required dependencies:


Continue reading %Mootor, an HTML5 Framework for Mobile Development%




by Jay Raj via SitePoint

Managing Client-Only State in AngularJS

View models in JavaScript frameworks such as AngularJS can be different from domain models on the server - a view model doesn't even have to exist on the server. It follows then that view models can have client only state, e.g. 'animation-started' and 'animation-ended' or 'dragged' and 'dropped'. This post is going to concentrate on state changes when creating and saving view models using Angular's $resource service.


It's actually very easy for a $resource consumer, e.g. a controller, to set state, as shown below.


[js] angular.module('clientOnlyState.controllers') .controller('ArticleCtrl', function($scope, $resource, ArticleStates /* simple lookup */) { var Article = $resource('/article/:articleId', { articleId: '@id' }); var article = new Article({ id: 1, title: 'A title', author: 'M Godfrey' }); article.state = ArticleStates.NONE; // "NONE" $scope.article = article; $scope.save = function() { article.state = ArticleStates.SAVING; // "SAVING" article.$save(function success() { article.state = ArticleStates.SAVED; // "SAVED" }); }; }); [/js]

This approach is fine for applications containing single consumers. Imagine how boring and error prone replicating this code would be for multiple consumers! But, what if we could encapsulate the state change logic in one place?


$resource Services


Let's start by pulling out our Article resource into an injectable service. Let's also add the most trivial setting of state to NONE when an Article is first created.


[js] angular.module('clientOnlyState.services') .factory('Article', function($resource, ArticleStates) { var Article = $resource('/article/:articleId', { articleId: '@id' }); // Consumers will think they're getting an Article instance, and eventually they are... return function(data) { var article = new Article(data); article.state = ArticleStates.NONE; return article; } }); [/js]

What about retrieving and saving? We want Article to appear to consumers as a $resource service, so it must consistently work like one. A technique I learned in John Resig's excellent book "Secrets of the JavaScript Ninja" is very useful here - function wrapping. Here is his implementation directly lifted into an injectable Angular service.


[js] angular.module('clientOnlyState.services') .factory('wrapMethod', function() { return function(object, method, wrapper) { var fn = object[method]; return object[method] = function() { return wrapper.apply(this, [fn.bind(this)].concat( Array.prototype.slice.call(arguments)) ); }; } }); [/js]

This allows us to wrap the save and get methods of Article and do something different/additional before and after:


Continue reading %Managing Client-Only State in AngularJS%




by Michael Godfrey via SitePoint

jQuery Html JSON Forms

A jQuery implementation of the draft for submitting forms encoded as JSON.




by via jQuery-Plugins.net RSS Feed

On Our Radar This Week: Advent Calendars and Internet Addiction

Trending mobile designs


This week mobile design has been on our minds, starting with the screen-size debate – how the iPhone 6 Plus Impacts Where We Read & Watch, and there's some good coverage of Chinese mobile app UI trends. If you're using Android, we've come across Material Design ideas and inspiration, and a must-read designer book called Don’t Make Me Think is revisited — it still holds up well today.

Addicted to web browsers


We also check out what’s new in Chrome 39 with generators, animation controls, and which even gives Windows 7 users a Windows 8 "immersive mode" experience. It's not the only browser worth checking out though, for Yandex offers an early look at the web browser of the future. Whichever browser you choose to use, Life as a sole web developer can certainly be tricky. If you're always on the internet outside of your job you might worry you have an addition, but is an internet addiction a real thing?

Keeping CSS typefaces simple


It can be tricky enough choosing one good typeface, and combining typefaces is even harder, so we have put together for you three principles for perfect typeface pairing. Another challenge developers have to deal with is the lengthy bulk of CSS. You can keep CSS short with currentColor, and if you're wanting gradients, we have good coverage this week on building a linear-gradient mixin in Sass, for which the psychology of color in marketing and branding may also be useful.

Continue reading %On Our Radar This Week: Advent Calendars and Internet Addiction%




by Paul Wilkins via SitePoint

Interview with Mark Safronov, author of “Web App Development with Yii 2″

I’ve made it no mystery that I work with Yii and enjoy using it. I’m somewhat of an old school guy and don’t mind reading a book to get started. I like the way they normally give you a gradual introduction to something you want to gain knowledge about. It’s a more subtle way to start with something and you don’t immediately drown in the huge amount of information.


That’s the way I started on Yii 1.1 some years ago. Unfortunately, I tossed the book I used back then half way through; it went too slow for me. Going over simple things repeatedly made me lose my interest quite fast. I wanted to learn more, faster. I had a whole bunch of ideas in my head and I wanted to find out how to realize them.


We’re a few years down the road and with the introduction of Yii 2.0 I let myself be tempted yet again by a book before starting some serious work with Yii 2.0. With mixed experiences in mind I started on a copy of Web Application Development with Yii 2 and PHP and ended up pleasantly surprised.


1885OS_Web%20Application%20Development%20with%20Yii%202%20and%20PHP_cover.jpg


Continue reading %Interview with Mark Safronov, author of “Web App Development with Yii 2″%




by Arno Slatius via SitePoint

The Non-Writer’s Guide to Writing for the Web

Five centuries ago, the Gutenberg press made books available to the masses. Fifteen years ago, blogging platforms like WordPress and Movable Type made self-publishing available to anyone with a computer.


Inbound marketing firms encourage small business owners to blog because “it will cause your business to reach new heights and succeed in today’s virtual marketplace.” This means plumbers, roofers, and office managers are beginning to produce content for their company or organization’s website.


Perhaps you’re one of these. Or maybe you’re a WordPress developer cringing at the copy your client sent you. An amateur behind a keyboard can often be as scary as an amateur behind a camera. But that doesn’t mean someone with no writing experience or training can’t become a good web writer.


Write First, Edit Later


Editing while writing requires switching between your creative brain and your critical brain, so you end up not doing either job well.


Setting a timer can prevent this. Try the Pomodoro technique. If 25 minutes of writing is too intense, pick a shorter increment.


Continue reading %The Non-Writer’s Guide to Writing for the Web%




by John Tabita via SitePoint