background preloader

JQuery & JS

Facebook Twitter

Removing an element with the plain JavaScript remove() method. As you might know, the DOM does not supports removing an element directly.

Removing an element with the plain JavaScript remove() method

When removing an element with JavaScript, you must go to its parent first instead. This was always odd and not so straightforward. According to DOM level 4 specs, which is the current version in development, there are some new handy mutation methods available: append(), prepend(), before(), after(), replace() and remove(). Make Client Side Data Available Server Side. That would be pretty useful, right?

Make Client Side Data Available Server Side

Right now it's very common to User Agent "sniff" when you want to make a server-side decision about what to give the client. But UA sniffing has always sucked and sucks more every day. Promise-Based Validation. The concept of "Promises" has changed the way we write asynchronous JavaScript.

Promise-Based Validation

Over the past year, many frameworks have incorporated some form of the Promise pattern to make asynchronous code easier to write, read and maintain. For example, jQuery added $.Deferred() and NodeJS has the Q and jspromise modules that work on both client and server. Client-side MVC frameworks, such as EmberJS and AngularJS, also implement their own versions of Promises.

JQuery - Javascript Tools. Make Your UI More Responsive with HTML5 Web Workers. Also read: Using Web Workers to Speed-Up Your JavaScript Applications Argh!!...

Make Your UI More Responsive with HTML5 Web Workers

Your web application has to sort a lot of data and you get the dreaded error message... "A script on this page may be busy, or it may have stopped responding…" Or maybe you're writing some image processing code that takes forever on large images... Your UI is non-responsive. Automatic Table of Contents.

Any long page of content with distinct and well marked up content can benefit from a table to contents.

Automatic Table of Contents

A table of contents provides a quick way to jump down the page to the desired section. Of course you can create a table of contents manually, but it may be smart to build it dynamically on-the-fly with JavaScript. This is true for several reasons:It's easier - write the JavaScript once and it can create the Table on Contents on every page you need it.It's more reliable - the JavaScript isn't subject to authoring errors.It's still accessible - A table of contents is good for the general concept of accessibility, but it is a bonus (not having it doesn't ruin the page) and nearly all screen readers run JavaScript. This kind of thing has been done many times and many ways. Meny - CSS 3D fold-in menu concept.

HTML5 Drag and Drop Avatar Changer with Resizing and Cropping. Posted at CSS Tricks by Chris Coyier In any app that has user avatars, users should be able to change those avatars.

HTML5 Drag and Drop Avatar Changer with Resizing and Cropping

Anything to make that easier is desirable. Many apps start with a user's Twitter avatar, Facebook avatar, or Gravatar. That's a smart move. Avatars give users a sense of ownership over a virtual space so any way to get them to have their desired avatar is good for engagement. The Workhorse of Drag and Drop Perhaps the most important bit we'll deal with is the drop event. Interestingly enough, as written, the above won't work. Using Web Workers to Speed-Up Your JavaScript Applications. Posted at Treehouse by Matt West The performance of JavaScript applications running in the browser has increased considerably over the past few years.

Using Web Workers to Speed-Up Your JavaScript Applications

This is mainly due to continued work on the underlying JavaScript engines (such as V8) that actually execute the code. But as these JavaScript engines get faster, our web applications also demand more. FooTable: a jQuery Plugin for Responsive Data Tables. Posted at CSS Tricks by Brad Vincent These days, everyone is jumping on the responsive bandwagon.

FooTable: a jQuery Plugin for Responsive Data Tables

Apart from responsive layouts, everything is going responsive: sliders, lightboxes, galleries, you name it! But then one day, when I was working on an HTML table with a lot of columns, I thought "How is this going to look on my iPhone? ". And then I searched for "responsive tables" and found Chris' roundup post on a few solutions out there. Sticky Captions Concept. Posted at Codrops by Mary Lou When creating thumbnail grids, we usually want to show image captions on hover to provide more information about the item. Image captions are usually shown in a very specific part of the thumbnail, either on the top, the middle or the bottom. When adding captions to the bottom of a thumbnail it can happen that a thumbnail that is overflowing the viewport (i.e. is partly beyond the "fold") is being hovered but the caption won’t be seen because it appears on the bottom part of the image that is not visible.

The user would have to scroll the page in order to see the bottom of the item and eventually the caption. A small trick can solve that problem by simply making the caption "sticky". What we basically do is to imitate position: sticky but since it’s not yet supported in many browsers, we’ll do a bit of JavaScript to achieve the same result. As an example, let’s take a simple grid with figures and figcaptions: And that's it!

View Demo. Simple Effects fro Drop-Down Lists. Posted at Codrops by Mary Lou Today we want to share some simple drop-down list effects with you. The idea is to transform a normal select input into something more appealing with a jQuery plugin. The expanding of the options will happen with a transition and parameters can be configured in a way to achieve unique effects. Javascript Full Screen API. Posted at Paulund The full screen API is an easy way to get the full web content to be displayed on the page. It's very similar to pressing F11 on your keyboard but this can be done at the developers choice. This is a great feature to use for things on slideshows, you can make the browser go into full screen on a click of an image.

The best thing about this feature is that it doesn't have to be the entire page, you can make any HTML element go full screen. This mean instead of always making the entire page go full screen, just assign the full screen API to an image and on the click of the image you can just focus on the image in full screen. Full Screen API support Unfortunately not all browsers support this feature so you need to make sure that your visitors browser supports this feature before you try to use it.

Real-Time Geolocation Service with Node.js.

Content/Page scroll

How to Capture CSS3 Animation Events in JavaScript. Posted at Sitepoint by Craig Buckler CSS3 animations are smooth and quick to implement but, unlike JavaScript, you don’t have frame-by-frame control.

How to Capture CSS3 Animation Events in JavaScript

Fortunately, you can apply event handlers to any element to determine the animation state. This permits fine-grained control such as playing different animations in sequence. Consider this simple CSS3 animation: JQuery - Javascript Tools. jQuery Sticky Header. Posted at gazpo In this tutorial we will create sticky header that is initially on its original place above the content, but as soon we start scrolling down the long page, it sticks at the top of the page.

jQuery Sticky Header

When scrolling up the page, the sticky header stops sticking and returns to its original position. We will use jQuery to create the sticky header. The HTML structure is very simple. Cool Animated Menu with jQuery. Posted at Line25 by Chris Spooner In this tutorial we’ll be building a cool navigation list complete with a sliding hover effect. Learn how to build the concept in Photoshop, lay out the basic HTML elements, style everything up in CSS then tie it all together with a few lines of jQuery to create a semantic, accessible and degradable menu design.

The design we’ll be building features a cool label image that slides into place under each navigation item on hover. Web Application Development with Sencha Ext JS Framework.

Images/SlideShows

Adding a Timepicker to jQuery UI Datepicker. Getting Started Highly Recommended Handling Time eBook. List of Videos for jQuery. JavaScripts Tutorials. JavaScript Design Patterns. I would like to thank Rebecca Murphey for inspiring me to open-source this mini-book and release it for free download and distribution - making knowledge both open and easily available is something we should all strive for where possible. I would also like to extend my thanks to the very talented Alex Sexton who was kind enough to be the technical reviewer for this publication. I hope that it helps you learn more about design patterns and the usefulness of their application to JavaScript.

Volume 2 of Essential JavaScript Design Patterns is currently being written and will be more detailed than this first edition. The ETA for it's online release is late Q4, 2011. For more detailed coverage of specific patterns, you may be interested in my posts on the Pub/Sub (Observer) or Decorator patterns. At the beginning of this book I will be focusing on a discussion about the importance and history of design patterns in any programming language. Patterns are not an exact solution. How To Use Impress.Js (creating online presentations) Yesterday, I wrote about Impress.js , an awesome JavaScript library for creating online presentations. Since posting online, I’ve had several people ask how exactly to use it, as there’s no set documentation on the actual project page.