From c90803e7e1730e57a3e1c3168ed1b4885df443a6 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Wed, 21 Dec 2016 00:00:01 -0500 Subject: [PATCH 01/19] Standardize on `fm.beta` for prefixes and slugs --- ...ze.css => fieldmanager-beta-customize.css} | 0 fieldmanager-beta-customize.php | 1 + ... fieldmanager-beta-customize-overrides.js} | 2 +- ...mize.js => fieldmanager-beta-customize.js} | 26 ++++++++++--------- js/fieldmanager.js | 6 ++--- ...ss-fieldmanager-beta-customize-control.php | 18 ++++++------- 6 files changed, 28 insertions(+), 25 deletions(-) rename css/{fieldmanager-customize.css => fieldmanager-beta-customize.css} (100%) rename js/{beta-overrides.js => fieldmanager-beta-customize-overrides.js} (82%) rename js/{fieldmanager-customize.js => fieldmanager-beta-customize.js} (89%) diff --git a/css/fieldmanager-customize.css b/css/fieldmanager-beta-customize.css similarity index 100% rename from css/fieldmanager-customize.css rename to css/fieldmanager-beta-customize.css diff --git a/fieldmanager-beta-customize.php b/fieldmanager-beta-customize.php index 9d17ed0..6f91f04 100755 --- a/fieldmanager-beta-customize.php +++ b/fieldmanager-beta-customize.php @@ -120,3 +120,4 @@ function fm_beta_customize_add_to_customizer( $args = array(), $fm ) { function fm_beta_customize_demo() { Fieldmanager_Beta_Customize_Demo::instance(); } +add_action( 'fm_beta_customize', 'fm_beta_customize_demo' ); diff --git a/js/beta-overrides.js b/js/fieldmanager-beta-customize-overrides.js similarity index 82% rename from js/beta-overrides.js rename to js/fieldmanager-beta-customize-overrides.js index be940e7..2e9f274 100644 --- a/js/beta-overrides.js +++ b/js/fieldmanager-beta-customize-overrides.js @@ -12,5 +12,5 @@ ); // Enable Datepickers. - $( document ).on( 'fm_customize_control_section_expanded', fm.datepicker.add_datepicker ); + $( document ).on( 'fm_beta_customize_control_section_expanded', fm.datepicker.add_datepicker ); })( jQuery ); diff --git a/js/fieldmanager-customize.js b/js/fieldmanager-beta-customize.js similarity index 89% rename from js/fieldmanager-customize.js rename to js/fieldmanager-beta-customize.js index 4624a7b..20c271d 100644 --- a/js/fieldmanager-customize.js +++ b/js/fieldmanager-beta-customize.js @@ -10,7 +10,9 @@ (function( $, api, _, fm ) { 'use strict'; - fm.customize = { + fm.beta = fm.beta || {}; + + fm.beta.customize = { /** * jQuery selector targeting all elements to include in a Fieldmanager setting value. * @@ -82,7 +84,7 @@ * @param {Event} e Event object. */ var onFmElementChange = function( e ) { - fm.customize.setControlsContainingElement( e.target ); + fm.beta.customize.setControlsContainingElement( e.target ); }; /** @@ -106,7 +108,7 @@ return; } - fm.customize.setControlsContainingElement( e.target ); + fm.beta.customize.setControlsContainingElement( e.target ); }; /** @@ -116,7 +118,7 @@ * @param {Element} el The sorted element. */ var onFmSortableDrop = function ( e, el ) { - fm.customize.setControlsContainingElement( el ); + fm.beta.customize.setControlsContainingElement( el ); }; /** @@ -125,7 +127,7 @@ * @param {Event} e Event object. */ var onFmAddedElement = function( e ) { - fm.customize.setControlsContainingElement( e.target ); + fm.beta.customize.setControlsContainingElement( e.target ); }; /** @@ -137,7 +139,7 @@ * @param {Object} wp Global WordPress JS API. */ var onFieldmanagerMediaPreview = function( e, $wrapper, attachment, wp ) { - fm.customize.setControlsContainingElement( e.target ); + fm.beta.customize.setControlsContainingElement( e.target ); }; /** @@ -149,7 +151,7 @@ var onFmRichtextInit = function( e, ed ) { ed.on( 'keyup AddUndo', function () { ed.save(); - fm.customize.setControlsContainingElement( document.getElementById( ed.id ) ); + fm.beta.customize.setControlsContainingElement( document.getElementById( ed.id ) ); } ); }; @@ -160,7 +162,7 @@ * @param {Element} el Colorpicker element. */ var onFmColorpickerUpdate = function( e, el ) { - fm.customize.setControlsContainingElement( el ); + fm.beta.customize.setControlsContainingElement( el ); }; /** @@ -170,7 +172,7 @@ */ var onFmMediaRemoveClick = function ( e ) { // The control no longer contains the element, so set all of them. - fm.customize.setEachControl(); + fm.beta.customize.setEachControl(); }; /** @@ -180,7 +182,7 @@ */ var onFmjsRemoveClick = function ( e ) { // The control no longer contains the element, so set all of them. - fm.customize.setEachControl(); + fm.beta.customize.setEachControl(); }; /** @@ -195,7 +197,7 @@ * We bind to sections whether or not they have FM controls in case a * control is added dynamically. */ - $( document ).trigger( 'fm_customize_control_section_expanded' ); + $( document ).trigger( 'fm_beta_customize_control_section_expanded' ); if ( fm.richtextarea ) { fm.richtextarea.add_rte_to_visible_textareas(); @@ -216,7 +218,7 @@ control.settings.default && null === control.settings.default.get() ) { - fm.customize.setControl( control ); + fm.beta.customize.setControl( control ); } }); }; diff --git a/js/fieldmanager.js b/js/fieldmanager.js index ade2daf..ad45f52 100644 --- a/js/fieldmanager.js +++ b/js/fieldmanager.js @@ -272,9 +272,9 @@ $( document ).ready( function () { init_label_macros(); init_sortable(); - $( document ).on( 'fm_activate_tab fm_customize_control_section_expanded', init_sortable ); - $( document ).on( 'fm_customize_control_section_expanded', init_label_macros ); - $( document ).on( 'fm_customize_control_section_expanded', function () { + $( document ).on( 'fm_activate_tab fm_beta_customize_control_section_expanded', init_sortable ); + $( document ).on( 'fm_beta_customize_control_section_expanded', init_label_macros ); + $( document ).on( 'fm_beta_customize_control_section_expanded', function () { $( '.display-if' ).each( fm.init_display_if ); } ); } ); diff --git a/php/customize/class-fieldmanager-beta-customize-control.php b/php/customize/class-fieldmanager-beta-customize-control.php index 02d1e0f..eef6dd7 100644 --- a/php/customize/class-fieldmanager-beta-customize-control.php +++ b/php/customize/class-fieldmanager-beta-customize-control.php @@ -49,14 +49,14 @@ public function __construct( $manager, $id, $args = array() ) { public function enqueue() { Fieldmanager_Util_Assets::instance()->add_style( array( 'deps' => array( 'fieldmanager_style' ), - 'handle' => 'fm_beta_customize', - 'path' => 'css/fieldmanager-customize.css', + 'handle' => 'fm-beta-customize', + 'path' => 'css/fieldmanager-beta-customize.css', 'plugin_dir' => FM_BETA_CUSTOMIZE_URL, 'ver' => FM_BETA_CUSTOMIZE_VERSION, ) ); wp_register_script( - 'fm-serializejson', + 'fm-beta-customize-serializejson', FM_BETA_CUSTOMIZE_URL . 'js/jquery-serializejson/jquery.serializejson.min.js', array(), '2.0.0', @@ -64,9 +64,9 @@ public function enqueue() { ); fm_add_script( - 'fm_beta_customize_overrides', - 'js/beta-overrides.js', - array( 'jquery', 'underscore', 'editor', 'quicktags', 'fieldmanager_script', 'customize-controls', 'fm-serializejson' ), + 'fm-beta-customize-overrides', + 'js/fieldmanager-beta-customize-overrides.js', + array( 'jquery', 'underscore', 'editor', 'quicktags', 'fieldmanager_script', 'customize-controls', 'fm-beta-customize-serializejson' ), FM_BETA_CUSTOMIZE_VERSION, true, '', @@ -75,9 +75,9 @@ public function enqueue() { ); fm_add_script( - 'fm-customize', - 'js/fieldmanager-customize.js', - array( 'fm_beta_customize_overrides' ), + 'fm-beta-customize', + 'js/fieldmanager-beta-customize.js', + array( 'fm-beta-customize-overrides' ), FM_BETA_CUSTOMIZE_VERSION, true, '', From 809b45c3ea679944dca5be95ba04f9f7cce8a205 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Wed, 21 Dec 2016 00:15:27 -0500 Subject: [PATCH 02/19] Prefix the Customize control type --- js/fieldmanager-beta-customize.js | 2 +- php/customize/class-fieldmanager-beta-customize-control.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/fieldmanager-beta-customize.js b/js/fieldmanager-beta-customize.js index 20c271d..6ceebc9 100644 --- a/js/fieldmanager-beta-customize.js +++ b/js/fieldmanager-beta-customize.js @@ -57,7 +57,7 @@ var serialized; var value; - if ( 'fieldmanager' !== control.params.type ) { + if ( 'fieldmanager-beta' !== control.params.type ) { return; } diff --git a/php/customize/class-fieldmanager-beta-customize-control.php b/php/customize/class-fieldmanager-beta-customize-control.php index eef6dd7..4051c80 100644 --- a/php/customize/class-fieldmanager-beta-customize-control.php +++ b/php/customize/class-fieldmanager-beta-customize-control.php @@ -22,7 +22,7 @@ class Fieldmanager_Beta_Customize_Control extends WP_Customize_Control { * * @var string */ - public $type = 'fieldmanager'; + public $type = 'fieldmanager-beta'; /** * Constructor. From ed363c5b353cb3f2262be421a454a2513785c405 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Wed, 21 Dec 2016 00:15:50 -0500 Subject: [PATCH 03/19] Prefix the validation error code --- php/context/class-fieldmanager-beta-context-customize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/context/class-fieldmanager-beta-context-customize.php b/php/context/class-fieldmanager-beta-context-customize.php index e72684b..4353e94 100644 --- a/php/context/class-fieldmanager-beta-context-customize.php +++ b/php/context/class-fieldmanager-beta-context-customize.php @@ -90,7 +90,7 @@ public function validate_callback( $validity, $value, $setting ) { $message = ( $e instanceof FM_Validation_Exception ) ? $e->getMessage() : __( 'Invalid value.', 'fieldmanager-beta-customize' ); // @see https://core.trac.wordpress.org/ticket/37890 for the use of array( $value ). - $validity->add( 'fieldmanager', $message, array( $value ) ); + $validity->add( 'fieldmanager-beta', $message, array( $value ) ); } // Resume normal wp_die() handling. From 88d7eb5316d5efcda995a7dfa3ac145bf43afcd9 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Wed, 21 Dec 2016 00:35:29 -0500 Subject: [PATCH 04/19] Remove debug code --- fieldmanager-beta-customize.php | 1 - 1 file changed, 1 deletion(-) diff --git a/fieldmanager-beta-customize.php b/fieldmanager-beta-customize.php index 6f91f04..9d17ed0 100755 --- a/fieldmanager-beta-customize.php +++ b/fieldmanager-beta-customize.php @@ -120,4 +120,3 @@ function fm_beta_customize_add_to_customizer( $args = array(), $fm ) { function fm_beta_customize_demo() { Fieldmanager_Beta_Customize_Demo::instance(); } -add_action( 'fm_beta_customize', 'fm_beta_customize_demo' ); From f17533dc67da6da6c1650f610530f8849a452b94 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Mon, 19 Dec 2016 01:47:06 -0500 Subject: [PATCH 05/19] Fix missed changelog entries and version bump --- README.md | 5 ++++- fieldmanager-beta-customize.php | 4 ++-- readme.txt | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dd97c88..f42aa69 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **Contributors:** [dlh](https://profiles.wordpress.org/dlh), [alleyinteractive](https://profiles.wordpress.org/alleyinteractive) **Requires at least:** 4.4 **Tested up to:** 4.7 -**Stable tag:** 0.1.1 +**Stable tag:** 0.2.0 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -41,6 +41,9 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo ## Changelog ## +### 0.2.0 ### +* Move CSS, and autocomplete and datepicker scripts, into separate files, rather than overriding those assets in Fieldmanager core. + ### 0.1.1 ### * Rename the Customize context action to 'fm_beta_customize' for improved future compatibility with Fieldmanager. diff --git a/fieldmanager-beta-customize.php b/fieldmanager-beta-customize.php index 9d17ed0..adc5831 100755 --- a/fieldmanager-beta-customize.php +++ b/fieldmanager-beta-customize.php @@ -7,7 +7,7 @@ * Author URI: https://www.alleyinteractive.com * Text Domain: fieldmanager-beta-customizer * Domain Path: /languages - * Version: 0.1.1 + * Version: 0.2.0 * * @package Fieldmanager_Beta_Customize */ @@ -25,7 +25,7 @@ /** * Plugin version. */ -define( 'FM_BETA_CUSTOMIZE_VERSION', '0.1.1' ); +define( 'FM_BETA_CUSTOMIZE_VERSION', '0.2.0' ); /** * Calculate a Fieldmanager context for the Customizer. diff --git a/readme.txt b/readme.txt index 2bfdea2..78631ff 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: dlh, alleyinteractive Requires at least: 4.4 Tested up to: 4.7 -Stable tag: 0.1.1 +Stable tag: 0.2.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -35,6 +35,9 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo == Changelog == += 0.2.0 = +* Move CSS, and autocomplete and datepicker scripts, into separate files, rather than overriding those assets in Fieldmanager core. + = 0.1.1 = * Rename the Customize context action to 'fm_beta_customize' for improved future compatibility with Fieldmanager. From 3645d3f732194fc4f9fb6c6a73b7e245737000e3 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 24 Dec 2016 14:51:56 -0500 Subject: [PATCH 06/19] Move remaining scripts that overrode Fieldmanager core assets --- fieldmanager-beta-customize.php | 23 -- js/fieldmanager-beta-customize-overrides.js | 105 +++++++- js/fieldmanager-beta-customize.js | 10 - js/fieldmanager-colorpicker.js | 31 --- js/fieldmanager.js | 282 -------------------- js/richtext.js | 173 ------------ readme.txt | 4 +- 7 files changed, 99 insertions(+), 529 deletions(-) delete mode 100644 js/fieldmanager-colorpicker.js delete mode 100644 js/fieldmanager.js delete mode 100644 js/richtext.js diff --git a/fieldmanager-beta-customize.php b/fieldmanager-beta-customize.php index adc5831..f8cadce 100755 --- a/fieldmanager-beta-customize.php +++ b/fieldmanager-beta-customize.php @@ -58,29 +58,6 @@ require_once( FM_BETA_CUSTOMIZE_PATH . 'php/field/class-fieldmanager-beta-customize-richtextarea.php' ); }, 0 ); -/** - * Override the path to some Fieldmanager scripts to use updated versions from this plugin. - * - * @param array Arrays of script arguments. @see Fieldmanager_Util_Assets::add_script(). - */ -add_filter( 'fm_enqueue_scripts', function ( $scripts ) { - return array_map( - function ( $script ) { - switch ( $script['handle'] ) { - case 'fm_colorpicker' : - case 'fieldmanager_script' : - case 'fm_richtext' : - $script['ver'] = FM_BETA_CUSTOMIZE_VERSION; - $script['path'] = str_replace( fieldmanager_get_baseurl(), FM_BETA_CUSTOMIZE_URL, $script['path'] ); - break; - } - - return $script; - }, - $scripts - ); -} ); - /** * Enqueue assets managed by Fieldmanager_Util_Assets in the Customizer. */ diff --git a/js/fieldmanager-beta-customize-overrides.js b/js/fieldmanager-beta-customize-overrides.js index 2e9f274..51f6d7a 100644 --- a/js/fieldmanager-beta-customize-overrides.js +++ b/js/fieldmanager-beta-customize-overrides.js @@ -1,16 +1,103 @@ /** * Integrate this beta plugin with core Fieldmanager scripts. - * - * Typically, these changes would most likely appear in the Fieldmanager core - * scripts for Autocomplete, Datepicker, etc. */ (function( $ ) { // Enable Autocomplete when focusing on an Autocomplete input. - $( document ).on( 'focus', - 'input[class*="fm-autocomplete"]:not(.fm-autocomplete-enabled)', - fm.autocomplete.enable_autocomplete - ); + if ( fm.autocomplete ) { + $( document ).on( 'focus', + 'input[class*="fm-autocomplete"]:not(.fm-autocomplete-enabled)', + fm.autocomplete.enable_autocomplete + ); + } - // Enable Datepickers. - $( document ).on( 'fm_beta_customize_control_section_expanded', fm.datepicker.add_datepicker ); + $( document ).on( 'fm_beta_customize_control_section_expanded', function () { + // Initialize Datepickers. + if ( fm.datepicker ) { + fm.datepicker.add_datepicker(); + } + + // Initialize display-ifs. + if ( fm.init_display_if ) { + $( '.display-if' ).each( fm.init_display_if ); + } + + // Initialize Colorpickers and respond to changes. + if ( fm.colorpicker ) { + fm.colorpicker.init(); + + $( '.fm-colorpicker-popup' ).each(function () { + var $this = $( this ); + + if ( $this.wpColorPicker( 'instance' ) && ! $this.data( 'fm-beta-customize' ) ) { + $this.data( 'fm-beta-customize', true ); + + $this.wpColorPicker( 'instance' ).option( 'change', function ( event, ui ) { + // Make sure the input's value attribute also changes. + $this.attr( 'value', ui.color.toString() ); + fm.beta.customize.setControlsContainingElement( this ); + }); + + $this.wpColorPicker( 'instance' ).option( 'clear', function () { + // Make sure the input's value attribute also changes. + $this.attr( 'value', '' ); + fm.beta.customize.setControlsContainingElement( this ); + }); + } + }); + } + + // Initialize RichTextAreas and respond to changes. + if ( fm.richtextarea ) { + fm.richtextarea.add_rte_to_visible_textareas(); + + tinymce.editors.forEach(function ( ed ) { + var $fm_richtext = $( document.getElementById( ed.id ) ); + + if ( $fm_richtext.hasClass( 'fm-richtext' ) && ! $fm_richtext.data( 'fm-beta-customize' ) ) { + $fm_richtext.data( 'fm-beta-customize', true ); + + ed.on( 'keyup AddUndo', function () { + ed.save(); + fm.beta.customize.setControlsContainingElement( document.getElementById( ed.id ) ); + }); + } + }); + } + + // Initialize sortables via existing event. + $( document ).trigger( 'fm_activate_tab' ); + + // Initialize label macros with a copy of init_label_macros(), which is + // suboptimal but more optimal than copying all of fieldmanager.js. + (function() { + $( '.fm-label-with-macro' ).each( function( label ) { + $( this ).data( 'label-original', $( this ).html() ); + var src = $( this ).parents( '.fm-group' ).first().find( $( this ).data( 'label-token' ) ); + if ( src.length > 0 ) { + var $src = $( src[0] ); + if ( typeof $src.val === 'function' ) { + var $label = $( this ); + var title_macro = function() { + var token = ''; + if ( $src.prop( 'tagName' ) == 'SELECT' ) { + var $option = $src.find( 'option:selected' ); + if ( $option.val() ) { + token = $option.text(); + } + } else { + token = $src.val(); + } + if ( token.length > 0 ) { + $label.html( $label.data( 'label-format' ).replace( '%s', token ) ); + } else { + $label.html( $label.data( 'label-original' ) ); + } + }; + $src.on( 'change keyup', title_macro ); + title_macro(); + } + } + } ); + })(); + }); })( jQuery ); diff --git a/js/fieldmanager-beta-customize.js b/js/fieldmanager-beta-customize.js index 6ceebc9..fd5e78d 100644 --- a/js/fieldmanager-beta-customize.js +++ b/js/fieldmanager-beta-customize.js @@ -199,14 +199,6 @@ */ $( document ).trigger( 'fm_beta_customize_control_section_expanded' ); - if ( fm.richtextarea ) { - fm.richtextarea.add_rte_to_visible_textareas(); - } - - if ( fm.colorpicker ) { - fm.colorpicker.init(); - } - /* * Reserialize any Fieldmanager controls in this section with null * values. We assume null indicates nothing has been saved to the @@ -235,8 +227,6 @@ $document.on( 'click', '.fmjs-remove', onFmjsRemoveClick ); $document.on( 'fm_sortable_drop', onFmSortableDrop ); $document.on( 'fieldmanager_media_preview', onFieldmanagerMediaPreview ); - $document.on( 'fm_richtext_init', onFmRichtextInit ); - $document.on( 'fm_colorpicker_update', onFmColorpickerUpdate ); }; /** diff --git a/js/fieldmanager-colorpicker.js b/js/fieldmanager-colorpicker.js deleted file mode 100644 index 19fbde6..0000000 --- a/js/fieldmanager-colorpicker.js +++ /dev/null @@ -1,31 +0,0 @@ -( function( $ ) { - - fm.colorpicker = { - init: function() { - $( '.fm-colorpicker-popup:visible' ).wpColorPicker({ - change: function ( e, ui ) { - // Make sure the input's value attribute also changes. - $( this ).attr( 'value', ui.color.toString() ); - fm.colorpicker.triggerUpdateEvent( this ); - }, - clear: function () { - // Make sure the input's value attribute also changes. - $( this ).attr( 'value', '' ); - fm.colorpicker.triggerUpdateEvent( this ); - }, - }); - }, - triggerUpdateEvent: function ( el ) { - /** - * Trigger a common event for a value 'change' or 'clear'. - * - * @var {Element} Colorpicker element. - */ - $( document ).trigger( 'fm_colorpicker_update', el ); - } - }; - - $( document ).ready( fm.colorpicker.init ); - $( document ).on( 'fm_collapsible_toggle fm_added_element fm_displayif_toggle fm_activate_tab', fm.colorpicker.init ); - -} )( jQuery ); \ No newline at end of file diff --git a/js/fieldmanager.js b/js/fieldmanager.js deleted file mode 100644 index ad45f52..0000000 --- a/js/fieldmanager.js +++ /dev/null @@ -1,282 +0,0 @@ -var fm = {}; - -( function( $ ) { - -var dynamic_seq = 0; - -var init_sortable_container = function( el ) { - if ( !$( el ).hasClass( 'ui-sortable' ) ) { - $( el ).sortable( { - handle: '.fmjs-drag', - items: '> .fm-item', - placeholder: "sortable-placeholder", - forcePlaceholderSize: true, - start: function( e, ui ) { - $( document ).trigger( 'fm_sortable_drag', el ); - }, - stop: function( e, ui ) { - var $parent = ui.item.parents( '.fm-wrapper' ).first(); - fm_renumber( $parent ); - $( document ).trigger( 'fm_sortable_drop', el ); - } - } ); - } -} - -var init_sortable = function() { - $( '.fmjs-sortable' ).each( function() { - if ( $( this ).is( ':visible' ) ) { - init_sortable_container( this ); - } else { - var sortable = this; - $( sortable ).parents( '.fm-group' ).first().bind( 'fm_collapsible_toggle', function() { - init_sortable_container( sortable ); - } ); - } - } ); -} - -var init_label_macros = function() { - // Label macro magic. - $( '.fm-label-with-macro' ).each( function( label ) { - $( this ).data( 'label-original', $( this ).html() ); - var src = $( this ).parents( '.fm-group' ).first().find( $( this ).data( 'label-token' ) ); - if ( src.length > 0 ) { - var $src = $( src[0] ); - if ( typeof $src.val === 'function' ) { - var $label = $( this ); - var title_macro = function() { - var token = ''; - if ( $src.prop( 'tagName' ) == 'SELECT' ) { - var $option = $src.find( 'option:selected' ); - if ( $option.val() ) { - token = $option.text(); - } - } else { - token = $src.val(); - } - if ( token.length > 0 ) { - $label.html( $label.data( 'label-format' ).replace( '%s', token ) ); - } else { - $label.html( $label.data( 'label-original' ) ); - } - }; - $src.on( 'change keyup', title_macro ); - title_macro(); - } - } - } ); -} - -var fm_renumber = function( $wrappers ) { - $wrappers.each( function() { - var level_pos = $( this ).data( 'fm-array-position' ) - 0; - var order = 0; - if ( level_pos > 0 ) { - $( this ).find( '> .fm-item' ).each( function() { - if ( $( this ).hasClass( 'fmjs-proto' ) ) { - return; // continue - } - $( this ).find( '.fm-element, .fm-incrementable' ).each( function() { - var fname = $(this).attr( 'name' ); - if ( fname ) { - fname = fname.replace( /\]/g, '' ); - parts = fname.split( '[' ); - if ( parts[ level_pos ] != order ) { - parts[ level_pos ] = order; - var new_fname = parts[ 0 ] + '[' + parts.slice( 1 ).join( '][' ) + ']'; - $( this ).attr( 'name', new_fname ); - if ( $( this ).attr( 'id' ) && $( this ).attr( 'id' ).match( '-proto' ) && ! new_fname.match( 'proto' ) ) { - $( this ).attr( 'id', 'fm-edit-dynamic-' + dynamic_seq ); - if ( $( this ).parent().hasClass( 'fm-option' ) ) { - $( this ).parent().find( 'label' ).attr( 'for', 'fm-edit-dynamic-' + dynamic_seq ); - } else { - var parent = $( this ).closest( '.fm-item' ); - if ( parent.length && parent.find( '.fm-label label' ).length ) { - parent.find( '.fm-label label' ).attr( 'for', 'fm-edit-dynamic-' + dynamic_seq ); - } - } - dynamic_seq++; - return; // continue; - } - } - } - if ( $( this ).hasClass( 'fm-incrementable' ) ) { - $( this ).attr( 'id', 'fm-edit-dynamic-' + dynamic_seq ); - dynamic_seq++; - } - } ); - order++; - } ); - } - $( this ).find( '.fm-wrapper' ).each( function() { - fm_renumber( $( this ) ); - } ); - } ); -} - -/** - * Get data attribute display-value(s). - * - * Accounts for jQuery converting string to number automatically. - * - * @param HTMLDivElement el Wrapper with the data attribute. - * @return string|number|array Single string or number, or array if data attr contains CSV. - */ -var getCompareValues = function( el ) { - var values = $( el ).data( 'display-value' ); - try { - values = values.split( ',' ); - } catch( e ) { - // If jQuery already converted string to number. - values = [ values ]; - } - return values; -}; - -var match_value = function( values, match_string ) { - for ( var index in values ) { - if ( values[index] == match_string ) { - return true; - } - } - return false; -} - -fm_add_another = function( $element ) { - var el_name = $element.data( 'related-element' ) - , limit = $element.data( 'limit' ) - 0 - , siblings = $element.parent().siblings( '.fm-item' ).not( '.fmjs-proto' ) - , add_more_position = $element.data( 'add-more-position' ) || "bottom"; - - if ( limit > 0 && siblings.length >= limit ) { - return; - } - - var $new_element = $( '.fmjs-proto.fm-' + el_name, $element.closest( '.fm-wrapper' ) ).first().clone(); - - $new_element.removeClass( 'fmjs-proto' ); - $new_element = add_more_position == "bottom" ? $new_element.insertBefore( $element.parent() ) : - $new_element.insertAfter( $element.parent() ) ; - fm_renumber( $element.parents( '.fm-wrapper' ) ); - // Trigger for subclasses to do any post-add event handling for the new element - $element.parent().siblings().last().trigger( 'fm_added_element' ); - init_label_macros(); - init_sortable(); -} - -fm_remove = function( $element ) { - $wrapper = $( this ).parents( '.fm-wrapper' ).first(); - $element.parents( '.fm-item' ).first().remove(); - fm_renumber( $wrapper ); -} - -$( document ).ready( function () { - $( document ).on( 'click', '.fm-add-another', function( e ) { - e.preventDefault(); - fm_add_another( $( this ) ); - } ); - - // Handle remove events - $( document ).on( 'click', '.fmjs-remove', function( e ) { - e.preventDefault(); - fm_remove( $( this ) ); - } ); - - // Handle collapse events - $( document ).on( 'click', '.fmjs-collapsible-handle', function() { - $( this ).parents( '.fm-group' ).first().children( '.fm-group-inner' ).slideToggle( 'fast' ); - fm_renumber( $( this ).parents( '.fm-wrapper' ).first() ); - $( this ).parents( '.fm-group' ).first().trigger( 'fm_collapsible_toggle' ); - $( this ).toggleClass( 'closed' ); - if ( $( this ).hasClass( 'closed' ) ) { - $( this ).attr( 'aria-expanded', 'false' ); - } else { - $( this ).attr( 'aria-expanded', 'true' ); - } - } ); - - $( '.fm-collapsed > .fm-group:not(.fmjs-proto) > .fm-group-inner' ).hide(); - - // Initializes triggers to conditionally hide or show fields - fm.init_display_if = function() { - var val; - var src = $( this ).data( 'display-src' ); - var values = getCompareValues( this ); - // Wrapper divs sometimes receive .fm-element, but don't use them as - // triggers. Also don't use autocomplete inputs as triggers, because the - // value is in their sibling hidden fields (which this still matches). - var trigger = $( this ).siblings( '.fm-' + src + '-wrapper' ).find( '.fm-element' ).not( 'div, .fm-autocomplete' ); - - // Sanity check before calling `val()` or `split()`. - if ( 0 === trigger.length ) { - return; - } - - if ( trigger.is( ':checkbox' ) ) { - if ( trigger.is( ':checked' ) ) { - // If checked, use the checkbox value. - val = trigger.val(); - } else { - // Otherwise, use the hidden sibling field with the "unchecked" value. - val = trigger.siblings( 'input[type=hidden][name="' + trigger.attr( 'name' ) + '"]' ).val(); - } - } else if ( trigger.is( ':radio' ) ) { - if ( trigger.filter( ':checked' ).length ) { - val = trigger.filter( ':checked' ).val(); - } else { - // On load, there might not be any selected radio, in which case call the value blank. - val = ''; - } - } else { - val = trigger.val().split( ',' ); - } - trigger.addClass( 'display-trigger' ); - if ( ! match_value( values, val ) ) { - $( this ).hide(); - } - }; - $( '.display-if' ).each( fm.init_display_if ); - - // Controls the trigger to show or hide fields - fm.trigger_display_if = function() { - var val; - var $this = $( this ); - var name = $this.attr( 'name' ); - if ( $this.is( ':checkbox' ) ) { - if ( $this.is( ':checked' ) ) { - val = $this.val(); - } else { - val = $this.siblings( 'input[type=hidden][name="' + name + '"]' ).val(); - } - } else if ( $this.is( ':radio' ) ) { - val = $this.filter( ':checked' ).val(); - } else { - val = $this.val().split( ',' ); - } - $( this ).closest( '.fm-wrapper' ).siblings().each( function() { - if ( $( this ).hasClass( 'display-if' ) ) { - if ( name && name.match( $( this ).data( 'display-src' ) ) != null ) { - if ( match_value( getCompareValues( this ), val ) ) { - $( this ).show(); - } else { - $( this ).hide(); - } - $( this ).trigger( 'fm_displayif_toggle' ); - } - } - } ); - }; - $( document ).on( 'change', '.display-trigger', fm.trigger_display_if ); - - init_label_macros(); - init_sortable(); - - $( document ).on( 'fm_activate_tab fm_beta_customize_control_section_expanded', init_sortable ); - $( document ).on( 'fm_beta_customize_control_section_expanded', init_label_macros ); - $( document ).on( 'fm_beta_customize_control_section_expanded', function () { - $( '.display-if' ).each( fm.init_display_if ); - } ); -} ); - -} )( jQuery ); diff --git a/js/richtext.js b/js/richtext.js deleted file mode 100644 index fe559dc..0000000 --- a/js/richtext.js +++ /dev/null @@ -1,173 +0,0 @@ -( function( $ ) { - fm.richtextarea = { - add_rte_to_visible_textareas: function() { - $( 'textarea.fm-richtext:visible' ).each( function() { - if ( ! $( this ).hasClass( 'fm-tinymce' ) ) { - var init, ed_id, mce_options, qt_options, proto_id; - $( this ).addClass( 'fm-tinymce' ); - ed_id = $( this ).attr( 'id' ); - - if ( typeof tinymce !== 'undefined' ) { - - if ( typeof tinyMCEPreInit.mceInit[ ed_id ] === 'undefined' ) { - proto_id = $( this ).data( 'proto-id' ); - - // Clean up the proto id which appears in some of the wp_editor generated HTML - $( this ).closest( '.fm-wrapper' ).html( $( this ).closest( '.fm-wrapper' ).html().replace( new RegExp( proto_id, 'g' ), ed_id ) ); - - // This needs to be initialized, so we need to get the options from the proto - if ( proto_id && typeof tinyMCEPreInit.mceInit[ proto_id ] !== 'undefined' ) { - mce_options = $.extend( true, {}, tinyMCEPreInit.mceInit[ proto_id ] ); - mce_options.body_class = mce_options.body_class.replace( proto_id, ed_id ); - mce_options.selector = mce_options.selector.replace( proto_id, ed_id ); - mce_options.wp_skip_init = false; - tinyMCEPreInit.mceInit[ ed_id ] = mce_options; - } else { - // TODO: No data to work with, this should throw some sort of error - return; - } - - if ( proto_id && typeof tinyMCEPreInit.qtInit[ proto_id ] !== 'undefined' ) { - qt_options = $.extend( true, {}, tinyMCEPreInit.qtInit[ proto_id ] ); - qt_options.id = qt_options.id.replace( proto_id, ed_id ); - tinyMCEPreInit.qtInit[ ed_id ] = qt_options; - } - } - - try { - if ( 'html' !== fm.richtextarea.mode_enabled( this ) ) { - tinyMCEPreInit.mceInit[ ed_id ].setup = function ( ed ) { - ed.on( 'init', function( args ) { - /** - * Event after TinyMCE loads for an Fieldmanager_RichTextArea. - * - * @var {Object} TinyMCE instance. - */ - $( document ).trigger( 'fm_richtext_init', ed ); - }); - }; - tinymce.init( tinyMCEPreInit.mceInit[ ed_id ] ); - $( this ).closest( '.wp-editor-wrap' ).on( 'click.wp-editor', function() { - if ( this.id ) { - window.wpActiveEditor = this.id.slice( 3, -5 ); - } - } ); - } - } catch(e){} - - try { - if ( typeof tinyMCEPreInit.qtInit[ ed_id ] !== 'undefined' ) { - quicktags( tinyMCEPreInit.qtInit[ ed_id ] ); - // _buttonsInit() only needs to be called on dynamic editors - // quicktags() handles it for us on the first initialization - if ( typeof QTags !== 'undefined' && -1 !== ed_id.indexOf( '-dynamic-' ) ) { - QTags._buttonsInit(); - } - } - } catch(e){}; - } - } - } ); - }, - - reload_editors: function( e, wrap ) { - if ( ! wrap || 'undefined' === typeof wrap.nodeType ) { - return; - } - - $( '.fm-tinymce', wrap ).each( function() { - var html_mode = ( 'html' === fm.richtextarea.mode_enabled( this ) ) - , ed = tinymce.get( this.id ) - , content = ed.getContent() - , cmd; - - if ( html_mode ) { - $( '#' + this.id + '-tmce' ).click(); - } - - // Disable the editor - cmd = 'mceRemoveControl'; - if ( parseInt( tinymce.majorVersion ) >= 4 ) { - cmd = 'mceRemoveEditor'; - } - tinymce.execCommand( cmd, false, this.id ); - - // Immediately re-enable the editor - cmd = 'mceAddControl'; - if ( parseInt( tinymce.majorVersion ) >= 4 ) { - cmd = 'mceAddEditor'; - } - tinymce.execCommand( cmd, false, this.id ); - - // Replace the content with what it was to correct paragraphs - ed = tinymce.get( this.id ); - ed.setContent( content ); - - if ( html_mode ) { - $( '#' + this.id + '-html' ).click(); - } - }); - }, - - mode_enabled: function( el ) { - return $( el ).closest( '.html-active' ).length ? 'html' : 'tinymce'; - }, - - /** - * Ensure that the main editor's state remains unaffected by any FM editors - */ - reset_core_editor_mode: function() { - if ( 'html' === core_editor_state || 'tinymce' === core_editor_state ) { - setUserSetting( 'editor', core_editor_state ); - } - } - } - $( document ).on( 'fm_collapsible_toggle fm_added_element fm_activate_tab fm_displayif_toggle', fm.richtextarea.add_rte_to_visible_textareas ); - $( document ).on( 'fm_sortable_drop', fm.richtextarea.reload_editors ); - - $( document ).on( 'click', '.fm-richtext .wp-switch-editor', function() { - var aid = this.id, - l = aid.length, - id = aid.substr( 0, l - 5 ), - mode = 'html' === aid.substr( l - 4 ) ? 'html' : 'tinymce'; - - // This only runs if the default editor is set to 'cookie' - if ( 'fm-edit-dynamic' !== id.substr( 0, 15 ) && $( this ).closest( '.fm-richtext-remember-editor' ).length ) { - setUserSetting( 'editor_' + id.replace( /-/g, '_' ).replace( /[^a-z0-9_]/ig, '' ), mode ); - } - - // Reset the core editor's state so it remains unaffected by this event. - // We delay by 50ms to ensure that this event has enough time to run. - // WordPress won't change the state of the editor until the end of the - // event delegation. - setTimeout( fm.richtextarea.reset_core_editor_mode, 50 ); - } ); - - var core_editor_state; - if ( typeof getUserSetting === 'function' ) { - core_editor_state = getUserSetting( 'editor' ); - } - - /** - * If the main editor's state changes, note that change. - */ - $( document ).on( 'click', '#content-tmce,#content-html', function() { - var aid = this.id, - l = aid.length, - id = aid.substr( 0, l - 5 ), - mode = 'html' === aid.substr( l - 4 ) ? 'html' : 'tinymce'; - - core_editor_state = mode; - } ); - - /** - * On document.load, init the editors and make the global meta box drag-drop - * event reload the editors. - */ - $( function() { - fm.richtextarea.add_rte_to_visible_textareas(); - $( '.meta-box-sortables' ).on( 'sortstop', function( e, obj ) { - fm.richtextarea.reload_editors( e, obj.item[0] ); - } ); - } ); -} ) ( jQuery ); \ No newline at end of file diff --git a/readme.txt b/readme.txt index 78631ff..e4e9e4b 100644 --- a/readme.txt +++ b/readme.txt @@ -35,6 +35,9 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo == Changelog == += Unreleased = +* Move remaining scripts that overrode Fieldmanager core assets into separate files. + = 0.2.0 = * Move CSS, and autocomplete and datepicker scripts, into separate files, rather than overriding those assets in Fieldmanager core. @@ -47,4 +50,3 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo == Fieldmanager-specific quirks == * RichTextAreas: These are supported via the `Fieldmanager_Beta_Customize_RichTextArea` class included with this plugin. Use a `Fieldmanager_Beta_Customize_RichTextArea` in place of `Fieldmanager_RichTextArea` when you want to use TinyMCE in the Customizer. -* Scripts: Some Fieldmanager JavaScript files require changes for the Customize context. This plugin includes the updated versions of those files and filters Fieldmanager to return them. From cf9c25786962d7f9cd24c602f1c4d68d4c41fccd Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 24 Dec 2016 14:52:37 -0500 Subject: [PATCH 07/19] Tweak language --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index e4e9e4b..a7f9c53 100644 --- a/readme.txt +++ b/readme.txt @@ -10,9 +10,9 @@ A Fieldmanager Beta plugin for the Customize Context. == Description == -This is the proposed Customize context for Fieldmanager. You can install the plugin alongside a stable Fieldmanager release to help test and refine the context. +This is a proposed Customize context for Fieldmanager. You can install the plugin alongside a stable Fieldmanager release to help test and refine the context. -The official Pull Request for the Customize context, plus tests, is [on GitHub](https://github.com/alleyinteractive/wordpress-fieldmanager/pull/399). +The official Pull Request for this context, plus tests, is [on GitHub](https://github.com/alleyinteractive/wordpress-fieldmanager/pull/399). == Installation == From de067ead55ee9928586a414681909867afb957ec Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 24 Dec 2016 22:24:32 -0500 Subject: [PATCH 08/19] Save settings on TinyMCE `SetContent` event --- js/fieldmanager-beta-customize-overrides.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/fieldmanager-beta-customize-overrides.js b/js/fieldmanager-beta-customize-overrides.js index 51f6d7a..f6b5e8d 100644 --- a/js/fieldmanager-beta-customize-overrides.js +++ b/js/fieldmanager-beta-customize-overrides.js @@ -56,7 +56,8 @@ if ( $fm_richtext.hasClass( 'fm-richtext' ) && ! $fm_richtext.data( 'fm-beta-customize' ) ) { $fm_richtext.data( 'fm-beta-customize', true ); - ed.on( 'keyup AddUndo', function () { + // SetContent handles adding images from the media modal and pasting. + ed.on( 'keyup AddUndo SetContent', function () { ed.save(); fm.beta.customize.setControlsContainingElement( document.getElementById( ed.id ) ); }); From fda1c405e6330c4063f4cea3547ca56ae053f239 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Wed, 28 Dec 2016 21:53:33 -0500 Subject: [PATCH 09/19] Support `Fieldmanager_RichTextArea`s natively --- fieldmanager-beta-customize.php | 35 +++++++++++++ ...class-fieldmanager-beta-customize-demo.php | 2 +- ...eldmanager-beta-customize-richtextarea.php | 51 ++----------------- readme.txt | 4 +- 4 files changed, 42 insertions(+), 50 deletions(-) diff --git a/fieldmanager-beta-customize.php b/fieldmanager-beta-customize.php index 9d17ed0..bf4b7e9 100755 --- a/fieldmanager-beta-customize.php +++ b/fieldmanager-beta-customize.php @@ -95,6 +95,41 @@ function ( $script ) { } } ); +/** + * Print Customizer control scripts for editors in the footer. + * + * This action must fire after settings are exported in WP_Customize_Manager::customize_pane_settings(). + * + * @since 0.3.0 + */ +add_action( 'customize_controls_print_footer_scripts', function () { + if ( wp_script_is( 'fm_richtext', 'enqueued' ) && class_exists( '_WP_Editors' ) ) { + if ( false === has_action( 'customize_controls_print_footer_scripts', array( '_WP_Editors', 'editor_js' ) ) ) { + // Print the necessary JS for an RTE, unless we can't or suspect it's already there. + _WP_Editors::editor_js(); + _WP_Editors::enqueue_scripts(); + } + } +}, 1001 ); + +/** + * Use a "teeny" editor by default in the Customizer to conserve space. + * + * @since 0.3.0 + * + * @param array $settings Array of editor arguments. + * @param string $editor_id ID for the current editor instance. + */ +add_filter( 'wp_editor_settings', function ( $settings, $editor_id ) { + if ( ( substr( $editor_id, 0, 3 ) === 'fm-' ) && is_customize_preview() ) { + if ( ! isset( $settings['teeny'] ) ) { + $settings['teeny'] = true; + } + } + + return $settings; +}, 10, 2 ); + /** * Add a field to the Customizer. * diff --git a/php/demo/class-fieldmanager-beta-customize-demo.php b/php/demo/class-fieldmanager-beta-customize-demo.php index a9ab5fd..2c41f67 100644 --- a/php/demo/class-fieldmanager-beta-customize-demo.php +++ b/php/demo/class-fieldmanager-beta-customize-demo.php @@ -63,7 +63,7 @@ public function customizer_init() { 'checkbox' => new Fieldmanager_Checkbox( 'Checkbox' ), 'radios' => new Fieldmanager_Radios( 'Radio Buttons', array( 'options' => array( 'One', 'Two', 'Three' ) ) ), 'select' => new Fieldmanager_Select( 'Select Dropdown', array( 'options' => array( 'One', 'Two', 'Three' ) ) ), - 'richtextarea' => new Fieldmanager_Beta_Customize_RichTextArea( 'Rich Text Area' ), + 'richtextarea' => new Fieldmanager_RichTextArea( 'Rich Text Area' ), ) ) ); fm_beta_customize_add_to_customizer( array( diff --git a/php/field/class-fieldmanager-beta-customize-richtextarea.php b/php/field/class-fieldmanager-beta-customize-richtextarea.php index 94853b1..e106eab 100644 --- a/php/field/class-fieldmanager-beta-customize-richtextarea.php +++ b/php/field/class-fieldmanager-beta-customize-richtextarea.php @@ -7,52 +7,7 @@ /** * Customizer RichTextArea. + * + * @deprecated 0.3.0 Fieldmanager_RichTextArea is supported natively. */ -class Fieldmanager_Beta_Customize_RichTextArea extends Fieldmanager_RichTextArea { - /** - * Whether this class is hooked into the Customizer to print editor scripts. - * - * @var bool - */ - public static $has_registered_customize_scripts = false; - - /** - * Render the form element. - * - * @param mixed $value Field value. - * @return string HTML. - */ - public function form_element( $value = '' ) { - if ( ! isset( $this->editor_settings['teeny'] ) ) { - $this->editor_settings['teeny'] = true; - } - - return parent::form_element( $value ); - } - - /** - * Add necessary filters before generating the editor. - */ - protected function add_editor_filters() { - parent::add_editor_filters(); - - if ( ! self::$has_registered_customize_scripts ) { - // This action must fire after settings are exported in WP_Customize_Manager::customize_pane_settings(). - add_action( 'customize_controls_print_footer_scripts', array( $this, 'customize_controls_print_footer_scripts' ), 1001 ); - self::$has_registered_customize_scripts = true; - } - } - - /** - * Print Customizer control scripts in the footer. - */ - public function customize_controls_print_footer_scripts() { - if ( class_exists( '_WP_Editors' ) ) { - if ( false === has_action( 'customize_controls_print_footer_scripts', array( '_WP_Editors', 'editor_js' ) ) ) { - // Print the necessary JS for an RTE, unless we can't or suspect it's already there. - _WP_Editors::editor_js(); - _WP_Editors::enqueue_scripts(); - } - } - } -} +class Fieldmanager_Beta_Customize_RichTextArea extends Fieldmanager_RichTextArea {} diff --git a/readme.txt b/readme.txt index 2bfdea2..b9d7c78 100644 --- a/readme.txt +++ b/readme.txt @@ -35,6 +35,9 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo == Changelog == += Unreleased = +* Support `Fieldmanager_RichTextArea` natively; using `Fieldmanager_Beta_Customize_RichTextArea` is no longer required. + = 0.1.1 = * Rename the Customize context action to 'fm_beta_customize' for improved future compatibility with Fieldmanager. @@ -43,5 +46,4 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo == Fieldmanager-specific quirks == -* RichTextAreas: These are supported via the `Fieldmanager_Beta_Customize_RichTextArea` class included with this plugin. Use a `Fieldmanager_Beta_Customize_RichTextArea` in place of `Fieldmanager_RichTextArea` when you want to use TinyMCE in the Customizer. * Scripts: Some Fieldmanager JavaScript files require changes for the Customize context. This plugin includes the updated versions of those files and filters Fieldmanager to return them. From 3c7e743e22e9e67e8a7952474befc2d86d350ff2 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Thu, 29 Dec 2016 22:37:16 -0500 Subject: [PATCH 10/19] Fix invisible TinyMCE popups --- css/fieldmanager-customize.css | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/css/fieldmanager-customize.css b/css/fieldmanager-customize.css index 68517dd..36659bb 100644 --- a/css/fieldmanager-customize.css +++ b/css/fieldmanager-customize.css @@ -29,3 +29,24 @@ /* Nudge for the Customizer. */ max-width: 80%; } + +/* Fix invisible TinyMCE popups. Props Customize Posts. */ + +.wp-customizer #wp-link-wrap { + z-index: 500105; /* originally 100105, but z-index of .wp-full-overlay is 500000 */ +} + +.wp-customizer #wp_editbtns, +.wp-customizer #wp_gallerybtns { + z-index: 500020; /* originally 100020, but z-index of .wp-full-overlay is 500000 */ + +} +.wp-customizer #TB_overlay, +.wp-customizer #TB_window { + z-index: 500050; +} + +.wp-customizer .mce-panel, +.wp-customizer .mce-tooltip { + z-index: 500100 !important; /* originally 100100, but z-index of .wp-full-overlay is 500000 */ +} From 9c135c79583df61a5da85a5d67efa35875a74aa8 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Thu, 29 Dec 2016 22:44:42 -0500 Subject: [PATCH 11/19] Update README --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 065ba82..218df92 100644 --- a/readme.txt +++ b/readme.txt @@ -38,6 +38,7 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo = Unreleased = * Support `Fieldmanager_RichTextArea` natively; using `Fieldmanager_Beta_Customize_RichTextArea` is no longer required. * Move remaining scripts that overrode Fieldmanager core assets into separate files. +* Fix invisible TinyMCE popups. = 0.2.1 = * Fix JavaScript errors. From 3bc0d254e9de6074eaa80ead05456be3980fc69b Mon Sep 17 00:00:00 2001 From: David Herrera Date: Thu, 29 Dec 2016 22:47:52 -0500 Subject: [PATCH 12/19] Link to Customize Posts repo --- css/fieldmanager-beta-customize.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/fieldmanager-beta-customize.css b/css/fieldmanager-beta-customize.css index 36659bb..63e17da 100644 --- a/css/fieldmanager-beta-customize.css +++ b/css/fieldmanager-beta-customize.css @@ -30,7 +30,7 @@ max-width: 80%; } -/* Fix invisible TinyMCE popups. Props Customize Posts. */ +/* Fix invisible TinyMCE popups. Props Customize Posts: https://github.com/xwp/wp-customize-posts. */ .wp-customizer #wp-link-wrap { z-index: 500105; /* originally 100105, but z-index of .wp-full-overlay is 500000 */ From 178fad2402838f538e49245649bbc01d9f7651af Mon Sep 17 00:00:00 2001 From: David Herrera Date: Thu, 29 Dec 2016 23:02:33 -0500 Subject: [PATCH 13/19] Remove block accidentally restored in a merge --- fieldmanager-beta-customize.php | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/fieldmanager-beta-customize.php b/fieldmanager-beta-customize.php index bedbb47..dd9e8e8 100755 --- a/fieldmanager-beta-customize.php +++ b/fieldmanager-beta-customize.php @@ -58,29 +58,6 @@ require_once( FM_BETA_CUSTOMIZE_PATH . 'php/field/class-fieldmanager-beta-customize-richtextarea.php' ); }, 0 ); -/** - * Override the path to some Fieldmanager scripts to use updated versions from this plugin. - * - * @param array Arrays of script arguments. @see Fieldmanager_Util_Assets::add_script(). - */ -add_filter( 'fm_enqueue_scripts', function ( $scripts ) { - return array_map( - function ( $script ) { - switch ( $script['handle'] ) { - case 'fm_colorpicker' : - case 'fieldmanager_script' : - case 'fm_richtext' : - $script['ver'] = FM_BETA_CUSTOMIZE_VERSION; - $script['path'] = str_replace( fieldmanager_get_baseurl(), FM_BETA_CUSTOMIZE_URL, $script['path'] ); - break; - } - - return $script; - }, - $scripts - ); -} ); - /** * Enqueue assets managed by Fieldmanager_Util_Assets in the Customizer. */ From db2a7f381d8d022b0e5b0408ccb227b0f5847c3f Mon Sep 17 00:00:00 2001 From: David Herrera Date: Mon, 2 Jan 2017 19:57:29 -0500 Subject: [PATCH 14/19] Bump to version 0.3 --- fieldmanager-beta-customize.php | 4 ++-- readme.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fieldmanager-beta-customize.php b/fieldmanager-beta-customize.php index dd9e8e8..d2e1c4f 100755 --- a/fieldmanager-beta-customize.php +++ b/fieldmanager-beta-customize.php @@ -7,7 +7,7 @@ * Author URI: https://www.alleyinteractive.com * Text Domain: fieldmanager-beta-customizer * Domain Path: /languages - * Version: 0.2.1 + * Version: 0.3.0 * * @package Fieldmanager_Beta_Customize */ @@ -25,7 +25,7 @@ /** * Plugin version. */ -define( 'FM_BETA_CUSTOMIZE_VERSION', '0.2.1' ); +define( 'FM_BETA_CUSTOMIZE_VERSION', '0.3.0' ); /** * Calculate a Fieldmanager context for the Customizer. diff --git a/readme.txt b/readme.txt index 218df92..c60f0d2 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: dlh, alleyinteractive Requires at least: 4.4 Tested up to: 4.7 -Stable tag: 0.2.1 +Stable tag: 0.3.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -35,7 +35,7 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo == Changelog == -= Unreleased = += 0.3.0 = * Support `Fieldmanager_RichTextArea` natively; using `Fieldmanager_Beta_Customize_RichTextArea` is no longer required. * Move remaining scripts that overrode Fieldmanager core assets into separate files. * Fix invisible TinyMCE popups. From 5f93c8811ea087e9cc4e36528526e26b47ab5dde Mon Sep 17 00:00:00 2001 From: David Herrera Date: Mon, 2 Jan 2017 20:02:58 -0500 Subject: [PATCH 15/19] Add structure to the README changelog --- readme.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index c60f0d2..65202e9 100644 --- a/readme.txt +++ b/readme.txt @@ -36,9 +36,10 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo == Changelog == = 0.3.0 = -* Support `Fieldmanager_RichTextArea` natively; using `Fieldmanager_Beta_Customize_RichTextArea` is no longer required. -* Move remaining scripts that overrode Fieldmanager core assets into separate files. -* Fix invisible TinyMCE popups. +* Changed: `Fieldmanager_RichTextArea` is now supported natively; using `Fieldmanager_Beta_Customize_RichTextArea` is no longer required. +* Changed: Move remaining scripts that overrode Fieldmanager core assets into separate files. +* Fixed: Fix invisible TinyMCE popups. +* Deprecated: `Fieldmanager_Beta_Customize_RichTextArea`, per above. = 0.2.1 = * Fix JavaScript errors. From 8a942c80151df0fd902bdb1aeb5785d400837f23 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Mon, 2 Jan 2017 20:03:49 -0500 Subject: [PATCH 16/19] Add jamesburke as contributor --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 65202e9..6189d53 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ === Fieldmanager Beta: Customize === -Contributors: dlh, alleyinteractive +Contributors: dlh,jamesburke, alleyinteractive Requires at least: 4.4 Tested up to: 4.7 Stable tag: 0.3.0 From 20568a4a96d5b30687c62184c47094f263593a72 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Mon, 2 Jan 2017 20:08:11 -0500 Subject: [PATCH 17/19] Fix missed space --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 6189d53..338aad7 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ === Fieldmanager Beta: Customize === -Contributors: dlh,jamesburke, alleyinteractive +Contributors: dlh, jamesburke, alleyinteractive Requires at least: 4.4 Tested up to: 4.7 Stable tag: 0.3.0 From e503b2c7d70e34235d91ee4e00316cce2a562199 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Mon, 2 Jan 2017 20:15:18 -0500 Subject: [PATCH 18/19] Add James to other author lists --- fieldmanager-beta-customize.php | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fieldmanager-beta-customize.php b/fieldmanager-beta-customize.php index d2e1c4f..0326e5f 100755 --- a/fieldmanager-beta-customize.php +++ b/fieldmanager-beta-customize.php @@ -3,7 +3,7 @@ * Plugin Name: Fieldmanager Beta: Customize * Plugin URI: https://www.github.com/dlh01/fieldmanager-beta-customize-context * Description: Add Fieldmanager fields to the Customizer. - * Author: David Herrera, Alley Interactive + * Author: David Herrera, James Burke, Alley Interactive * Author URI: https://www.alleyinteractive.com * Text Domain: fieldmanager-beta-customizer * Domain Path: /languages diff --git a/package.json b/package.json index cbd1187..f6e03ac 100755 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "main": "Gruntfile.js", "contributors": [ "David Herrera", + "James Burke", "Alley Interactive" ], "devDependencies": { From 51a65f47e99807aeefe0525f9a1c2c158883b6ba Mon Sep 17 00:00:00 2001 From: David Herrera Date: Mon, 2 Jan 2017 20:15:32 -0500 Subject: [PATCH 19/19] Run Grunt tasks --- README.md | 19 ++++++++++--------- languages/fieldmanager-beta-customize.pot | 10 +++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 82494d6..678cc18 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Fieldmanager Beta: Customize # -**Contributors:** [dlh](https://profiles.wordpress.org/dlh), [alleyinteractive](https://profiles.wordpress.org/alleyinteractive) +**Contributors:** [dlh](https://profiles.wordpress.org/dlh), [jamesburke](https://profiles.wordpress.org/jamesburke), [alleyinteractive](https://profiles.wordpress.org/alleyinteractive) **Requires at least:** 4.4 **Tested up to:** 4.7 -**Stable tag:** 0.2.1 +**Stable tag:** 0.3.0 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -10,9 +10,9 @@ A Fieldmanager Beta plugin for the Customize Context. ## Description ## -This is the proposed Customize context for Fieldmanager. You can install the plugin alongside a stable Fieldmanager release to help test and refine the context. +This is a proposed Customize context for Fieldmanager. You can install the plugin alongside a stable Fieldmanager release to help test and refine the context. -The official Pull Request for the Customize context, plus tests, is [on GitHub](https://github.com/alleyinteractive/wordpress-fieldmanager/pull/399). +The official Pull Request for this context, plus tests, is [on GitHub](https://github.com/alleyinteractive/wordpress-fieldmanager/pull/399). ## Installation ## @@ -41,6 +41,12 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo ## Changelog ## +### 0.3.0 ### +* Changed: `Fieldmanager_RichTextArea` is now supported natively; using `Fieldmanager_Beta_Customize_RichTextArea` is no longer required. +* Changed: Move remaining scripts that overrode Fieldmanager core assets into separate files. +* Fixed: Fix invisible TinyMCE popups. +* Deprecated: `Fieldmanager_Beta_Customize_RichTextArea`, per above. + ### 0.2.1 ### * Fix JavaScript errors. @@ -52,8 +58,3 @@ For more code examples, browse `php/demos/class-fieldmanager-beta-customize-demo ### 0.1.0 ### * Initial release. - -## Fieldmanager-specific quirks ## - -* RichTextAreas: These are supported via the `Fieldmanager_Beta_Customize_RichTextArea` class included with this plugin. Use a `Fieldmanager_Beta_Customize_RichTextArea` in place of `Fieldmanager_RichTextArea` when you want to use TinyMCE in the Customizer. -* Scripts: Some Fieldmanager JavaScript files require changes for the Customize context. This plugin includes the updated versions of those files and filters Fieldmanager to return them. diff --git a/languages/fieldmanager-beta-customize.pot b/languages/fieldmanager-beta-customize.pot index 42c9003..f552037 100644 --- a/languages/fieldmanager-beta-customize.pot +++ b/languages/fieldmanager-beta-customize.pot @@ -1,15 +1,15 @@ -# Copyright (C) 2016 David Herrera, Alley Interactive +# Copyright (C) 2017 David Herrera, James Burke, Alley Interactive # This file is distributed under the same license as the Fieldmanager Beta: Customize package. msgid "" msgstr "" -"Project-Id-Version: Fieldmanager Beta: Customize 0.1.0\n" +"Project-Id-Version: Fieldmanager Beta: Customize 0.3.0\n" "Report-Msgid-Bugs-To: " "https://wordpress.org/support/plugin/fieldmanager-beta-customize\n" -"POT-Creation-Date: 2016-10-12 02:04:05+00:00\n" +"POT-Creation-Date: 2017-01-03 01:14:23+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "X-Generator: grunt-wp-i18n 0.5.4\n" @@ -70,7 +70,7 @@ msgid "Add Fieldmanager fields to the Customizer." msgstr "" #. Author of the plugin/theme -msgid "David Herrera, Alley Interactive" +msgid "David Herrera, James Burke, Alley Interactive" msgstr "" #. Author URI of the plugin/theme