Skip to content
Permalink
Browse files

Fixed a bug that the `select2` fields were not functional when repeat…

…ed. Fixes #279.

- Fixed a bug that the `id` attribute values of `option` tags were not updated for repeated field elements.
- Updated the `select2` jQuery library to 4.0.7 from 4.0.6-rc.1.
- Added some clean-ups before initializing select elements.
  • Loading branch information...
michaeluno committed May 30, 2019
1 parent dab4bf3 commit 7805f233651d2ff090e9d0ee6d993c1ecee950e4
Showing with 270 additions and 176 deletions.
  1. +1 −1 ...pment/factory/_common/form/_view/script/AdminPageFramework_Form_View___Script_RepeatableField.php
  2. +1 −1 ...ent/factory/_common/form/_view/script/AdminPageFramework_Form_View___Script_RepeatableSection.php
  3. +9 −8 example/library/select2-custom-field-type/Select2CustomFieldType.php
  4. +5 −0 example/library/select2-custom-field-type/changelog.txt
  5. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/af.js
  6. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/ar.js
  7. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/az.js
  8. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/bg.js
  9. +3 −0 example/library/select2-custom-field-type/select2/js/i18n/bn.js
  10. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/bs.js
  11. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/ca.js
  12. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/cs.js
  13. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/da.js
  14. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/de.js
  15. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/dsb.js
  16. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/el.js
  17. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/en.js
  18. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/es.js
  19. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/et.js
  20. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/eu.js
  21. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/fa.js
  22. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/fi.js
  23. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/fr.js
  24. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/gl.js
  25. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/he.js
  26. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/hi.js
  27. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/hr.js
  28. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/hsb.js
  29. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/hu.js
  30. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/hy.js
  31. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/id.js
  32. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/is.js
  33. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/it.js
  34. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/ja.js
  35. +3 −0 example/library/select2-custom-field-type/select2/js/i18n/ka.js
  36. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/km.js
  37. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/ko.js
  38. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/lt.js
  39. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/lv.js
  40. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/mk.js
  41. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/ms.js
  42. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/nb.js
  43. +3 −0 example/library/select2-custom-field-type/select2/js/i18n/ne.js
  44. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/nl.js
  45. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/pl.js
  46. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/ps.js
  47. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/pt-BR.js
  48. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/pt.js
  49. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/ro.js
  50. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/ru.js
  51. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/sk.js
  52. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/sl.js
  53. +3 −0 example/library/select2-custom-field-type/select2/js/i18n/sq.js
  54. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/sr-Cyrl.js
  55. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/sr.js
  56. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/sv.js
  57. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/th.js
  58. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/tk.js
  59. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/tr.js
  60. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/uk.js
  61. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/vi.js
  62. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/zh-CN.js
  63. +2 −2 example/library/select2-custom-field-type/select2/js/i18n/zh-TW.js
  64. +65 −27 example/library/select2-custom-field-type/select2/js/select2.full.js
  65. +1 −1 example/library/select2-custom-field-type/select2/js/select2.full.min.js
  66. +65 −27 example/library/select2-custom-field-type/select2/js/select2.js
  67. +1 −1 example/library/select2-custom-field-type/select2/js/select2.min.js
@@ -273,7 +273,7 @@ static public function getScript( /* $oMsg */ ) {
_iFieldCount, // increment from
_sFieldTagIDModel // digit model
);
oElement.find( 'input,textarea,select' ).incrementAttribute(
oElement.find( 'input,textarea,select,option' ).incrementAttribute(
'id', // attribute name
_iFieldCount, // increment from
_sFieldTagIDModel // digit model
@@ -261,7 +261,7 @@ static public function getScript( /* $oMsg */ ) {
iSectionsCount, // increment from
_sSectionIDModel // digit model
);
$( oElement ).find( 'tr.admin-page-framework-fieldrow, .admin-page-framework-fieldset, .admin-page-framework-fields, .admin-page-framework-field, table.form-table, input,textarea,select' )
$( oElement ).find( 'tr.admin-page-framework-fieldrow, .admin-page-framework-fieldset, .admin-page-framework-fields, .admin-page-framework-field, table.form-table, input,textarea,select,option' )
.incrementAttribute(
'id',
iSectionsCount,
@@ -77,7 +77,7 @@
* @since 3.8.7
* @version 0.0.4
* @supports IE8 or above. (uses JSON object)
* @requires Admin Page Framework 3.8.14
* @requires Admin Page Framework 3.8.20
*/
class Select2CustomFieldType extends AdminPageFramework_FieldType_select {
@@ -236,7 +236,7 @@ protected function getScripts() {
}
/**
* Initialize no ui slider with the given slider container node.
* Initialize elements with the given container node.
*
* @since 3.8.7
* @param oNode The target select tag DOM node object.
@@ -423,9 +423,9 @@ protected function getScripts() {
/**
* Initialization
*/
*/
_oSelect2Target.select2( _aOptions );
/**
* Ajax handling.
*
@@ -435,7 +435,7 @@ protected function getScripts() {
if ( _aOptions[ 'search_callback' ] ) {
/**
* Set inital values.
* Set initial values.
*/
var _oInputForEncoded = _oSelect2Target.closest( '.admin-page-framework-field' )
.children( 'input[data-encoded]' ).first();
@@ -523,8 +523,7 @@ protected function getScripts() {
}
/**
* Initialize toggle elements. Note that a pair of inputs (min and max) are parsed for each field.
* So skip one of them.
* Initialize select2 elements.
*/
jQuery( 'select[data-type=select2]' ).each( function () {
_initializeSelect2( this );
@@ -536,10 +535,12 @@ protected function getScripts() {
* Called when a field of this field type gets repeated.
*/
repeated_field: function( oCloned, aModel ) {
oCloned.find( '.select2-container' ).remove();
oCloned.find( 'select[data-type=select2]' ).each( function () {
jQuery( this ).removeAttr( 'data-select2-id tabindex aria-hidden' );
jQuery( this ).removeClass( 'select2-hidden-accessible' );
_initializeSelect2( this );
});
@@ -1,6 +1,11 @@
# Change Log

= 0.0.5 - 2019/05/30 =
- Updated select2 from v4.0.6-rc.1 to v4.0.7.
- Fixed a bug that initialization failed for repeated fields.

= 0.0.4 - 2019/02/17 =
- Updated select2 from v4.0.3 to v4.0.6-rc.1.
- Fixed a bug with that requests did not go through with nested fields.
- Fixed an issue that the message "the results could not be loaded" was displayed while during Ajax requests by updating the select2 library to 4.0.6-rc.1.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

0 comments on commit 7805f23

Please sign in to comment.
You can’t perform that action at this time.