Michael Gaigg: Über UI/UX Design

24Apr0

Touch Event Support for jQuery UI

Posted by Michael Gaigg

Swipe

Swipe

Problem: jQuery UI doesn't support touch gestures

We are customizing a map application with swipe functionality which is based on some legacy code mash-up with dojo and jquery/jquery ui. Everything was nice and dandy until we tried swiping on the iPad for the first time. Bad awakening. jQuery UI user interface library does not support the use of touch events in their widgets and interactions. This means that our mouse event simply don't work on touch devices. One might think the jQuery toolkit would take care of it... but no!

Solution:

Solution A: For every mouse/keyboard event, provide the equivalent touch event: touchstart, touchmove, touchend,...

Solution B: Use a hack called jQuery UI Touch Punch that adds simulated events (that mimic touch events) to your app and respond to the mouse events you already have in your app. It's really simple:

<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js"></script>
<script src="jquery.ui.touch-punch.js"></script>

Add the jquery and jquery ui libraries (if you don't have them already or if you use older versions) plus the reference to your local copy of the touch-punch file (download the Development version!!)

Solution C: Go to github and get the really nice swipe story map template which works "out of the box" (but didn't satisfy our complex requirements)

19Apr0

Recommended usage of Dojo Topic (Publish/Subscribe)

Posted by Michael Gaigg

Communication between multiple object instances can be implemented using the global messaging mechanism of dojo/topic. It's like a centralized hub for publishing and subscribing to topics that are not bound to a particular object.

While the dojo reference guide documents a good usage example, I believe and strongly encourage you to implement pub/sub with the following signature:

// widget:
require(["dojo/topic"], function(topic){
	topic.publish("/filter/changed", this, { title: "My Blog", author: "Michael Gaigg" });
});
 
// controller:
require(["dojo/topic"], function(topic){
	topic.subscribe("/filter/changed", function (sender, args) {
		console.log("Title: " + args.title + " by " + args.author);
		this.headerWidget.updateTitle(args.title);
	});
});

While the topic.publish allows you to define any combination of parameters I found passing two parameters - sender and args - the most consistent and useful:

  • The first parameter is the sending object, i.e. the widget instance (this) that originates the publish
  • The second parameter is an object literal of arguments

One could use the sender to implement conditions within the subscriber. But the biggest advantage by far is that the signature is always the same and the amount and order of the arguments can be neglected. The code becomes more readable and easier to maintain.

One more note: Any widget can publish topics but only the controller should subscribe to these topics and then redirect actions back to the appropriate widgets, that is without introducing widget-specific logic at the controller level.

16Jun0

The Three-?-stick

Posted by Michael Gaigg

The Three-?-stick is going around ... and and so it came around. Björn from the Webzeugkoffer (excellent webdesign blog in German) picked up the stick by answering 3 questions that I will answer now too:

The three questions

Which Editor do you use for (X)HTML and CSS?

I'm using Macromedia Dreamweaver. I'm still stuck at MX 2004, but I really got used to the color coding and other superficial things - it's like toothpaste, once you are hooked you'll never change again (don't ask for the trade pls).

...and notepad 😉

Which little tool became a true time saver for you?

Can't live without Firebug - seriously, can't live without it. That's not a little tool? Ok, what about ColorSet, love that also.

Flash - what do you think of that technology?

Call me a purist, but I'm really into DHTML. Unless somebody convinces me otherwise I can do what I need to do with HTML a JavaScript library like jQuery, Dojo, YUI or even the Facebook JavaScript Library.
I disliked flash when it got into 'mode' a century ago and still think that flash intros should die. Accessibility is still an issue also.

On the flipside our company created a really powerful ArcGIS API for Flex for building Rich Internet applications on top of ArcGIS Server, our internet mapping server. I might need to reconsider some of my previous believes.

I forward the three-?-stick to