Nov 8, 2009

Mootools - My Favourite Javascript Library

free web hosting
Open Discussion > MODERATED AREA > Tutorials

Mootools - My Favourite Javascript Library

codercode
It kind of amazes me that there's not even a mention of the Mootools javascript library throughout this whole forum. So here I'll do a brief introduction and a tutorial on how to produce the famous accordion effect.

MooTools is a compact, modular, Object-Oriented javascript framework designed to make writing extensible and compatible code easier and faster. MooTools lets you get the job done efficiently and effectively.
It is slightly based on the powerful Prototype javascript framework, of which Scriptaculous runs on.

(But frankly, I dislike Scriptaculous due to its large file size = slows down page load time. The same effects could be achieved using Mootools which is much much much smaller in size (about 30kb compressed with other plugins included)) Moreover, you can select the only modules you want (thus reducing file size) because Mootools is modular.

Seeing is believing. See for yourself what can be done with Mootools.

It first started as the popular Moo.fx javascript effects library which boasts its 3kb file size and powerful effects


Moo.fx became so popular that its creators decided to lay out a full-featured javscript library. Mootools is currently in version 1.1.

Even sites like Ubuntu.com and Joomla.com use Mootools

Now on to my tutorial: How to create Accordion effect with Mootools

First, we create a HTML skeleton of your webpage
CODE


<h3>
The Mighty Accordion
</h3>
<div id="accordion">
<h3 class="toggler atStart">
History
</h3>
<div class="element atStart">
<p>
The first suggestion that all organisms may have had a common ancestor and diverged
through random variation and natural selection was made in 1745 by the French
mathematician and scientist Pierre-Louis Moreau de Maupertuis (1698-1759) in his work
Venus physique. Specifically:
</p>
<blockquote>
"Could one not say that, in the fortuitous combinations of the productions of nature,
as there must be some characterized by a certain relation of fitness which are able
to subsist, it is not to be wondered at that this fitness is present in all the
species that are currently in existence? Chance, one would say, produced an
innumerable multitude of individuals; a small number found themselves constructed in
such a manner that the parts of the animal were able to satisfy its needs; in another
infinitely greater number, there was neither fitness nor order: all of these latter
have perished. Animals lacking a mouth could not live; others lacking reproductive
organs could not perpetuate themselves... The species we see today are but the
smallest part of what blind destiny has produced..."
</blockquote>
<p>
In 1790, Immanuel Kant (Konigsberg (Kaliningrad) 1724 - 1804), in his Kritik der
Urtheilskraft, states that the analogy of animal forms implies a common original type
and thus a common parent.
</p>
<p>
Charles Darwin's grandfather, Erasmus Darwin, hypothesized in 1795 that all
warm-blooded animals were descended from a single "living filament":
</p>
<blockquote>
"...would it be too bold to imagine, that all warm-blooded animals have arisen from
one living filament, which THE GREAT FIRST CAUSE endued with animality...?"
(Zoonomia, 1795, section 39, "Generation")
</blockquote>
<p>
In 1859, Charles Darwin's The Origin of Species was published. The views about common
descent expressed therein vary between suggesting that there was a single "first
creature" to allowing that there may have been more than one. Here are the relevant
quotations from the Conclusion:
</p>
<blockquote>
"[P]robably all of the organic beings which have ever lived on this earth have
descended from some one primordial form, into which life was first breathed." "The
whole history of the world, as at present known, ... will hereafter be recognised as
a mere fragment of time, compared with the ages which have elapsed since the first
creature, the progenitor of innumerable extinct and living descendants, was created."
"When I view all beings not as special creations, but as the lineal descendants of
some few beings which lived long before the first bed of the Silurian system was
deposited, they seem to me to become ennobled."
</blockquote>
<p>
The famous closing sentence describes the "grandeur in this view of life, with its
several powers, having been originally breathed into a few forms or into one." The
phrase "one form" here seems to hark back to the phrase "some few beings"; in any
case, the choice of words is remarkable for its consistency with recent ideas about
there having been a single ancestral "genetic pool".
</p>
</div>
<h3 class="toggler atStart">
Evidence of universal common descent
</h3>
<div class="element atStart">
<h4>
Common biochemistry and genetic code
</h4>
<p>
All known forms of life are based on the same fundamental biochemical organisation:
genetic information encoded in DNA, transcribed into RNA, through the effect of
protein- and RNA-enzymes, then translated into proteins by (highly similar)
ribosomes, with ATP, NADH and others as energy currencies, etc. Furthermore, the
genetic code (the "translation table" according to which DNA information is
translated into proteins) is nearly identical for all known lifeforms, from bacteria
to humans, with minor local differences. The universality of this code is generally
regarded by biologists as definitive evidence in favor of the theory of universal
common descent. Analysis of the small differences in the genetic code has also
provided support for universal common descent.[2]
</p>
<h4>
Irrelevant differences
</h4>
<p>
Differences which have no relevance to evolution and therefore cannot be explained by
convergence, tend to be very compelling support for the universal common descent
theory.
</p>
<p>
Such evidence has come from two domains: amino acid sequences and DNA sequences.
Proteins with the same 3-d structure need not have identical amino acid sequences;
any irrelevant similarity between the sequences is evidence for common descent. In
certain cases, there are several codons (DNA triplets) that code for the same amino
acid. Thus, if two species use the same codon at the same place to specify an amino
acid that can be represented by more than one codon, that is evidence for recency of
a common ancestor.
</p><img src=
"http://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Phylogenetic_tree.svg/340px-Phylogenetic_tree.svg.png"
class="float-right" />
<p>
The universality of many aspects of cellular life is often pointed to as supportive
evidence to the more compelling evidence listed above. These similarities include the
energy carrier ATP, and the fact that all amino acids found in proteins are
left-handed. It is possible that these similarities resulted because of the laws of
physics and chemistry, rather than universal common descent and therefore resulted in
convergent evolution.
</p>
<h4>
Phylogenetic trees
</h4>
<p>
Another important piece of evidence is that it is possible to construct detailed
phylogenetic trees mapping out the proposed divisions and common ancestors of
species, and no matter what method is used, morphological (based on appearance,
embryology, etc) or molecular (based on mutation rates and relative similarities of
important, conserved genes), still get extremely similar results. If there were no
common ancestor, these different methods should give wildly different results, thus
the phylogenetic tree is strong evidence of common descent.
</p>
<div style="clear:both"></div>
</div>
<h3 class="toggler atStart">
Examples of common descent
</h3>
<div class="element atStart">
<h4>
Artificial selection
</h4>
<p>
Artificial selection offers remarkable examples of the amount of diversity that can
exist between individuals sharing a late common ancestor. To perform artificial
selection, one begins with a particular species (following examples include wolves
and wild cabbage) and then, at every generation, only allow certain individuals to
reproduce, based on the degree to which they exhibit certain desirable
characteristics. In time, it is expected that these characteristics become
increasingly well-developed in successive generations. Many examples of artificial
selection, like the ones below, occurred without the guidance of modern scientific
insight.
</p>
<h4>
Dog breeding
</h4><img src=
"http://upload.wikimedia.org/wikipedia/en/thumb/7/7e/IMG013biglittledogFX_wb.jpg/180px-IMG013biglittledogFX_wb.jpg"
class="float-right" />
<p>
An obvious example of the power of artificial selection is the diversity found in
various breed in domesticated dogs. The various breeds of dogs all share common
ancestry (being all ultimately descended from wolves) but were domesticated by humans
and then selectively bred in order to enhance various features such as coat color and
length or body size. To see the wide range of difference between the many breeds of
dogs compare the Chihuahua, Great Dane, Basset Hound, Pug, and Poodle. Also compare
this enormous diversity with the relative uniformity of wild wolves.
</p>
</div>
</div>



Then, we style it properly with CSS
CODE


.toggler {
color: #222;
margin: 0;
padding: 2px 5px;
background: #eee;
border-bottom: 1px solid #ddd;
border-right: 1px solid #ddd;
border-top: 1px solid #f5f5f5;
border-left: 1px solid #f5f5f5;
font-size: 11px;
font-weight: normal;
font-family: 'Andale Mono', sans-serif;
}

.element {

}

.element p {
margin: 0;
padding: 4px;
}

.float-right {
padding:10px 20px;
float:right;
}

blockquote {
text-style:italic;
padding:5px 0 5px 30px;
}



Just to give you an idea of how it looks like without the accordion effect:


With the accordion effect, everything stacks up nicely, thus saving viewport space and at the same time produces aesthetics value:


Now that we already have the HTML and CSS, all we need to do is just add a few lines of javascript. With Mootools, this has never really been easier:
CODE
var accordion = new Accordion('h3.atStart', 'div.atStart', {
opacity: false,
onActive: function(toggler, element){
toggler.setStyle('color', '#ff3300');
},

onBackground: function(toggler, element){
toggler.setStyle('color', '#222');
}
}, $('accordion'));


var newTog = new Element('h3', {'class': 'toggler'}).setHTML('Common descent');

var newEl = new Element('div', {'class': 'element'}).setHTML('<p>codercode codercode sample</p>');

accordion.addSection(newTog, newEl, 0);


That is all it takes to create a nice accordion effect for your divs! Hope y'all enjoy this tutorial

 

 

 


Comment/Reply (w/o sign-up)

delivi
this looks an interesting javascript library like the prototype ans scriptlocious for cool webeffects

please add more tutorials on this so the noobs can learn easily on using this library for their web interfaces smile.gif

Comment/Reply (w/o sign-up)

darran
I like MooTools a lot as well.

I am actually using it to design a navigational bar of my company's website. Although it is nothing special, just some fades. E.g. when you hover on a logo, it will fade in all the previously invisible logos. Really cool and simple effect but yet it is in someways sophisticated.

I think you need to have a basic understanding of how to use element IDs, JavaScript and CSS to fully utilize MooTools. Without these, you will just probably be using the demo examples and unable to make any breakthroughs or unique design.

What I love the most about MooTools is that it is object oriented base, I studied it and practiced it in my codes. So this is a breeze for me. I can create multiple objects and use the transition whenever and wherever I want in the site.

This is a good way of making your site look more Web 2.0

Comment/Reply (w/o sign-up)

hippiman
I think I'm going to look into that. I was really bored the other day, and I saw some other Javascript libraries out there, but I don't know how good they are, because I didn't look that far into them, but I guess I should check different ones out.

Is MooTools just for effects, or does it have other functions, too?

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Mootools Favourite Javascript Library

  1. Image Preloader With Progress Bar Status - Pure Client-Side JavaScript tested in 4 Browsers! (28)
    Tutorial: Image Preloader with Progress Bar, by Rob J. Secord, B.Sc. (SystemWisdom)
    Description : A Tutorial for a Client-Side Image Preloader with Dynamic Real-Time Progress Bar
    Indicator written in JavaScript! Tested to work with 4 Major Internet Browsers: Firefox, MSIE,
    Netscape, Opera (Complete sample solution provided at end of tutorial, just put it on your
    web-server, add your images and go!) Intended Audience : Beginner to Intermediate Web
    Developers. Although this tutorial will cover some advanced aspects of JavaScript, I will try to
    explain it all ...
  2. How To: Change An Image When A User Clicks On It - using both php and javascript (12)
    How To: Change An Image When A User Clicks On It using both php and javascript - a powerful
    combination I have seen quite a few how tos offering a method of doing this but none of which
    resembled my method of making use of both php and javascript. This code is fairly repetitive and
    most of the functions are easy to pick-up if you haven't heard of them before. Here it is...
    Create your two images. Call them anything you like, you'd just need to change their filenames
    in $imgano $imgayes. In fact with this script you can easily create more than one pair...
  3. Simple Javascript And Password System - How to protect your pages with password (10)
    The quickest way to get a password protection system up and running is to use a Prompt box in
    JavaScript that has a title like "Enter your Email Address". Only you and the relevant users know
    what the password should be, could even be one each, that can be sorted out at the next page then
    pass the "input" directly through the url by changing the .href, like
    http://www.iSource.net.nz/users/?leTmeIn= The page that then processes this should also check for
    the referring page, and three fails from an IP if you like the php (the next page): CODE //
    processdownloads.p...
  4. Make A Moderately-secure Password System Using Javascript - using file redirection to hide the password. (11)
    JavaScript is very handy at making forms, allowing for much more customization and easier ways to
    send data. So making Login forms using JavaScript may seem to many to be a very feasable idea.
    However, JavaScript is very bad at protecting Passwords, as since the passwords are not encypted and
    the whole JavaScript code is in the page, a person could just view the Page Source and find out
    everything. Even if you use an external JavaScript, it would still be poor as the file name for the
    external JavaScript would still be revealed. But I have an answer! There is a relative...
  5. Lesser Known Useful Javascript Features - (2)
  6. Css And Javascript Combined For Dynamic Layout - use of different CSS files at same site (9)
    This tutorial is meant for people that are dealing with problems while coding their site at 100% of
    width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS
    file (take this in account when creating your website). How this script works. In the HEAD of your
    HTML document will apply this command, so variable.js file will be load at start: CODE
    In browser JavaScript file variable.js is loaded. This Javascript file consist of this parameters,
    copy this code and name it variable.js CODE // JavaScript Document if (sc...
  7. Simple Scripts In Html And Javascript - Things like BackgroundColorChanger and so (7)
    like in the topic, here is a description how to change the Backgroundcolor "On The Fly", by klicking
    on a button or radio-box first, we ned the html-and body-tags, create a new html-file on your
    desktop and write the following: QUOTE browser interpretation: html - tag
    means "hey, browser, here comes HTML" in the body-tag you define the looking of your site. you can
    add things like "bgcolor" for the background, "text" for the textcolor and link / alink / hlink /
    vlink to define the linkcolor ( ) the scripttag is the tag, we'll need now (sorr...
  8. Javascript Scroll Bar - A scroll bar for your webpage using javascript (13)
    In this tutorial I will show you how to create two buttons in the bottom left of the screen that,
    when hovered over, will scroll the page. Now to start with, we must create a our buttons, the first
    line will create a div element, or block. Using blocks you can position items anywhere on a page.
    We use the ID property just to let us know what the block is used for, as for the first block, its
    obvious that it contains the vertical buttons and the second two blocks contains the horizontal
    buttons. The style property of the div tag tells the browser how to draw it, in the...
  9. Create A Simple Html Editor With Php And Javascript - (3)
    Ok, I will teach you how to create a simple HTML editor that runs online with buttons that add HTML
    tags. Before we start: You should have basic knowledge of these languages. HTML/XHTML
    Javascript PHP You will need Ability to use filesystem functions. Chmodding abilities
    Features of Editor Online PHP safe Full HTML support A Few Bad Features Can only create new
    documents or overwrite Fairly unsafe Now we are ready to begin. The PHP Script This will be
    our PHP script that we will use to make the file. Make a file called save.php Here is the...
  10. Image Rollovers In Javascript - A Write-Once, Use-Anywhere Approach (11)
    Tutorial: Image Rollovers w/ Javascript, by Rob J. Secord, B.Sc. (SystemWisdom) See a
    working Sample of this Script! Download a ZIP containing all working files in this tutorial!
    Note: If you are not interested in reading this entire tutorial and/or have a basic understanding of
    the underlying concepts, you may safely skip to the Implementation section to get the code!
    Description : A Dynamic Image Rollover Script tested to work in 4 major internet browsers: MSIE,
    FireFox, Netscape and Opera. Using only Javascript combined with regular HTML Images ( ...
  11. Javascript Framework - A Shortcut Javascript - a shortcut javascript (3)
    hi, today im going to give you small tutorial how to use `Prototype JavaScript Framework` 1st you
    have to download `Prototype JavaScript Framework`library from http://prototype.conio.net/
    prototype makes easy to using Javascript, ex : when you want to point (get) the element from HTML
    usually we use : CODE document.getElementById('elementId') with prototype we use
    CODE $('elementId') , yeah...world getting small..with prototype. example we`re going
    to get value from an element of CODE with prototype we use CODE alert(...
  12. Tool Tips Using Only Css To Pop Up The Tool Tip - No javascript involved! (8)
    Tool Tip Tutorial Example Found Here . Please review before continuing. Nice. And no
    javascript at all to be found. The colours I have used are for demonstration purposes only to show
    you that they are adjustable to suit the background or to contrast against them. Your choice. That
    is a styling issue. It is your site, you decide. The original author's idea was to add
    position:relative to the link, in order to allow the span element inside to position absolutely
    in respect to the parent link. This code has been tested in Ie5.5, IE6, Opera7.11 and M...
  13. Handy Javascript Code Snips - Ready to Apply in your webpage (5)
    /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif' /> Some common things to
    implement in our webpage very frequently are as follows. How to implement all these I am going to
    tell you in this tutorial. Add To Favorite Set As Homepage Go To Top Of Page No Right Click
    Print Page Adding Current Date Adding Current Time Pop-Up Page Creation Closing Window
    Copyright Notice Updation 01. Add To Favorite Someone may be interested in the content of your
    page. Offer him/her to add the page in his/her favorite menu. To do this you have ...
  14. Writing On Images - ...with PHP and GD library (2)
    Demo: http://www.fantastictutorials.com/files/av...er&color=random ..and:
    http://www.fantastictutorials.com/files/avatar/index.php This tutorial is based on the code I used
    for this avatar generator . This tutorial is for people that are reasonably comfortable with
    php. I have went to a lot of work making it as simple as possible so even if you are a beginer you
    shouldn't have problems. After writing the tutorial, I realised how difficult it is to read
    when the source and tutorial seperately ... so I commented the tutorial into the source of the php.
    First...
  15. Creating Rollovers With Buttons - Short & simple javascript tutorial that shows you how. (2)
    Javascript in action can render some very neat visual effects, which can make your website more
    appealing, and sometimes even easier to navigate. Among the most common effects are the
    'button' effect, and the mouseover effect. The buttons are very common, of course; if
    nowhere else, most of us have seen them at the end of forms (Click the 'submit' button to
    proceed...). The basic idea is to have a 'depressible' object, which can give you the
    illusion that you're 'pressing' it when you click it. The rollover effect causes
    something to h...
  16. Opening New Tabs With Javascript - (1)
    I just spent a couple of hours trying to figure out how to open new tabs from a Firefox sidebar. I
    found lots of different suggestions but none worked. Well finally I found this and it works. var
    browser = top.document.getElementById("content"); var tab = browser.addTab("http://www.google.com");
    An even better way of doing it is through: const kWindowMediatorContractID =
    "@mozilla.org/appshell/window-mediator;1"; const kWindowMediatorIID =
    Components.interfaces.nsIWindowMediator; const kWindowMediator = Components.classes
    .getService(kWindowMediatorIID); var browserWi...



Looking for mootools, favourite, javascript, library

Searching Video's for mootools, favourite, javascript, library
See Also,
advertisement


Mootools - My Favourite Javascript Library

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com