When used correctly, jQuery can help you make your website more interactive, interesting and exciting. This article will share some best practices and examples for using the popular Javascript framework to create unobtrusive, accessible DOM scripting effects. The article will explore what constitutes best practices with regard to Javascript and, furthermore, why jQuery is a good choice of a framework to implement best practices.
function ZParenizor2(value) {
var that = new Parenizor(value);
that.toString = function () {
if (this.getValue()) {
return this.uber('toString');
}
return "-0-"
};
return that;
}
Again, we augment Function. We make an instance of the
parent class and use it as the new prototype. We also
correct the constructor field, and we add the uber method to
the prototype as well.
This adds a public method to the Function.prototype, so all
functions get it by Class Augmentation. It takes a name and a function, and
adds them to a function's prototype object.
To make the examples above work, I wrote four sugar
methods. First, the method method, which adds an instance method to
a class.
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
JavaScript can be used like a classical language, but it also has a level of
expressiveness which is quite unique. We have looked at Classical Inheritance,
Swiss Inheritance, Parasitic Inheritance, Class Augmentation, and Object Augmentation.
This large set of code reuse patterns comes from a language which is considered
smaller and simpler than Java.
I have been writing JavaScript
for 8 years now, and I have never once found need to use an uber
function. The super idea is fairly important in the classical
pattern, but it appears to be unnecessary in the prototypal and functional
patterns. I now see my early attempts to support the classical model in
JavaScript as a mistake.
Mapeed.AddressChooser is a Javascript script to create a nice address form for any websites that need to collect addresses. For example getting user's address, place's location or anything that can be localized on a map. This script just add behavior on HTML form, it does'nt geerate HTML markup and can be plugged on any existing forms.
Whatever:hover is a small script that automatically patches :hover, :active and :focus for IE6, IE7 and IE8 quirks, letting you use them like you would in any other browser. Version 3 introduces ajax support, meaning that any html that gets inserted into the document via javascript will also trigger :hover, :active and :focus styles in IE.
javascript.options.showInConsole = true. Logs errors in chrome files to the Error Console. nglayout.debug.disable_xul_cache = true. Disables the XUL cache so that changes to windows and dialogs do not require a restart. This assumes you're using directories rather than JARs. Changes to XUL overlays will still require reloading of the document overlaid. browser.dom.window.dump.enabled = true. Enables the use of the dump() statement to print to the standard console. See window.dump
for more info. You can also use nsIConsoleService
from privileged script. javascript.options.strict = true. Enables strict JavaScript warnings in the Error Console. Note that since many people have this setting turned off when developing, you will see lots of warnings for problems with their code in addition to warnings for your own extension. You can filter those with Console2. extensions.logging.enabled = true. This will send more detailed information about installation and update problems to the Error Console.
Links are getting shorter, information smaller and here's another smaller blogroll avatar... the favicon. Google has an online PNG converter for favicon.ico files in the root directory of a domain. eg. http://google.com/favicon.ico Here's a realtime script to help get the favicon link.