protected function getScripts()
{
$_aJSArray = json_encode($this->aFieldTypeSlugs);
return parent::getScripts() . <<<JAVASCRIPTS
/* For tabs */
var enableAdminPageFrameworkTabbedBox = function( nodeTabBoxContainer ) {
jQuery( nodeTabBoxContainer ).each( function() {
jQuery( this ).find( '.tab-box-tab' ).each( function( i ) {
if ( 0 === i ) {
jQuery( this ).addClass( 'active' );
}
jQuery( this ).click( function( e ){
// Prevents jumping to the anchor which moves the scroll bar.
e.preventDefault();
// Remove the active tab and set the clicked tab to be active.
jQuery( this ).siblings( 'li.active' ).removeClass( 'active' );
jQuery( this ).addClass( 'active' );
// Find the element id and select the content element with it.
var thisTab = jQuery( this ).find( 'a' ).attr( 'href' );
active_content = jQuery( this ).closest( '.tab-box-container' ).find( thisTab ).css( 'display', 'block' );
active_content.siblings().css( 'display', 'none' );
});
});
});
};
jQuery( document ).ready( function() {
enableAdminPageFrameworkTabbedBox( jQuery( '.tab-box-container' ) );
/* The repeatable event */
jQuery().registerAdminPageFrameworkCallbacks( {
/**
* Called when a field of this field type gets repeated.
*/
repeated_field: function( oCloned, aModel ) {
// Update attributes.
oCloned.find( 'div, li.category-list' ).incrementAttribute(
'id', // attribute name
aModel[ 'incremented_from' ], // index incremented from
aModel[ 'id' ] // digit model
);
oCloned.find( 'label' ).incrementAttribute(
'for', // attribute name
aModel[ 'incremented_from' ], // index incremented from
aModel[ 'id' ] // digit model
);
oCloned.find( 'li.tab-box-tab a' ).incrementAttribute(
'href', // attribute name
aModel[ 'incremented_from' ], // index incremented from
aModel[ 'id' ] // digit model
);
// Initialize
enableAdminPageFrameworkTabbedBox( oCloned.find( '.tab-box-container' ) );
},
},
{$_aJSArray}
);
});
JAVASCRIPTS;
}