Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

The Divi WordPress Theme: Changing the Way You Blog

Di, 2015-07-14 18:00

If you aren’t familiar with Divi, it’s a WordPress theme I covered a while back. The Divi WordPress theme is a great starting point for any website. It has one of the best drag and drop page builders for building your own custom layouts.

Rakhitha Nimesh wrote about the power of WordPress page builders in an article published earlier this year, exploring some of the popular plugins that enable page building functionality. He also covered some of the pros and cons, but love them or hate them, page builders are here to stay.

Divi uses modules that you insert and stack on top of each other to build your own custom design. You can tweak nearly every aspect of the page’s look, including fonts, colors, images, animations, and more. Each module even has a section where you can add IDs and classes to elements, giving you the ability to customize your site, right down to the last detail. Up until now, this feature was only available for pages. The blog was left fairly standard, and the only way to customize it was to hack at the CSS yourself. With the new Divi update, they have completely changed the way you blog.

Continue reading %The Divi WordPress Theme: Changing the Way You Blog%

Apple Watch Is Improving Health. Does This Come With a Price?

Di, 2015-07-14 17:00

The Apple Watch launched last March and shipped in April to those who pre-ordered. Thousands of apps are available for Apple Watch, either as standalone apps or combined with iPhone apps. A compelling (and popular) feature is the ability of the watch to track health and fitness, a trend throughout wearable technology. This article will discuss how Apple Watch can help with health and fitness but also the issues with Apple Watch's data privacy and security.

Continue reading %Apple Watch Is Improving Health. Does This Come With a Price?%

50 Free Productivity Dashboards and Templates

Di, 2015-07-14 16:00

Please raise your hand if you think redundant tasks suck. You know the ones I’m talking about – designing invoices, creating project roadmaps and writing business plans. Formatting charts and/or designing business invoices can be a time suck that add up overtime. But it doesn’t have to be. Stop reinventing the wheel, and download a […]

Continue reading %50 Free Productivity Dashboards and Templates%

Exploring the Hero Section

Di, 2015-07-14 15:00

As defined by the Oxford Dictionary: Hero /ˈhirō/ (noun)

:A person, typically a man, who is admired or idealized for courage, outstanding achievements, or noble qualities

:The chief male character in a book, play, or movie, who is typically identified with good qualities, and with whom the reader is expected to sympathize

:(In mythology and folklore) a person of superhuman qualities and often semi-divine origin, in particular one of those whose exploits and dealings with the gods were the subject of ancient Greek myths and legends.

These are all definitions to a word derived from the Ancient Greek word ἥρως which means heroes. A word that has a rich history dating back to a time where Gods clashed with mythological beasts and championed heroes to fell nasty foes on a path of destruction.

But what does the etymology and history of such a word have to do with web design? In short, if you know how to make mortar you can build something a lot more effective than a straw hut.

What is the Hero Section?

Sad truth time: the hero section has nothing to do with your favorite comic and movie heroes. That means no Batman, Hellboy, Ironman, Doctor Strange or any other cape crusader.

The “Hero Section” – also commonly referred to as the “Hero Header” and “Hero Image” – is a design trend that isn't all that new. Soap companies of the 1800's competed vigorously to develop the most effect hero panels on their labels and newspaper ads, featuring lithographs of cute kids, caring mothers and fluffy kittens.

Not a lot has changed there.

For the first time companies were understood the benefits of drawing links between their products and contemporary heroes such as Benjamin Franklin, Horatio Nelson, or the Duke of Wellington – not always with permission.

On the web the hero section is typically a prominent image, slider, text or similar element that has pride of place at the top of your homepage layout and possibly subsequent pages. It is front and center and in your face.

Don't confuse Hero Sections with those large, trendy background images used in lieu of color or patterns. There is always a purpose and focus for these sections opposed to just serving to set a general look and tone.

The Hero Section is not only a visual stimulant but it is also a core tool that is used to not only give the design a focal point but to pull in the masses and get them hooked. The Hero Section is not only the ‘likable protagonist’ in your story, but also the summary in the book jacket that gets you to read on.

The Literary Hero

When I create music videos for artists (maybe you didn’t know I do that) I often find myself being left to my own devices without any concept but my own. I’ve found that looking for unconscious links between song meaning and images not only yields a better understanding of the project, but allows me to create visuals that leave the artists happy.

With web design and specifically with the Hero Section the concept works pretty much the same. Know the past – the hero's backstory – and you can apply it to the present.

_______

Joseph John Campbell introduced the concept of “monomyth” or “the heroes journey” back in 1947. The concept goes as followed:

A hero ventures forth from the world of common day into a region of supernatural wonder: fabulous forces are there encountered and a decisive victory is won: the hero comes back from this mysterious adventure with the power to bestow boons on his fellow man. 

The hero archetype is something that is not only a literary vehicle but also one that has hooks in psychology. Carl Jung described this journey as the process of “individuation”. This individuation of the hero which Jung referred to as the “Self” served as the central archetype of order amongst all the others.

You see this manifestation of the Self often in literature no matter the genre.

The Take Away

In a typical monomyth structure there are three acts, departure, initiation and return. Each act is broken up in phases which when looked at can be applied to the creation and structuring of your site’s Hero Section.

The key things to remember when using literary and psychological attributes of the hero to your sections are:

  • The hero is idolized and is a chief player in the world they inhabit
  • The hero’s journey is a journey of purpose, from start to finish
  • The myth of the hero is consequently the beginning step to finding the true “self”
  • The end product or individuation of the hero is as important as the rest of the story

Continue reading %Exploring the Hero Section%

Sass Maps vs. Nested Lists

Di, 2015-07-14 14:00

The title of this post may be surprising to some of you. If you are a Sass veteran, you may remember the days (pre-Ruby-Sass-3.3) of using lists of lists to emulate nested arrays of data. (Ruby) Sass 3.3 added a new data type called maps. Lists of lists could hold complex data in a nested format, but without key-value pairing. Maps added key-value pairs and let us create arrays of data.

With the advent of maps, many of us Sass users started putting everything into maps (and for good reason!). All your breakpoint widths, color values, grid layouts, type scales and other responsive typography details can go into maps!

Now that Sass has maps with key-value pairs, is there a good reason to use a list of lists? One theoretical reason would be backwards-compatibility: if your Sass might be maintained by a developer with an older version installed, lists will help them. In practice, however, Sass versions are often controlled by a package.json or other project config, and the Ruby gem can be updated with just one command (gem update sass).

A more practical reason that you might choose to use nested lists instead of a map is typing less. Let's compare a map and a nested list to see how they compare in their own syntax, and in how we'd loop through them.

Continue reading %Sass Maps vs. Nested Lists%

12 Little-Known CSS Facts (The Sequel)

Di, 2015-07-14 13:00

Over a year ago I published the original 12 Little-known CSS Facts and, to this day, it has been one of SitePoint’s most popular articles ever. Since that post was published, I’ve been collecting more little CSS tips and tidbits for a new post. Because we all know that every successful movie should spawn a cheesy sequel, right?

[caption id="attachment_110386" align="aligncenter" width="800"] Artwork by SitePoint/Natalia Balska.[/caption]

So let’s get right into this year’s developer’s dozen. I’m sure many of us will know at least some of these, but you can let me know in the comments how many of these were new to you.

1. The border-radius property can use “slash” syntax

This is something I’ve written about before more than four years ago on SitePoint, but I still think many beginners and even some experienced developers don’t know this feature exists.

Believe it or not, the following is valid border-radius code:

[code language="css"]
.box {
border-radius: 35px 25px 30px 20px / 35px 25px 15px 30px;
}
[/code]

If you’ve never seen that, it might seem a little confusing, so here’s the explanation from the spec:

If values are given before and after the slash, then the values before the slash set the horizontal radius and the values after the slash set the vertical radius. If there is no slash, then the values set both radii equally.

The spec also provides the following diagram:

The caption for that image explains: “The two values of border-top-left-radius: 55pt 25pt define the curvature of the corner.”

So the use of the slash in the value allows you to create curved corners that are not symmetrical. If you want a more detailed consideration of this, check out my original article linked above, or better yet, try out this handy little interactive demo from MDN:

Most border-radius generators do not allow you to set these optional values. The MDN generator is the only one I’ve found that does this.

2. The font-weight property accepts relative keywords

Normally when you see the font-weight property defined, the value will be either normal or bold. You might also occasionally see an integer value in hundred increments: 100, 200, etc., up to 900.

The two values that are often forgotten, however, are bolder and lighter.

According to the spec, these keywords specify a bolder or lighter weight than the inherited value. This comes into play most significantly when you are dealing with a font that has multiple weights that are bolder than just plain “bold” and lighter than just normal text.

In the hundred-based values, “bold” maps to 700 and “normal” maps to 400. So if you have a font that has a 300 weight, but nothing lower, a value of “lighter” will produce 300 if the inherited value is 400. If there is no lighter weight (i.e. 400 is the lightest weight) then it will just stay at 400 and thus a value of “lighter” will have no effect.

Look at the following CodePen demo:

See the Pen Using font-weight bolder/lighter Keywords by SitePoint (@SitePoint) on CodePen.

In this example, I’m using a font called Exo 2, which has 18 different styles available. My demo embeds only the non-italic styles, which are enough for each of the hundred-based weights.

Notice that the demo includes 12 nested ‘box’ elements with different font-weight values, including “bolder” and “lighter” so you can see how these affect the weight of the text in different inheritance contexts. Below is the CSS from that example. Notice the comments in the code, and remember that each subsequent “box” is nested inside the previous:

[code language="css"]
.box {
font-weight: 100;
}

.box-2 {
font-weight: bolder; /* maps to 400 */
}

.box-3 {
font-weight: bolder; /* maps to 700 */
}

.box-4 {
font-weight: 400;
}

.box-5 {
font-weight: bolder; /* maps to 700 */
}

.box-6 {
font-weight: bolder; /* maps to 900 */
}

.box-7 {
font-weight: 700;
}

.box-8 {
font-weight: bolder; /* maps to 900 */
}

.box-9 {
font-weight: bolder; /* maps to 900 */
}

.box-10 {
font-weight: lighter; /* maps to 700 */
}

.box-11 {
font-weight: lighter; /* maps to 400 */
}

.box-12 {
font-weight: lighter; /* maps to 100 */
}
[/code]

In this case, the “bolder” and “lighter” keywords will map only to the 100, 400, 700, and 900 values. With 9 different styles, these keywords will never map to the 200, 300, 500, 600, and 800 values.

This happens because you’re telling the browser to choose the next font in the series that is considered either ‘bold’ or ‘light’. So it’s not picking the next boldest or the next lightest, but merely a bold or light font relative to what is inherited. If, however, the lightest font started at 300 (as in the case of Open Sans), and the inherited value was 400, then a value of “lighter” would map to 300.

This might all be a bit confusing at first, but you can fiddle around with the demo to see how these keywords work.

3. There is an outline-offset property

The outline property is pretty well known due to its ability to help in debugging (it doesn’t affect page flow). The spec, however, has added an outline-offset property, which does exactly what its name suggests — it lets you define how far the outline should be offset from the element.

See the Pen The outline-offset property by SitePoint (@SitePoint) on CodePen.

In the demo above, move the range slider left or right to see the outline offset change. The range in this example covers 0px to 30px, but you could go as large as you want in the CSS. Take note that although the outline property is a shorthand property, it doesn’t include outline-offset, so you always have to define outline-offset separately.

The only major drawback to the outline-offset property is the fact that it’s supported in every browser except Internet Explorer (not even IE 11).

4. There is a table-layout property

You’re probably thinking, Old news. I know all about display: table, bruh. Easiest way to vertically center! But that’s not what I’m talking about. Notice I said the table-layout property, not the display property.

The table-layout property isn’t the easiest CSS feature to explain so let’s first go to the spec, and then look at an example. The spec says:

Continue reading %12 Little-Known CSS Facts (The Sequel)%

jQuery 3.0 and jQuery Compat 3.0 Alpha Versions Released

Mo, 2015-07-13 23:11

It’s been a long time since we did a major release, and you certainly deserve one. So we’re glad to announce the first alpha of jQuery 3.0!

Despite the 3.0 version number, we anticipate that these releases shouldn’t be too much trouble when it comes to upgrading existing code. Yes, there are a few breaking changes that justified the major version bump, but we’re hopeful these breakages don’t actually affect that many people. The jQuery Migrate plugin can help you to identify compatibility issues in your code as well. Your feedback on the changes in this alpha will help us greatly, so please try it out on your existing code and plugins!

There are actually two releases here. First is jQuery 3.0, which supports modern browsers and environments from IE9 forward. Second is jQuery Compat 3.0, which includes support for IE8. As an added bonus, both jQuery and jQuery Compat will include support for Yandex.Browser, a freeware browser released in 2012. You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.0.0-alpha1.js

https://code.jquery.com/jquery-compat-3.0.0-alpha1.js

You can also get the alpha versions from npm:

npm install jquery@3.0.0-alpha1

npm install jquery-compat@3.0.0-alpha1

 

Major changes

Below are just the highlights of the major new features, improvements, and bug fixes in these releases. A complete list of changes is available at the bottom of this post and on our GitHub issue tracker. On GitHub, you can additionally see the features we expect to put in later beta and final versions that have yet to land.

Simplified .show() and .hide() methods

Everyone’s mental model of jQuery’s .hide() method is that it sets display: none in CSS. Conversely, .show() clears the display so that the element shows again (assuming its parents are not hidden). Simple, right?

Well, no. There are actually many complex special cases that people asked us to “fix” over the years, which turned these methods into a convoluted confluence of principles. For example, what if the element is set to display: none in a stylesheet? jQuery would try to override that by forcing display: block on the element directly. Okay, but what if a normally block element like <li> was set to display: inline by a different stylesheet rule? How about the case where you call these methods on an element before it’s been added to the document and we don’t know what display value it will have? Determining all of that takes extra work. Sometimes it’s still just a guess that turns out to be wrong.

Since these methods add a style attribute to the element, they don’t tend to play well with techniques like responsive design where the visibility of elements may also be set by media queries. This leads to the need for jQuery handlers that listen for the orientationchange or resize events and manually hide or show parts of the page; it defeats the elegant solution that media queries were trying to implement.

You can see that jQuery was already about halfway down the path to total madness, and it didn’t make sense to complete the journey. The special cases and checks were not only complex and incomplete, but they caused significant performance issues on large pages.

So, instead, we’re experimentally defying the evolution of these methods and reverting to a simple, primordial model. This will break some code. If you have elements in a stylesheet that are set to display: none, the .show() method will no longer override that. So the most important rule for moving to jQuery 3.0 is this: Don’t use a stylesheet to set the default of display: none and then try to use .show() – or any method that shows elements, such as .slideDown() and .fadeIn() – to make it visible.

If you need an element to be hidden by default, the best way is to add a class name like “hidden” to the element and define that class to be display: none in a stylesheet. Then you can add or remove that class using jQuery’s .addClass() and .removeClass() methods to control visibility. Alternately, you can have a .ready() handler call .hide() on the elements before they are displayed on the page. Or, if you really must retain the stylesheet default, you can use .css("display", "block") (or the appropriate display value) to override the stylesheet.

We know that this is likely to be one of the most contentious and difficult changes in jQuery 3.0, so we wanted to put it out in this early release to see the effects. Please let us know how it affects your code and what you need to change in order to work with this new model.

https://github.com/jquery/jquery/issues/1767
https://github.com/jquery/jquery/issues/2057
https://github.com/jquery/jquery/issues/2308

Special case with .data() names

We have updated our .data() implementation to closer match the HTML5 dataset specification. All keys are now converted from kebab-case to camelCase, regardless of access method, and digits no longer participate in the conversion. For example, we will no longer differentiate between “foo-bar” and “fooBar”, but will differentiate between “foo-42” and “foo42”. These changes will mainly come into play when retrieving all data by calling .data() with no arguments, or when trying to access the data using a converted key (.data(“foo42”)) instead of the original (.data(“foo-42”)).

https://github.com/jquery/jquery/issues/1751

jQuery.Deferred is now Promises/A+ compatible

jQuery.Deferred objects have been updated for compatibility with Promises/A+ and ES2015 Promises, verified with the Promises/A+ Compliance Test Suite. This meant the introduction of a .catch() method and some major changes to the .then() method:

  • An exception thrown in a .then() callback now becomes a rejection value. Previously, exceptions bubbled all the way up, aborting callback execution and irreversibly locking both the parent and child Deferred objects.
  • The resolution state of a Deferred created by .then() is now controlled by its callbacks—exceptions become rejection values and non-thenable returns become fulfillment values. Previously, returns from rejection handlers became rejection values.
  • Callbacks are always invoked asynchronously. Previously, they would be called immediately upon binding or resolution, whichever came last.
  • Progress callbacks can no longer resolve Deferred objects to which they are bound.

Consider the following, in which a parent Deferred is rejected and a child callback generates an exception:

var parent = jQuery.Deferred(); var child = parent.then( null, function() { return "bar"; }); var callback = function( state ) { return function( value ) { console.log( state, value ); throw new Error( "baz" ); }; }; var grandchildren = [ child.then( callback( "fulfilled" ), callback( "rejected" ) ), child.then( callback( "fulfilled" ), callback( "rejected" ) ) ]; parent.reject( "foo" ); console.log( "parent resolved" );

As of jQuery 3.0, this will log “parent resolved” before invoking any callback, each child callback will then log “fulfilled bar”, and the grandchildren will be rejected with Error “baz”. In previous versions, this would log “rejected bar” (the child Deferred having been rejected instead of fulfilled) once and then immediately terminate with uncaught Error “baz” (“parent resolved” not being logged and the grandchildren remaining unresolved).

While caught exceptions had advantages for in-browser debugging, it is far more declarative (i.e. explicit) to handle them with rejection callbacks. Keep in mind that this places the responsibility on you to always add at least one rejection callback when working with promises. Otherwise, any errors will go unnoticed.

Legacy behavior can be recovered by replacing use of .then() with the now-deprecated .pipe() method (which has an identical signature).

jQuery.when has also been updated to accept any thenable object, which includes native Promise objects.

https://github.com/jquery/jquery/issues/1722
https://github.com/jquery/jquery/issues/2102

Removed special-case Deferred methods in jQuery.ajax

jqXHR object is a Promise, but also has extra methods like .abort() so that you can stop a request after it has been made.

As users increasingly embrace the Promise pattern for asynchronous work like AJAX, the idea of having special cases for the Promise returned by jQuery.ajax is an increasingly bad idea.

success, error, complete
done, fail, always

Note that this does not have any impact at all on the callbacks of the same name, which continue to exist and are not deprecated. This only affects the Promise methods!

https://github.com/jquery/jquery/issues/2084

Error cases don’t silently fail

Perhaps in a profound moment you’ve wondered, “What is the offset of a window?” Then you probably realized that is a crazy question – how can a window even have an offset?

In the past, jQuery has sometimes tried to make cases like this return something rather than having them throw errors. In this particular case of asking for the offset of a window, the answer up to now has been { top: 0, left: 0 } With this alpha of jQuery 3.0 we’re experimenting with the idea of having such cases throw errors so that crazy requests aren’t silently ignored. Please try the alpha and see if there is any code out there depending on jQuery to mask problems with invalid inputs.

https://github.com/jquery/jquery/issues/1784

.width(), .height(), .css(“width”), and .css(“height”) to return decimal values (whenever the browser does)

Previously, jQuery rounded values when retrieving width and height. Some browsers return subpixel values – such as IE and Firefox – and sometimes users need this precision when relying on these values for layout. We don’t expect this change to have a big impact on your code, but let us know if it does.

https://github.com/jquery/jquery/issues/1724

Removed deprecated event aliases

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.

https://github.com/jquery/jquery/issues/2286

jQuery.swap, jQuery.buildFragment, and jQuery.domManip are no longer accessible on the jQuery object

These methods were always intended for internal use only and were never documented. We are finally making them private to avoid confusion.

https://github.com/jquery/jquery/issues/2224
https://github.com/jquery/jquery/issues/2225

Animations now use requestAnimationFrame

On platforms that support the requestAnimationFrame API, which is pretty much everywhere but IE8 and IE9, jQuery will now use that API when performing animations. This should result in animations that are smoother and use less CPU time – and save battery as well on mobile devices.

jQuery tried using requestAnimationFrame a few years back but there were serious compatibility issues with existing code so we had to back it out. We think we’ve beaten most of those issues by suspending animations while a browser tab is out of view. Still, any code that depends on animations to always run in nearly real-time is making an unrealistic assumption.

.unwrap( selector )

Before jQuery 3.0, the .unwrap() method did not take any arguments. The selector parameter offers a way to be specific about which wrappers to remove.

https://github.com/jquery/jquery/issues/1744

Massive speedups for some jQuery custom selectors

Thanks to some detective work by Paul Irish at Google, we identified some cases where we could skip a bunch of extra work when custom selectors like :visible are used many times in the same document. That particular case is up to 17 times faster now!

Keep in mind that even with this improvement, selectors like :visible and :hidden can be expensive because they depend on the browser to determine whether elements are actually displaying on the page. That may require, in the worst case, a complete recalculation of CSS styles and page layout! While we don’t discourage their use in most cases, we recommend testing your pages to determine if these selectors are causing performance issues.

https://github.com/jquery/jquery/issues/2042

  Thanks

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Chris Antaki, Jason Bedard, Leonardo Braga, Bastian Buchholz, Anne-Gaelle Colom, David Corbacho, Brenard Cubacub, Hamish Dickson, Ben Edelman, Stephen Edgar, elas7, flexphperia, Corey Frang, Xue Fuqiao, Oleg Gaidarenko, Richard Gibson, Michał Gołębiowski, Scott González, goob, Veaceslav Grimalschi, Mu Haibao, Dan Hart, Frederic Hemberger, Nicolas Henry, Daniel Herman, Jon Hester, Victor Homyakov, Winston Howes, Daniel Husar, Essam Al Joubori, Veres Lajos, George Mauer, Richard McDaniel, Amit Merchant, Calvin Metcalf, Dave Methvin, MightyBranch, Nazar Mokrynskyi, Matthew Mueller, Martin Naumann, Alexander O’Mara, Randson Oliveira, Gilad Peleg, James Pearce, PJ, Senya Pugach, Aditya Raghavan, Chris Rebert, Aurelio De Rosa, Gabriel Schulhof, Mike Sidorov, Nick Stefan, Arthur Stolyar, Timo Tijhof, Ben Toews, Thomas Tortorini, Shivaji Varma, Arthur Verschaeve, Rick Waldron, Bin Xin, Imran M Yousuf, Jörn Zaefferer.

  Changes

Here is the full list of changes since the last official releases (1.11.3 and 2.1.4):

  Common to both jQuery and jQuery Compat Ajax
  • Always use script injection in globalEval (#14757, bbdfbb4)
  • Remove jsonp callbacks through “jQuery#removeProp” method (#2323, a2ae215)
  • remove event dependency from the ajax module (4e7f34f)
  • Fix for request aborted in ajaxSend (#1775, 598ed05)
  • use anchor tag for parsing urls (#1875, b091fdb)
  • Fix cross-domain detection test for non-default port (83b038f)
  • $.post and $.get can now take an options object (#1986, 89ce0af)
  • simplify one ajax call and add explanatory comment (0ac28ed)
  • make jQuery#load “type” field explicit (4ef120d)
  • replace “jqXHR.complete” callback with “always” (97ef1f2)
  • remove deprecated extensions from ajax promise (#2084, 9d1b989)
  • remove use of jQuery#each second argument (a4715f4)
  • remove “onunload” event handler (a117dd0)
  • Remove remnants of the load event alias handling (38a6697)
Attributes
  • add SVG class manipulation (#2199, 20aaed3)
  • return null when attribute does not exist (#2118, aaeed53)
  • Use the option val hook in select val hook and simplify it (#1902, f6302b0)
  • remove unnecessary element null check (55ac56a)
  • fix failing test for new return value (5dc4616)
  • revert returning null for non-elements (7632b74)
  • revert returning null for non-existant attributes (2905961)
Build
  • update Sizzle to 2.0.0 (bcca4f0)
  • Update grunt-contrib-jshint (1556c46)
  • remove bower.json lint target (285cfbf)
  • add mailmap entry (3ec73ef)
  • Update the license attribute (#2331, 8e92e1e)
  • drop bower; use npm for front-end deps (#15186, e1949f4)
  • update front-end dependencies (8356948)
  • update node dependencies barring jscs (8e3a0ce)
  • update grunt-jscs-checker and pass with the new rules (c869a1e)
  • update requirejs dependency to 2.1.17 (#2290, a644101)
  • update source map options for the new grunt jshint (269a27c)
  • bower.json: remove moot `version` field (61e21a4)
  • fix broken assertions caused by QUnit update (8b6aeae)
  • Update commitplease dev dependency (39b7606)
  • remove deprecated JSHint options (34da7d5)
  • update AUTHORS.txt (8f13997)
  • Upgrade to commitplease 2.0.0 (5bc1ddc)
  • Update QUnit to latest (1.17.1) (2d5c5d2)
  • update version to 3.0.0-pre (7a607c5)
  • Move test to appropriate module (fbdbb6f)
  • Fix various typos (dc4b914)
  • Speed up the Travis build (31f4f8e)
  • Remove empty define({}) from build output (#1768, 2c1b556)
  • Remove npm from dependencies (b92acf7)
  • Upgrade to grunt-bowercopy 1.0.0 (323e82c)
  • Remove unused Sizzle test files (8d11310)
  • fix tests in AMD mode (6051609)
  • Move all external libraries to external directory (c5d9d88)
  • account for version labels in Sizzle versions (#1939, 78ac753)
  • update node dependencies (9101704)
  • Sizzle version labels must start with a dash (d6c97ab)
  • Don’t assume the browser environment; smoke test on Node w/ jsdom (#1950, 76df9e4)
  • Remove dates from copyright notice (66e1b6b)
  • Specify valid components for commit messages (0c9d018)
  • ignore test dependencies for npm install (35f8e15)
  • update Sizzle to 1.11.1 and include license (c0b23e2)
  • update Sizzle (#2042, #1969, 3a0dd5a)
  • update grunt-bowercopy (712e78c)
  • Update license (4f776e5)
  • Sanctify the component name status of Wrap (a4133ff)
  • Update native-promise-only (again) (f5aa89a)
  • Rearrange grunt/npm tasks into a build/dist/test pattern (bb928bd)
  • Update native-promise-only (0065e1f)
  • save sinon update for later (#2160, 98c25b7)
Callbacks Core
  • Return empty array instead of null for parseHTML(“”) (#1997, 4116914)
  • use document.implemenation.createHTMLDocument in jQuery.parseHTML (58c2460)
  • Follow the AMD specification for define (892625b)
  • Throw an error on $(“#”) rather than returning 0-length collection (80022c8)
  • allow init to accept an alternate rootjQuery for migrate’s sake (#2101, 7a6931d)
  • remove unnecessary support test for createHTMLDocument (5923282)
  • pass empty string to createHTMLDocument to appease IE (31c7d7f)
  • revert addition of createHTMLDocument. Thanks, Safari 8. (b779831)
  • Update tested jsdom, drop obsolete workarounds (#2153, 06f6cd1)
  • re-introduce createHTMLDocument in parseHTML; Safari 8 left out (cfe468f)
  • Standardize indexOf comparisons (53aa87f)
  • remove custom ready event (#2264, c252c5f)
  • Consistently use local reference to access() (2fb719e)
  • Remove deprecated context and selector properties (#1908, 0ea8c32)
  • remove isArraylike check for nodes (#2238, 436f0ae)
  • add support to tag-hyphenated elements (534f130)
  • Use window.setTimeout & friends instead of global equivalents (#2177, 219c749)
  • Drop size and andSelf methods (#1749, f110360)
  • Drop strundefined variable (29838b6)
  • Make jQuery objects iterable (#1693, bb026fc)
  • add workaround for iOS JIT error in isArrayLike (#2145, 1541664)
  • Test all factory use cases from intro.js (#2181, ab40725)
  • Switch from modules to just window.setTimeout etc. (842958e)
  • Align branches: remove an unused variable, add comments (f6de5a9)
  • simplify “each” stylesheet iteration test (fcb6c4d)
  • Simplify and speed up .each (eeda11c)
  • organize prop & attr code to be similar (5153b53)
  • change jQuery.each and jQuery#each signatures (#2090, 2380028)
CSS
  • CSS:Event: simplification of native method signatures (85577a3)
  • Fix the “sanity check” test (995f707)
  • Remove non-functional unit test for negative margin (4ab7431)
  • Add an integration test for issue gh-1764 (8887106)
  • Remove use of getDefaultComputedStyle (#15227, 274feb5)
  • Use pre-defined displays for html and body (a772418)
  • Correct typo in the comment (7e09619)
  • Removed redundant “to the number” in comment (895ea68)
  • fix :visible/:hidden selectors for inline element w/ content (#2227, 79bcb29)
  • Support relative adjustment in any applicable unit (#1711, 9b03f6d)
  • elements are hidden when either offsetWidth or offsetHeight is zero (#10406, #13132, 10399dd)
  • Ignore the CSS cascade in show()/hide()/etc. (#1767, #2071, 86419b1)
  • Fix the pixelMarginRight support test in Android 2.3 (cdfc2d0)
  • Clean up memory leak in reliableMarginRight (#1795, 7d15b4d)
  • Don’t cache unrecognized CSS property names (#2015, d471842)
  • Don’t name the anonymous swap function (0019a46)
  • make the getStyles function more readable (3a0d582)
  • Work around an IE11 fullscreen dimensions bug (#1764, 90d828b)
  • Add unit tests for negative margins and positioning (1b932bb)
  • simplify “defaultDisplay” module (c62486f)
  • Make .css(“width”) & .css(“height”) return fractional values (#1724, b60b26e)
  • Don’t expose jQuery.swap (#2058, bb4d888)
  • Improve a comment explaining IE11 fullscreen bug (8e4aac8)
Data
  • do not include digits when camelCasing (#1751, 2862a07)
  • always camelCase keys in .data() (#2257, 0e79098)
  • Use a PDF object instead of a Java applet for acceptData testing (#1938, 087d280)
  • camelCasing should not ignore case (#2070, 172cad8)
Deferred Dimensions
  • allow modification of coordinates argument (#1848, f7e60dc)
Docs
  • 1.x-master branch -> compat branch; 2.x branch -> master branch (758fd6c)
  • correct grunt command in README.md (#1850, 9d6beac)
  • remove redundant instruction from the readme (#2359, 3c92770)
  • Clarify custom build instructions (a3779bc)
Effects
  • Adding unit tests for jQuery.Animation (b3b2d6c)
  • Reintroduce use of requestAnimationFrame (#15147, 72119e0)
  • add tests for jQuery.easing._default in Animation and Tween (6d7ef56)
  • set default easing using jQuery.easing._default (#2219, 5f2ea40)
  • Add tests for jQuery.Tween (cdaed15)
  • Improve raf logic (708764f)
Events
  • remove preDispatch hook & simplify “simulate” signature (3655c4e)
  • remove guard for falsy handler argument of jQuery#on method (fac67a9)
  • add support comment (9db9316)
  • correct support comment (361a0d5)
  • HTML5 drop events inherit from MouseEvent (#2009, d7e5fce)
  • Fully clean up events in unit test (4467ed6)
  • Empty namespaces should be uneventfully ignored (8653068)
  • remove outdated originalEvent hack (6df669f)
  • Remove fake originalEvent from jQuery.Event.simulate (#2300, 7475d5d)
  • fix incorrect window bug with scrollTop/Left in iframes (#1945, d21edb5)
  • remove deprecated event aliases (#2286, 0705be4)
  • Add a note about a mouseenter bug in Chrome (a5e1c9b)
  • Restore the `constructor` property on jQuery.Event prototype (#15090, b807aed)
  • Copy detail property to jQuery.Event on native events (#1867, d9ed166)
  • Remove an internal argument to the on method (04a2969)
  • Normalize mouse event properties in drag events (#1925, 97cf528)
  • provide verbose comment for focus(in | out) & rename support prop (c074006)
  • remove redundant guards for the event methods (#2047, a873558)
Manipulation Misc
  • Drop support for older browsers; update support comments (740e190)
  • Need for speed removed by 9ad6e7e (ff928f5)
  • Mac OS is now OS X, thanks @xfq (d30c482)
Offset
  • remove ownerDocument check in offset getter (#2115, 6176567)
  • Round offset value for the sake of floating errors (#2147, 62ae2d0)
  • return zeros for disconnected/hidden elements (#2310, 40dcc76)
  • Fix .offset() to correctly work with ShadowDOM (#1784, 1617479)
  • account for scroll when calculating position (#1708, 2d71594)
  • don’t run scrollTop/scrollLeft iframe test in Android 2.3 & 4.0 (#1981, 0c46643)
  • return before getBoundingClientRect to avoid error in IE8-11 (0e4477c)
  • add tests for hidden elements + scroll (b041242)
  • simplify jQuery#offsetParent method (74ae544)
README
  • Fix punctuation in tile (df62159)
  • Fix minor style issues. Thanks @MightyBranch! (edfc94d)
  • update the Homebrew site address (b410b15)
  • various text fixes (31b63fc)
  • Update the description of the deprecated module (1d75273)
  • Improve build instructions (2e9c1ea)
Release
  • update AUTHORS.txt (e905dcd)
  • Remove copying of jquery-latest files (c34ed46)
  • properly set the dist remote when it’s a real release (c44dd77)
  • bower.json is actually generated from scratch (61224f5)
  • Distribute files to distribution repo (#1869, #1673, #2045, 26eca14)
  • dist can be run during a test (aae998b)
  • push dist to same remote as project (1ba45fc)
  • remove sourcemap comment from all copies of minified file (#1707, a76c781)
  • fix CDN archive creation (#1940, e0673df)
Selector/Sizzle
  • add jQuery.uniqueSort; deprecate jQuery.unique (#2228, e1090c3)
  • add test for jQuery.unique() alias (add85af)
  • Remove “#” exception for identifier tokens (86e62d8)
  • update to 2.1.1 (7602dc7)
Support
  • Re-organize browser order, add Safari 8 (43faf6d)
  • Correct iOS 8 support test results, re-arrange entries (ce308e2)
Tests
  • Update QUnit (6748ba3)
  • Minor updates for QUnit 1.16 compatibility (26276a3)
  • Accommodate page changes from the QUnit HTML reporter (3c13f4c)
  • Increase QUnit timeout (ff18d8e)
  • Tilt at a few style guide windmills (906caeb)
  • Correct a typo in the regex matching Safari 8 (c17543f)
  • Add Microsoft Edge results (from Windows 10 build 10130) (8e111df)
  • Remove Edge version from the user agent (5a1217e)
  • Remove test/data/ua.txt (#2398, e831856)
  • fix tests in accordance with new :visible behavior (16713fb)
  • add the current version of node and iojs to the travis config (bd9a138)
  • Expand CSS relative adjustment tolerance for IE (e22ef5d)
  • Fix CSS relative adjustment test for round-down browsers (48be675)
  • Lower the checks rounding error (a44cfa0)
  • make top of the HTML suite compliant with style guide (8356281)
Wrap
  • Support .unwrap( selector) for selective unwrapping (#1744, 7b09235)
  jQuery 3.0 Only Ajax
  • Remove workaround for IE6/7 (e519098)
  • simplify jQuery.parseXML method (5a0867d)
Build
  • use different versions of jsdom for Node and iojs testing (#2266, 5c3101f)
  • Refactor Node smoke tests (9c8a3ec)
  • Moved JSHint directives to .jshintrc file (15a609f)
CSS
  • save 20 bytes in css/support (45ec73f)
  • Collapse a double if statement into one (7855a1a)
  • Restore the hack to get pixels for .css(‘width’) etc. (3747cc6)
Data
  • shave off a couple of bytes (6f65f5f)
  • avoid Object.defineProperties for nodes (#1728, 95fb798)
  • avoid non-alphanumeric chars in expando properties (0cdec79)
  • updates to element[expando] cache (222ac3a)
  • move element cache to element[expando] (#1734, d702b76)
  • remove some unused code (764dc94)
  • remove the expando when there’s no more data (#1760, 56bb677)
  • speed up $.fn.data() for camel-cased key (#1941, 72c4a06)
  • restore explicit data removal of private data in cleanData. (#2127, 332fd94)
  • Drop the tests relying on applets (#1938, 95c0a10)
Docs
  • Add info about Sizzle not being excludable on the compat branch (#2184, 062b526)
  • Fix README uppercase (b50e0f2)
Manipulation
  • Tolerate XMLNode host object input to getAll (#15151, 1ae025e)
  • Check state lost if the name is set for Android 4.0-4.3 (1bbb678)
Misc
  • Adjust comments & docs to dropping IE * Misc: Update all references to bugs.jquery.com (#1681, 3e89a53)
  • Remove leftover -moz-box-sizing in tests (e81b258)
Offset
  • Simplified a conditional (4287442)
  • don’t run scrollTop/scrollLeft iframe test in mobile Safari (4ab8603)
README
  • Add selector-native.js link. Thanks @randsonjs! (cfe2eae)
Tests
  • Remove a trailing comma for compatibility with the compat branch (dc8ba6a)
  jQuery Compat 3.0 only Ajax
  • Add support comment and fix code style issue (e38a94a)
  • Run the PATCH test only in IE8 on TestSwarm (#1994, 2524da0)
  • move explanatory comment to appropriate place (04fc801)
  • Use the native XHR for all non-local requests in IE9+ (#1684, 61f812b)
  • Rename Spartan to Edge in a comment (8d88cd5)
  • Fix the XHR fallback logic for IE8 (bd699cb)
Attributes
  • Use typeof check for getAttribute method (075da30)
  • don’t test SVG CSS-class manipulation in IE8 (57fb2dc)
  • fix IE8 issues (f2bcf87)
Build
  • Point to files from the compat branch, not master (b7663ea)
  • Put “jQuery Compat” in banners in built files (8cd6875)
  • 1.x-master -> compat (2912ddd)
  • Add “timers_ie.js” file back to the repo (31e6697)
  • append “+compat” to tag version and jQuery.fn.jquery (#2269, d18b645)
  • Correct indentation issue (d0f27a7)
Callbacks
  • Change broken url to wayback one (e4cbc97)
Core
  • Align code in intro.js with master (fe2a584)
CSS
  • Add a support test for the hack for .css(‘marginRight’) etc. (25bc680)
  • Fix get upper case alpha opacity in IE8 (#1705, c5e8e12)
  • simplify hack of css getter for the computed values (dac716c)
  • fix dependency order for amd (e185aa3)
Data
  • use removeAttribute in cleanData to bypass Chrome bug (#1664, 9d1d90e)
Deferred
  • pass lint in new catch tests (203979d)
Docs Effects Events
  • Add reference to data module (2866da9)
  • correct an unfinished comment (ac23f91)
Manipulation
  • don’t test data-URI with script element in IE8 (503e545)
  • Plug an IE8 memory leak in noCloneEvent feature detect (#1840, faf295a)
  • Update html5shiv elements (#15241, a953389)
  • blacklist IE8 from running tests for tag-hyphenated elems (87bb713)
Misc Offset
  • allow offset setter to throw for disconnected elements (#2114, dc49f62)
  • getBounding doesn’t return width/height in IE8. Fixes test. (3b1de11)
  • fix iframe scrollTop/Left test for IE8 (d632699)
  • fix iframe scrollTop/Left test for IE8 and iPhone (62a333e)
  • revert to jQuery.contains for IE8’s sake (compat only) (6df3990)
  • no need to check for ownerDocument (523de77)
Tests
  • Restore IE8 workarounds (Sinon timers for IE & HTML5 shiv) (0b07c65)
Traversing
  • simplify jQuery#contents method (7230df1)

Fast WordPress Customizer Options with Kirki

Mo, 2015-07-13 19:00

One thing WordPress users have grown accustomed to, is easy, no code required theme customization options. The idea is: download a theme, activate it in the Themes panel, access the Customize panel, and start tweaking the theme’s colors, layout, fonts, etc., with just a mouse click.

WordPress offers theme developers the Customizer API. This is a clean, object-oriented set of methods that facilitate the creation of a consistent customization interface. On the Customize panel, users can easily make changes and live-preview them without having to mess with PHP or CSS code.

Developing theme options using the Customizer API, while being a straightforward and logical process, involves writing a certain amount of repetitive code. To cut down on some of the steps required to build functioning and safe Customizer options, Aristeides Stathopoulos has been developing a free and open-source plugin, Kirki.

In this post I’m going to show how to integrate Kirki into your WordPress theme and how to use it to build a few Customizer options.

What is Kirki?

Let’s hear what Kirki is about from the developer behind it:

Kirki is not a framework. It’s a toolkit allowing WordPress developers to use the Customizer and take advantage of its advanced features and flexibility by abstracting the code and making it easier for everyone to create beautiful and meaningful user experiences.

Kirki Documentation

I’d like to drive home two points about this toolkit.

Continue reading %Fast WordPress Customizer Options with Kirki%

How to Create Form-Based Directives in AngularJS

Mo, 2015-07-13 18:00

Enforcing complex business constraints against user submitted data poses unique challenges to a significant number of developers. Recently, my team and I were faced with such a challenge while writing an application at GiftCards.com. We needed to find a way to allow our customers to edit multiple products in a single view within our application, where each product had a unique set of validation rules.

This proved challenging because it required us to have multiple <form> tags within the HTML source and maintain a validation model per form instance. We tried many approaches, such as using ngRepeat to display the child forms, before settling on a solution. We would create one directive per product type (where each directive would have a <form> in its view) and have the directive bind to its parent controller. This allowed us to take advantage of Angular’s child / parent form inheritance to ensure the parent form was only valid if all child forms were valid.

In this tutorial we will build a simple product review screen (which highlights the key components of our current application). We will have two products, each with their own directive and each with unique validation rules. There will be a simple checkout button that will ensure that both forms are valid.

If you’re anxious to see this in action, you can jump straight to our demo, or download the code form our GitHub repo.

A Word about Directives

A directive is a block of HTML code that runs through AngularJS’s HTML compiler ($compile) and is appended to the DOM. The compiler is responsible for traversing the DOM looking for components it can turn into objects using other registered directives. Directives work within an isolated scope and maintain their own view. They are powerful tools that promote reusable components that can be shared across an entire application. For a quick refresher check out this SitePoint article or the AngularJS docs.

Directives solved our fundamental issue in two ways: first, each instance has an isolated scope, and second, the directive uses a compiler pass, whereby the compiler identifies a form element in the view’s HTML using Angular’s ngForm directive. This inbuilt directive allows multiple nested form elements, accepts an optional name attribute to instantiate a Form Controller, and will return with the form object.

And a Word about Form Controllers

When the compiler identifies any form object in the DOM, it will use the ngForm directive to instantiate a Form Controller object. This controller will scan for all input select and textarea elements and create the appropriate controls. The controls require a model attribute to set up two-way data binding and allow instant user feedback via various pre-built validation methods. Providing instant feedback to the consumer allows them to know which information is valid before making a HTTP request.

Pre-Built Validation Methods

Angular comes packaged with 14 standard validation methods. These include validators for min, max, required to name but a few. They are built to understand and operate with nearly all HTML5 input types and are cross-browser compliant.

[code language="js"]

Size:

The value is required!

[/code]

The example above shows the usage of the ngRequired directive validator in Angular. This validation ensures that the field is filled out before it is considered valid. It does not validate any of the data, just that the user has entered something. Having the attribute novalidate indicates that the browser should not validate upon submission.

Pro Tip: Do not set an action attribute on any Angular form. This will prevent Angular’s attempts to ensure the form is not submitted in a round trip manner.

Custom Validation Methods

Angular provides an extensive API to assist in the creation of custom validation rules. Using this API gives you the ability to create and extend your own validation rules for complex inputs not covered in the standard validations. My team and I rely on a few custom validation methods to run complex RegEx patterns that are used by our server. Without the ability to run the complex RegEx matchers we would potentially be sending incorrect data to our backend server. This would present the user with errors which causes a undesirable user experience. Custom validators use the directive syntax and require ngModel to be injected. More information can be found by consulting AngularJS’s Documentation.

Creating the Controller

With that out of the way, we can make a start on our application. You can find an overview of the controller code here.

The controller will be the heart of things. It only has a handful of responsibilities—its view will have a form element named parentForm, it will have only one property and its methods will consist of registerFormScope, validateChildForm, and checkout.

Controller Properties

We will need one property in the controller:

[code language="js"]
$scope.formsValid = false;
[/code]

This property is used to maintain a boolean state of the overall validity of the forms. We are using this property to disable the state of the “Checkout” button after it has been clicked.

Method: registerFormScope

[code language="js"]
$scope.registerFormScope = function (form, id) {
$scope.parentForm['childForm'+id] = form;
};
[/code]

When registerFormScope is called it will be passed a Form Controller along with the unique directive id created in the directive instantiation. This method will then append the form scope to the parent Form Controller.

Method: validateChildForm

This is the method that will be used to coordinate with the backend server which performs validation. It is is invoked when the user is editing content and it needs to go through additional validation. We conceptually don’t allow directives to perform any external communication.

Please note that I have omitted the backend component for the purposes of this tutorial. Instead I am rejecting or resolving a promise, based on whether the amount a user enters falls within a certain range (10 - 50 for product A and 25-500 for product B).

[code language="js"]
$scope.validateChildForm = function (form, data, product) {
// Reset the forms so they are no longer valid
$scope.formsValid = false;
var deferred = $q.defer();

// Logic to validate the form and data
// Must return either resolve(), or reject() on the promise.
$timeout(function () {
if (angular.isUndefined(data.amount)) {
return deferred.reject(['amount']);
}

if ((data.amount < product.minAmount) ||
(data.amount > product.maxAmount)) {
return deferred.reject(['amount']);
}

deferred.resolve();
});
return deferred.promise;
}
[/code]

Using the $q service allows the directives to adhere to an interface with a success and failure state. The nature of the application interface alters between “Edit” and “Save” depending on the editing of the model data. It should be noted that the model data is updated as soon as the user starts typing.

Method: Checkout

Clicking “Checkout” indicates a user has finished editing and desires to checkout. This actionable item will need to validate that all the forms loaded within the directives pass validation, before sending the model data to the server. The scope of this article will not cover the methods used to send data through to the server. I encourage you to explore using the $http service for all your client to server communications.

[code language="js"]
$scope.checkout = function () {
if($scope.parentForm.$valid) {
// Connect with the server to POST data
}
$scope.formsValid = $scope.parentForm.$valid;
};
[/code]

This method uses Angular’s ability for a child form to invalidate a parent form. The parent form is named parentForm to clearly illustrate its relationship to the child forms. When a childForm uses its $setValidity method, it will automatically ascend to the parent form to set the validity there. All forms within the parentForm must be valid for its internal $valid property to be true.

Creating Our Directives

Our directives must follow a common interface that allows complete interoperability and extensibility. The names of our directives depend on the product they contain.

You can find an overview of the directive code here (Product A) and here (Product B).

Isolated Directive Scope

Every directive that’s instantiated will obtain an isolated scope which is localized to the directive and has no knowledge of external attributes. AngularJS does however allow directives to be created that utilize parental scope methods and properties. When passing external attributes into the localized scope, you can indicate you want two-way data binding to be setup.

Our application will need a handful of external two-way data bound methods and properties:

[code language="js"]
scope: {
registerFormScope: '=',
giftData: '=',
validateChildForm: '=',
product: '='
},
[/code]

Method: registerFormScope

The first property in the directive’s local scope is the method which registers the local scope.form with the controller. The directive needs a conduit to pass the local Form Controller object to the main Controller.

Object: giftData

This is the centralized model data that will be used within the directive views. This information will be two-way data bound to ensure that the updates that happen in the Form Controller will propagate to the main Controller.

Continue reading %How to Create Form-Based Directives in AngularJS%

Streaming a Raspberry Pi Camera Into VR With JavaScript

Mo, 2015-07-13 18:00

I spent the week tinkering with a Raspberry Pi Camera and exploring ways to get it to stream images to a web browser. In this article, we'll explore the simplest and most effective way I found to stream images into client side JavaScript. In the end, we'll stream those images into the Virtual Reality viewer built in my earlier article on Filtering Reality with JavaScript and Google Cardboard.

What You'll Need

For this demo, you'll currently need a Raspberry Pi (I used the Raspberry Pi 2 Model B) with Raspbian installed (NOOBS has you covered here), an Internet connection for it (I recommend getting a Wi-Fi adaptor so your Pi can be relatively portable) and a Camera module.

If your Pi is brand new and not currently set up, follow the instructions on the Raspberry Pi NOOBS setup page to get your Pi ready to go.

If you've got a bunch of stuff on your Pi already, please make sure you back everything up as the installation process replaces various files. Hopefully everything should play nicely but it's always important to be on the safe side!

The Code

Our demo code that uses the camera data is accessible on GitHub for those eager to download and have a go.

Attaching Your Pi Camera

If you are new to the Raspberry Pi and attaching a camera, I'll cover it quickly here. Basically, there is a plastic container (called the flex cable connector) around the opening which you'll want to gently open. To do so, pull the tabs on the top of the connector upwards and towards the Ethernet port. Once you've got it loosened, you'll be able to slot in your camera's flex cable. The cable has a blue strip on it on one side, connect it so that side is facing the ethernet port. Be careful to keep the cable straight (don't place it into the slot at an angle, it should fit straight in). Here's a photo of my camera flex cable connected correctly to show what we're looking for here:

RPi Cam Web Interface

The easiest way I've found to stream images from the Pi camera was to use the RPi Cam Web Interface. You run a few basic terminal commands to install it and then it sets up your camera on an Apache server ready to use.

If you've installed Raspbian from scratch already, you may have also already enabled the camera in the config screen that appeared afterwards. If not, you can get to it by typing in the following command:

[bash]sudo raspi-config[/bash]

On that screen, you'll be able to select "Enable Camera", click that option and and choose "Enable" from the screen that appears.

Next up, make sure your Raspberry Pi is up to date (before doing this, I want to reiterate - back things up to be safe). We start by downloading the latest repository package lists:

[bash]sudo apt-get update[/bash]

We then make any updates to existing repositories on our Pi that we might have found:

[bash]sudo apt-get dist-upgrade[/bash]

Finally, we update our Raspberry Pi software itself too:

[bash]sudo rpi-update[/bash]

Then, we install the RPi Cam Web Interface itself from its GitHub repo. Go to the location on your Pi that you'd like to clone the repo to and run the git clone command:

[bash]git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git[/bash]

This will create a RPi_Cam_Web_Interface folder ready with a bash installer. Firstly, go to that directory:

[bash]cd RPi_Cam_Web_Interface[/bash]

Update the permissions on the bash file so you can run it:

[bash]chmod u+x RPi_Cam_Web_Interface_Installer.sh[/bash]

Then run the bash install program:

[bash]./RPi_Cam_Web_Interface_Installer.sh install[/bash]

The install program has slightly more of a visual interface. I personally installed it via the Apache server option (the first option), so the following will all focus on that method. If you prefer to use an Nginx server, you can. I'd imagine much of the process is relatively similar though.

You'll then specify where you'd like to place the RPi Cam Web Interface on your server's /var/www directory. If you don't list anything, it will install in the root /var/www folder. I installed it in a folder called picam to keep it separate.

On the next screen, I selected "yes" to whether I wanted the camera to auto start on boot time.

Continue reading %Streaming a Raspberry Pi Camera Into VR With JavaScript%

The Ultimate Guide to Online Communities for Entrepreneurs

Mo, 2015-07-13 16:00

Human beings are naturally tribal. Unlike those holier-than-thou sea turtles, we bipeds are drawn toward other members of our species with similar interests, characteristics and backgrounds. Fortunately, this biological quirk isn’t thwarted by the anonymity of cyberspace. There are an unimaginable number of online communities floating around your silly human head right now, some of […]

Continue reading %The Ultimate Guide to Online Communities for Entrepreneurs%

Caching Hat-trick: Varnish, Memcached and PHP libraries

Mo, 2015-07-13 16:00

Previously, we looked at some common caching mechanisms we can easily utilize to make our apps faster. In this part, we’ll walk through some of the additional software that we can use with PHP for caching.

Memcached

Memcached is an in-memory key-value store. You can use it to store things like strings, numeric values, objects and arrays.

Installing Memcached

You can execute the command below to install memcached on ubuntu or other debian based OS:

sudo apt-get install memcached

To make it work with PHP, you also need to install the PHP extension:

sudo apt-get install php5-memcached

To check if memcached is working, look for ‘memcached’ in the output returned when you call the phpinfo() method from a page. You should see something similar to the following:

Continue reading %Caching Hat-trick: Varnish, Memcached and PHP libraries%

Enumerated Types with ActiveRecord and PostgreSQL

Mo, 2015-07-13 14:00

An Enumerated Type (also called an “enum”) is a data type with a set of named elements, each of them having a different value that can be used as constants, among other things. An enum can be implemented in various languages and frameworks, and in this article we will implement an enum in a Ruby […]

Continue reading %Enumerated Types with ActiveRecord and PostgreSQL%

Caching Hat-trick: Zend Opcache, Etags and Query Caching

Sa, 2015-07-11 16:00

In this article, we will be looking at some of the common caching techniques in PHP: Opcache, Expires Headers and Query Caching in MySQL. We’ll look at additional approaches in part 2.

PHP’s Request Lifecycle

Before we move on, it’s important to understand PHP’s request lifecycle. What happens behind the scenes when you access a PHP file from the browser?

  1. A file is fetched from the file system - it doesn’t really matter if it has changed since the last request.
  2. Lexical analysis - the human-readable code is converted into something (tokens) that the parser can understand.
  3. Parsing - the machine-readable strings are analyzed for potential errors. This is like grammar-checking.
  4. Opcode Creation - the tokens that we got from step 2 are converted into machine executable code.
  5. Machine code execution - machine code is processed and then executed.

For a more in-depth explanation, check out this article on how PHP echos a Hello World.

All of those steps happen really quickly, and yet there is a lot of time and resources wasted on every request. That is because for every request for each PHP file on the server, the server has to go through all of them.

The caching techniques that we will be going through in these two articles help bypass steps 2, 3 and 4. That means less time and fewer resources wasted, leading to faster page load times for the user.

Continue reading %Caching Hat-trick: Zend Opcache, Etags and Query Caching%

Interview: How to Join a Major Open Source Project

Fr, 2015-07-10 18:00

Recently, my co-editor Aurelio was invited to become a member of the jQuery team. To mark this spectacular achievement and to find out what’s involved in contributing to the most popular JavaScript library in use today, I took the opportunity to ask him a few questions.

To kick things off Aurelio, could you tell us something about yourself?

Sure. My name is Aurelio De Rosa. I’m a (full-stack) web developer living and working in London. I have more than 5 years’ professional experience programming for the web using HTML5, CSS3, Sass, JavaScript, and PHP. I’m a regular blogger for several networks, speaker, author of books, member of the jQuery team and the JoindIn team, and co-author of some academic papers. I’m also the technical reviewer of several online courses for Learnable and the book “HTML5 & CSS3 for the Real World, second edition”. Above all these things, I’m really passionate about everything related to the web (well, not everything…sorry Java). In my spare time I love to experiment, learn, contribute to open source projects, and have a few beers.

Wow! Sounds like you’re a busy guy. What made you decide to get involved with jQuery?

I don’t think I’ve ever really thought about being involved in jQuery as part of the team, it just happened.

Like many developers that have started working on the front end a few years ago, I lived in a world full of browsers issues and inconsistencies. jQuery was (and is) the best solution to avoid dealing with such issues in order to focus on what really mattered: the website. Everyone is aware of the good work that the jQuery team has done over the years and I think this year the web community has recognized the effort by voting to have the jQuery team as one of the finalists of the Net awards in the category “Team of the year” (vote for us!).

As the curious developer that I am, only working with jQuery wasn’t enough for me. So, I often read the documentation of methods I never used and sometimes I even read the source code to learn as much as I could. In performing these activities, I started finding minor inconsistencies or issues in the documentation that I promptly notified to the jQuery team of on GitHub. Sometimes I tried to fix these issues by submitting small pull requests. This is how I started in May 2013, by submitting a pull request to improve the jQuery documentation. I was happy because I was improving a project that I used on a daily basis and that I was really passionate about.

I see. And how did you approach the project?

I probably found the issue that I fixed with my first pull request while reading the documentation to verify something. Then, I started working on my book jQuery in Action, Third Edition and everything changed. When you write a book, you put a lot of effort into it and you go even deeper into the subject compared to what you used to do. This means that often I had to read the source to understand why a method was acting in a certain way or to confirm some statements I wrote in the book. This activity allows you to find documentation inconsistencies, errors, or even undocumented method signatures. For example not so long ago I found that wrapAll() acts like wrap() when passing a function to it, an issue that is corrected in the upcoming version 3 of jQuery.

Continue reading %Interview: How to Join a Major Open Source Project%

Create a Most Shared Posts Plugin for WordPress

Fr, 2015-07-10 17:00

Displaying a list of posts in a blog with the most number of shares is a good way to improve a site’s user navigation. In the case of WordPress, a widget is the ideal place for this. Users who wouldn’t otherwise know where to go after reading the current post might check out and hopefully participate in your blog’s most shared posts. These are commonly also the ones which have the most page views, and are likely to be of interest to more readers.

In this tutorial we’ll create a basic plugin to display the most shared posts in a widget. Although there are lots of plugins available for this purpose, many of them tend to be overwhelming and also don’t support caching. In this article, the plugin we’ll build will be lightweight and will cache the top ten most shared posts for the past six hours.

Continue reading %Create a Most Shared Posts Plugin for WordPress%

Extending an iOS App with WatchKit

Fr, 2015-07-10 15:00

In this tutorial I will show you how to extend an existing iOS app with WatchKit using a brain training app called “Brain Enhancer”. The Watchkit version of the app will be a pared down version of the full iOS app. It will be a different experience but within the context of the iOS app to avoid a disjoined experience between the two apps. The user should understand that they are still using the same app.

The Watch App will make use of glances and notifications. Once the user opens the Watch App, they’ll be able to interact with small versions of the quizzes. Think of these as bite size quizzes. This tutorial will show how to add functionality into the Watch App that allows the user to take the short quizzes.

Continue reading %Extending an iOS App with WatchKit%

6 Handy, Free Icon & Favicon Editors

Fr, 2015-07-10 14:00

Earlier in the year we looked at some handy, 'pre-fab' icons that were ready to plug straight into your mockups, prototypes and projects. But, being a designer, I know what it's like – sooner or later you need to generate your own.

While it's perfectly possible to use Photoshop or any other full-blown graphics software to create/edit icons, specialized editors can be helpful when it comes to focussing on a specialized task like icon design.

There are dozens of both free and paid icon editors out there, both web-based and desktop. Some offer very limited, task-focussed functionality and are perfect for small quick fixes. Other editors with a wider set of tools and they give you the freedom to author your icons exactly as you want them.

It's also worth noting that icon editors tend to fall into two categories:

a). Editors for producing favicons, Apple Touch icons (iOS) and app icons (PNGs and ICO files)
b). Icons for use in app and website UIs.

Let's start with the web-based editors. As a general rule they don't offer as much functionality as their desktop counterparts, but execute their core task efficiently. Icons tend to be small files, so they're well-suited for manipulation within a browser.

If you are looking for more advanced features, or perhaps larger, more complex icon sets, check the desktop apps for your OS.

1. X-Icon Editor

The first free icon editor we will look at is the web-based X-Icon editor. It runs in any browser above IE9 and it allows to create favicons for branding your browser address bar.

You can create icons in 4 sizes – 16x16, 24x24, 32x32, and 64x64. The tools it offers include standard ones, such as Brush, Pencil, Eyedropper, Line, Circle, Text tool, etc.

You can start with a blank canvas or import a jpg, gif, bmp, png, or an ico file, crop it as necessary and have your fav icon created in no time at all. X-Icon Editor doesn't offer much but it's fine if you want to create a nice fav icon in seconds.

2. Free Icon Maker

Free Icon Maker is another web-based editor. It has more functionality than X-Icon Editor but still it's not Photoshop. You can use it to modify an existing icon, or start a new one from scratch.

If you want, you can use the numerous icons and presets they provide for free. You can also import from your own SVG files. When you are done, you can download the whole bundle of PNG icons to your drive.

The editor is absolutely free to use (though the Try It For Free note on the homepage made me think they have a free trial only) but for most operations – i.e. upload and download of the created icons you need to register.

3. Junior Icon Editor

In comparison to the more limited choice of web-based icon editors, there are many more desktop ones, particularly for Windows. One of the best I've found is Junior Icon Editor, previously known as Free Icon Editor. This application is not only free but available across multiple platforms, such as Windows 8, 7, Vista, XP, 2003, 2000, ME, 98, 95, NT, iOS, Linux, Android, web and others.

Junior Icon Editor might have echoes of Paint but it is created especially with icons in mind. It works with multiple icon formats, such as ICO, PNG, XPM, XBM and ICPR. You can create not only standard-size icons but you can go with any custom size you need.

The color depths of the icons are up to 32-bit True Color with 8-bit alpha channel.

The tools that come with the program are really numerous. Some of the tools you fill find are a pencil, brush, flood fill, text tool, spray can, color replacer, color selector, line tool, rectangle, curve and ellipse.

4. IcoFX Portable

IcoFX is another free icon editor you might want to consider. It has a free and a paid version.

IcoFX works with Windows XP, Windows Vista, Windows 7 and Macintosh icons. This application has really a lot of features, such as the ability to convert Windows to Mac icons and vice versa, custom effects and filters, batch processing, icon manipulation inside exe files, etc. I am not sure all these options are available in the free version but even if some of them are not, it still offers more than most free editors. This is a mini Photoshop for icons.

Continue reading %6 Handy, Free Icon & Favicon Editors%

Uploading Files with Paperclip

Fr, 2015-07-10 14:00

Some time ago I wrote Better File Uploads with Dragonfly and Asynchronous File Uploads in Rails, two articles that covered Dragonfly, a nice gem to handle various attachments. In this article I am going to introduce Paperclip by Thoughtbot - probably, the most popular and feature-rich solution for integrating file uploading and management into an application.

One of the great things about Paperclip is its large and active community - this gem is constantly being updated and that's really important. You don't want to use a solution that will be abandoned in a year, do you?

We are going to observe all the main features of Paperclip and create a pretty simple but useful app featuring:

  • Basic file uploading
  • Validations and callbacks
  • Post-processing (with thumbnail generation)
  • Amazon S3

Continue reading %Uploading Files with Paperclip%

User Testing: Painful… But Worth It

Fr, 2015-07-10 05:23

Perhaps this is a familiar story. You’ve built a new website or app, dogfooded it with your team, and now you’re ready to test with real-life users. Excitedly, you gather a few people who are most likely to be your target audience, and begin the testing sessions.

Immediately you start getting some rather… painful feedback.

  • "I have no idea what this is"
  • "I would never use, or come back to this website”
  • "How do I log-in?” *Ignores giant log-in button*

User testing is often the moment where the rubber meets the road. All your ideas, decisions, sketches, and code comes together to create a real interface… one that a user is now attempting to use, and is forming their own ideas about.

It can be hard to watch.

Forgive me if my emotions are a bit raw from some recent feedback sessions, but I’d like to share a bit about the experience, and a few of the lessons I’ve learned along the way. Hopefully these tips can help you build better products… and not burst out crying in the middle of a user critique.

The humbling experience of testing Versioning

After a few weeks of working on Versioning, our new curation platform, with our developers, I headed to a local co-working space to watch web developers use the prototype. At this point we had a working web app. We’d been dogfooding it for a week, the SitePoint team was using it daily, and we really enjoyed it! While Versioning was rough around the edges, I thought we had a reasonably intuitive web app.

After three sessions, I was a lot less excited. People had NO CLUE what it was, or what it did. It was a hard truth - we had built something that wasn’t intuitive at all.

Testing can be a hard process. Here are a few bits of advice.

Continue reading %User Testing: Painful… But Worth It%