• Home
  • Quick Start
    • Configurator
    • Download YUI 3
  • Documentation
    • User Guides
    • Examples
    • Tutorials
    • API Docs
  • Community
    • Gallery
    • Blog
    • Forums
    • YUI Theater
    • Calendar
  • Contribute
    • YUI on GitHub »
    • File a Ticket
    • View Tickets
    • Dashboard
  • Other Projects
    • YUI 2
    • YUI Compressor
    • YUI Doc »
    • YUI Builder
    • YUI PHP Loader
    • YUI Test
    • YUI Website

Blog: Archive for October, 2010

|
Newer Entries »

Building TipTheWeb with YUI 3

About the Author: Eric Ferraiuolo is a Director of TipTheWeb and Co-Founder of Oddnut Software. He writes on his blog: 925 HTML, and can be found on Twitter: @ericf. Eric was a featured presenter at YUIConf 2009.

TipTheWeb is a new service that lets people directly support their favorite web content by tipping it. For instance, if you find a great blog post, you could tip it 25 cents.

TipTheWeb is a non-profit organization promoting freely-accessible, high-quality web content by awarding publishers that receive tips. If you publish online, you can use your TipTheWeb account to claim the places you publish to receive tips and be eligible to receive awards from TipTheWeb.

Screenshot showing the Landing page of tiptheweb.org

TipTheWeb’s Use of YUI 3

The user interface of TipTheWeb is completely built on top of YUI 3 (we drank the Kool-Aid.) The approach we took was to use YUI 3 as the foundation and structure for our JavaScript code. We’ve built 33 custom YUI 3 modules (56 if you include submodules, plugins, and roll-ups), several of which we contributed the YUI 3 Gallery: Component Manager, Markout, Overlay Extras, and REST Resource.

Page-Level Classes

The core features of TipTheWeb are implemented on a few highly-functional web pages which communicate with the server over Ajax. For each of these pages we created a custom YUI 3 module that exposes a page-level class used to coordinate actions between the functional parts of the page.

In one of our application’s main pages, the Tips page, you can see how this approach is applied with the page-level class TipsWindow. The main functional parts of the page are the widgets: CreateTip used for creating tips, and the TipList widgets for editing, canceling, and funding existing tips.

Annotated diagram labeling the main Widgets and Components that make up the Tips page of TipTheWeb

A Lot of Overlays

We use Y.Overlays extensively throughout our application’s UI to implement user-interactions; this allows us to keep the interface clutter-free while still having the functionality for advanced features available on the page. We needed features that were not built into Y.Overlay, so we developed Overlay Extras, which is in the YUI 3 Gallery and being used by a lot of other YUI 3 powered sites. Here are some place where we use Overlays on TipTheWeb:

Screenshot showing the confirmation overlay that appears when canceling a tip

Screenshot showing the overlay which contains a slider to allow a custom amount to be set when donating to TipTheWeb

Screenshot showing the menu which lists the various places a user can claim and accept tips at

Current State of TipTheWeb

We’d love for you to try out TipTheWeb; right now we are in invite-only beta, so request an invite on our site and we’ll send you an invite code.

Be sure to catch our talk at YUIConf 2010 where we will be presenting (more in depth) on how we use YUI 3 and YQL at TipTheWeb.

By Eric FerraiuoloOctober 5th, 2010

Quick Tip: Customizing the Mobile Safari tap highlight color

Ever notice the semi-transparent gray background that appears sometimes when you tap on something in Mobile Safari? That’s the default tap highlight color, which Mobile Safari displays when you tap on an element with a JavaScript click handler.

Unfortunately, Mobile Safari has no way to distinguish between normal click subscribers and delegated click subscribers, which is when the click event is attached to a container rather than to each child of that container. As a result, a delegated click will result in the entire container being highlighted rather than just the item that was tapped, and this can be both ugly and confusing for the user.

The good news is that Mobile Safari supports a CSS extension called -webkit-tap-highlight-color, which you can use to customize the color of the tap highlight or hide it completely.

The -webkit-tap-highlight-color property accepts any standard CSS color value, but you’ll probably want to provide an rgba value in order to control the alpha transparency. Disabling the tap highlight is as simple as setting the alpha value to 0, like so:

#container {
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

Fire up your favorite iOS device and view this simple demo to see what a delegated click looks like both with and without a tap highlight. For more details on -webkit-tap-highlight-color and other useful Mobile Safari CSS extensions, see the Safari CSS Reference.

By Ryan GroveOctober 1st, 2010

In the Wild for October 1, 2010

There has been significant buzz this week about Dav Glass’s tech talk on YUI 3 support in Node.js and what that enables in terms of progressive enhancement, as well as for Matt Taylor’s YUI 3 Gallery module for RaphaelJS. Luke Smith had a nice developer tip on the blog this week on extending YUI to “add your own awesome,” developer Stefan Klopp from CarRentalExpress.com shared his thoughts about using YUI 2 to power his site, and Carlo Zottmann shared his gorgeous new “Dana” theme for YUI’s documentation workhorse, YUI Doc.

Meanwhile, here are a few other recent pieces of news from the community:

  • Andrew Wooldridge — “Learning YUI: Introduction”: Andrew Wooldridge (@triptych) is embarking on a series of YUI articles on his blog, and the introductory piece is online: “I’ve decided to write a few articles about getting starting in YUI, and various things I learn as I go along… I assume you have some sort of need for a javascript library, or perhaps you read about YUI and are basically curious about it. Let me give you a bit of a background. YUI was originally created as a common set of javascript library functions within Yahoo years ago, with the idea of allowing web developers to have a basic set of functionality to use inside Yahoo pages. This naturally grew and expanded – breaking out of just Yahoo and also moving towards and open set of components you see today. Yahoo folks curate the library but take changes and updates from anyone, and you are free to use this code any way you like… YUI may seem like this giant set of libraries, doing everything from animations to widgets, but in reality the YUI team has tried hard to make it very small, fast, and modular. You only load the bare core when you include the YUI base js (although you can if you want load more via the configurator) and when you need more functionality, you can fetch it on the fly and avoid having long initial download times for your page.” Check out the full post for more. #
  • Evan Goer (@evangoer), “YUI 3 Grids Are Dead Simple”: Evan likes Matt Sweeney’s YUI 3 Grids, which debuted in beta in YUI 3.2.0. Writes Evan: “Not only is this version tiny (1.5 KB), but it’s the first layout system I’ve ever used where I can just write out whatever grid I want from memory, without ever needing to look at the docs.” Check out the full article for more. (Original source.) #
  • Saurabh Odhyan on the YUI 3 Cache Utility: Writes Saurabh: YUI 3 Cache “allows to cache frequently used data in javascript memory (Basic caching) or HTML5 localStorage object (Offline caching). Although we can implement our own caching mechanism in javascript, the YUI caching is general purpose and also provides a set of events. Moreover it can be easily integrated with YUI Datasource which can be very beneficial. I’ll show you how useful YUI caching utility can be using a very standard example, Factorial.” (Original source.) #
  • IHikeWithMeetup.com Built with YUI 2.8: IHikeWithMeetup.com is a clever mashup of Meetup.com data from Bay Area hiking groups along with weather data and Yahoo! Maps — and all hosted with Yahoo web hosting. Naturally, the site is powered by a healthy helping of YUI 2.8 components. #
  • Canonical’s Landscape Ubuntu Systems Manager Powered by YUI 3: Canonical uses YUI 3 extensively, including in its Landscape product. According to the product page, “Landscape makes the management and monitoring of Ubuntu systems simple and effective by combining world-class support with easy to use online management tools.” #
  • Sidnei Da Silva, “Even Faster Websites with YUI”: Writes Sidnei: “Ever since I got my copy of Steve Souders’ Even Faster Web Sites I’ve became obsessed with speed. During my day job I’m constantly looking for things that can be improved to make the user experience smoother, specially for first-time visitors. I’m fairly happy with what we’ve achieved in the last year, though there are always things to be improved. Today I’m going to share with you one of the tricks that we’ve discovered almost by accident and that can help with making your website faster, if YUI is your Javascript framework of choice.” (Original source.) #
By Eric MiragliaOctober 1st, 2010

Carlo Zottmann’s Dana Theme for YUI Doc

Carlo ZottmannAbout the author: Carlo Zottmann (two n’s) is a freelance web developer and former Yahoo! from Munich, Germany. These days, he’s happy writing Ruby and Javascript for fun and profit. He has a blog and is known to use the Twitters.

I like to use YUI Doc for all my JavaScript documentation needs. I have found that it works well for documenting plain vanilla JS or jQuery code — it’s not just for YUI-based projects.

I was skeptical at first, as I tend to write more jQuery than YUI code. It was a pleasant surprise to find that YUI Doc easily integrated into my workflow, and could produce useful documentation for my non-YUI projects. Sure, it has some expectations regarding a project’s file structure etc., but none of these expectations are showstoppers for me. On the other hand, it is a light system and I can get it up and running in no time.

Having a tool parse my source code and automagically build quality documentation for me is great — not just for quickly looking up function calls etc. later on; to me it adds value in two ways:

Firstly, I document my code either way for my own sake — I’m probably going to have to re-visit it in a few months and I should be able to pick it up quickly. Not having documentation means certain confusion in the future, which is not an impression I want to give my customers.

Secondly, code documentation might be a bit of an abstract concept for a client: I can tell her it’s there, but the only way I can “prove” my claim is by firing up my editor and point my finger at the comment blocks in my code. Which really don’t look very impressive — at worst they look like a sorry excuse for “proper” documentation.

Yet firing up my browser and showing the very same comments parsed and processed by YUI Doc — clean, sparkling, coherent — now that’s professional code monkeying right there, people.

(If you just thought “code documented in a wiki is as good and less of a hassle”, please accept my sad golf clap — because it’s not.)

Unfortunately, I’m not a fan of the base YUI Doc skin. When I hand over a solidly documented piece of code to my clients, I want them to see solidly documented code; to me, YUI Doc’s default theme doesn’t shine brightly enough.

Looking around for replacement themes I couldn’t find any. So a few weeks ago I decided to write my own — Dana. Here’s an example screenshot:

Screenshot of the YUI.widget.SimpleEditor class documentation

As you can see above, I’ve generated the well-known YUI API docs as an example. Here’s the original YUI documentation — and here is the very same documentation sporting the new Dana theme.

I find the latter more pleasing to the eye — I hope you agree! Click around a bit, check some of the class documentations for a more in-depth comparison, play with the filters, feel the luxurious yet cheap plastic underneath.

So far, I’ve gotten plenty of positive feedback. My clients appreciate the cleaner look, and I feel better about the more professional presentation of the work I put into my projects, right down to the generated markup.

How it was built

I started writing Dana by throwing away every bit of HTML inside the default YUI Doc templates, starting over from scratch and layering my own markup on top of the core blocks of YUI Doc Cheetah code. (Cheetah is the Python templating engine used by YUI Doc. The # blocks you’ll find in the templates contain Python code executed by Cheetah.)

To be honest, figuring out what’s going on in the templates wasn’t really a walk in the park — YUI Doc’s templates are not annotated, and getting oriented as a newcomer to the system took some time. When I had the feeling I understood the structure and Cheetah logic, I gutted the rest of the markup, replacing it with some really simple constructs, and built on top of that. It took a while.

If you think about writing your own themes, I’d recommend either using Dana’s main.tmpl as a starting point, or looking at the properly formatted original main.tmpl. Many Bothans died to bring you this template.

I am not a designer; I’ve tried to keep the look simple and clear without adding many bells and whistles.

Built-in Goodies

I’ve taken the liberty of implementing an (IMHO) better display of object-type parameters: if several parameters are passed in as properties on a single object, only that object will be displayed as a parameter in the tables’ first columns.

As an example, let’s say you’re documenting a method expecting an object-type parameter containing three properties:

* @param  obj.param1 {String} A string!
* @param  obj.param2 {Number} A number!
* @param  obj.param3 {Boolean} A boolean, surprisingly!

Here’s how this method would be displayed in the generated documentation:

Default theme: method( obj.param1, obj.param2, obj.param3 )

Dana theme: method( obj )

For a real-life example, see the docs for YAHOO.widget.DataTable’s events.

I find that this treatment makes the output more concise.

Requirements

Dana requires one of the later YUI Doc builds; for example, build 50 works just fine — but it won’t work with YUI Doc 1.0.0b1.

Installation / Usage

I assume you’ve got YUI Doc up and running at this point. Just download Dana from GitHub, unpack it, and tell yuidoc.py to use it via the -t/--template option.

Closing remarks

Dana is still a work in progress; there are some minor issues left, for example with some HTML code blocks which come out too wide. These aren’t deal breakers for me, but your mileage may vary.

For those readers who, like me, get giddy at the idea of Markdown support in YUI Doc like I do (hint, hint), check out Mike West’s YUI Doc fork which adds exactly that. While we wait for a new original YUI Doc release, I mean. *cough ;)*

You’ll find Dana on GitHub. If you’re so inclined, you can download the latest stable release as zip/tgz file, too. If you encounter any errors, please create a
ticket
.

Dana is dual-licensed under MIT & GNU GPL v2. It’s been tested in Safari 5 (OSX), FF3.6 (OSX), IE8 (WinXP).

By Carlo ZottmannOctober 1st, 2010
|
Newer Entries »

Pages

  • About
  • Contribute
  • YUI Jobs

Recent Posts

  • YUI Weekly for May 17th, 2013
  • Yahoo’s International Team Is Hiring!
  • YUICompressor 2.4.8 Released
  • YUI 3.10.1 Released to Fix SWF Vulnerability
  • YUI Weekly for May 10th, 2013

Archives

Categories

  • Accessibility (25)
  • CSS 101 (6)
  • Design (51)
  • Development (590)
  • Frontend Jobs at Yahoo (13)
  • Graded Browser Support (8)
  • In the Wild (63)
  • Miscellany (11)
  • Open Hours (44)
  • Performance (23)
  • Releases (25)
  • Target Environments (11)
  • Yeti (3)
  • YUI 3 Gallery (29)
  • YUI Events (45)
  • YUI Implementations (55)
  • YUI Theater (146)
  • YUI Weekly (37)

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
© 2013 YUI Blog