Yahoo! Ui libraries target cross-browser web development woes

Source: Internet
Author: User
URL: http://www.devx.com/webdev/Article/31225/0/page/2

The recently released Yahoo! Ui libraries provide cross-browser DHTML and Ajax capabilities with a specified cial-friendly BSD license. Unfortunately poor documentation, verbose syntax, and incomplete capabilities mar the experience.

By David Talbot

2017l 17,200 6

Ver since the 4.0 browsers were released, cross-browser Dynamic HTML libraries have proliferated as a simple matter of necessity. any developer who wants to take advantage of the latest and greatest html/JavaScript capabilities while maintaining cross-browser compatibility has probably developed something of a library of "hacks" to normalize the API between the warring and buggy browsers.

Overall, Yahoo provides a decent library for general cross-browser hacks, but unfortunately, the effort doesn't measure up to some of the other open source APIs available such as dynapi. you can download the free Yahoo! UI (Yui) Libraries and experiment with them yourself.

A quick tour
After you 've downloaded Yui and extracted. ZIP file, you'll find the extraction creates eight folders, each with a similar sub-folder structure. each folder contains several subfolders, but the only ones of interest are:

  • The build folders, which contain just the files you'll need to use the functionality.
  • The example folder that shows the functionality in action.

I wouldn't recommend bothering with the source directories as these contain some. JS files that also exist in combined versions in the build directories, no doubt created by a utility they didn't include in the package nor reference on their Web site.

Overall, Yui is basically a function library that you access through a combination of anonymous methods and "namespace-like" syntax. for example, if you wanted to set the x/y location of an element on the page, instead of writing code such as setlayerloc ('myid', 10, 10 ), you wowould instead make a library call as follows:

   YAHOO.util.Dom.setXY('MyID', new Array(10,10));

Although Yui gets the job done, the syntax is thoroughly verbose.

The documentation consists of some javadoc-like API reference that was automatically generated from some sort of automatic tool with no effort to clean it up or add useful detail to the generated class descriptions. it does include a fairly complete set of examples that go through most of the common functions in a reasonable and straightforward way, but without any linkages to or from the rest of the generated documentation.

The Dom and event Libraries
Yui's capabilities in regard to core Dom and event handling are incredibly rock-solid, perform as expected, and cover a broad range of capabilities. most surprisingly, this API gives you simple cross-browser transparency control. most developers aren't even aware that magic tricks even exist (via DirectX CILS) to make semi-transparency work in IE, much less the Mozilla-based equivalents, but Yui enables access to most, if not all, of the CSS properties you 'd ever want. here's an example:

   YAHOO.util.Dom.setStyle('MyDivID', 'opacity', .5);

The caveat of so far of these wonderful capabilities is again the documentation. the documentation implies that you can set the CSS style properties on all elements using their JavaScript equivalent names, for example, by writing backgroundcolor rather than the CSS equivalent background-color, but the downside is that it lacks a full list of supported properties.

After you realize Yui has an amazingly cool cross-browser hack to enable transparency, your hopes will briefly rise that perhaps the libraries also implement cross-browser hacks to save you from having to remember every CSS hack around non-standard CSS properties. unfortunately this isn' t the case. upon further inspection of the code you'll discover that the transparency hack is the only CSS hack supported by Yui-all other setstyle CILS are passed directly through to the browser's Dom unchecked.

Fortunately, the event API is deeper than the dom api and has des functions to normalize attributes of the cross-browser events. It normalizes the API to the more standards based addlistener/removelistener functions.

Overall, the Dom and event libraries do the job but require verbose syntax to accomplish what other libraries do with half the typing.

Animation API
The animation API is where the framework starts to provide real value. the approach of the API is to define a series of from and to key states as well as the duration the animation shoshould last from start to finish.

Among the properties you can animate are: Color transitions, location, size, and opacity. you can create fascinating displays with relatively little effort in a manner similar to the Dreamweaver JavaScript. however, these API capabilities are only truly useful if you know the precise path of your animation at design time, because the declarative syntax used makes it difficult to alter animation paths at runtime.

Drag and Drop
Drag-and-drop support has always been an area of divergence among browser implementations. Yui does a masterful job of not only smoothing out of the differences but adding some great functionality on top of it.

The drag and drop API provides a lot of advanced functionality not seen in other freely available JavaScript libraries. the End User Experience with Yui drag-and-drop elements is very slick. you can specify what items are draggable and what items are drop targets in a relatively simple, though verbose, way.

I wowould have liked to have seen Yui behave a little more like some of the other freely available libraries out there in terms of associating drag sources with possible drop targets. in Yui you have to write code (there's an example in the documentation) to specify drop targets as opposed to simply adding grouping tags to your targets as you can with script. aculo. us.

Connection API
Remote scripting has been around for years but when Google launched Google maps it set the Internet afire with Ajax mania. the mania is of course well-founded, because AJAX can offer a dramatic User Experience Improvement. the result of this mania has been a tremendous proliferation of libraries that normalize the interface to the underlying browser hacks that enable you to make a round trip to the server for more data without refreshing the browser.

Yui provides a reasonably complete API for remote scripting. it functions des the ability to make remote CILS, handle successes, and handle failures. if you're using a server-side language that does not yet have a client side API for remote scripting, Yui is pretty good choice.

The code example below highlights the relative simplicity of the Yui connection libraries.

   var handlers = {
success: success,
failure: failure }
function success(t)
{ alert('Yea, success'); }
function failure(t)
{ alert('Awww.'); }
YAHOO.util.Connect.asyncRequest('GET',
'http://mysite.com/Remote.aspx?GetPage=1',
handlers,null);

Despite the fact that the Connection Library is one of the strong points of Yui, I wocould still recommend sticking with whatever Ajax libraries are specifically designed for your server-side language. the reason for this is simple-consistency in data type handling will reduce the overall amount of effort required to achieve the desired result. however, if you work in a multi-language or multi-platform environment, the Yui Connection Library is the better choice.

To be completely honest, I rewrote this article after my initial review. I had half of my review written based on playing with a few of the examples but repeatedly found myself disappointed with so far facets of the library that I had to delete the first article attempt and try again. overall, Yui is filled with verbose syntax and unformatted ented bizarre Parameter options. personally, as. net man, I'll stick with writing good xbrowser Dom, using dynapi for event normalization and Atlas for my Ajax needs.

In sum, the Yui libraries attempt to provide a complete cross-browser DHTML and Ajax API, but while parts of the libraries are rock-solid and work well, the attempt falls short in a few areas and fails miserably in its overall syntax.

Page 2 of 2



<A href = "http: // users/RealMedia/ADS/click_nx.ads/devx/Java/712/31225 @ house_ribbon, 468x60-1, marketplace01, CP1, CP2, CP3, cp4, cp5, cp6, CP7, cp8, cp9, cp10, cp11, cp12, cp13, cp14, 120x60-1, 125x125-2, 336x280, accessunit, FL1, fl2, fl3, fl4, fl5, 468x60-2! Accessunit "> </a>

David TalbotIs the vice president of development for Data Systems International, a company that develops case-management software for the social services industry. his experience ranges from license-plate recognition using neural networks to television set-top boxes to highly scalable Web applications. he is also the author of applied ADO. net.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.