Issue #42  (call/apply, Sass, jQuery, Mobile)05/08/14

Support this week's main sponsor:

Sell websites for $15,000 Sell websites for $15,000
Learn how to run a profitable web design business from the Marketing Director of a 14-year-old web design agency. Rated 4.5/5 stars, this video course is available at an outstanding price of 80% off until the end of May.
Start getting more high-paying clients today!

For this week's tip I'm excited to have a guest contributor, Derick Bailey. Derick is an author, blogger, and speaker and he produces JavaScript screencasts at WatchMeCode. Be sure to check that out and use discount code webtoolsweekly to get 35% off the subscription price.

In issue #39 of Web Tools Weekly, Louis introduced several methods of function invocation. He showed how various invocation patterns change the value of this inside of methods, and left off with a mention of the .call() and .apply() methods. These methods exist on all functions — that's right, every JavaScript function has functions attached to it. The purpose of these methods is to let you execute a function with a specified context and also to let you supply parameters to the function in two different ways.

Using .call()
When using .call() on a function, the first parameter will be the context or the this variable. Any additional parameters passed in will be passed as arguments to the original function.
function doStuff(b){
  return this.a + b;

var myContext = {a: 1};
var result =, 2);
console.log(result); //=> 3

(Demo) You can supply any number of arguments to the .call() method, and all of them will be passed to the original function after setting the context., 1, 2, [... n]);

The .call() method is most often used when you need to dynamically call a function with a given context and a set of values that you already have as variables.

Using .apply()
The use of .apply() is essentially the same, except you pass in an array as the second parameter and that array gets passed through to the original object as the list of arguments.
function doStuff(b, c){
  return this.a + b + c;

var myContext = {a: 1};
var result = doStuff.apply(myContext, [2, 3]);
console.log(result); //=> 6

(Demo) If you try to pass more than 2 parameters to the .apply() method, you'll get an error.

The .apply() method is most often used when you need to dynamically call a function with a given context and a set of values in an array, such as splitting the arguments object from another function.

For more on JavaScript, check out Derick's screencast series WatchMeCode. Use coupon code webtoolsweekly for 35% off.

Now on to this week's tools!

Preprocessor Tools

Bourbon Neat
"A lightweight semantic grid framework for Sass and Bourbon."

Less Elements
"A set of basic mixins for the LESS CSS pre-processor. Most of these mixins focus on consolidating cross-browser prefixes into single, concise declarations."

"Testing tools for compass/sass."

Modular Scale
"Modular scale calculator built into your Sass."

"Flexible system to manipulate icons, SVG, PNG, sprites. Works on top of compass sprite tools. It was designed to easily switch between SVG and PNG while working with icons as background-images."

"A Sass mix-in for turning OpenType features on and off in your embedded web fonts."

Hacking made easy
"A couple of Sass functions to ease the pain of dealing with special values for IE."

"A simple sass mixin library for animations and transitions."

"A Sass component that allows you to create multiple CSS files from a single Sass partial by wrapping your code within breakpoint blocks."


jQuery Plugins

"jQuery plugin to resize images to fit in a container."

"A responsive carousel for cycling through objects." Uses CSS transitions and works with slide or fade.

jQuery Panorama Viewer
"Embed interactive Panorama Pictures on your site with this simple plugin."

"Polyfill for the HTML5 <input type="range"> slider element."

A form validation plugin, designed to be used with Bootstrap 3.

"The last carousel you'll ever need. Fully responsive. Scales with its container. Separate settings per breakpoint. Uses CSS3 when available. Fully functional when not."

"Combines some awesome libraries to provide a ease-to-use plugin for applying CSS3 animations to any text."

"Allows your web application to only load images within the viewport. It also allows you to have different version of an image for 4 different screen sizes."

Align text on a curve.


RWD and Mobile Tools

"A jQuery Plugin that helps you quickly and easily add features to your Web Site to enable it respond and adapt to virtually every Web-enabled Device."

Android WebPagetest
A fork of specifically for Chrome on various Android devices.

Responsive Design Tester
Yet another responsive layout tester. Has some presets along with a two-paned adjustable view.

jQuery plugin for responsive menus. "A decent multi-level menu with support for touch, hover reveal, and keyboard tab input accessibility."

"A simple in-browser tool created by developers at BBC Sport for checking how a responsive website responds to different screen sizes."

"Build mobile apps with simple HTML‚ CSS‚ and JS components."

"Yet another lightweight, customisable responsive image solution."


A Tweet for Thought

From Viljami Salminen, all the dashes in web typography.


Suggestions / Corrections

Made something? Send links via Twitter @WebToolsWeekly (details here). No tutorials or articles, please. If you have any suggestions, corrections, or improvements, feel free to reply to this email.


Before I Go...

If you use MailChimp, you might find Mailion useful. It's an app that lets you edit your subscriber lists super fast in bulk, multiple fields at a time.

Thanks to all for subscribing and reading!

Keep tooling,
Copyright © Web Tools Weekly, All rights reserved.

Email Marketing Powered by MailChimp