background preloader

JavaScript

Facebook Twitter

jQuery throttle / debounce: Sometimes, less is more! jQuery throttle / debounce allows you to rate-limit your functions in multiple useful ways.

jQuery throttle / debounce: Sometimes, less is more!

Passing a delay and callback to $.throttle returns a new function that will execute no more than once every delay milliseconds. Passing a delay and callback to $.debounce returns a new function that will execute only once, coalescing multiple sequential calls into a single execution at either the very beginning or end. Note for non-jQuery users jQuery isn’t actually required for this plugin, because nothing internal uses any jQuery methods or properties. jQuery is just used as a namespace under which these methods can exist. Since jQuery isn’t actually required for this plugin, if jQuery doesn’t exist when this plugin is loaded, the methods described below will be created in the Cowboy namespace.

Throttle versus debounce Both throttling and debouncing will rate-limit execution of a function, but which is appropriate for a given situation? Throttling A Visualization Key: Usage example 07. 11. 15. Debouncing. jQuery UI DatePicker: Disable Specified Days. One project I'm currently working on requires jQuery.

jQuery UI DatePicker: Disable Specified Days

The project also features a datepicker for requesting a visit to their location. jQuery UI's DatePicker plugin was the natural choice and it does a really nice job. One challenge I encountered was the need to prevent specific days from being picked. Here's the jQuery JavaScript I used to accomplish that. The jQuery JavaScript The base code is taken from this forum post. I'd like to see jQuery UI implement a standard way of disabling days.

Be Heard Tip: Wrap your code in <pre> tags or link to a GitHub Gist! Older Sliding Labels Using MooTools Newer. Arbor.js. Code Playground. Chart Tools. Index scripts. I think - SVG menu tree. JavaScript UI Library, Ajax Components & HTML5 Framework - DHTMLX. Raphaël—JavaScript Library. Créer une carte de France cliquable en HTML5 / SVG. Fichier:Régions de France.svg. Carte de France cliquable en SVG avec la librairie js Raphaël. Je vous propose de faire une carte cliquable des régions françaises (hors Dom Tom), le but ici est d’avoir une carte compatible avec les anciens navigateur (oui même notre ami IE) et sur un maximum de terminaux, donc adieu flash (Flash n’étant pas supporté sur les ipad, iphone et Android).

Carte de France cliquable en SVG avec la librairie js Raphaël

On va donc se concentrer sur le format SVG (wikipédia) et surtout pour assurer la compatibilité avec les anciens navigateurs on va utiliser la librairie JS Raphael. Voici les étapes * Volontairement je ne m’étendrais pas sur la création du fichier SVG, mais sachez qu’avec un logiciel de dessin vectoriel comme inkscape, en sélectionnant un objet (les contours des départements par exemple) et en faisant Ctrl+ Maj + X (Editeur XML) la première ligne « d » correspond aux coordonnées dont nous avons besoin. Ici une belle carte existe déjà profitons en ! Voilà vous avez téléchargé les fichiers, nous allons créer une simple page web nommée index.html, et un répertoire « js » pour nos fichiers javascript.

<! Introduction to Raphaël.js. Introduction SVG, short for Scalable Vector Graphics, is a XML-based language for describing objects and scenes.

Introduction to Raphaël.js

SVG elements can fire events and can be scripted with JavaScript. SVG comes with several built-in primitive types such as circles and rectangles as well as being able to display text. While SVG as a technology is not new, HTML5 now enables SVG objects to be embedded in a page directly without the use of a <object> or <embed> tag bringing it in line with what is currently available with the canvas. Raphaël.js is a JavaScript library that allows you to create SVG scenes programmatically. Drawing Your First Scene Let's begin by drawing a simple scene with Raphaël.

Each SVG object can have attributes assigned to it for things like the the color, rotation, stroke color and size, etc. Drawing Advanced Shapes with Paths.

Impress.js

Spin.js. JSON. TinySort. Annotated ES5. Creating Responsive Applications Using jQuery Deferred and Promises. Today we’re going to explore the concept of deferreds - an important feature found in JavaScript toolkits such as dojo and MochiKit, which recently also made its debut to popular JavaScript library jQuery.

Creating Responsive Applications Using jQuery Deferred and Promises

Deferreds offer a solution for abstracting non-blocking elements (such as the response to ajax requests) and achieve this by creating a ‘promise’ which aims to return a response at some point in the future. If you haven’t come across the concept of ‘promises’ before, we'll be covering them in some detail shortly. At a high-level, deferreds can be thought of as a way to represent costly operations which can take a long time to complete. They’re the asynchronous alternative to blocking functions and the general idea is that rather than your application blocking while it awaits some request to complete before returning a result, a deferred object can instead be returned immediately.

Promises promise = callToAPI( arg1, arg2, ...) The video player for Web · Flowplayer.

jQuery