jQuery UI Extensions

This my collection of customizations and enhancements to the standard jQuery UI library.

 

Download Latest Version

Features

Usage

Either download the Minified or the Full source and add it after the normal jQuery UI scripts.

Also download the CSS file and include it after any jQuery UI CSS files.

You can also just browse the source and grab what you want to use. Just be mindful of the dependencies:

WaitButton

WaitButton adds two options that enable controling the label and icon used to show the waiting status:

  $('#save')
     .waitbutton({
        waitLabel: 'Saving ...',
        waitIcon: 'my-icon-class'
     })

Neither are required to use the widget. When omitted, the label will remain the same as the current label and the class used for the primary icon will be the default ui-icon-waiting class which expects a GIF named waitbutton-loading.gif to be present in a images folder relative to the CSS file. You can use the one I have created or design your own. Just be aware that the ui-icon class on the button widget a lot 16x16 pixels for the icon.

The widget triggers a waiting event when a user clicks the button. An object is passed to the handler with a callback that should be called once the action is complete. Failure to call the callback will result in the button remaining in the waiting state.

  $('#save')
     .waitbutton({
        waiting: function ( e, ui ) {

           // do something
           ui.done();
        }
     })

or

  $('#save')
     .waitbutton()
     .on( 'buttonwaiting',  function ( e, ui ) {

           // do something
           ui.done();
        }
     })

The done() callback takes up to two option arguments that control the new label and state of the button. Review the demo for examples of each variation.

TimePicker

TimePicker currently exposes the getter/setter function value. After initializing the widget, set the value using a time string:

   $( '#picker' ).timepicker();

   $( '#picker' ).timepicker( 'value', '8:25 AM' );

And retrieve the value as a time string:

   time = $( '#picker' ).timepicker( 'value' );
   // time == '8:25 AM'

You can also initialize the picker to show time in either a 12 or 24 hour clock:

12-hour (default)

   $( '#picker' ).timepicker({ format: 'hh:mm a' });

24-hour

   $( '#picker' ).timepicker({ format: 'HH:mm' });

Optionally, you can include MomentJS to activate more advanced value handling. Without Moment, only time strings will be accepted/returned by the value function. With Moment, you can pass Date, String, or Moment instances to the value function and it will return Moment instances representing the selected time:

   $( '#picker' ).timepicker();

   $( '#picker' ).timepicker( 'value', '8:25 AM' );

   time = $( '#picker' ).timepicker( 'value' );

   time.format( 'HH:mm' ); // 08:25
   time.add( 'm', 5 );
   time.format( 'h:mm A' ); // 8:30 AM

Demo

I created some tests that show what the widgets can do.

License

Copyright (c) 2012-2014 Ben Olson
Licensed under the MIT License