Import legacy nurinda.co.id website
This commit is contained in:
1 parent
3f59bb9038
commit
6e21646ac4
13389 files changed
+3246690
No files matched your search
@@ -0,0 +1,57 @@
|
||||
jQuery( function ( $ )
|
||||
{
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Update date picker element
|
||||
* Used for static & dynamic added elements (when clone)
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
var $this = $( this ),
|
||||
options = $this.data( 'options' ),
|
||||
$inline = $this.siblings( '.mashsb-rwmb-datetime-inline' ),
|
||||
$timestamp = $this.siblings( '.mashsb-rwmb-datetime-timestamp' ),
|
||||
current = $this.val();
|
||||
|
||||
$this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
|
||||
if ( $timestamp.length )
|
||||
{
|
||||
var $picker = $inline.length ? $inline : $this;
|
||||
options.onSelect = function ()
|
||||
{
|
||||
$timestamp.val( getTimestamp( $picker.datepicker( 'getDate' ) ) );
|
||||
};
|
||||
}
|
||||
|
||||
if ( $inline.length )
|
||||
{
|
||||
options.altField = '#' + $this.attr( 'id' );
|
||||
$inline
|
||||
.removeClass( 'hasDatepicker' )
|
||||
.empty()
|
||||
.prop( 'id', '' )
|
||||
.datepicker( options )
|
||||
.datepicker( 'setDate', current );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this.removeClass( 'hasDatepicker' ).datepicker( options );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert date to Unix timestamp in milliseconds
|
||||
* @link http://stackoverflow.com/a/14006555/556258
|
||||
* @param date
|
||||
* @return number
|
||||
*/
|
||||
function getTimestamp( date )
|
||||
{
|
||||
var milliseconds = Date.UTC( date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds() );
|
||||
return Math.floor( milliseconds / 1000 );
|
||||
}
|
||||
|
||||
$( ':input.mashsb-rwmb-date' ).each( update );
|
||||
$( '.mashsb-rwmb-input' ).on( 'clone', ':input.mashsb-rwmb-date', update );
|
||||
} );
|
||||
Reference in new issue
Block a user