From 42cb7c5aa6874c6560165c0dce3b71edbafd0d01 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Wed, 11 Jan 2017 23:14:04 -0500 Subject: [PATCH 01/10] Add listeners to newly initialized RichTextAreas The previous implementation didn't account for repeatable RTAs. --- js/fieldmanager-beta-customize-overrides.js | 28 ++++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/js/fieldmanager-beta-customize-overrides.js b/js/fieldmanager-beta-customize-overrides.js index f6b5e8d..5f7e06f 100644 --- a/js/fieldmanager-beta-customize-overrides.js +++ b/js/fieldmanager-beta-customize-overrides.js @@ -46,23 +46,9 @@ }); } - // Initialize RichTextAreas and respond to changes. + // Initialize RichTextAreas. 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 ); - - // 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 ) ); - }); - } - }); } // Initialize sortables via existing event. @@ -101,4 +87,16 @@ } ); })(); }); + + // Respond to RichTextArea changes. + $( document ).on( 'tinymce-editor-init', function ( event, editor ) { + var editor_element = document.getElementById( editor.id ); + + if ( editor_element && editor_element.classList.contains( 'fm-richtext' ) ) { + editor.on( 'keyup AddUndo SetContent', function () { + editor.save(); + fm.beta.customize.setControlsContainingElement( editor_element ); + }); + } + }); })( jQuery ); From 36f5653db246227d0bc110ed879c4b05c7532d62 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Wed, 11 Jan 2017 23:16:52 -0500 Subject: [PATCH 02/10] Add demo of repeatable RichTextArea --- php/demo/class-fieldmanager-beta-customize-demo.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/php/demo/class-fieldmanager-beta-customize-demo.php b/php/demo/class-fieldmanager-beta-customize-demo.php index 2c41f67..8c162ac 100644 --- a/php/demo/class-fieldmanager-beta-customize-demo.php +++ b/php/demo/class-fieldmanager-beta-customize-demo.php @@ -133,6 +133,16 @@ public function customizer_init() { 'sanitize' => 'intval', ) ); fm_beta_customize_add_to_customizer( 'Fieldmanager Validated Fields', $fm ); + + $fm = new Fieldmanager_Group( array( + 'name' => 'repeatable_richtextarea', + 'limit' => 0, + 'one_label_per_item' => false, + 'children' => array( + 'richtext' => new Fieldmanager_RichTextArea(), + ), + ) ); + fm_beta_customize_add_to_customizer( 'Fieldmanager Repeatable Fields', $fm ); } /** From e165f3f2cfcf92497c6bde46c9ae75dfa7369518 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 15 Jan 2017 00:16:24 -0500 Subject: [PATCH 03/10] Add listeners to newly initialized Colorpickers --- js/fieldmanager-beta-customize-overrides.js | 37 ++++++++++----------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/js/fieldmanager-beta-customize-overrides.js b/js/fieldmanager-beta-customize-overrides.js index 5f7e06f..0df7758 100644 --- a/js/fieldmanager-beta-customize-overrides.js +++ b/js/fieldmanager-beta-customize-overrides.js @@ -24,26 +24,6 @@ // 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. @@ -99,4 +79,21 @@ }); } }); + + // Respond to Colorpicker changes. + $( document ).on( 'wpcolorpickercreate', '.fm-colorpicker-popup', function () { + var $this = $( this ); + + $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 ); + }); + }); })( jQuery ); From 5b89723b95b4f52b0a719eddebb77ee56ed3400a Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 15 Jan 2017 00:21:39 -0500 Subject: [PATCH 04/10] Clean up repeatable demo, and add Colorpicker demo --- ...class-fieldmanager-beta-customize-demo.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/php/demo/class-fieldmanager-beta-customize-demo.php b/php/demo/class-fieldmanager-beta-customize-demo.php index 8c162ac..4c6c1dc 100644 --- a/php/demo/class-fieldmanager-beta-customize-demo.php +++ b/php/demo/class-fieldmanager-beta-customize-demo.php @@ -134,7 +134,13 @@ public function customizer_init() { ) ); fm_beta_customize_add_to_customizer( 'Fieldmanager Validated Fields', $fm ); - $fm = new Fieldmanager_Group( array( + add_action( 'customize_register', function ( $manager ) { + $manager->add_section( 'fm_repeatable_fields', array( + 'title' => 'Fieldmanager Repeatable Fields', + ) ); + } ); + + $fm = new Fieldmanager_Group( 'RichTextAreas', array( 'name' => 'repeatable_richtextarea', 'limit' => 0, 'one_label_per_item' => false, @@ -142,7 +148,21 @@ public function customizer_init() { 'richtext' => new Fieldmanager_RichTextArea(), ), ) ); - fm_beta_customize_add_to_customizer( 'Fieldmanager Repeatable Fields', $fm ); + fm_beta_customize_add_to_customizer( + array( 'control_args' => array( 'section' => 'fm_repeatable_fields' ) ), + $fm + ); + + fm_beta_customize_add_to_customizer( + array( + 'control_args' => array( 'section' => 'fm_repeatable_fields' ), + ), + new Fieldmanager_Colorpicker( 'Colorpickers', array( + 'name' => 'repeatable_colorpicker', + 'limit' => 0, + 'one_label_per_item' => false, + ) ) + ); } /** From 6b3f9e7d0f1c8a0c86bb688df61af2204ee8ce12 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 15 Jan 2017 00:34:05 -0500 Subject: [PATCH 05/10] Remove unnecessary variable --- .../class-fieldmanager-beta-customize-demo.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/php/demo/class-fieldmanager-beta-customize-demo.php b/php/demo/class-fieldmanager-beta-customize-demo.php index 4c6c1dc..4b4fc4d 100644 --- a/php/demo/class-fieldmanager-beta-customize-demo.php +++ b/php/demo/class-fieldmanager-beta-customize-demo.php @@ -140,17 +140,16 @@ public function customizer_init() { ) ); } ); - $fm = new Fieldmanager_Group( 'RichTextAreas', array( - 'name' => 'repeatable_richtextarea', - 'limit' => 0, - 'one_label_per_item' => false, - 'children' => array( - 'richtext' => new Fieldmanager_RichTextArea(), - ), - ) ); fm_beta_customize_add_to_customizer( array( 'control_args' => array( 'section' => 'fm_repeatable_fields' ) ), - $fm + new Fieldmanager_Group( 'RichTextAreas', array( + 'name' => 'repeatable_richtextarea', + 'limit' => 0, + 'one_label_per_item' => false, + 'children' => array( + 'richtext' => new Fieldmanager_RichTextArea(), + ), + ) ) ); fm_beta_customize_add_to_customizer( From 432bd3deefb0c0fad1bf1002afc719bad2a43c67 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 15 Jan 2017 00:34:17 -0500 Subject: [PATCH 06/10] Update readme --- readme.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.txt b/readme.txt index 338aad7..1d10dfc 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 = +* Fixed: Track the changes to instances of repeatable RichTextAreas and Colorpickers added after loading the Customizer. + = 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. From bc0e1bbbb26cb76de84e39b54ea04dc7cffbf38d Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 15 Jan 2017 00:34:58 -0500 Subject: [PATCH 07/10] Fix another code style inconsistency --- php/demo/class-fieldmanager-beta-customize-demo.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/php/demo/class-fieldmanager-beta-customize-demo.php b/php/demo/class-fieldmanager-beta-customize-demo.php index 4b4fc4d..6458717 100644 --- a/php/demo/class-fieldmanager-beta-customize-demo.php +++ b/php/demo/class-fieldmanager-beta-customize-demo.php @@ -153,9 +153,7 @@ public function customizer_init() { ); fm_beta_customize_add_to_customizer( - array( - 'control_args' => array( 'section' => 'fm_repeatable_fields' ), - ), + array( 'control_args' => array( 'section' => 'fm_repeatable_fields' ) ), new Fieldmanager_Colorpicker( 'Colorpickers', array( 'name' => 'repeatable_colorpicker', 'limit' => 0, From 62e49c1a30f828bfd77119d02addeea07f012d84 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 21 Jan 2017 19:21:06 -0500 Subject: [PATCH 08/10] Version bump --- 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 0326e5f..5f6ae55 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.3.0 + * Version: 0.3.1 * * @package Fieldmanager_Beta_Customize */ @@ -25,7 +25,7 @@ /** * Plugin version. */ -define( 'FM_BETA_CUSTOMIZE_VERSION', '0.3.0' ); +define( 'FM_BETA_CUSTOMIZE_VERSION', '0.3.1' ); /** * Calculate a Fieldmanager context for the Customizer. diff --git a/readme.txt b/readme.txt index 1d10dfc..7cb69a4 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: dlh, jamesburke, alleyinteractive Requires at least: 4.4 Tested up to: 4.7 -Stable tag: 0.3.0 +Stable tag: 0.3.1 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.1 = * Fixed: Track the changes to instances of repeatable RichTextAreas and Colorpickers added after loading the Customizer. = 0.3.0 = From edaead3dfa4cc0f43efdd3d399d670a97e68671a Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 21 Jan 2017 19:22:41 -0500 Subject: [PATCH 09/10] Add `grunt prerelease` for running prep tasks --- Gruntfile.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 78af68e..b16448a 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -48,8 +48,9 @@ module.exports = function( grunt ) { grunt.loadNpmTasks( 'grunt-wp-i18n' ); grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' ); - grunt.registerTask( 'i18n', ['addtextdomain', 'makepot'] ); - grunt.registerTask( 'readme', ['wp_readme_to_markdown'] ); + grunt.registerTask( 'i18n', [ 'addtextdomain', 'makepot' ] ); + grunt.registerTask( 'readme', [ 'wp_readme_to_markdown' ] ); + grunt.registerTask( 'prerelease', [ 'i18n', 'readme' ] ); grunt.util.linefeed = '\n'; From d09c391c203ab9c14965b0106371d4bb016a49fb Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 21 Jan 2017 19:23:13 -0500 Subject: [PATCH 10/10] Generate .md and .pot --- README.md | 5 ++++- languages/fieldmanager-beta-customize.pot | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 678cc18..e2a3b0b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **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.3.0 +**Stable tag:** 0.3.1 **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.3.1 ### +* Fixed: Track the changes to instances of repeatable RichTextAreas and Colorpickers added after loading the Customizer. + ### 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. diff --git a/languages/fieldmanager-beta-customize.pot b/languages/fieldmanager-beta-customize.pot index f552037..78b8d25 100644 --- a/languages/fieldmanager-beta-customize.pot +++ b/languages/fieldmanager-beta-customize.pot @@ -2,10 +2,10 @@ # This file is distributed under the same license as the Fieldmanager Beta: Customize package. msgid "" msgstr "" -"Project-Id-Version: Fieldmanager Beta: Customize 0.3.0\n" +"Project-Id-Version: Fieldmanager Beta: Customize 0.3.1\n" "Report-Msgid-Bugs-To: " "https://wordpress.org/support/plugin/fieldmanager-beta-customize\n" -"POT-Creation-Date: 2017-01-03 01:14:23+00:00\n" +"POT-Creation-Date: 2017-01-22 00:22:27+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n"