/** * Returns the output of the field type. * * Returns the output of post type checklist check boxes. * * @remark the posttype checklist field does not support multiple elements by passing an array of labels. * @since 2.0.0 * @since 2.1.5 Moved from AdminPageFramework_FormField. * @since 3.0.0 Reconstructed entirely. * @since 3.3.1 Changed from `_replyToGetField()`. */ protected function getField($aField) { $this->_sCheckboxClassSelector = ''; // disable the checkbox class selector. $aField['label'] = $this->_getPostTypeArrayForChecklist(isset($aField['slugs_to_remove']) ? $this->getAsArray($aField['slugs_to_remove']) : $this->aDefaultRemovingPostTypeSlugs, $aField['query'], $aField['operator']); return parent::getField($aField); }
/** * Returns the output of the field type. */ public function getField($aField) { // Fix some checkbox specific field arguments. $aField['label'] = ''; $aField['select_all_button'] = false; $aField['select_none_button'] = false; $_sOutput = parent::getField($aField); $_sOutput = str_replace("<div class='repeatable-field-buttons'></div>", '', $_sOutput); return $_sOutput . "<div class='toggle-button-container'>" . $this->_getToggleElement($aField) . "</div>" . "<div class='repeatable-field-buttons'></div>"; }
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( { /** * The repeatable field callback for the add event. * * @param object node * @param string the field type slug * @param string the field container tag ID * @param integer the caller type. 1 : repeatable sections. 0 : repeatable fields. */ added_repeatable_field: function( oCloned, sFieldType, sFieldTagID, iCallType ) { // Repeatable Sections if ( 1 === iCallType ) { var _oSectionsContainer = jQuery( oCloned ).closest( '.admin-page-framework-sections' ); var _iSectionIndex = _oSectionsContainer.attr( 'data-largest_index' ); var _sSectionIDModel = _oSectionsContainer.attr( 'data-section_id_model' ); jQuery( oCloned ).find( 'div, li.category-list' ).incrementAttribute( 'id', // attribute name _iSectionIndex, // increment from _sSectionIDModel // digit model ); jQuery( oCloned ).find( 'label' ).incrementAttribute( 'for', // attribute name _iSectionIndex, // increment from _sSectionIDModel // digit model ); jQuery( oCloned ).find( 'li.tab-box-tab a' ).incrementAttribute( 'href', // attribute name _iSectionIndex, // increment from _sSectionIDModel // digit model ); } // Repeatable fields else { var _oFieldsContainer = jQuery( oCloned ).closest( '.admin-page-framework-fields' ); var _iFieldIndex = Number( _oFieldsContainer.attr( 'data-largest_index' ) - 1 ); var _sFieldTagIDModel = _oFieldsContainer.attr( 'data-field_tag_id_model' ); jQuery( oCloned ).find( 'div, li.category-list' ).incrementAttribute( 'id', // attribute name _iFieldIndex, // increment from _sFieldTagIDModel // digit model ); jQuery( oCloned ).find( 'label' ).incrementAttribute( 'for', // attribute name _iFieldIndex, // increment from _sFieldTagIDModel // digit model ); jQuery( oCloned ).find( 'li.tab-box-tab a' ).incrementAttribute( 'href', // attribute name _iFieldIndex, // increment from _sFieldTagIDModel // digit model ); } enableAdminPageFrameworkTabbedBox( jQuery( oCloned ).find( '.tab-box-container' ) ); } }, {$_aJSArray} ); }); JAVASCRIPTS; }
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; }
protected function getScripts() { $_aJSArray = json_encode($this->aFieldTypeSlugs); return parent::getScripts() . <<<JAVASCRIPTS /* For tabs */ var enableAPFTabbedBox = 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() { enableAPFTabbedBox( jQuery( '.tab-box-container' ) ); /* The repeatable event */ jQuery().registerAPFCallback( { /** * The repeatable field callback for the add event. * * @param object node * @param string the field type slug * @param string the field container tag ID * @param integer the caller type. 1 : repeatable sections. 0 : repeatable fields. */ added_repeatable_field: function( oClonedField, sFieldType, sFieldTagID, iCallType ) { /* If it is not the color field type, do nothing. */ if ( jQuery.inArray( sFieldType, {$_aJSArray} ) <= -1 ) { return; } oClonedField.nextAll().andSelf().each( function() { jQuery( this ).find( 'div' ).incrementIDAttribute( 'id' ); jQuery( this ).find( 'li.tab-box-tab a' ).incrementIDAttribute( 'href' ); jQuery( this ).find( 'li.category-list' ).incrementIDAttribute( 'id' ); enableAPFTabbedBox( jQuery( this ).find( '.tab-box-container' ) ); }); }, /** * The repeatable field callback for the remove event. * * @param object the field container element next to the removed field container. * @param string the field type slug * @param string the field container tag ID * @param integer the caller type. 1 : repeatable sections. 0 : repeatable fields. */ removed_repeatable_field: function( oNextFieldConainer, sFieldType, sFieldTagID, iCallType ) { /* If it is not the color field type, do nothing. */ if ( jQuery.inArray( sFieldType, {$_aJSArray} ) <= -1 ) { return; } oNextFieldConainer.nextAll().andSelf().each( function() { jQuery( this ).find( 'div' ).decrementIDAttribute( 'id' ); jQuery( this ).find( 'li.tab-box-tab a' ).decrementIDAttribute( 'href' ); jQuery( this ).find( 'li.category-list' ).decrementIDAttribute( 'id' ); }); } }); }); JAVASCRIPTS; }