AdminPageFramework_FieldType_checkbox::getScripts PHP Метод

getScripts() защищенный Метод

protected getScripts ( )
    protected function getScripts()
    {
        new AdminPageFramework_Form_View___Script_CheckboxSelector();
        $_sClassSelectorSelectAll = $this->_getSelectButtonClassSelectors($this->aFieldTypeSlugs, 'select_all_button');
        $_sClassSelectorSelectNone = $this->_getSelectButtonClassSelectors($this->aFieldTypeSlugs, 'select_none_button');
        return <<<JAVASCRIPTS
jQuery( document ).ready( function(){
    // Add the buttons.
    jQuery( '{$_sClassSelectorSelectAll}' ).each( function(){
        jQuery( this ).before( '<div class=\\"select_all_button_container\\" onclick=\\"jQuery( this ).selectAllAdminPageFrameworkCheckboxes(); return false;\\"><a class=\\"select_all_button button button-small\\">' + jQuery( this ).data( 'select_all_button' ) + '</a></div>' );
    });            
    jQuery( '{$_sClassSelectorSelectNone}' ).each( function(){
        jQuery( this ).before( '<div class=\\"select_none_button_container\\" onclick=\\"jQuery( this ).deselectAllAdminPageFrameworkCheckboxes(); return false;\\"><a class=\\"select_all_button button button-small\\">' + jQuery( this ).data( 'select_none_button' ) + '</a></div>' );
    });
});
JAVASCRIPTS;
    }

Usage Example

    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;
    }
All Usage Examples Of AdminPageFramework_FieldType_checkbox::getScripts