Skip to content

Commit

Permalink
Added sortable handle in validation settings and chart settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Jan 20, 2015
1 parent 2a23ae2 commit 6586f56
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 13 deletions.
5 changes: 3 additions & 2 deletions classes/controllers/class.admin.php
@@ -1,11 +1,11 @@
<?php
/**
* Name : MW WP Form Admin Controller
* Version : 1.0.0
* Version : 1.0.1
* Author : Takashi Kitajima
* Author URI : http://2inc.org
* Created : December 31, 2014
* Modified :
* Modified : January 20, 2015
* License : GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down Expand Up @@ -220,6 +220,7 @@ public function admin_enqueue_scripts() {
wp_enqueue_script( MWF_Config::NAME . '-repeatable', $url . '../../js/mw-wp-form-repeatable.js' );
wp_enqueue_script( MWF_Config::NAME . '-admin', $url . '../../js/admin.js' );
wp_enqueue_script( 'jquery-ui-dialog' );
wp_enqueue_script( 'jquery-ui-sortable' );

global $wp_scripts;
$ui = $wp_scripts->query( 'jquery-ui-core' );
Expand Down
5 changes: 3 additions & 2 deletions classes/views/class.admin.php
@@ -1,11 +1,11 @@
<?php
/**
* Name : MW WP Form Admin View
* Version : 1.0.0
* Version : 1.0.1
* Author : Takashi Kitajima
* Author URI : http://2inc.org
* Created : January 2, 2015
* Modified :
* Modified : January 20, 2015
* License : GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down Expand Up @@ -91,6 +91,7 @@ public function validation_rule() {
<div class="repeatable-boxes">
<?php foreach ( $validation as $key => $value ) : $value = array_merge( $validation_keys, $value ); ?>
<div class="repeatable-box" <?php if ( $key === 0 ) : ?>style="display:none"<?php endif; ?>>
<div class="sortable-icon-handle"></div>
<div class="remove-btn"><b>×</b></div>
<div class="open-btn"><span><?php echo esc_attr( $value['target'] ); ?></span><b></b></div>
<div class="repeatable-box-content">
Expand Down
5 changes: 3 additions & 2 deletions classes/views/class.chart.php
@@ -1,11 +1,11 @@
<?php
/**
* Name : MW WP Form Chart View
* Version : 1.0.0
* Version : 1.0.1
* Author : Takashi Kitajima
* Author URI : http://2inc.org
* Created : January 2, 2015
* Modified :
* Modified : January 20, 2015
* License : GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down Expand Up @@ -85,6 +85,7 @@ public function index() {
<div class="repeatable-boxes">
<?php foreach ( $postdata as $key => $value ) : ?>
<div class="repeatable-box" <?php if ( $key === 0 ) : ?>style="display:none"<?php endif; ?>>
<div class="sortable-icon-handle"></div>
<div class="remove-btn"><b>×</b></div>
<div class="open-btn"><span><?php echo esc_html( $value['target'] ); ?></span><b></b></div>
<div class="repeatable-box-content">
Expand Down
21 changes: 21 additions & 0 deletions css/admin.css
Expand Up @@ -196,6 +196,27 @@ span#formkey_field {
margin: 0 0 0 10px;
}

/**
* ソートボタン
*/
#mw-wp-form_validation .repeatable-box .sortable-icon-handle,
#mw-wp-form_chart .repeatable-box .sortable-icon-handle {
background: url( ../images/handle.png ) no-repeat;
cursor: move;
float: left;
margin-right: 10px;
height: 10px;
width: 10px;
overflow: hidden;
position: relative;
top: 4px;
}
#mw-wp-form_validation .repeatable-box .remove-btn b,
#mw-wp-form_chart .repeatable-box .remove-btn b {
cursor: pointer;
display: block;
}

/**
* 削除ボタン
*/
Expand Down
Binary file added images/handle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion js/admin-chart.js
Expand Up @@ -3,5 +3,8 @@ jQuery( function( $ ) {
add_position: 'last'
} );

$( '#mw-wp-form_chart .repeatable-boxes' ).sortable();
$( '#mw-wp-form_chart .repeatable-boxes' ).sortable( {
items : '> .repeatable-box',
handle: '.sortable-icon-handle'
} );
} );
17 changes: 11 additions & 6 deletions js/admin.js
Expand Up @@ -9,12 +9,9 @@ jQuery( function( $ ) {
$( '#mw-wp-form_complete_message_metabox input[id^="qt_mw-wp-form_complete_message_mwform_"]' ).remove();
} );

} );

/**
* フォームタグジェネレータ
*/
jQuery( function( $ ) {
/**
* フォームタグジェネレータ
*/
function mwform_create_shortcode( dialog_id ) {
var shortcode = [];
var shortcode_name = dialog_id.replace( 'dialog-', '' );
Expand Down Expand Up @@ -71,4 +68,12 @@ jQuery( function( $ ) {
var select = $( '.add-mwform-btn select' ).val();
$( '#dialog-' + select ).dialog( 'open' );
} );

/**
* sortable
*/
$( '#mw-wp-form_validation .repeatable-boxes' ).sortable( {
items : '> .repeatable-box',
handle: '.sortable-icon-handle'
} );
} );

0 comments on commit 6586f56

Please sign in to comment.