Percentage Loader run loaderor download on BitBucket jQuery.PercentageLoader is a jQuery plugin for displaying a progress widget in more visually striking way than the ubiquitous horizontal progress bar / textual counter. Installation and use is quick and simple. It makes use of HTML 5 canvas for a rich graphical appearance with only a 10kb (minified) javascript file necessary (suggested web font optional), using vectors rather than images so can be easily deployed at various sizes. It is open source (BSD licensed) and available with instructions on BitBucket [here] or you can just grab the files [here] more examples Controllable It's also possible to use the percentage loader as a controller - try clicking and dragging on the widget. Multiple run loaders You can easily run multiple loaders simultaneously. back to top
Create your own Javascript Library Create your own javascript library in these fun, easy steps! Background We all know about the performance benefits of putting all of our javascript/jQuery calls into .js files, so that browsers will cache the whole chunk on the client-side. It’s even more tempting to put all of our complicated jQuery calls into a single file, thus further enhancing performance by reducing HTTP requests (i.e. the browser doesn’t have to download so many files). However, have you ever taken a look at a site using the jQuery Cycle plugin on the homepage? [cycle] terminating; too few slides: 0 This is because the cycle init code, while correctly put inside the DOM-ready function, is still being called on every page, regardless of whether it has a slideshow or not. Most of the time you won’t even notice the extra overhead because jQuery fails gracefully, but it’s still traversing the DOM, looking for elements that aren’t there. Solution Library Shell The Code //hide by default $advancedSearch.slideUp(’3000′); Examples
CoverScroll jQuery plugin by Slobodan Jovanovic This is a CSS3 variant of the Apple's CoverFlow design pattern Usage Options These are the default options: Methods This is a list of methods supported: next - moves to next item $('#container').coverscroll('next'); prev - moves to previous item $('#container').coverscroll('prev'); Example $('#container').coverscroll(); More complex example (shelf) <div id="shelf"><div id="container"><div class="item"><img style="width:100%,height:100%" src="image.jpg" /><div class="itemTitle">the title 1</div></div><! JavaScript the title 1 previous next Adding items shows how CoverScroll starts behaving differently when there are more than five items in the "shelf".
Seven JavaScript Things I Wish I Knew Much Earlier In My Career Advertisement I’ve been writing JavaScript code for much longer than I care to remember. I am very excited about the language’s recent success; it’s good to be a part of that success story. I’ve written dozens of articles, book chapters and one full book on the matter, and yet I keep finding new things. Shortcut Notations One of the things I love most about JavaScript now is shortcut notations to generate objects and arrays. var car = new Object(); car.colour = 'red'; car.wheels = 4; car.hubcaps = 'spinning'; car.age = 4; The same can be achieved with: Much shorter, and you don’t need to repeat the name of the object. The other handy shortcut notation is for arrays. var moviesThatNeedBetterWriters = new Array( 'Transformers','Transformers2','Avatar','Indiana Jones 4' ); The shorter version of this is: var moviesThatNeedBetterWriters = [ 'Transformers','Transformers2','Avatar','Indiana Jones 4' ]; The other thing about arrays is that there is no such thing as an associative array. Resources
“prettyPrint” for JavaScript Those of you following me on Github may have noticed a recently added project called “prettyPrint“. “prettyPrint” is an in-browser JavaScript “variable dumper” similar to ColdFusions’s cfdump. It enables you to print out an object of any type in table format for viewing during debugging sessions. In combination with Firebug, “prettyPrint” will make you the best-equipped JavaScript debugger on earth! (not guaranteed) Some of its key features: Entirely independent. I’ve recorded a short screencast demonstrating a couple of prettyPrint’s features: “prettyPrint” is entirely independent. See the demonstration » Using it is simple enough: var table = prettyPrint( anyRandomThing, { /*optional options object */ } ); // Making the table viewable is down to you...// e.g. document.body.appendChild(table); For more information visit the project’s page on Github! PS.
JavaScript : organiser son code en modules Cet article vous propose d'étudier différentes techniques permettant d'isoler votre code dans des modules « hermétiques », évitant ainsi les interactions involontaires avec le reste de votre code, ou avec le code que vous ne contrôlez pas. JavaScript a été initialement conçu pour être un langage facile à prendre en main. Néanmoins, avec l'augmentation importante des volumes de code utilisés sur Internet, on se heurte désormais comme dans la plupart des langages de programmation aux problèmes inhérents à la cohabitation de plusieurs bibliothèques. L'objectif de cet article est de présenter quelques techniques permettant de rendre vos bibliothèques plus faciles à maintenir, plus lisibles et mieux structurées en les organisant sous forme de modules, minimisant ainsi les risques d'interaction involontaire avec l'extérieur. Enoncé du problème Voici tout d'abord un exemple assez simple, qui sera le fil conducteur de cet article : Cette bibliothèque est à première vue plutôt bien écrite : Conclusion
qTip2 - Pretty powerful tooltips - Demos - Simple integration HTML, Text and AJAX qTip2 allows you to use not only regular textual content, but also complex HTML from other elements on the site. It can even pull content in from other pages via jQuery's .ajax() functionality, and supports in-built titles and close button. Styles and Customisation Not much of an artist? Choose a style from below to change the styling of every qTip on the page! qTip2 even supports styling via the jQuery UI Themeroller themes! Positioning Featuring a fully configurable, human-readable positioning system, qTip2 allows you to easily position your tooltips using element corners, and even reposition themselves when the viewport sizes changes! qTip2 also supports corner positioning on <map>, <area> and all standard <svg> shapes (+transforms!) You can even use the mouse pointer as the positioning target Adding small adjustmentsUsing a different targetViewport repositioning Show and Hide properties Sometimes a regular mouseover just won't cut it, so why hack away? API and Callbacks
Creating your own JavaScript Library One of the phases I went through while learning about JavaScript was the intense desire to write my own library, similar to jQuery (but massively scaled down). My library has gone through several major revisions — and more than one complete re-write, but now is exactly what I started out hoping it would be: functional, clean, small, and a solid learning experience. I’d like to share what I learned from this project, and I hope you share back with me through the comments! Finished project demo Step 1: Identify the purpose of your library This might just be one of the toughest parts of the whole process! Pick one particular function, or aspect of web development/design that you would like your library to handle. I decided my library would be a simple way to manipulate elements visually. Step 2: Mock-up how would use the library You always mock-up a webpage before you start building it right? Have you ever mocked-up your code? We can also tell some design patterns: Step 3: Code up an outline