Skip to content

Commit

Permalink
Clean-up, implement the toggle-all button
Browse files Browse the repository at this point in the history
  • Loading branch information
pglewis committed Dec 11, 2013
1 parent 78a5b6f commit c11a041
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 112 deletions.
30 changes: 26 additions & 4 deletions admin/assets/js/admin.js
Expand Up @@ -3,27 +3,49 @@

$( function () {

var ajax_action = 'pods_export_code';

var $export_button = $( '#export' );
var $toggle_all_button = $( '#toggle-all' );

var $checkboxes = $( '.pods-field.pods-boolean input' );
var $output = $( '#feedback' );

// Event to run the export
$( '.submit #export' ).click( function ( e ) {
$export_button.click( function ( e ) {
e.preventDefault();

// Get an array of selected Pod names
var pod_names = [];
$( '.pods-field.pods-boolean input:checked' ).each( function () {
$checkboxes.filter( ':checked' ).each( function () {
pod_names.push( $( this ).attr( 'name' ) );
} );

// AJAX call
var data = {
action : 'pods_export_code',
action : ajax_action,
pod_names : pod_names
};
$.post( ajaxurl, data, function ( response ) {
$('#feedback').html( response );
$output.html( response );
} );

} );

// Handle toggle click
$toggle_all_button.click( function ( e ) {
e.preventDefault();

// Any unchecked boxes? Check them all.
if ( $checkboxes.not( ':checked' ).length > 0 ) {
$checkboxes.prop( 'checked', true );
}
// All were checked, uncheck them all.
else {
$checkboxes.prop( 'checked', false );
}
} );

} );

}( jQuery ));
20 changes: 0 additions & 20 deletions admin/class-pods-export-code.php
Expand Up @@ -43,10 +43,6 @@ private function __construct () {
// Hook into the pods admin menu
add_filter( 'pods_admin_menu', array( $this, 'add_plugin_admin_menu' ) );

// Add an action link pointing to the options page.
$plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_slug . '.php' );
add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) );

// Ajax handler
add_action( 'wp_ajax_pods_export_code', array( $this, 'pods_export_code' ) );
}
Expand Down Expand Up @@ -154,22 +150,6 @@ public function display_plugin_admin_page () {
include_once( 'views/admin.php' );
}

/**
* Add settings action link to the plugins page.
*
* @since 1.0.0
*/
public function add_action_links ( $links ) {

return array_merge(
array(
'settings' => '<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_slug ) . '">' . __( 'Settings', $this->plugin_slug ) . '</a>'
),
$links
);

}

/**
* AJAX handler
*/
Expand Down
1 change: 0 additions & 1 deletion admin/includes/index.php

This file was deleted.

88 changes: 37 additions & 51 deletions admin/views/admin.php
@@ -1,61 +1,47 @@
<?php
/**
* Represents the view for the administration dashboard.
*
* This includes the header, options, and other information that should provide
* The User Interface to the end user.
*
* @package Plugin_Name
* @author Your Name <email@example.com>
* @license GPL-2.0+
* @link http://example.com
* @copyright 2013 Your Name or Company Name
*/
?>
<div class="wrap">
<div class="wrap">

<?php screen_icon( 'options-general' ); ?>
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
<?php screen_icon( 'options-general' ); ?>
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>

<form action="" method="post" class="pods-submittable">
<div class="stuffbox pods-export-code">
<h3><label for="link_name"><?php _e( 'Choose which Pods to export', 'pods' ); ?></label></h3>
<form action="" method="post" class="pods-submittable">
<div class="stuffbox pods-export-code">
<h3><label for="link_name"><?php _e( 'Choose which Pods to export', 'pods' ); ?></label></h3>

<div class="pods-manage-field">
<div class="pods-field-option-group">
<p>
<a href="#" class="button" ><?php _e( 'Toggle all on / off', 'pods' ); ?></a>
</p>
<div class="pods-manage-field">
<div class="pods-field-option-group">
<p id="toggle-all">
<a href="#" class="button"><?php _e( 'Toggle all on / off', 'pods' ); ?></a>
</p>

<div class="pods-pick-values pods-pick-checkbox pods-zebra">
<ul>
<?php
$pods = pods_api()->load_pods( array( 'fields' => false ) );
$zebra = false;
foreach ( $pods as $this_pod ) {
<div class="pods-pick-values pods-pick-checkbox pods-zebra">
<ul>
<?php
$pods = pods_api()->load_pods( array( 'fields' => false ) );
$zebra = false;
foreach ( $pods as $this_pod ) {

// We only support meta-based Pods
if ( 'table' == $this_pod[ 'storage' ] ) {
continue;
}

$class = ( $zebra ? 'even' : 'odd' );
$zebra = ( !$zebra );
?>
<li class="pods-zebra-<?php echo $class; ?>">
<?php echo PodsForm::field( $this_pod['name'], true, 'boolean', array( 'boolean_yes_label' => $this_pod[ 'name' ] . ( !empty( $this_pod[ 'label' ] ) ? ' (' . $this_pod[ 'label' ] . ')' : '' ) ) ); ?>
</li>
<?php
// We only support meta-based Pods
if ( 'table' == $this_pod[ 'storage' ] ) {
continue;
}

$class = ( $zebra ? 'even' : 'odd' );
$zebra = ( !$zebra );
?>
</ul>
</div>
<div class="submit">
<a class="button button-primary" id="export" href="#"> Export </a>
</div>
<textarea id="feedback"></textarea>
<li class="pods-zebra-<?php echo $class; ?>">
<?php echo PodsForm::field( $this_pod[ 'name' ], true, 'boolean', array( 'boolean_yes_label' => $this_pod[ 'name' ] . ( !empty( $this_pod[ 'label' ] ) ? ' (' . $this_pod[ 'label' ] . ')' : '' ) ) ); ?>
</li>
<?php
}
?>
</ul>
</div>
<div class="submit">
<a class="button button-primary" id="export" href="#"> Export </a>
</div>
<textarea id="feedback"></textarea>
</div>
</div>
</form>
</div>
</div>
</form>
</div>
Binary file removed assets/banner-1544x500.png
Binary file not shown.
Binary file removed assets/banner-772x250.png
Binary file not shown.
1 change: 0 additions & 1 deletion assets/index.php

This file was deleted.

Binary file removed assets/screenshot-1.png
Binary file not shown.
1 change: 0 additions & 1 deletion includes/index.php

This file was deleted.

2 changes: 0 additions & 2 deletions pods-export-code.php
Expand Up @@ -29,8 +29,6 @@
die;
}

// ToDo: exit or take other action if Pods is not activated

/*----------------------------------------------------------------------------*
* Public-Facing Functionality
*----------------------------------------------------------------------------*/
Expand Down
1 change: 0 additions & 1 deletion public/assets/css/index.php

This file was deleted.

1 change: 0 additions & 1 deletion public/assets/css/public.css

This file was deleted.

1 change: 0 additions & 1 deletion public/assets/index.php

This file was deleted.

1 change: 0 additions & 1 deletion public/assets/js/index.php

This file was deleted.

10 changes: 0 additions & 10 deletions public/assets/js/public.js

This file was deleted.

1 change: 0 additions & 1 deletion public/includes/index.php

This file was deleted.

1 change: 0 additions & 1 deletion public/views/index.php

This file was deleted.

16 changes: 0 additions & 16 deletions public/views/public.php

This file was deleted.

0 comments on commit c11a041

Please sign in to comment.