Converting jQuery Code to a Plugin Martin Angelov When it comes to efficiently organizing jQuery code, one of the best options is turning certain parts of it into a plugin. There are many benefits to this – your code becomes easier to modify and follow, and repetitive tasks are handled naturally. This also improves the speed with which you develop, as plugin organization promotes code reuse. This is why today we are going to demonstrate the process of converting code to a plugin. The Idea Writing a jQuery plugin is not at all difficult. Here are several problems that we need to solve when converting the tutorial code into a jQuery plugin: We need to give users the ability to control what markup is generated for the dropdown. The Code As you remember from the tutorial, our jQuery code scans the select’s option elements and builds an unordered list. This is, however, too specific for a plugin. Lets put this into code: jQuery & CSS3 Select Replacement Plugin $(document).ready(function(){ $('select').tzSelect(); }); script.js jQuery
Codrops Creating a bookmarklet with easyXDM | easyXDM Bookmarklets has been common for a long time and are quite easy to make. But one thing that you often see when examining the code behind bookmarklets are that most of the code is just to facilitate simple cross domain communication back to the whatever service the bookmarklet supports. Following is a sample bookmarklet with support for full RPC and XHR between the page its being applied to and the supporting backend. If you want to, save the above link as a bookmark, navigate to any page on the internet, and hit the bookmark Set up the provider as usual, one example is the xhr provider The bookmark code or as it would look like in a link The main code (bookmark.js) This code does not require any files to be uploaded to the ‘consumer’. Francis Hwang: Should your web application be rich-client from day one? For the sake of discussion, I'm going to make a recommendation about the state of web application development today: If you are writing a new web application, you should make it a rich-client application from the start. Your servers should not generate any HTML. You should do all that work in the browser with a Javascript framework such as Backbone.js or Ember.js, and the server should only talk to the browser via a REST API. I'm not saying I believe this idea 100%, mind you. There's bad news, and there's good news There are plenty of good reasons to avoid jumping on this particular bandwagon: But no matter how rickety the wheels look, there are some good reasons to jump on this bandwagon right now: One day, you'll want all those APIs defined anyway, for iPhone apps, Android apps, mobile-optimized sites, partners, power users, etc. "You Aren't Gonna Need It" vs. A lot of this comes down to cost of change. Nobody ever said "I like it, but I wish it involved more waiting around"
3 Simple Things to Make Your jQuery Code Awesome jQuery is one of the most popular (if not the most) JavaScript libraries in existence and a great number of people use it to do some amazing things. Personally, jQuery is what got me excited for learning JavaScript. The problem is that a lot of programmers don't understand that with all that power massive amounts of CPU cycles are used. As much as jQuery engineers try to optimize jQuery, they are always limited in how fast they can make it go. 1 - jQuery Object Caching Caching your jQuery objects may possibly be the best thing you can do to cut your code down to run leaner and meaner. In all of these cases, you could save some DOM searching trips by assigning the jQuery object to a variable (generally prefixed with a dollar sign to distinguish it as a jQuery object), like so: One of the most expensive operations you can do is query the DOM, especially in older browsers that can't be optimized for with built-in functions. 2 – Selector Optimization 3 – Delegating Events About the Author
25 Free jQuery Photo Gallery / Albums with Tutorials | VisonwidGet 30 Free Photo Gallery / Albums with Tutorials Details Category: Webdev Hits: 20172 jQuery image galleries and albums are very common on portfolio sites and are also useful for any other type of site for displaying images and photos. In this post we’ll see tutorials and plugins that can provide you with the resources that you need to get a gallery of slider on your site. Since they are already so popular I believe you don’t need me to tell you more about it. A Cool Instagram “Gravity” Gallery This will be a script that runs a search on Instagram, fetches and displays the photos in a grid, and then uses the Box2D library to simulate physical interactions between them. {ads1} Fresh Sliding Thumbnails Gallery with jQuery and PHP In this tutorial we are going to create another full page image gallery with a nice thumbnail area that scrolls automatically when moving the mouse. Thumbnail Grid With Expanding Preview Photo Booth Strips With Lightbox Free jQuery Photo Gallery ( Tutorial ) Trip Tracker
Build Internet | Web Design, Development, and Business Scalable JavaScript Design Patterns Introduction Welcome to the resource page for my talk on Scalable JavaScript Design Patterns last presented at Web Directions (South). It's an extended version of the talk I gave at Fronteers and includes more information about a highly-decoupled architecture for building large applications I've been discussing recently. This version of the talk also covered live code demos of 'Aura', a framework based on some of the ideas in the presentation (see lower down for some code examples). Many of the concepts presented build upon previous work by Nicholas Zakas. I'm a firm believer in lowering the barrier of entry to (sometimes) complex concepts in JavaScript; this is one reason why the theme of my slides is 'Star Wars' and some of the initial concepts behind the design patterns used are explained through Star Wars metaphors. Notes In this talk, which expands on my earlier article, I describe a JavaScript application architecture that: Aura Code Samples todo-entry.js todo-counter.js Definitely.
How I built the Hacker News mobile web app - cheeaunblog Last month, I tweeted about one of my recent projects, the Hacker News mobile web app. It's a simple little app to read Hacker News' stories and comments in Mobile Safari. It started out as an experiment for me to try one of the new CSS extensions introduced in Mobile Safari in iOS5, -webkit-overflow-scrolling: touch which uses native-style scrolling in an overflow: scroll element. Before working on this app, I've also worked on another project called Kanade which is a mobile web app that shows a list of anime series for every season. Despite the functionality, the actual reason I create it is that I want to try creating a web app that not only looks native but feels native. There are two parts; the look and the feel. For brevity sake, I'll use the term 'HNmobile' for 'Hacker New mobile web app'. The look Every operating system has its own native look. The latter, of course. I start by getting screenshots. The result is surprisingly good if you compare it with the native interface. The feel
Slide Elements in Different Directions Although jQuery has a nice set of slide methods — .slideDown(), .slideUp(), and .slideToggle() — sometimes we may want to slide an element in a different direction. Fortunately, it's pretty easy to do. Reverse the Slide Direction With the built-in slide methods, elements are shown by sliding them down and into view. But what if we want to slide something from the bottom up and into view? The trick here is to use some judicious CSS. <div id="slidebottom" class="slide"> <button>slide it</button> <div class="inner">Slide from bottom</div></div> To get the inner div to slide up, we'll anchor its bottom edge to the bottom of the bottom of the nearest positioned ancestor (in this case, the #slidebottom div): Other properties such as width, padding, margin, and background-color have been set for these elements, but only the essential properties for modifying the slide behavior are shown above. Now, we can write the jQuery the same way we would with a traditional slide effect: JavaScript: Try it out: