| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /** |
| 2 | - * JavaScript code for all TablePress admin screens | |
| 2 | + * JavaScript code for all TablePress admin screens. | |
| 3 | 3 | * |
| 4 | 4 | * @package TablePress |
| 5 | 5 | * @subpackage Views JavaScript |
| 6 | 6 | * @author Tobias Bäthge |
| @@ -6,57 +6,22 @@ | ||
| 6 | 6 | * @author Tobias Bäthge |
| 7 | 7 | * @since 1.0.0 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -/* global confirm, tp, postboxes, pagenow, tp, tablepress_common */ | |
| 10 | +/* globals postboxes, pagenow, jQuery */ | |
| 11 | 11 | |
| 12 | -// Ensure the global `tp` object exists. | |
| 13 | -window.tp = window.tp || {}; | |
| 12 | +/** | |
| 13 | + * Enable toggle/order functionality for post meta boxes. | |
| 14 | + * For TablePress, pagenow has the form "tablepress_{$action}". | |
| 15 | + * | |
| 16 | + * @since 1.0.0 | |
| 17 | + */ | |
| 18 | +postboxes.add_postbox_toggles( pagenow ); | |
| 14 | 19 | |
| 15 | -jQuery( function( $ ) { | |
| 16 | - | |
| 17 | - 'use strict'; | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * Enable toggle/order functionality for post meta boxes | |
| 21 | - * For TablePress, pagenow has the form "tablepress_{$action}" | |
| 22 | - * | |
| 23 | - * @since 1.0.0 | |
| 24 | - */ | |
| 25 | - postboxes.add_postbox_toggles( pagenow ); | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * Check that numerical fields (e.g. column/row number fields) only contain numbers | |
| 29 | - * | |
| 30 | - * Provides this functionality for browsers that don't yet support <input type="number" />. | |
| 31 | - * | |
| 32 | - * @since 1.0.0 | |
| 33 | - */ | |
| 34 | - $( '#tablepress-page' ).on( 'blur', '.numbers-only, .form-field-numbers-only input', function( /* event */ ) { | |
| 35 | - var $input = $(this); | |
| 36 | - $input.val( $input.val().replace( /[^0-9]/g, '' ) ); | |
| 37 | - } ); | |
| 38 | - | |
| 39 | - /** | |
| 40 | - * Show a AYS warning when a "Delete" link is clicked | |
| 41 | - * | |
| 42 | - * @since 1.0.0 | |
| 43 | - */ | |
| 44 | - $( '#tablepress-page' ).on( 'click', '.delete-link', function() { | |
| 45 | - if ( ! confirm( tablepress_common.ays_delete_single_table ) ) { | |
| 46 | - return false; | |
| 47 | - } | |
| 48 | - | |
| 49 | - // Prevent onunload warning. | |
| 50 | - tp.made_changes = false; | |
| 51 | - } ); | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * Select all text in the Shortcode (readonly) text fields, when clicked | |
| 55 | - * | |
| 56 | - * @since 1.0.0 | |
| 57 | - */ | |
| 58 | - $( '#tablepress-page' ).on( 'click', '.table-shortcode', function() { | |
| 59 | - $(this).trigger( 'focus' ).trigger( 'select' ); | |
| 60 | - } ); | |
| 61 | - | |
| 62 | -} ); | |
| 20 | +/** | |
| 21 | + * Turn off the collapsing feature of postboxes when directly clicking on the postbox header bar. | |
| 22 | + * This causes confusion to many users that accidentally click this. | |
| 23 | + * After this, the postboxes can only be collapsed/expanded via the arrow icon in their header bar. | |
| 24 | + * | |
| 25 | + * @since 2.1.0 | |
| 26 | + */ | |
| 27 | +jQuery( '.postbox .hndle' ).off( 'click.postboxes', postboxes.handle_click ); | |