Ajax Updates

Ajax Updates


AD Gallery, gallery plugin for jQuery

Posted: 09 Oct 2009 11:25 AM PDT

A highly customizable gallery/showcase plugin for jQuery.

Features

* Choose effect, should the image slide in, or fade in?
* Show fifth image by adding #ad-image4 to the url, this takes precedence over over settings.start_at_index
* jQuery call returns gallery instances, which enables you to change settings on the fly like the “Change to fade effect” link above
* Keyboard arrows to move back and forth
* Click on the edge of the big image to go to the next/previous
* Images are preloaded, and if the aren’t finished loading when they are supposed to be displayed, a loading image will appear
* Slideshow count down only begins when the image has loaded and is visible
* Image title, can either be set in the title attribute, or in elm.data(’ad-title’, ‘My title here’). $.data takes precedence over the title attribute
* Image descriptions, can either be set in the longdesc attribute, or in elm.data(’ad-desc’, ‘My description here’). $.data takes precedence over the longdesc attribute
* Callbacks on different events that has access to the internal object, which means that you can access all internal methods, etc
* Takes the dimensions of the image container div and scales down images that are larger than it
* Image is positioned in the middle if it’s smaller than the container div
* Images that are larger than the container are scaled down to fit inside the container

Browser compatibility

The script has currently been tested in Firefox 3/Win, Firefox 3.5/Mac, IE6+7+8/Win, Chrome 2/Win, Safari 3/Win, Safari 4/Mac, Opera 9/Win, Opera 9/Mac. If you have seen it working correctly in some other browser, or on some other platform, please let me know.

Example code

Don’t worry, all of these options are optional.

var galleries = $('.ad-gallery').adGallery({   loader_image: 'loader.gif',   width: 600, // Width of the image, set to false and it will read the CSS width   height: 400, // Height of the image, set to false and it will read the CSS height   thumb_opacity: 0.7, // Opacity that the thumbs fades to/from, (1 removes fade effect)                       // Note that this effect combined with other effects might be resource intensive                       // and make animations lag   start_at_index: 0, // Which image should be displayed at first? 0 is the first image   animate_first_image: false, // Should first image just be displayed, or animated in?   animation_speed: 400, // Which ever effect is used to switch images, how long should it take?   display_next_and_prev: true, // Can you navigate by clicking on the left/right on the image?   display_back_and_forward: true, // Are you allowed to scroll the thumb list?   scroll_jump: 0, // If 0, it jumps the width of the container   slideshow: {     enable: true,     autostart: true,     speed: 5000,     start_label: 'Start',     stop_label: 'Stop',     stop_on_scroll: true, // Should the slideshow stop if the user scrolls the thumb list?     countdown_prefix: '(', // Wrap around the countdown     countdown_sufix: ')',     onStart: function() {       // Do something wild when the slideshow starts     },     onStop: function() {       // Do something wild when the slideshow stops     }   },   effect: 'slide-hori', // or 'slide-vert', 'resize', 'fade', 'none' or false   enable_keyboard_move: true, // Move to next/previous image with keyboard arrows?   cycle: true, // If set to false, you can't go from the last image to the first, and vice versa   // All callbacks has the AdGallery objects as 'this' reference   callbacks: {     // Executes right after the internal init, can be used to choose which images     // you want to preload     init: function() {       // preloadAll uses recursion to preload each image right after one another       this.preloadAll();       // Or, just preload the first three       this.preloadImage(0);       this.preloadImage(1);       this.preloadImage(2);     },     // This gets fired right after the new_image is fully visible     afterImageVisible: function() {       // For example, preload the next image       var context = this;       this.loading(true);       this.preloadImage(this.current_index + 1,         function() {           // This function gets executed after the image has been loaded           context.loading(false);         }       );        // Want slide effect for every other image?       if(this.current_index % 2 == 0) {         this.settings.effect = 'slide';       } else {         this.settings.effect = 'fade';       }     },     // This gets fired right before old_image is about to go away, and new_image     // is about to come in     beforeImageVisible: function(new_image, old_image) {       // Do something wild!     }   } });  // Set image description some_img.data('ad-desc', 'This is my description!');  // Change effect on the fly galleries[0].settings.effect = 'fade';  

HTML:

 <div class="ad-gallery">   <div class="ad-image-wrapper">   </div>   <div class="ad-controls">   </div>   <div class="ad-nav">     <div class="ad-thumbs">       <ul class="ad-thumb-list">         <li>           <a href="images/1.jpg">             <img src="images/thumbs/t1.jpg" title="Title for 1.jpg"/>           </a>         </li>         <li>           <a href="images/2.jpg">             <img src="images/thumbs/t2.jpg" longdesc="Description of the image 2.jpg"/>           </a>         </li>       </ul>     </div>   </div> </div>  

These are the only elements required for it to work. If you want, you can add all sorts of crazy elements inside those elements, but I would advice you not to put stuff into .ad-image-wrapper for the simple reason that it’s emptied on start up.
Customize

You can alter the way it looks by editing the CSS file, or overriding the default CSS rules.
Image sizes

You probably want some other image size than the one in the demo above, and the only thing you need to do for this is to add this pice of CSS.

 .ad-gallery {   width: YOUR-IMAGE-WIDTHpx; } .ad-gallery .ad-image-wrapper {   height: YOUR-IMAGE-HEIGHTpx; }   

Or you can specify it in the settings.width and settings.height. If you do that though, the gallery might flicker on page load, since it might take a while before that code runs, so I would suggest that you set it with CSS. If you want bigger thumbnails, the height of the thumb list adjusts itself to that, but you might want to position the arrows next to the list of your thumbs. You do that by adding this CSS and modifying to fit your needs.

 .ad-gallery .ad-back {   left: -20px;   width: 13px;   background: url(your_back_button.png) no-repeat; } .ad-gallery .ad-forward {   right: -20px;   width: 13px;   background: url(your_forward_button.png) no-repeat; }  

Animations

 // The first argument is the name of your animation, which you then set in // galleries[0].settings.effect // The second argument is the function that handles the animation and it takes // three arguments. The first is a jQuery object to the div that holds the image // element and the image description element of the image that should be displayed // The second is the direction, either 'left' or 'right' // The third is the jQuery object that holds the description // Your function should return an object like this: // {old_image: {}, new_image: {}, speed: 100, easing: 'swing'} // 'speed' and 'easing' are optional // 'old_image' and 'new_image' are sent to the jQuery animate-method // so use it just like you would use the $.animate-method // This function gets executed with the gallery instance as its context // so 'this' points to the gallery instance galleries[0].addAnimation('wild',   function(img_container, direction, desc) {     var current_left = parseInt(img_container.css('left'), 10);     var current_top = parseInt(img_container.css('top'), 10);     if(direction == 'left') {       var old_image_left = '-'+ this.image_wrapper_width +'px';       img_container.css('left',this.image_wrapper_width +'px');       var old_image_top = '-'+ this.image_wrapper_height +'px';       img_container.css('top', this.image_wrapper_height +'px');     } else {       var old_image_left = this.image_wrapper_width +'px';       img_container.css('left','-'+ this.image_wrapper_width +'px');       var old_image_top = this.image_wrapper_height +'px';       img_container.css('top', '-'+ this.image_wrapper_height +'px');     };     if(desc) {       desc.css('bottom', '-'+ desc[0].offsetHeight +'px');       desc.animate({bottom: 0}, this.settings.animation_speed * 2);     };     img_container.css('opacity', 0);     return {old_image: {left: old_image_left, top: old_image_top, opacity: 0},             new_image: {left: current_left, top: current_top, opacity: 1},             easing: 'easeInBounce',             speed: 2500};   } ); 

You can now add your own animation, by doing something like this.





Demo: http://coffeescripter.com/code/ad-gallery/
Download: http://coffeescripter.com/code/ad-gallery/jquery.ad-gallery.1.2.2.zip
Source: http://coffeescripter.com/code/ad-gallery/

Related Listings:

  1. GalleryView – A jQuery Content Gallery Plugin Using GalleryView requires a simple function call and four parameters:...
  2. E24Squares Gallery Script E24Squares is an extension written for scriptaculous to make transitions...
  3. Minishowcase Gallery Script Minishowcase is a small and simple php/javascript online photo gallery,...

FireQuery – a collection of Firebug enhancements for jQuery

Posted: 09 Oct 2009 10:59 AM PDT

FireQuery is a Firefox addon integrated with Firebug. jQuery expressions are intelligently presented in Firebug Console and DOM inspector. jQuerify enables you to inject jQuery into any web page.

Features:
FireQuery is a Firefox addon integrated with Firebug

* jQuery expressions are intelligently presented in Firebug Console and DOM inspector
* attached jQuery datas are first class citizens
* elements in jQuery collections are highlighted on hover
* jQuerify: enables you to inject jQuery into any web page

Compatibility

* v0.3 works with official Firebug 1.3 and official Firebug 1.4 (Firefox 2.0 – 3.5)
* v0.2 works with beta Firebug 1.4 (Firefox 3.0.x or Firefox 3.5)

Installation

The best way is to install the addon from addons.mozilla.org or you can go wild and build this on your own.
Security

This extension may be insecure!

So please don’t browse porn sites with this enabled. I still don’t fully understand Firefox extension security model. The reality is that I’m interacting with naked HTML page from privileged code which may be insecure.

Good solution is to have dedicated Firefox profile for development and use it only for safe sites.
Build instructions

If you want to install latest addon from sources, you need to build it. It should be simple, but make sure you have these tools on your paths:

Build steps:

 git clone git://github.com/darwin/firequery.git cd firequery rake

After that your XPI should be available in build/firequery-X.Y.xpi.

You should be able to install XPI file into Firefox: File -> Open File … and browse for firequery-X.Y.xpi





Download: git://github.com/darwin/firequery.git
Source: http://firequery.binaryage.com

Related Listings:

  1. Firediff – Firebug extension that tracks changes to a pages DOM and CSS Firediff is a Firebug extension that tracks changes to a...
  2. Date and Time Picker CalendarDateSelect is semi-light-weight (about ~20k of javascript/css) and easy to...
  3. Online Javascript Code Beautifier This beautifier can process your messy or compacted javascript, making...

ClearField : jQuery Plugin

Posted: 09 Oct 2009 10:39 AM PDT

This plugin takes care of your input fields. Often used by opt-in input fields where the default value of the field is something like “Your e-mail address”. If you click the field the text disappears so that you can type your e-mail address.

The plugin depends on the jQuery framework and is very simple to implement.
How to use:
Put this in your HTML pages header:

 <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.clearfield.js"></script>

Add this function somewhere on the page:

 $(document).ready(function() { 	$('.clearField').clearField(); });

Your input field might look like this:

 <input type="text" class="clearField" value="What's your name?" /> 

Setting:
As you can see the default value is grayed out, and when you type something in the field it’s black. This is because the fields are provided with a specific class on the ‘active’ and ‘blurred’ state. I know, the active state doesn’t have much added value, but hey… it’s there. :) To style the field depending on it’s status, just add these stylesheets to your layout:

 .clearFieldBlurred { color: #666; font-style: italic; } .clearFieldActive { color: #000; }

You probably only need the .clearFieldBlurred class, style it to your needs!
It’s possible to rename those classes, do so in your javascript function:

 $(document).ready(function() { 	$('.clearField').clearField({ 		blurClass: 'myBlurredClass', 		activeClass: 'myActiveClass' 	}); });






Demo: http://labs.thesedays.com/projects/jquery/clearfield/
Download: http://plugins.jquery.com/files/clearfield.js.txt
Source: http://labs.thesedays.com/projects/jquery/clearfield/

Related Listings:

  1. jQuery Field Plugin This plugin greatly expands the ability to retrieve and set...
  2. ToggleFormText : jQuery Plugin ToggleFormText is a jQuery plugin to enable help text for...
  3. jQuery Plugin – autoSave autoSave is the result of one too many user complaints...

UITableFilter – jQuery Plugin

Posted: 09 Oct 2009 10:17 AM PDT

A simple and easy to use jQuery plugin for filtering table rows.
make an html table editable by the user
user clicks on a cell, edits the value,
then presses enter or clicks on any cell to save the new value

Options :

* off : turns off table editing
* find : defaults to tbody > tr > td
* mousedown : callback on mouseDown event
called in context of the table cell
if mousedown returns false, cell will not become editable
* dataVerify : callback after cell has been changed
called in context of the cell,
if dataVerify returns false, cell will stay in editable state
if dataVerify returns a value, that value will replace the cell’s value
arguments are cell’s value, original text, event
* editDone : invoked on completion
arguments are cell’s new value, original text

$(function() {   var theTable = $('table.food_planner')    theTable.find("tbody > tr").find("td:eq(1)").mousedown(function(){     $(this).prev().find(":checkbox").click()   });    $("#filter").keyup(function() {     $.uiTableFilter( theTable, this.value );   })    $('#filter-form').submit(function(){     theTable.find("tbody > tr:visible > td:eq(1)").mousedown();     return false;   }).focus(); //Give focus to input field });    






Demo: http://gregweber.info/projects/demo/flavorzoom.html
Download: http://plugins.jquery.com/files/jquery.uitableedit.js_3.txt
Source: http://gregweber.info/projects/uitableedit.html

Related Listings:

  1. KeyTable – jQuery Table Plugin KeyTable is a Javascript library which provides keyboard navigation and...
  2. Table Editor with jQuery TableEditor provides flexible in place editing of HTML tables. User...
  3. Scrollable Table – JQuery Plugin This JavaScript code can be used to convert tables in...

Jquery Plugin – Feedback

Posted: 09 Oct 2009 09:51 AM PDT

Feedback is a jQuery plugin that lets you send Feedback messages to a user after any event you choose. You can use it for custom error message handling, for example. So if you write some custom script to perform either a client or server-side validation, you can use Feedback to send an error message. Or, you can send informational messages. It uses the jQuery UI plugin to determine the default styles of the informational and error messages, so it is dependent on that plugin. It has properties that make it easy to position a feedback message next to an existing page element. For example, to place it to the right of an input field, just specify a property of right: true. Here's a sample implementation:

  $("#msg_btn").click(function() { $(this).feedback("This is an informational message!", {duration: 3000, right: true}); });  

This example uses a button with an id of 'msg_btn'. When you click it, the info message appears to the right of the button and stays there for 3 seconds, then fades out.

Property Default Value Valid Values Purpose
type "info" "info" or "error" Type of message. "info" uses jQuery UI default info message style, 'error' uses jQuery UI default error message style. See jQueryUI or themeroller for examples.
infoIcon "ui-icon-info" Any. Class for info message icon. "ui-icon-info" is used by default if you specify type: "info". This is the appropriate jQuery UI class for info message icons
infoClass "ui-state-highlight ui-corner-all" Any. Class for info message. "ui-state-highlight ui-corner-all" are used by default if you specify type: "info". This is the appropriate jQuery UI class for info messages.
errorIcon "ui-icon-alert" Any. Class for error message icon. "ui-icon-alert" is used by default if you specify type: "error". This is the appropriate jQuery UI class for error message icons
errorClass "ui-state-error ui-corner-all" Any. Class for error message. "ui-state-error ui-corner-all" are used by default if you specify type: "error". This is the appropriate jQuery UI class for error messages.
duration "2000″ 0-90000. Duration in milliseconds (eg: 2000 = 2 seconds). The message fades away at the end of this time period.
left "false" "true" or "false" Position message to left of reference element – true or false.
right "false" "true" or "false" Position message to right of reference element – true or false.
above "false" "true" or "false" Position message above reference element – true or false.
below "false" "true" or "false" Position message below reference element – true or false.
offsetX "0″ value in pixels Offset on x-axis. If you specify left:true then a positive value moves the message further left. If you specify right: true then a positive value moves the message further right.
offsetY "0″ value in pixels Offset on y-axis. If you specify above:true then a positive value moves the message up higher. If you specify bottom: true then a positive value moves the message further down.
Example Installation

This plugin depends on the jQuery UI, so you can use it with any page designs that take advantage of all the other jQuery UI components to have a consistent look. If you don't know how to use or configure jQuery UI, go to Themeroller for info. Here is an example implementation, which includes the appropriate stylesheet for the jQuery UI Lightness theme, the jQuery core, the jQuery UI core, and the plugin source:

  <link href="jquery/ui/css/ui-lightness/jquery-ui-1.7.1.custom.css" type="text/css" rel="stylesheet" /> <script src="jquery/core/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="jquery/ui/jquery-ui-1.7.1.custom.min.js" type="text/javascript" ></script> <script src="jquery/plugins/feedback/jquery.feedback-1.0.js" type="text/javascript" ></script> 






Demo: http://www.fbloggs.com/sandbox/index.html
Download: http://www.fbloggs.com/sandbox/jquery/plugins/feedback/jquery.feedback-1.0.js
Source: http://www.fbloggs.com/jquery-plugin-feedback/

Related Listings:

  1. Accordion Plugin using Jquery Script This plugin is now part of jQuery UI and this...
  2. Impromptu – prompt jQuery plugin for Forms jQuery Impromptu is an extention to help provide a more...
  3. Humanized Messages jQuery extension written by me, based on Aza Raskin's...

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.