Cloud Four Blog

Technical notes, War stories and anecdotes

What’s New in hideShowPassword 2

Last June, we released our hideShowPassword plugin for improving the experience of password-entry (particularly on mobile devices). As of this writing, it’s our most-starred and most-forked project on GitHub.

We’ve released a handful of incremental and bug-fix updates since then, but today we’re shipping a full-fledged Version 2 with several noteworthy improvements.

Simpler Usage

The plugin’s “inner toggle” feature tended to steal the show, yet its syntax was verbose:

$(selector).hideShowPassword(true, { innerToggle: true });

We now support a simpler, shorthand syntax for enabling the inner toggle:

$(selector).hideShowPassword(true, true);
 
// enable toggle but hide till input focus:
$(selector).hideShowPassword(true, 'focus');
 
// using shorthand method:
$(selector).showPassword('focus');

Improved Accessibility

My personal favorite feature is the improved accessibility of the inner toggle button. Some changes we made based on real-world feedback:

  • The toggle button element is now a <button> by default (it was previously a <div>).

  • Several accessibility attributes have been added to better communicate the purpose and state of the button to assistive devices.

  • The toggle should now be keyboard-accessible, with space and enter key events attached where necessary.

We understand every project’s different, and you may need to tweak some of these new properties. Luckily, Version 2 also includes…

Overhauled Options

Just about anything we could make an option, we have. There are so many new options, we had to re-organize the options object to accommodate them all. See the full list here.

Built For jQuery and Zepto

Version 1 of hideShowPassword supported Zepto, but we’ve decided to simplify the plugin’s dependencies by only supporting jQuery from here on out. This makes sense to us for a few reasons:

  • Zepto’s data module was required, necessitating a custom build of Zepto to work at all.

  • The plugin’s inner toggle features could be unpredictable given Zepto’s simpler width and height calculation methods.

  • Zepto does not support AMD, and likely never will. We introduced AMD support to hideShowPassword in our first minor update based on developer feedback.

  • While Zepto’s modest file size remains an attractive feature, its performance once loaded may not be so competitive.

Get It Now!

All the aforementioned improvements (plus more fixes and tweaks) are available right now on GitHub (which is also a great place to report issues or request features). Check out the live demo if you remain unconvinced.

If you use the plugin in a project, please drop us a line and let us know. We’d love to hear about it!

SimpleSlideView: Controlling Flow With JavaScript

In July we released SimpleSlideView, a jQuery and Zepto plugin for simple, responsive sliding views (here’s a demo). In the last few months, I’ve noticed an uptick in developers emailing to ask a variation of this question:

How do I change or stop a view transition based on user input?

It’s a great question, and one that may not be immediately apparent from the demo alone.

When using SimpleSlideView, there are two ways to navigate between views. The simplest way is with HTML, which is great for predictable, non-dynamic interactions or prototyping:

<button data-pushview="#result">See Result</button>

The straightforwardness of this technique is a double-edged sword. It’s easy to use, but it’s also kind of static. What if we want to change the destination? Or prevent the transition altogether? For that, we’ll want to use JavaScript instead.

We can remove the data-pushview attribute from the button, but we’ll need some way to select it via JS, so let’s give it an ID:

<button id="result-btn">See Result</button>

And here’s the scripty part:

// Save the simpleSlideView instance to a variable
var slideView = $('#container').simpleSlideView();
// Add a click event handler to the button
$('#result-btn').click(function(){
  // On click, push the view with an ID of 'result'
  slideView.pushView('#result');
});

Right now this probably feels like a step backward. It’s more verbose. But we’ve gained the freedom to define the sliding-view behavior any way we like.

Suppose you only want to transition when certain criteria are met:

if (isValid) {
  slideView.pushView('#thanks');
} else {
  alert('Oops! Something seems off.');
}

Or maybe you’d like the next view to depend on the value of something else:

if (age < 21) {
  slideView.pushView('#soda');
} else {
  slideView.pushView('#beer');
}

Here’s a working example that uses Moment.js and your browser to determine the weekday of a date you provide. The result is populated before the view transitions, and only if Moment.isValid() returns true:

See the Pen Weekday (SimpleSlideView Demo) by Tyler Sticka (@tylersticka) on CodePen.

For more info on what you can do with SimpleSlideView and JavaScript, refer to the documentation on GitHub. If you’re using SimpleSlideView in your own projects, we’d love to hear about it!

Dan Bricklin on Responsive App Design

Have you seen Dan Bricklin‘s Responsive App Design video? Yes, that Dan Bricklin. The “father of the spreadsheet” Dan Bricklin.

I desperately wanted to include this video in my last article on when responsive design makes sense for your app. But it felt forced so it got cut.

The video is worth watching. It’s fun to hear Dan compare responsive design to the challenge of fitting a spreadsheet on a 40 character screen. Check it out.

Defining Responsiveness

When people say that something is responsive, what do they mean?

I’m not being facetious. I think many of us think we know what is meant, but when you dig deeper, there is disagreement about what it means for something to be responsive.1

Responsive web design has a clear definition

To his credit, Ethan defined responsive web design clearly with three technical pieces:

  • Fluid grids
  • Flexible images
  • Media queries

That seems simple enough. But when it comes to defining what is responsive, things get a bit fuzzier.

Is Google Plus responsive?

The best way to understand where the differences of opinion exist is by looking at an real life example: is Google Plus responsive?

It looks like it might be responsive. The layout varies from one, two or three columns depending on the width of the page. The size of elements on the page change as well.

Let’s look at some reasons why Google Plus might not be responsive.

Reason #1: Google Plus is not responsive because it has a separate mobile site

The first time I cited Google Plus as responsive example, I was told that it didn’t qualify as responsive because it doesn’t go all the way down to support small screens.

This is silly to me. Nothing in Ethan’s article says that responsive web design has to support any possible screen resolution.

We’re perfectly happy calling things responsive designs that have a fixed width past a certain point on wide screens. And we praise the efforts by the BBC, Guardian, People and others that build a responsive mdot site that will eventually replace their main site.

So why would the fact that Google Plus doesn’t support small screens preclude it from being considered responsive?

Reason #2: Google Plus doesn’t use media queries

Google Plus isn’t using media queries the way you might expect.

As far as I can tell2, none of the major layout changes you see in Google Plus are handled by media queries. They are controlled in JavaScript.

This is similar to Nathan Smith’s Adaptive.js library which puts breakpoints in JavaScript instead of CSS.

So by definition, Google Plus is not a responsive web design. It may look like one, but it doesn’t contain the three technical pieces necessary to be a responsive web design.

Getting off on a technicality?

So I exaggerated a bit. Google Plus is using media queries. But as I said, they aren’t being used the way we normally think of them.

All but one of the media queries is looking at viewport height instead of viewport width. The one that looks at viewport width only applies at less than 340px; only adjusts a single icon; and I can’t get the rest of the page to adapt to less than 340px so the entire media query seems moot.

But perhaps we can give Google Plus a pass as a responsive web design because it technically has media queries even if they aren’t being used to make the design responsive?

Nah, that’s cheating. And even if we did let Google Plus off on this technicality, it would still leave us with designs that use JavaScript like Adaptive.js and wondering what we call them.

When does something stop being a responsive web design?

What happens when you use responsive web design, but add to it things that seem to be at odds with the philosophy of responsive design?

For example, do any of these change whether or not something is a responsive web design:

  • Device detection used to select the best-sized source image?
  • Redirects based on user agent string to a mobile site that is responsive?
  • Less content on small screens with more content on larger screens? What if the developer uses AJAX to pull in the additional content? What if they use device detection to make decisions before the page loads and then AJAX after?
  • A couch-mode design that only worries about resolutions from 720p to 1080i but uses responsive web design techniques for those resolutions?

These questions may seem crazy, but I’ve seen people use the presence of device detection as a reason to discount a responsive web design.

When people are looking for reasons why a given implementation doesn’t fit their perspective on what responsive web design is good for, it is pretty easy to find reasons why any given site isn’t a “pure” responsive web design.

Doing responsive web design well often requires more than responsive web design

When a client comes to us to help them make their existing site or app responsive, we know that we’re going to be using fluid grids, flexible images and media queries.

But we also know we’re going to be using much more than just those three techniques. The best responsive web designs are doing much more. And when we teach workshops or train client teams, much of what we’re discussing are the things that you do after you’ve got the three techniques down.

Which led me to the idea that there is a difference between “being responsive” and responsive web design. That responsiveness was something bigger.

So I asked Ethan for his thoughts.

A more web appropriate design

As you might expect, Ethan had great thoughts on this topic. I’m republishing part of our email exchange here with his permission, but this is just a fraction of his insights. I hope he gets the time to share his thoughts in more detail.

I suggested that “being responsive” or “responsiveness” might be characterized by larger principles such as:

  • Designs that utilize the size of the viewport to determine the layout.
  • Designs that adjust the layout and the size of the elements in the layout as the size of the viewport changes.
  • Designs that ensure content parity across devices.
  • Designs that treat URLs as sacrosanct and ensure they work across devices.

Now, Ethan disagreed there was a need to revise the original definition. But he replied:

All of them—but the last two especially—seem to me to be pretty foundational tenets of good web design, full stop. If an interface doesn’t adapt to the display—be it responsive or device-specific—its utility is pretty limited; if it doesn’t honor and respect URLs—be it responsive or device-specific—its utility is pretty limited; and so on, and so on.

The web’s still digging itself out of the constraints of the printed page, in many ways, and we’re still—some twenty years on—trying to articulate the best way to design for this medium. What you’re describing feels bigger and more foundational to me than responsive design. It really feels like you’re describing the way the web wants to be: fluid, addressable, and accessible to all.

So Google Plus, to use your closing example, might not be responsive, but maybe it’s adopting a more web-appropriate design model. And maybe that’s enough.

I think Ethan is right. In the long run, “being responsive” is simply designing for the web the way it was intended.

But in the short run, I find myself struggling to describe the new toolbox and mindset that is required to do responsive web design well. And I see people talk past each other because of their mistaken belief that they have a common understanding of what responsive means.

I’m left with Justice Potter Stewart’s definition for whether or not something is responsive, “I know it when I see it”, which is wholly unsatisfying.

I take comfort ignoring the definitions and instead asking these questions about a design and its implementation:

  • Does it adapt to screen size?
  • Does it take advantage of device capabilities?
  • Is it accessible anywhere?
  • Does it work well?

For our users, those are the things that matter.


  1. Not addressed in here is the fact that responsive is also used in the web performance community to refer to something entirely different.
  2. Google Plus CSS and JS is quite complex. I’ve done my best to confirm they are using media queries only in the ways I’ve described here, but I can’t guarantee I’ve got it right.

  3. Don’t get me started on the definition of adaptive design. Unless I’m talking to Aaron Gustafson, I know I don’t know what someone means when they say that.

Why Chrome not shipping with Android 4.4 might not be a bad thing

Maximiliano Firtman broke the news a couple days ago that Android 4.4 (Kit Kat) will not ship to manufacturers with a browser:

At first blush, this seems like a bad thing especially for those of us who have been waiting so long for the Android browser to die and Chrome to take its place. However, I think this may actually be good news.

The first thing to keep in mind is that what ships to carriers and manufacturers is not the same thing as what ships to the store. Android doesn’t include Google Maps by default. If you want that on the phone you’re building, you have to license the Google apps services separately from Android’s open source code.

I attended the Mobile Summit during Google I/O earlier this year. One of the questions we asked was when will Chrome be the default browser for Android. The answer was that couldn’t say precisely because the handset manufacturer would have a say in the matter.

This has been one of Google’s biggest challenges with Android is the speed at which handset manufacturers adopt new versions of Android (if they ever do). Over the last year or so, Google has developed a strategy for addressing this problem.

Ron Amadeo wrote a great article for Ars Technica earlier this year that outlined how Google is now side-stepping the carriers and OEMs. In the article he describes how Google is using its Google Play Services which it licenses to OEMs as a way to keep applications on a frequent update cycle.

Google Play Services takes care of lower-level APIs and background services, and the other part of Google’s fragmentation takedown plan involves the Play Store. Google has been on a multi-year mission to decouple just about every non-system app from the OS for easy updating on the Play Store.

With that in mind, let’s go back to the question of Chrome. The slow pace of carrier and handset updates is the complete opposite of Chrome’s frequent release cycle. The Chrome team prides itself on the frequent releases and touts how they’re bringing that same release cycle to mobile.

If Google released Android 4.4 to carriers and handset manufacturers with Chrome installed, they would have no control over when Chrome is updated. By bundling it with Google services that the handset manufacturers sign up for and license, Google controls the app and how frequently it updates.

The big question is whether or not when a handset manufacturer signs up for Google services if Google forces the manufacturer to ship Chrome as the default browser. Because they dictate the terms of licensing of Google’s proprietary services and apps, I don’t see any reason why Google would put that condition on usage.

Yes, there is the potential that more devices will come out with browsers that aren’t using Chrome. But those are the Android-derived devices that don’t play in the Google apps space regardless. We’re talking about the Android devices in China or forks like the Amazon Kindle. It was unlikely they would use Chrome anyways so at least when they ship a browser, we’ll know it is something different.

But for end consumers and web developers, this seems like the best possible scenario. If you buy a phone that utilizes all the Google services we think of on Android (e.g., Google Maps, Gmail, Calendar, etc.), then you’ll get Chrome and I’m speculating here, but I suspect you get Chrome by default.

More importantly, you get real Chrome. The Chrome that updates every six weeks. And not a hobbled version of Chrome that would be limited by whims of the carriers and the manufacturers as to when it is updated.