Ever since Peter from piBlog wrote an article about how to integrate JavaScript into the client code, I was thinking about the use of it. Recently, I came with the idea of using Script.aculo.us effect library to apply some cool effects to Morfik’s Visual Controls. In fact I first used moo.fx, which is smaller (and perhaps easier to understand), but it has fewer effects. So I moved to Script.aculo.us and here it is the guide in same easy steps. (If you don’t want to get into details, and just want to see this in action, scroll to bottom for a download link).
First you will need to place some controls on a form. I’ve used: TextLabel, TextEdit, Button, Option Button, CheckBox, ComboBox, DateTimeEdit, Container, TabControl and a Image.
Then you need to define a external function, which will manipulate the control, by passing one parameter to it: a TDOMHTMLControl. If you need to apply the effect to a TextLabel1, you need to pass TextLabel1.DOMHandle to it. The external function is defined as follows (right after the implementation keyword):
function scriptAUEffectToggle(h:TDOMHTMLControl); External ’scriptAU’;
Now you just need to call that function somewhere in your code with a parameter like this:
scriptAUEffectToggle(TextLabel1.DOMHandle);
That’s it? Where is the implementation? Ok, the implementation of that function is in the scriptAU.js. Let’s see what happens there:
// ————————TOGGLE——————-
function scriptAUEffectToggle(h){
new Effect.toggle(h);
}
Yes, this is it, one line of actual code in the .js and a couple of others in the Morfik’s source and you are ready … almost. You have to include references to effects.js file (part of Script.aculo.us). But then Script.aculo.us uses prototype.js. For some weird reason, I could not import them dynamically into the scriptAU.js, so I decided to just put everything in one file: my code, effects.js and prototype.js. It does not seem like a good solution for a production code, but for a demonstration it works just fine.
To understand what all available effects are and how to use them, I went to Script.aculo.us site. There are some cool demos of the effects in action so you can have a pretty good idea what can be done. But the information in the Wiki system was a little odd to me, so when I googled about Script.aculo.us, I’ve found this great cheet sheet Scriptaculous Combination Effects Cheat Sheet (pdf) which I used to organize my demonstration.
I extended the demo functions by adding one more parameter to them: duration(how fast the effect will happen). Almost all of the effects have other options, but I did not use them in this.
And finally, every effect could be done using the language of your choise (c#, pascal, vb or java). Probably. But why? (Given there is already developed library?) There will be more on why’s in my next article: “The WebOS AppsBuilder meets Script.aculo.us (The RAD IDE part)”
To download the application (source included) click here.
If you want to compile the source, you will need WebOS AppsBuilder.
Update (18.06.2006) :
You can see the application in action here (via Morfik Labs)
June 29th, 2006 at 4:23 pm
[...] Just got note from Fuad Ta’eed of Morfik fame that they have posted two demos in the Labs with Zaptec and Dojo integration and there is more in the pipeline. This, together with Stoicho’s integration with Script.aculo.us points to a direction of which I have been great proponent for a while: Morfik has to embrace all the high quality AJAX/UI toolkits and other component sets out there and must make it very simple to use them together with Morfik’s own GUI controls and infrastructure. [...]
January 22nd, 2007 at 8:14 pm
[...] I just installed my first 3rd party component in WebOS Apps Builder: TAnalogClock. It is build by Peter Illés. I first wrote about him here, when he gave me a hack (then it was a hack), on how to use external JavaScript in Morfik. It is a “browser independent vector graphics”. The cool thing is that when you install the component, following a simple guide in the readme.txt, there is a new icon in the component palette between Google, Zapatec, Dojo and the others. [...]
March 19th, 2007 at 10:32 pm
[...] On a funny side, I am really confused: I am working as a (Desktop) Application Developer, and I thought when I start use the AppsBuilder, I will automatically become a Web Developer. It turns out I won’t, until I learn HTML, Javascript and CSS. I don’t want to, I don’t want to, I dont’ want to! I don’t want to fight with every browser weirdness on earth. And that’s untill I need some cool effects. [...]
June 18th, 2007 at 9:33 pm
Hello! Good Site! Thanks you! jligwwznxjxi