balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

redux-date.js (1281B)


      1 /*global jQuery, redux*/
      2 
      3 (function( $ ) {
      4 	'use strict';
      5 
      6 	redux.field_objects      = redux.field_objects || {};
      7 	redux.field_objects.date = redux.field_objects.date || {};
      8 
      9 	redux.field_objects.date.init = function( selector ) {
     10 		selector = $.redux.getSelector( selector, 'date' );
     11 
     12 		$( selector ).each(
     13 			function() {
     14 				var el     = $( this );
     15 				var parent = el;
     16 
     17 				if ( ! el.hasClass( 'redux-field-container' ) ) {
     18 					parent = el.parents( '.redux-field-container:first' );
     19 				}
     20 
     21 				if ( parent.is( ':hidden' ) ) {
     22 					return;
     23 				}
     24 
     25 				if ( parent.hasClass( 'redux-field-init' ) ) {
     26 					parent.removeClass( 'redux-field-init' );
     27 				} else {
     28 					return;
     29 				}
     30 
     31 				el.find( '.redux-datepicker' ).each(
     32 					function() {
     33 						$( this ).datepicker(
     34 							{
     35 								'dateFormat': 'mm/dd/yy', beforeShow: function( input, instance ) {
     36 									var el      = $( '#ui-datepicker-div' );
     37 									var popover = instance.dpDiv;
     38 
     39 									$( this ).parent().append( el );
     40 
     41 									el.hide();
     42 									setTimeout(
     43 										function() {
     44 											popover.position(
     45 												{ my: 'left top', at: 'left bottom', collision: 'none', of: input }
     46 											);
     47 										},
     48 										1
     49 									);
     50 								}
     51 							}
     52 						);
     53 					}
     54 				);
     55 			}
     56 		);
     57 	};
     58 })( jQuery );