| Blog Home | About | Entries By Date | Search |
|
Recent Blog Entries
PastA small status update on spry-it.com. When I created the first blog post on Adobe groups it stated that Spry-it.com would run on Aptana Jaxer, a serverside JavaScript and DOM engine. With the removal of Jaxer from the Aptana Studio the future got uncertain and i decided to go to more stable engine as base for Spry-it.
FutureExpression Engine is now our engine of choice and we are working hard on porting the existing code base to PHP. And its coming alone nicely and we hope to release it before Spry 1.7 goes live. There is still much work to be done thats why I'm also proud to announce that as of today, Johns Beharry will be helping out Spry-it as official co-manager. He creates cool stuff on a rock in the Caribbean, he's a talented web developer with a strong sense for design, front-end development and has experiance with the Expersion Engine. If you have questions or just like to chat with him feel free to following (stalk) him on twitter @johnsbeharry or AIM him at johnsbeharry@mac.com.
NowBecause our time zones differ so much, there will always be one of us online to answer your questions related the the Spry-it.com usergroup. You can reach the both of us at team@spry-it.com.
I'ts been more than year since the last revision of the Spry library. The last preview of Spry 1.7 originates from 12/08/08. A rewrite of the xpath handling inside SpryXMLDataSet took place, eliminating the need of the xpath.js library. Most people where and are wondering if Spry might have been discontinued which was never the case. The Spry team is also part of the Dreamweaver development team so they have allot of priorities to for fill. But I'm proud to announce that new builds of the Spry library has been spotted in the wild!
Mysterious extensions for Dreamweaver started requiring a "Widget browser" to be downloaded. After taking closer look at the pages I noticed the header: "Dreamweaver Widget Browser/Open Ajax Widgets". This actually started to ring a bell with me, I noticed that Adobe is actively involved in the Open Ajax initiative, especially KinBlas the main developer of the Spry framework. The puzzle pieces seem to fall in place now.
One of the extensions listed in this Open Ajax category contained information on how to download the item without the requiring Widget Browser. After Downloading and unzipping the "Spry Content Slide Show" extension and navigate to assets/includes you will notice various of new Spry files.
When you open SpryWidget.js you will notice the upgrade license header:
// SpryWidget.js - version 0.14 - Spry Pre-Release 1.7
This the one of the base modules of the newly rumoured widget framework that the Spry team has been working on. The SpryWidget.js depends on the SpryDOMUtils.js modules for navigating the DOM using the Spry.$$ css selector engine and other various of utilities. The SpryWidget.js will provide the base class of all new and future widgets. After closer inspection you will notice that the Spry.Wiget.Base is based on the Spry Notifier or Observer class. This allows the widgets to send out different events where you can subscribe to making the widgets asynchronous.
The Spry.Widget.Base provides you with different methods for developing your widgets such as:
And multiple slice functions for creating different element containers. As you will see the Spry.Widget.Base is will make it easier and faster to build widgets. An example implementation can be found at the bottom of the SpryWidget.js.
As i stated in a few paragraphs above the Spry Widget framework depends on the SpryDOMUtils.js module. There are noticeable upgrades made there as well. The one's that cought my attention where the upgrades to set and getAttributes these add support for custom attributes creation in Safari 2+. Creating support
for Unobtrusive Spry Data in Safari. Making the most reliable cross browser option for validating your Spry Pages. One other noticeable enhancement is that the Spry.$$ selector engine now allows you to send HTML elements to the function so they can be wrapped in to the Spry.$$'s result methods.
One other remarkable file and the last one that we are going to discuss today is the SpryDOMEffects.js. Its also based on the SpryDOMUtils.js so you need to have that included in to your page before using. Its smaller and more powerful than the SpryEffects.js, so I'm expecting this to replace the SpryEffects.js completely overtime. It might not happen in the 1.7 final release but in the near future it would be possible. The file includes it own animation engine and CSS animation engine. Animating CSS properties are now possible using the SpryDOMEffects unlocking a whole range of new possibilities for Spry and future widgets. Spry 1.7 will be one of the upgrades Spry has been waiting for. Thanks Steve for sharing your great find on Spry 1.7.
Spry comes with CSS3 complain selector engine since version 1.6. You can basically query any document page with a CSS selector and get the results for that. I'm going to dive to deep in that. If you want to learn more about the CSS selectors i suggest taking a look at the Element Selector Overview. The selector engine comes with a few default functions to make it easier to work with browsers DOM. These functions where all pre-defined by the Spry team. But they build it in a way that its actually quite easy to extend it and create your own custom functions. Before extending the selectors functions lets see how they get attached to the result set. Spry.$$ = function(selectorSequence, rootNode)
{
if (!rootNode)
rootNode = document;
else
rootNode = Spry.$(rootNode);
var sequences = Spry.$$.tokenizeSequence(selectorSequence);
var matches = [];
Spry.$$.addExtensions(matches);
++Spry.$$.queryID;
var nid = 0;
var ns = sequences.length;
for (var i = 0; i < ns; i++)
{
var m = Spry.$$.processTokens(sequences[i], rootNode);
var nm = m.length;
for (var j = 0; j < nm; j++)
{
var n = m[j];
if (!n.spry$$ID)
{
n.spry$$ID = ++nid;
matches.push(n);
}
}
}
var nm = matches.length;
for (i = 0; i < nm; i++)
matches[i].spry$$ID = undefined;
return matches;
};
I have highlighted the important parts of this function where the magic happens. They create a array (matches) and applies the Spry.$$.addExtensions() function on that. After they have processed the selectors query, they are pushing the found elements in the array. So the array is still an "actual" array. After all the matches has been cleared of Spry$$ID references the array is returned. The Spry.$$.addExtensions just loops over a Spry.$$.Results object and adds the methods to the array. The Spry.$$.Results is object that we need to extend to apply our custom functions. Spry.$$.addExtensions = function(a)
{
for (var f in Spry.$$.Results)
a[f] = Spry.$$.Results[f];
};
Spry.$$.Results = {};
Spry.$$.Results.forEach = function(func)
{
var n = this.length;
for (var i = 0; i < n; i++)
func(this[i]);
return this;
};
Spry.$$.Results.setAttribute = function(name, value)
{
return this.forEach(function(n) { Spry.Utils.setAttribute(n, name, value); });
};
All the selectors functions are based on the forEach functions. This loops over all elements. And calls the supplied func (function) with the currently looped element as argument. The forEach functions returns this. This will allow you to chain different selector functions together as long the function called function also returns a this .forEach as seen the .setAttributes function. Now that we know how the selector engines functions works we can implement our custom functions. Lets say we want to create a show and hide functions that just sets the display of the element to none or block. Spry.$$.Results.hide = function(){}
Add a function to the Spry.$$.Results object, lets call it hide. return this.forEach(function( node ){});
Inside the function we will start adding the required return this.forEach that calls a anonymous function. As we have seen in the code snippets above, the forEach gives the current looped HTML node as agrument to the function. I have named this "node". Now all we need to do is set the style of the node to display:none; Spry.$$.Results.hide = function(){
return this.forEach(function(node){
node.style.display = "none";
}
};
And thats all that is needed to create your own custom functions for the selector engine. But you can actually write this piece of code a bit shorter. The selector engine comes with a setStyle function. That allows you to setStyles directly with out having to know DOM syntax to modify styles. Spry.$$.Results.show = function(){
return this.setStyle("display:block;");
};
That will do the exact opposite of the hide function. It sets the display to "block" using the build in functions. This will make you code more readable and its actually allot shorter to write as well. Because we are also returning build in function the chaining will remain unbroken. The sky is the limit, if you are a fan of the short hands jQuery uses to attach events you can easily reproduce that behaviour with Spry by creating custom functions for that as well. Spry.$$.Results.click = function(handler, capture){
return this.addEventListener( "click", handler, capture);
};
Spry.$$.Results.change = function(handler, capture){
return this.addEventListener( "change", handler, capture);
};
Spry.$$.Results.focus = function(handler, capture){
return this.addEventListener( "focus", handler, capture);
};
Spry.$$.Results.blur = function(handler, capture){
return this.addEventListener( "blur", handler, capture);
};
.. and so on ..
If you have done it correctly you can use your custom selector functions: Spry.$$("div").hide().click(function(){ alert("yup it works"); });
While most parts of the Spry framework are well and intensively documented. There are some features and functions missing inside the documentation. For the new and upcoming website of Spry-it we are tackling this issue with a new search-able and re-documented database. But until than we are still stuck with the old documentation.. Or not? In the upcoming blog posts, we will attempt to shine some light on these hidden functions. To kick it off, we will be starting with the SpryDOMUtils.js. SpryDOMUtils This part of the Spry framework provides us with tools to work with browsers DOM (Document Object Model) such as a CSS3 complaint element selector (Spry.$$). You can this file by downloading the complete Spry library at: http://labs.adobe.com/technologies/spry/ Spry.$( arguments ); The Spry.$ is a wrapper for the native document.getElementsById function. It gets like the native function, elements by the id="" attribute. But the Spry function allows you to send multiple arguments to the function. Syntax: Spry.$( arguments ); Arguments: arguments "String", one or multiple strings that represent the id's Returns: HTML Node or Array of HTML Nodes, depending on the amount of arguments you supplied. Example: <strong id="element">Strong</strong> <b id="another">Bold</b> Spry.$( 'element' ); // returns the HTML element with the id="element" Spry.$( 'element', 'another' );// returns a Array with both the elements
Welcome to the first and currently only Adobe Spry user group. With growing number of Spry developers the need for a community is growing. The Spry forums are currently the only good and high quality source of information for your questions. But because it's only one forum it limited to its boundaries. Spry-it aims to solve those issues. We will providing users with more and in-depth information about the Spry framework. This is additional documentation, information, a more extensive and search-able API. And different channels of information, from RSS feeds to Adobe Wave notifications. Adobe Groups and Spry-it.com We are currently inviting beta testers to our platform. If you have signed-up already please do so at: http://www.spry-it.com. We will be using the Adobe groups site to distribute information and future paths of the user group. So its recommended to also sign-up for the Adobe groups site so you will always be up to date with the latest information. Get involved! Currently development and progress of the new site is low because its a one man crew. If you wish to contribute feel free to contact me. We can always work something out. We will be running on Jaxer ( serverside JavaScript and DOM ). |
Search Blog
Recent Comments1-5 of 5
JohnsBeharry on Welcome, Tere tulemast, Karibu, ????, Willkommen or just Hello
.V1 on Documenting the undocumented
@lexaka on Documenting the undocumented
Pevets Volshebny on Extending the Spry Selector engine
JohnsBeharry on Status |