From 3e51d5a019cf268f3794c15ebf0b886381ef48f8 Mon Sep 17 00:00:00 2001 From: "alex.oakland" Date: Wed, 12 Jun 2024 08:17:06 +0100 Subject: [PATCH] Ran PHPStorms reformat code to make future PRs more readable --- .github/workflows/deploy-to-wp-org.yml | 44 +- .jshintrc | 42 +- Gruntfile.js | 4 +- README.md | 46 +- assets/css/gathercontent-importer.css | 652 +- assets/css/sass/_modal.scss | 16 +- assets/css/sass/_single.scss | 13 + assets/css/sass/_sync.scss | 12 +- assets/css/sass/gathercontent-importer.scss | 173 +- assets/css/vendor/select2-4.0.13/select2.css | 883 +- assets/js/gathercontent-general.js | 3009 +++-- assets/js/gathercontent-mapping.js | 1543 ++- assets/js/gathercontent-single.js | 1477 +- assets/js/gathercontent-sync.js | 1625 +-- assets/js/gathercontent.js | 240 +- assets/js/src/components/collections/base.js | 8 +- assets/js/src/components/collections/items.js | 118 +- .../components/collections/modal-nav-items.js | 24 +- assets/js/src/components/collections/posts.js | 48 +- .../collections/search-extension.js | 52 +- .../js/src/components/collections/tab-rows.js | 6 +- assets/js/src/components/collections/tabs.js | 4 +- assets/js/src/components/database.js | 24 +- assets/js/src/components/general.js | 86 +- assets/js/src/components/initiate-objects.js | 8 +- assets/js/src/components/log.js | 8 +- assets/js/src/components/main.js | 74 +- assets/js/src/components/mapping.js | 36 +- assets/js/src/components/models/ajax.js | 60 +- assets/js/src/components/models/base.js | 4 +- assets/js/src/components/models/item.js | 66 +- .../src/components/models/modal-nav-item.js | 10 +- .../js/src/components/models/modify-json.js | 16 +- assets/js/src/components/models/post.js | 76 +- assets/js/src/components/models/tab-row.js | 56 +- assets/js/src/components/models/tab.js | 26 +- assets/js/src/components/single.js | 46 +- assets/js/src/components/sync.js | 56 +- assets/js/src/components/views/base.js | 20 +- assets/js/src/components/views/default-tab.js | 54 +- assets/js/src/components/views/item.js | 30 +- assets/js/src/components/views/items.js | 201 +- .../src/components/views/mapping-metabox.js | 168 +- .../js/src/components/views/metabox-base.js | 36 +- .../src/components/views/metabox-statuses.js | 92 +- assets/js/src/components/views/metabox.js | 226 +- .../components/views/modal-assign-mapping.js | 36 +- .../js/src/components/views/modal-post-row.js | 38 +- assets/js/src/components/views/modal.js | 357 +- assets/js/src/components/views/post-row.js | 26 +- assets/js/src/components/views/post-rows.js | 132 +- .../js/src/components/views/status-select2.js | 38 +- assets/js/src/components/views/tab-link.js | 16 +- assets/js/src/components/views/tab-row.js | 214 +- assets/js/src/components/views/tab.js | 22 +- assets/js/src/components/views/table-base.js | 127 +- assets/js/src/components/views/table-nav.js | 14 +- .../js/src/components/views/table-search.js | 24 +- assets/js/src/components/views/tabs.js | 166 +- assets/js/vendor/select2-4.0.13/select2.js | 11213 ++++++++-------- composer.lock | 7296 +++++----- gathercontent-importer.php | 13 +- includes/classes/admin/admin.php | 27 +- includes/classes/admin/ajax/handlers.php | 56 +- includes/classes/admin/ajax/sync-bulk.php | 4 +- includes/classes/admin/ajax/sync-items.php | 1 + includes/classes/admin/base.php | 55 +- includes/classes/admin/bulk.php | 63 +- includes/classes/admin/enqueue.php | 14 +- includes/classes/admin/mapping-wizard.php | 98 +- includes/classes/admin/mapping/base.php | 58 +- .../classes/admin/mapping/field-types/acf.php | 205 +- .../admin/mapping/field-types/base.php | 2 +- .../admin/mapping/field-types/database.php | 92 +- .../admin/mapping/field-types/media.php | 10 +- .../admin/mapping/field-types/meta.php | 16 +- .../admin/mapping/field-types/post.php | 12 +- .../admin/mapping/field-types/taxonomy.php | 13 +- .../admin/mapping/field-types/type.php | 4 + .../admin/mapping/field-types/types.php | 9 +- .../admin/mapping/field-types/wpseo.php | 26 +- includes/classes/admin/mapping/items-sync.php | 32 +- .../classes/admin/mapping/template-mapper.php | 170 +- includes/classes/admin/post-base.php | 10 +- includes/classes/admin/single.php | 23 +- includes/classes/admin/support.php | 135 +- includes/classes/api.php | 231 +- includes/classes/base.php | 55 +- includes/classes/compatibility/acf.php | 69 +- includes/classes/compatibility/wpml.php | 27 +- includes/classes/debug.php | 77 +- includes/classes/dom.php | 4 +- includes/classes/exception.php | 9 +- includes/classes/general.php | 8 +- includes/classes/mapping-post.php | 118 +- .../classes/post-types/async-save-hook.php | 8 +- includes/classes/post-types/base.php | 12 +- .../classes/post-types/template-mappings.php | 50 +- includes/classes/settings/form-section.php | 12 +- includes/classes/settings/setting.php | 5 +- includes/classes/sync/async-base.php | 12 +- includes/classes/sync/async-pull-action.php | 1 + includes/classes/sync/async-push-action.php | 1 + includes/classes/sync/base.php | 226 +- includes/classes/sync/log.php | 18 +- includes/classes/sync/pull.php | 467 +- includes/classes/sync/push.php | 336 +- includes/classes/utils.php | 48 +- includes/classes/views/form-element.php | 7 +- includes/classes/views/input.php | 1 + includes/classes/views/radio.php | 3 +- includes/classes/views/view.php | 19 +- includes/functions/core.php | 29 +- includes/functions/functions.php | 160 +- includes/vendor/edd/browser.php | 278 +- includes/views/admin-page.php | 3 +- includes/views/bulk-edit-field.php | 3 +- includes/views/gc-items-list.php | 6 +- includes/views/gc-post-column-row.php | 8 +- includes/views/graceful-degradation.php | 2 +- includes/views/metabox.php | 10 +- includes/views/refresh-connection-button.php | 6 +- includes/views/system-info.php | 31 +- includes/views/table-header.php | 3 +- includes/views/table-headers.php | 2 +- includes/views/tabs-wrapper.php | 14 +- includes/views/tmpl-gc-item.php | 16 +- .../views/tmpl-gc-items-sync-progress.php | 26 +- includes/views/tmpl-gc-items-sync.php | 32 +- ...c-mapping-defaults-tab-status-mappings.php | 27 +- .../views/tmpl-gc-mapping-defaults-tab.php | 16 +- includes/views/tmpl-gc-mapping-metabox.php | 39 +- includes/views/tmpl-gc-mapping-tab-row.php | 171 +- includes/views/tmpl-gc-metabox-statuses.php | 14 +- includes/views/tmpl-gc-metabox.php | 27 +- includes/views/tmpl-gc-modal-window.php | 115 +- includes/views/tmpl-gc-post-column-row.php | 2 +- includes/views/tmpl-gc-select2-item.php | 3 +- includes/views/tmpl-gc-status-select2.php | 19 +- includes/views/tmpl-gc-tab-wrapper.php | 23 +- includes/views/tmpl-gc-table-nav.php | 7 +- includes/views/tmpl-gc-table-search.php | 3 +- includes/views/tmpl-gc-tabs-wrapper.php | 3 +- includes/views/underscore-data-status.php | 3 +- includes/views/underscore-data-updated.php | 9 +- phpunit.xml.dist | 6 +- tasks/build.js | 2 +- tasks/css.js | 4 +- tasks/default.js | 2 +- tasks/js.js | 2 +- tasks/options/browserify.js | 18 +- tasks/options/concat.js | 12 +- tasks/options/copy.js | 2 +- tasks/options/cssmin.js | 8 +- tasks/options/mocha.js | 2 +- tasks/options/postcss.js | 6 +- tasks/options/uglify.js | 20 +- tasks/options/watch.js | 4 +- tasks/test.js | 2 +- tests/mocha/gathercontent-importer.html | 44 +- tests/mocha/tests/gathercontent-importer.js | 10 +- tests/phpunit/Core_Tests.php | 13 +- tests/phpunit/test-tools/TestCase.php | 32 +- 163 files changed, 18213 insertions(+), 17295 deletions(-) diff --git a/.github/workflows/deploy-to-wp-org.yml b/.github/workflows/deploy-to-wp-org.yml index 43ffdb96..dbe16c1d 100644 --- a/.github/workflows/deploy-to-wp-org.yml +++ b/.github/workflows/deploy-to-wp-org.yml @@ -1,25 +1,25 @@ name: Deploy to WordPress.org on: - push: - tags: - - "*" + push: + tags: + - "*" jobs: - tag: - name: New tag - runs-on: ubuntu-latest - steps: - # Clone the repo - - uses: actions/checkout@master - # Prepare the release - - run: ls - - run: "composer install --no-dev" - # Release to WordPress.org - - name: WordPress Plugin Deploy - id: deploy - uses: 10up/action-wordpress-plugin-deploy@2.2.2 - with: - generate-zip: true - env: - SVN_USERNAME: ${{ secrets.SVN_USERNAME }} - SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} - SLUG: gathercontent-import + tag: + name: New tag + runs-on: ubuntu-latest + steps: + # Clone the repo + - uses: actions/checkout@master + # Prepare the release + - run: ls + - run: "composer install --no-dev" + # Release to WordPress.org + - name: WordPress Plugin Deploy + id: deploy + uses: 10up/action-wordpress-plugin-deploy@2.2.2 + with: + generate-zip: true + env: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + SLUG: gathercontent-import diff --git a/.jshintrc b/.jshintrc index 61dc29a2..fc17dce3 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,25 +1,25 @@ { - "curly" : true, - "eqeqeq" : true, - "immed" : true, - "latedef" : true, - "newcap" : true, - "noarg" : true, - "sub" : true, - "undef" : true, - "boss" : true, - "eqnull" : true, - "validthis" : true, + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "boss": true, + "eqnull": true, + "validthis": true, "globals": { - "exports" : true, - "module" : false, - "console" : true, - "require" : true, - "document" : true, - "jQuery" : true, - "wp" : true, - "Backbone" : true, - "_" : true, - "window" : true + "exports": true, + "module": false, + "console": true, + "require": true, + "document": true, + "jQuery": true, + "wp": true, + "Backbone": true, + "_": true, + "window": true } } diff --git a/Gruntfile.js b/Gruntfile.js index 51216e10..d6f6e7be 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,8 +11,8 @@ module.exports = function (grunt) { var object = {}; var key; - glob.sync('*', {cwd: path}).forEach(function(option) { - key = option.replace(/\.js$/,''); + glob.sync('*', {cwd: path}).forEach(function (option) { + key = option.replace(/\.js$/, ''); object[key] = require(path + option); }); diff --git a/README.md b/README.md index a58d7b91..722b19e7 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,15 @@ This plugin allows you to transfer content from your Content Workflow projects i ## Description ## -Installing our WordPress plugin on your site allows you to quickly perform updates of your content from your Content Workflow account to WordPress as well as push your WordPress content updates back to Content Workflow. Content can be imported as new pages/posts or custom post types, and you can also import your WordPress content back to new Content Workflow items. +Installing our WordPress plugin on your site allows you to quickly perform updates of your content from your Content +Workflow account to WordPress as well as push your WordPress content updates back to Content Workflow. Content can be +imported as new pages/posts or custom post types, and you can also import your WordPress content back to new Content +Workflow items. -The plugin allows you to map each field in your Content Workflow Templates with WordPress fields. This is accomplished by creating a Template Mapping, which allows you to map each field in Content Workflow to various fields in WordPress; title, body content, custom fields, tags, categories, Yoast fields, advanced custom fields, featured images … and many more. +The plugin allows you to map each field in your Content Workflow Templates with WordPress fields. This is accomplished +by creating a Template Mapping, which allows you to map each field in Content Workflow to various fields in WordPress; +title, body content, custom fields, tags, categories, Yoast fields, advanced custom fields, featured images … and many +more. The module currently supports the following features: @@ -17,7 +23,10 @@ The module currently supports the following features: ### What is Content Workflow? -Content Workflow is an online platform for pulling together, editing, and reviewing website content with your clients and colleagues. It's a reliable alternative to emailing around Word documents and pasting content into your CMS. This plugin replaces that process of copying and pasting content and allows you to bulk import structured content, and then continue to update it in WordPress with a few clicks. +Content Workflow is an online platform for pulling together, editing, and reviewing website content with your clients +and colleagues. It's a reliable alternative to emailing around Word documents and pasting content into your CMS. This +plugin replaces that process of copying and pasting content and allows you to bulk import structured content, and then +continue to update it in WordPress with a few clicks. Connecting a powerful content production platform, to a powerful content publishing platform. @@ -26,39 +35,54 @@ Connecting a powerful content production platform, to a powerful content publish This section describes how to install the plugin and get it working. ### Downloading the plugin ### + 1. To download the plugin, click the green "Code" button on the top right of this page. 2. Then click "Download ZIP". -For more information on how to download from GitHub please visit their [help page](https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives). +For more information on how to download from GitHub please visit +their [help page](https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives). ### Installing the plugin ### 1. Upload `content-workflow` to the `/wp-content/plugins/` directory 2. Activate the Content Workflow plugin through the 'Plugins' menu in WordPress 3. Click on the menu item "Content Workflow" -4. Link your accounts. You will need to enter your Content Workflow account URL (e.g. http://mywebsite.gathercontent.com) and your personal Content Workflow API key. You can find your API key in your [Settings area within Content Workflow](https://gathercontent.com/developers/authentication/). +4. Link your accounts. You will need to enter your Content Workflow account URL ( + e.g. http://mywebsite.gathercontent.com) and your personal Content Workflow API key. You can find your API key in + your [Settings area within Content Workflow](https://gathercontent.com/developers/authentication/). -For more detailed installation instructions, please visit our [Help Centre](http://help.gathercontent.com/importing-and-exporting-content#wordpress-integration). +For more detailed installation instructions, please visit +our [Help Centre](http://help.gathercontent.com/importing-and-exporting-content#wordpress-integration). ## Support ## -If you need help, Please [visit our support documentation](http://help.gathercontent.com/importing-and-exporting-content#wordpress-integration). +If you need help, +Please [visit our support documentation](http://help.gathercontent.com/importing-and-exporting-content#wordpress-integration). -Also note, in your WordPress dashboard, under the Content Workflow menu item, you will see a Support page. On this page, you'll find a large textarea filled with technical information about your server, browser, plugin, etc. This information is very useful when debugging, and the Content Workflow support team may ask you for it at some point. +Also note, in your WordPress dashboard, under the Content Workflow menu item, you will see a Support page. On this page, +you'll find a large textarea filled with technical information about your server, browser, plugin, etc. This information +is very useful when debugging, and the Content Workflow support team may ask you for it at some point. -Below the text box is a button that will allow you to simply save all of that information to a .txt file. This allows you to easily deliver it to anyone who needs it. +Below the text box is a button that will allow you to simply save all of that information to a .txt file. This allows +you to easily deliver it to anyone who needs it. -**However**, this information contains potentially senstive data. Please be careful with where you post it. Do not post it in the WordPress support forums. +**However**, this information contains potentially senstive data. Please be careful with where you post it. Do not post +it in the WordPress support forums. ### Third-Party Services ### This plugin relies on the following third-party services: -1. **Content Workflow**: This service is used for content management and synchronization between your WordPress site and Content Workflow. For more information, please visit [Content Workflow](https://www.bynder.com/en/products/content-workflow/). The [Terms of Service](https://gathercontent.com/legal/terms-of-service) and [Privacy Policy](https://www.bynder.com/en/legal/privacy-policy/) are available for review. +1. **Content Workflow**: This service is used for content management and synchronization between your WordPress site and + Content Workflow. For more information, please + visit [Content Workflow](https://www.bynder.com/en/products/content-workflow/). + The [Terms of Service](https://gathercontent.com/legal/terms-of-service) + and [Privacy Policy](https://www.bynder.com/en/legal/privacy-policy/) are available for review. ## Changelog ### 1.0.0 ### + * Officially supporting components by using the Advanced Custom Fields plugins * Full rebrand to Content Workflow by Bynder * Migration from the [GatherContent Wordpress plugin](https://wordpress.org/plugins/gathercontent-import/) diff --git a/assets/css/gathercontent-importer.css b/assets/css/gathercontent-importer.css index be7ad72d..025cca43 100644 --- a/assets/css/gathercontent-importer.css +++ b/assets/css/gathercontent-importer.css @@ -6,408 +6,449 @@ * Licensed under the GPL-2.0+ license. */ .gc-avatar { - border-radius: 50px; - display: block; - float: left; - height: 50px; - margin-right: 10px; - vertical-align: middle; - width: 50px; + border-radius: 50px; + display: block; + float: left; + height: 50px; + margin-right: 10px; + vertical-align: middle; + width: 50px; } .gc-hello { - margin: 5px 0; + margin: 5px 0; } .gc-profile { - padding: 1em; - overflow: hidden; + padding: 1em; + overflow: hidden; } .platform-url-wrap { - position: relative; - display: inline-block; + position: relative; + display: inline-block; } .platform-url-help { - position: absolute; - top: 0; - right: 6px; - line-height: 2em; + position: absolute; + top: 0; + right: 6px; + line-height: 2em; } + .platform-url-help.gc-domain-prefix { - left: 6px; - right: 0; - width: 35px; + left: 6px; + right: 0; + width: 35px; } #platform_url_slug { - padding-right: 138px; - padding-left: 55px; + padding-right: 138px; + padding-left: 55px; } .gc-refresh-connection.button { - width: 2em; - font-size: 2em; - display: inline-block; - vertical-align: bottom; + width: 2em; + font-size: 2em; + display: inline-block; + vertical-align: bottom; } .form-table td .gc-submit-top { - margin-bottom: 0.5em; + margin-bottom: 0.5em; } .wp-core-ui p .gc-refresh-connection { - line-height: 1.3; - vertical-align: bottom; + line-height: 1.3; + vertical-align: bottom; } .description.gc-radio-desc { - margin-left: 1.5em; - margin-bottom: 1em; + margin-left: 1.5em; + margin-bottom: 1em; } .gc-reveal-items { - text-decoration: none; - position: relative; + text-decoration: none; + position: relative; } + .gc-reveal-items.description { - display: inline-block; - margin-bottom: 0.5em; + display: inline-block; + margin-bottom: 0.5em; } .gc-reveal-items:before { - display: block; - position: absolute; - right: -1em; - top: -0.1em; + display: block; + position: absolute; + right: -1em; + top: -0.1em; } ul.gc-radio-desc, ul.gc-reveal-items-list { - border-top: 1px solid #999; - margin-top: 0.5em; - padding-top: 1em; - list-style-type: disc; - margin-bottom: 1em; + border-top: 1px solid #999; + margin-top: 0.5em; + padding-top: 1em; + list-style-type: disc; + margin-bottom: 1em; } ul.gc-radio-desc li, ul.gc-reveal-items-list li { - margin-left: 2.8em; + margin-left: 2.8em; } .gc-nav-tab-wrapper { - border-bottom: 1px solid #ccc; + border-bottom: 1px solid #ccc; } .gc-template-tab { - padding: 1em 0; - /****** COMPONENT TABLE ******/ + padding: 1em 0; + /****** COMPONENT TABLE ******/ } + .gc-template-tab h4 { - margin-top: 0; + margin-top: 0; } + .gc-template-tab table thead > tr > th:first-child, .gc-template-tab table thead > tr > td:first-child, .gc-template-tab table tbody > tr > th:first-child, .gc-template-tab table tbody > tr > td:first-child { - width: 40%; + width: 40%; } + .gc-template-tab table thead > tr > th:last-child, .gc-template-tab table thead > tr > td:last-child, .gc-template-tab table tbody > tr > th:last-child, .gc-template-tab table tbody > tr > td:last-child { - width: 60%; + width: 60%; } + .gc-template-tab td { - border-bottom: 1px solid #ccc; - padding: 0.5em 1em; + border-bottom: 1px solid #ccc; + padding: 0.5em 1em; } + .gc-template-tab td:nth-child(2) { - vertical-align: top; + vertical-align: top; } + .gc-template-tab td option[value=wp-type-acf] { - display: none; + display: none; } + .gc-template-tab td.gc-component option[value=wp-type-acf], .gc-template-tab td.type-repeater option[value=wp-type-acf] { - display: block; + display: block; } + .gc-template-tab .component-td { - padding-left: 0; - padding-right: 0; - border: none; + padding-left: 0; + padding-right: 0; + border: none; } + .gc-template-tab .component-td-wrapper { - border-bottom: 1px solid #ccc; + border-bottom: 1px solid #ccc; } + .gc-template-tab .component-table-wrapper { - width: 100%; + width: 100%; } + .gc-template-tab .component-table-wrapper tbody > tr > td { - border: none; + border: none; } + .gc-template-tab .component-table-inner { - border-collapse: collapse; - width: 100%; + border-collapse: collapse; + width: 100%; } + .gc-template-tab .component-table-inner td { - border: none; + border: none; } + .gc-template-tab .component-table-inner td:first-child { - padding-left: 2.5em; + padding-left: 2.5em; } + .gc-template-tab .component-table-inner tr.text option[data-type=text], .gc-template-tab .component-table-inner tr.text option[data-type=textarea], .gc-template-tab .component-table-inner tr.text option[data-type=wysiwyg] { - display: block; + display: block; } + .gc-template-tab .component-table-inner tr.attachment option[data-type=gallery], .gc-template-tab .component-table-inner tr.attachment option[data-type=image] { - display: block; + display: block; } + .gc-template-tab .component-table-inner tr.choice_checkbox option[data-type=checkbox] { - display: block; + display: block; } + .gc-template-tab .component-table-inner tr.choice_radio option[data-type=radio] { - display: block; + display: block; } + .gc-template-tab .component-table-inner tr.repeater option[data-type=text], .gc-template-tab .component-table-inner tr.repeater option[data-type=textarea], .gc-template-tab .component-table-inner tr.repeater option[data-type=wysiwyg] { - display: none; + display: none; } + .gc-template-tab .component-table-inner tr.repeater option[data-type=repeater] { - display: block; + display: block; } + .gc-template-tab .ajax-disabled { - opacity: 0.75; - pointer-events: none; + opacity: 0.75; + pointer-events: none; } .gc-disabled label span, .gc-disabled .description { - opacity: 0.5; + opacity: 0.5; } .nav-tab.alignright { - float: right; + float: right; } .mapping-defaults .link-to-mapping-defaults { - display: none; + display: none; } .gathercontent-admin .form-table th { - font-weight: normal; - padding: 20px 1em; + font-weight: normal; + padding: 20px 1em; } + .gathercontent-admin.gc-sync .form-table th { - padding: 10px; + padding: 10px; } + .gathercontent-admin select, .gathercontent-admin .select2-container { - width: 250px; + width: 250px; } + .gathercontent-admin .wp-field-th { - width: 60%; + width: 60%; } + .gathercontent-admin .gc-field-th.gc-check-column { - width: 20px; - padding: 6px 0 6px 6px; - vertical-align: middle; + width: 20px; + padding: 6px 0 6px 6px; + vertical-align: middle; } .gc-enabled .gc-status-column { - cursor: pointer; + cursor: pointer; } .gc-disabled input[type=checkbox] { - cursor: default; + cursor: default; } .gathercontent-admin .select2-results__option, .gathercontent-admin-select2 .select2-results__option { - border-bottom: 1px solid #eee; - margin: 0; + border-bottom: 1px solid #eee; + margin: 0; } + .gathercontent-admin .select2-results__option .description, .gathercontent-admin-select2 .select2-results__option .description { - font-style: italic; - opacity: 0.7; - margin-top: 0.2em; + font-style: italic; + opacity: 0.7; + margin-top: 0.2em; } .gc-template-tab ul.gc-reveal-items-list li { - margin-left: 1.5em; - text-transform: capitalize; + margin-left: 1.5em; + text-transform: capitalize; } .gc-loader { - margin: 0 auto; - display: block; - float: none; + margin: 0 auto; + display: block; + float: none; } .gc-sync-items-descriptions .dashicons-randomize { - text-decoration: none; + text-decoration: none; } .gc-status-color { - width: 1.1em; - height: 1.1em; - display: inline-block; - border-radius: 100%; - line-height: 1.1em; - margin-bottom: -2px; - float: left; - margin-right: 5px; + width: 1.1em; + height: 1.1em; + display: inline-block; + border-radius: 100%; + line-height: 1.1em; + margin-bottom: -2px; + float: left; + margin-right: 5px; } + .gc-status-color.gc-status-color-white { - border: 1px solid #b1b1b1; + border: 1px solid #b1b1b1; } .select2-gc_status .gc-status-color, .select2-post_status_mapping_after .gc-status-color { - float: right; - margin-right: 0; + float: right; + margin-right: 0; } + .select2-gc_status.select2-container--default .gc-status-color, .select2-post_status_mapping_after.select2-container--default .gc-status-color { - position: relative; - top: 0.4em; + position: relative; + top: 0.4em; } .gc-logo-column { - overflow: hidden; - width: 21px; - height: 20px; - max-width: 100%; - display: inline-block; - vertical-align: top; - margin-right: 1px; + overflow: hidden; + width: 21px; + height: 20px; + max-width: 100%; + display: inline-block; + vertical-align: top; + margin-right: 1px; } + .gc-logo-column img { - width: 100px; - height: auto; + width: 100px; + height: auto; } .column-gathercontent .gc-status-color { - margin-top: 2px; + margin-top: 2px; } .inline-edit-gc-status .gc-status-select2 { - display: inline-block; + display: inline-block; } + .inline-edit-gc-status .gc-status-select2 .spinner { - visibility: visible; + visibility: visible; } .gc-button-primary, .wp-core-ui .button.gc-button-primary { - background-color: #fff; - border: 1px solid #00ABBD; - color: #00ABBD; - font-weight: bold; + background-color: #fff; + border: 1px solid #00ABBD; + color: #00ABBD; + font-weight: bold; } + .gc-button-primary:hover, .wp-core-ui .button.gc-button-primary:hover { - background-color: #00ABBD; - border: 1px solid #00ABBD; - color: #fff; + background-color: #00ABBD; + border: 1px solid #00ABBD; + color: #fff; } .gc-button-danger, .wp-core-ui .button.gc-button-danger { - background-color: #fff; - border: 1px solid #fc5c54; - color: #fc5c54; - font-weight: bold; + background-color: #fff; + border: 1px solid #fc5c54; + color: #fc5c54; + font-weight: bold; } + .gc-button-danger:hover, .wp-core-ui .button.gc-button-danger:hover { - background-color: #fc5c54; - border: 1px solid #fc5c54; - color: #fff; + background-color: #fc5c54; + border: 1px solid #fc5c54; + color: #fff; } .gc-auth-required .gc-section-auth table { - background-color: #f5bfbf; + background-color: #f5bfbf; } .gc-component-disabled { - pointer-events: none; - opacity: 0.5; + pointer-events: none; + opacity: 0.5; } #gc-items-search { - float: left; + float: left; } #sync-tabs .tablenav { - clear: none; + clear: none; } #sync-tabs { - margin-bottom: 1.5em; + margin-bottom: 1.5em; } + #sync-tabs .gc-check-column { - width: 20px; - padding: 6px 0 6px 6px; - vertical-align: middle; + width: 20px; + padding: 6px 0 6px 6px; + vertical-align: middle; } + #sync-tabs #gc-edit { - width: 20px; + width: 20px; } + #sync-tabs th:nth-child(5), #sync-tabs td:nth-child(5) { - display: none; + display: none; } .gc-sync-progress #progress { - padding: 0; - border: 1px solid #e5e5e5; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); + padding: 0; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); } + .gc-sync-progress table { - background: none; + background: none; } + .gc-sync-progress #gc-items-search { - display: none; + display: none; } .gc-progress-bar { - position: relative; + position: relative; } + .gc-progress-bar:before { - content: ""; - background: #dbf4f6; - height: 38px; - display: block; - width: 100%; + content: ""; + background: #dbf4f6; + height: 38px; + display: block; + width: 100%; } .gc-progress-bar-partial { - background: #0ab3c4; - height: 38px; - color: #fff; - text-align: center; - line-height: 38px; - font-weight: bold; - margin-top: -38px; - transition: width 400ms ease-in-out; + background: #0ab3c4; + height: 38px; + color: #fff; + text-align: center; + line-height: 38px; + font-weight: bold; + margin-top: -38px; + transition: width 400ms ease-in-out; } + .gc-progress-bar-partial span { - display: block; - min-width: 3.2em; + display: block; + min-width: 3.2em; } .gc-sync-table { - border-spacing: 0; - width: 100%; - clear: both; - margin: 0; + border-spacing: 0; + width: 100%; + clear: both; + margin: 0; } #gc-reload-spinner .gc-loader { - padding-left: 32px; - width: auto; - line-height: 1.5em; + padding-left: 32px; + width: auto; + line-height: 1.5em; } .gc-status-warning { - color: orange; - font-size: 10px; - display: none; + color: orange; + font-size: 10px; + display: none; } .gc-status-warning.not-current { - display: block; + display: block; } /* @@ -415,234 +456,249 @@ ul.gc-radio-desc li, ul.gc-reveal-items-list li { ~~ Thanks for building a beautiful Modal UI ( that I could steal ) */ .gc-modal-open { - overflow: hidden; + overflow: hidden; } + .gc-modal-open #gc-items-search { - display: block; - position: absolute; - top: 0; - left: 0; - z-index: 160001; + display: block; + position: absolute; + top: 0; + left: 0; + z-index: 160001; } + .gc-modal-open #gc-tablenav { - margin: 0 16px 0 0; + margin: 0 16px 0 0; } + .gc-modal-open #gc-items-search { - margin-left: 16px; + margin-left: 16px; } .gc-bb-modal { - position: fixed; - top: 30px; - left: 30px; - right: 30px; - bottom: 30px; - z-index: 160000; - font-family: sans-serif; - font-size: 14px; + position: fixed; + top: 30px; + left: 30px; + right: 30px; + bottom: 30px; + z-index: 160000; + font-family: sans-serif; + font-size: 14px; } .gc-bb-modal .gc-bb-modal-close { - position: absolute; - text-decoration: none; - top: 10px; - right: 10px; - width: 30px; - height: 30px; - z-index: 1000; - transition: color 0.1s ease-in-out, background 0.1s ease-in-out; - color: #444; + position: absolute; + text-decoration: none; + top: 10px; + right: 10px; + width: 30px; + height: 30px; + z-index: 1000; + transition: color 0.1s ease-in-out, background 0.1s ease-in-out; + color: #444; } .gc-bb-modal .gc-bb-modal-close:hover, .gc-bb-modal .gc-bb-modal-close:focus { - color: #2ea2cc; + color: #2ea2cc; } .gc-bb-modal .gc-bb-modal-content { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - overflow: hidden; - min-height: 300px; - background: #fff; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + overflow: hidden; + min-height: 300px; + background: #fff; } .gc-bb-modal-backdrop { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - min-height: 360px; - background: #000; - opacity: 0.7; - z-index: 159900; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + min-height: 360px; + background: #000; + opacity: 0.7; + z-index: 159900; } .gc-bb-modal-title h1 { - padding: 16px; - line-height: 0; + padding: 16px; + line-height: 0; } .gc-bb-modal-nav-tabs { - top: 74px; + top: 74px; } .gc-bb-modal-main { - top: 105px; - padding: 16px; + top: 105px; + padding: 16px; } + .gc-bb-modal-main.has-nav-tabs { - top: 108px; + top: 108px; } .text-right { - text-align: right; + text-align: right; } .ir { - background-color: transparent; - border: 0; - overflow: hidden; - /* IE 6/7 fallback */ - *text-indent: -9999px; + background-color: transparent; + border: 0; + overflow: hidden; + /* IE 6/7 fallback */ + *text-indent: -9999px; } .ir:before { - content: ""; - display: block; - width: 0; - height: 150%; + content: ""; + display: block; + width: 0; + height: 150%; } .gc-modal-tabs .hidden { - display: none; + display: none; } .gc-modal-tabs .gc-disabled td:not(.gc-item-wp-post-title) { - opacity: 0.4; + opacity: 0.4; } .gc-set-mapping .gc-cloak { - position: absolute; - top: 84px; - left: 200px; - right: 0; - bottom: 0; - height: auto; - width: auto; - background: #fff; - opacity: 0.5; - z-index: 101; + position: absolute; + top: 84px; + left: 200px; + right: 0; + bottom: 0; + height: auto; + width: auto; + background: #fff; + opacity: 0.5; + z-index: 101; } + .gc-set-mapping .gc-mapping-metabox { - position: absolute; - right: 16px; - bottom: 41px; - width: 270px; - z-index: 102; + position: absolute; + right: 16px; + bottom: 41px; + width: 270px; + z-index: 102; } + .gc-set-mapping .gc-mapping-metabox select { - width: 250px; + width: 250px; } #poststuff #gc-manage .inside { - margin: 0; - padding: 0; + margin: 0; + padding: 0; } .gc-major-publishing-actions { - padding: 10px; - clear: both; - border-top: 1px solid #ddd; - background: #f5f5f5; + padding: 10px; + clear: both; + border-top: 1px solid #ddd; + background: #f5f5f5; } .gc-publishing-action { - text-align: right; - float: right; - line-height: 23px; + text-align: right; + float: right; + line-height: 23px; } + .gc-publishing-action button.button, .gc-publishing-action .button { - margin-left: 0.5em; + margin-left: 0.5em; } #gc-manage .dashicons { - color: #82878c; + color: #82878c; } #gc-status-selec2 { - padding: 5px 0; + padding: 5px 0; } #gc-related-data { - overflow: hidden; + overflow: hidden; } + #gc-related-data.no-js, #gc-related-data.gc-mapping-metabox:not(.gc-mapping-started) { - text-align: center; + text-align: center; } + #gc-related-data .spinner { - float: none; - margin: 0.2em; + float: none; + margin: 0.2em; } + #gc-related-data > p { - text-align: center; + text-align: center; } .misc-pub-post-status .gc-status-color { - display: block; - margin-top: 2px; - margin-left: 4px; + display: block; + margin-top: 2px; + margin-left: 4px; } + .misc-pub-post-status .gc-status-name { - font-weight: 600; + font-weight: 600; } .gc-status-status.current { - color: #49ab00; + color: #49ab00; } + .gc-status-status.not-current { - color: #c12c2f; + color: #c12c2f; } .gc-no-mapping .spinner { - display: none; + display: none; } + .gc-no-mapping .spinner.is-active { - display: inline-block; + display: inline-block; } + .gc-no-mapping .gc-publishing-action { - text-align: center; - float: none; + text-align: center; + float: none; } + .gc-no-mapping .gc-publishing-action button.button, .gc-no-mapping .gc-publishing-action .button { - margin-left: 0; + margin-left: 0; } .gc-mapping-started label { - margin-bottom: 0.2em; - display: block; + margin-bottom: 0.2em; + display: block; } .gc-metabox-status { - display: inline-block; - position: relative; + display: inline-block; + position: relative; } /** * System Info */ #system-info-textarea { - background: none; - font-family: Menlo, Monaco, monospace; - display: block; - overflow: auto; - white-space: pre; - width: 800px; - height: 400px; - min-height: 400px; - margin-bottom: 1.5em; -} \ No newline at end of file + background: none; + font-family: Menlo, Monaco, monospace; + display: block; + overflow: auto; + white-space: pre; + width: 800px; + height: 400px; + min-height: 400px; + margin-bottom: 1.5em; +} diff --git a/assets/css/sass/_modal.scss b/assets/css/sass/_modal.scss index c0dfe851..1aa7b1e6 100644 --- a/assets/css/sass/_modal.scss +++ b/assets/css/sass/_modal.scss @@ -33,6 +33,7 @@ font-family: sans-serif; font-size: 14px; } + .gc-bb-modal .gc-bb-modal-close { position: absolute; text-decoration: none; @@ -42,11 +43,12 @@ height: 30px; z-index: 1000; transition: color .1s ease-in-out, background .1s ease-in-out; - color: #444 ; + color: #444; } -.gc-bb-modal .gc-bb-modal-close:hover , + +.gc-bb-modal .gc-bb-modal-close:hover, .gc-bb-modal .gc-bb-modal-close:focus { - color: #2ea2cc ; + color: #2ea2cc; } .gc-bb-modal .gc-bb-modal-content { @@ -59,6 +61,7 @@ min-height: 300px; background: #fff; } + .gc-bb-modal-backdrop { position: fixed; top: 0; @@ -70,16 +73,20 @@ opacity: .7; z-index: 159900; } + .gc-bb-modal-title h1 { padding: 16px; line-height: 0; } + .gc-bb-modal-nav-tabs { top: 74px; } + .gc-bb-modal-main { top: 105px; padding: 16px; + &.has-nav-tabs { top: 108px; } @@ -88,6 +95,7 @@ .text-right { text-align: right; } + .ir { background-color: transparent; border: 0; @@ -126,12 +134,14 @@ opacity: .5; z-index: 101; } + .gc-mapping-metabox { position: absolute; right: 16px; bottom: 41px; width: 270px; z-index: 102; + select { width: 250px; } diff --git a/assets/css/sass/_single.scss b/assets/css/sass/_single.scss index 90975ae4..c17edf94 100644 --- a/assets/css/sass/_single.scss +++ b/assets/css/sass/_single.scss @@ -2,6 +2,7 @@ margin: 0; padding: 0; } + .gc-major-publishing-actions { padding: 10px; // margin: 10px -12px -12px; @@ -14,10 +15,12 @@ text-align: right; float: right; line-height: 23px; + button.button, .button { margin-left: .5em; } } + #gc-manage { .dashicons { color: #82878c; @@ -30,13 +33,16 @@ #gc-related-data { overflow: hidden; + &.no-js, &.gc-mapping-metabox:not( .gc-mapping-started ) { text-align: center; } + .spinner { float: none; margin: .2em; } + > p { text-align: center; } @@ -48,6 +54,7 @@ margin-top: 2px; margin-left: 4px; } + .gc-status-name { font-weight: 600; } @@ -57,6 +64,7 @@ &.current { color: $greendk; } + &.not-current { color: $reddk; } @@ -65,24 +73,29 @@ .gc-no-mapping { .spinner { display: none; + &.is-active { display: inline-block; } } + .gc-publishing-action { text-align: center; float: none; + button.button, .button { margin-left: 0; } } } + .gc-mapping-started { label { margin-bottom: .2em; display: block; } } + .gc-metabox-status { display: inline-block; position: relative; diff --git a/assets/css/sass/_sync.scss b/assets/css/sass/_sync.scss index ee51d69c..60a645f3 100644 --- a/assets/css/sass/_sync.scss +++ b/assets/css/sass/_sync.scss @@ -8,14 +8,17 @@ #sync-tabs { margin-bottom: 1.5em; + .gc-check-column { width: 20px; padding: 6px 0 6px 6px; vertical-align: middle; } + #gc-edit { width: 20px; } + // For now, until we can have more than one mapping on this page. th:nth-child( 5 ), td:nth-child( 5 ) { display: none; @@ -26,9 +29,10 @@ #progress { padding: 0; border: 1px solid #e5e5e5; - -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04); - box-shadow: 0 1px 1px rgba(0,0,0,0.04); + -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); } + table { background: none; } @@ -40,6 +44,7 @@ .gc-progress-bar { position: relative; + &:before { content: ''; background: #dbf4f6; @@ -61,6 +66,7 @@ -moz-transition: width 400ms ease-in-out; -o-transition: width 400ms ease-in-out; transition: width 400ms ease-in-out; + span { display: block; min-width: 3.2em; @@ -90,4 +96,4 @@ .gc-status-warning.not-current { display: block; -} \ No newline at end of file +} diff --git a/assets/css/sass/gathercontent-importer.scss b/assets/css/sass/gathercontent-importer.scss index b79da791..0d4950aa 100644 --- a/assets/css/sass/gathercontent-importer.scss +++ b/assets/css/sass/gathercontent-importer.scss @@ -45,6 +45,7 @@ $reddk: #c12c2f; top: 0; right: 6px; line-height: 2em; + &.gc-domain-prefix { left: 6px; right: 0; @@ -81,6 +82,7 @@ $reddk: #c12c2f; .gc-reveal-items { text-decoration: none; position: relative; + &.description { display: inline-block; margin-bottom: .5em; @@ -118,17 +120,18 @@ ul.gc-radio-desc li, ul.gc-reveal-items-list li { margin-top: 0; } - table{ + table { thead, - tbody{ - & > tr{ + tbody { + & > tr { & > th, - & > td{ - &:first-child{ - width:40%; + & > td { + &:first-child { + width: 40%; } - &:last-child{ - width:60%; + + &:last-child { + width: 60%; } } } @@ -138,83 +141,103 @@ ul.gc-radio-desc li, ul.gc-reveal-items-list li { td { border-bottom: 1px solid #ccc; padding: .5em 1em; + &:nth-child(2) { vertical-align: top; } + // &:last-child { // text-align: right; // } - option[value="wp-type-acf"]{ - display:none; + option[value="wp-type-acf"] { + display: none; } + &.gc-component, - &.type-repeater{ - option[value="wp-type-acf"]{ - display:block; + &.type-repeater { + option[value="wp-type-acf"] { + display: block; } } } /****** COMPONENT TABLE ******/ - .component-td{ - padding-left:0; - padding-right:0; - border:none; + .component-td { + padding-left: 0; + padding-right: 0; + border: none; } - .component-td-wrapper{ + + .component-td-wrapper { border-bottom: 1px solid #ccc; } - .component-table-wrapper{ - width:100%; - tbody > tr > td{ - border:none; + + .component-table-wrapper { + width: 100%; + + tbody > tr > td { + border: none; } } - .component-table-inner{ - border-collapse:collapse; - width:100%; - td{ - border:none; - &:first-child{ - padding-left:2.5em; + + .component-table-inner { + border-collapse: collapse; + width: 100%; + + td { + border: none; + + &:first-child { + padding-left: 2.5em; } } - tr{ + tr { // Show / Hide ACF field types - &.text{ + &.text { option[data-type="text"], option[data-type="textarea"], - option[data-type="wysiwyg"]{ - display:block; + option[data-type="wysiwyg"] { + display: block; } } - &.attachment{ + + &.attachment { option[data-type="gallery"], - option[data-type="image"]{ - display:block; + option[data-type="image"] { + display: block; } } - &.choice_checkbox{ - option[data-type="checkbox"]{ display:block; } + + &.choice_checkbox { + option[data-type="checkbox"] { + display: block; + } } - &.choice_radio{ - option[data-type="radio"]{ display:block; } + + &.choice_radio { + option[data-type="radio"] { + display: block; + } } - &.repeater{ + + &.repeater { option[data-type="text"], option[data-type="textarea"], - option[data-type="wysiwyg"]{ - display:none; + option[data-type="wysiwyg"] { + display: none; + } + + option[data-type="repeater"] { + display: block; } - option[data-type="repeater"]{ display:block; } } } } - .ajax-disabled{ - opacity:0.75; - pointer-events:none; + .ajax-disabled { + opacity: 0.75; + pointer-events: none; } } @@ -274,6 +297,7 @@ ul.gc-radio-desc li, ul.gc-reveal-items-list li { .select2-results__option { border-bottom: 1px solid #eee; margin: 0; + .description { font-style: italic; opacity: .7; @@ -285,12 +309,11 @@ ul.gc-radio-desc li, ul.gc-reveal-items-list li { .gc-template-tab { ul.gc-reveal-items-list li { margin-left: 1.5em; - text-transform:capitalize; + text-transform: capitalize; } } - .gc-loader { margin: 0 auto; display: block; @@ -310,15 +333,18 @@ ul.gc-radio-desc li, ul.gc-reveal-items-list li { margin-bottom: -2px; float: left; margin-right: 5px; + &.gc-status-color-white { border: 1px solid #b1b1b1; } } + .select2-gc_status, .select2-post_status_mapping_after { .gc-status-color { float: right; margin-right: 0; } + &.select2-container--default { .gc-status-color { position: relative; @@ -335,6 +361,7 @@ ul.gc-radio-desc li, ul.gc-reveal-items-list li { display: inline-block; vertical-align: top; margin-right: 1px; + img { width: 100px; height: auto; @@ -349,42 +376,46 @@ ul.gc-radio-desc li, ul.gc-reveal-items-list li { .inline-edit-gc-status .gc-status-select2 { display: inline-block; + .spinner { visibility: visible; } } .gc-button-primary { - background-color: #fff; - border: 1px solid $gcblue; - color: $gcblue; - font-weight: bold; - &:hover { - background-color: $gcblue; + background-color: #fff; border: 1px solid $gcblue; - color: #fff; - } + color: $gcblue; + font-weight: bold; + + &:hover { + background-color: $gcblue; + border: 1px solid $gcblue; + color: #fff; + } } .gc-button-danger { - background-color: #fff; - border: 1px solid $gcred; - color: $gcred; - font-weight: bold; - &:hover { - background-color: $gcred; + background-color: #fff; border: 1px solid $gcred; - color: #fff; - } + color: $gcred; + font-weight: bold; + + &:hover { + background-color: $gcred; + border: 1px solid $gcred; + color: #fff; + } } .wp-core-ui .button { - &.gc-button-primary { - @extend .gc-button-primary; - } - &.gc-button-danger { - @extend .gc-button-danger; - } + &.gc-button-primary { + @extend .gc-button-primary; + } + + &.gc-button-danger { + @extend .gc-button-danger; + } } .gc-auth-required .gc-section-auth table { diff --git a/assets/css/vendor/select2-4.0.13/select2.css b/assets/css/vendor/select2-4.0.13/select2.css index 750b3207..bd57172e 100644 --- a/assets/css/vendor/select2-4.0.13/select2.css +++ b/assets/css/vendor/select2-4.0.13/select2.css @@ -1,481 +1,628 @@ .select2-container { - box-sizing: border-box; - display: inline-block; - margin: 0; - position: relative; - vertical-align: middle; } - .select2-container .select2-selection--single { - box-sizing: border-box; - cursor: pointer; - display: block; - height: 28px; - user-select: none; - -webkit-user-select: none; } - .select2-container .select2-selection--single .select2-selection__rendered { - display: block; - padding-left: 8px; - padding-right: 20px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; } - .select2-container .select2-selection--single .select2-selection__clear { - position: relative; } - .select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered { - padding-right: 8px; - padding-left: 20px; } - .select2-container .select2-selection--multiple { - box-sizing: border-box; - cursor: pointer; - display: block; - min-height: 32px; - user-select: none; - -webkit-user-select: none; } - .select2-container .select2-selection--multiple .select2-selection__rendered { - display: inline-block; - overflow: hidden; - padding-left: 8px; - text-overflow: ellipsis; - white-space: nowrap; } - .select2-container .select2-search--inline { - float: left; } - .select2-container .select2-search--inline .select2-search__field { - box-sizing: border-box; - border: none; - font-size: 100%; - margin-top: 5px; - padding: 0; } - .select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button { - -webkit-appearance: none; } + box-sizing: border-box; + display: inline-block; + margin: 0; + position: relative; + vertical-align: middle; +} + +.select2-container .select2-selection--single { + box-sizing: border-box; + cursor: pointer; + display: block; + height: 28px; + user-select: none; + -webkit-user-select: none; +} + +.select2-container .select2-selection--single .select2-selection__rendered { + display: block; + padding-left: 8px; + padding-right: 20px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.select2-container .select2-selection--single .select2-selection__clear { + position: relative; +} + +.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered { + padding-right: 8px; + padding-left: 20px; +} + +.select2-container .select2-selection--multiple { + box-sizing: border-box; + cursor: pointer; + display: block; + min-height: 32px; + user-select: none; + -webkit-user-select: none; +} + +.select2-container .select2-selection--multiple .select2-selection__rendered { + display: inline-block; + overflow: hidden; + padding-left: 8px; + text-overflow: ellipsis; + white-space: nowrap; +} + +.select2-container .select2-search--inline { + float: left; +} + +.select2-container .select2-search--inline .select2-search__field { + box-sizing: border-box; + border: none; + font-size: 100%; + margin-top: 5px; + padding: 0; +} + +.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button { + -webkit-appearance: none; +} .select2-dropdown { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - box-sizing: border-box; - display: block; - position: absolute; - left: -100000px; - width: 100%; - z-index: 1051; } + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + box-sizing: border-box; + display: block; + position: absolute; + left: -100000px; + width: 100%; + z-index: 1051; +} .select2-results { - display: block; } + display: block; +} .select2-results__options { - list-style: none; - margin: 0; - padding: 0; } + list-style: none; + margin: 0; + padding: 0; +} .select2-results__option { - padding: 6px; - user-select: none; - -webkit-user-select: none; } - .select2-results__option[aria-selected] { - cursor: pointer; } + padding: 6px; + user-select: none; + -webkit-user-select: none; +} + +.select2-results__option[aria-selected] { + cursor: pointer; +} .select2-container--open .select2-dropdown { - left: 0; } + left: 0; +} .select2-container--open .select2-dropdown--above { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} .select2-container--open .select2-dropdown--below { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; } + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; +} .select2-search--dropdown { - display: block; - padding: 4px; } - .select2-search--dropdown .select2-search__field { - padding: 4px; - width: 100%; - box-sizing: border-box; } - .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button { - -webkit-appearance: none; } - .select2-search--dropdown.select2-search--hide { - display: none; } + display: block; + padding: 4px; +} + +.select2-search--dropdown .select2-search__field { + padding: 4px; + width: 100%; + box-sizing: border-box; +} + +.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +.select2-search--dropdown.select2-search--hide { + display: none; +} .select2-close-mask { - border: 0; - margin: 0; - padding: 0; - display: block; - position: fixed; - left: 0; - top: 0; - min-height: 100%; - min-width: 100%; - height: auto; - width: auto; - opacity: 0; - z-index: 99; - background-color: #fff; - filter: alpha(opacity=0); } + border: 0; + margin: 0; + padding: 0; + display: block; + position: fixed; + left: 0; + top: 0; + min-height: 100%; + min-width: 100%; + height: auto; + width: auto; + opacity: 0; + z-index: 99; + background-color: #fff; + filter: alpha(opacity=0); +} .select2-hidden-accessible { - border: 0 !important; - clip: rect(0 0 0 0) !important; - -webkit-clip-path: inset(50%) !important; - clip-path: inset(50%) !important; - height: 1px !important; - overflow: hidden !important; - padding: 0 !important; - position: absolute !important; - width: 1px !important; - white-space: nowrap !important; } + border: 0 !important; + clip: rect(0 0 0 0) !important; + -webkit-clip-path: inset(50%) !important; + clip-path: inset(50%) !important; + height: 1px !important; + overflow: hidden !important; + padding: 0 !important; + position: absolute !important; + width: 1px !important; + white-space: nowrap !important; +} .select2-container--default .select2-selection--single { - background-color: #fff; - border: 1px solid #aaa; - border-radius: 4px; } - .select2-container--default .select2-selection--single .select2-selection__rendered { - color: #444; - line-height: 28px; } - .select2-container--default .select2-selection--single .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; } - .select2-container--default .select2-selection--single .select2-selection__placeholder { - color: #999; } - .select2-container--default .select2-selection--single .select2-selection__arrow { - height: 26px; - position: absolute; - top: 1px; - right: 1px; - width: 20px; } - .select2-container--default .select2-selection--single .select2-selection__arrow b { - border-color: #888 transparent transparent transparent; - border-style: solid; - border-width: 5px 4px 0 4px; - height: 0; - left: 50%; - margin-left: -4px; - margin-top: -2px; - position: absolute; - top: 50%; - width: 0; } + background-color: #fff; + border: 1px solid #aaa; + border-radius: 4px; +} + +.select2-container--default .select2-selection--single .select2-selection__rendered { + color: #444; + line-height: 28px; +} + +.select2-container--default .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; +} + +.select2-container--default .select2-selection--single .select2-selection__placeholder { + color: #999; +} + +.select2-container--default .select2-selection--single .select2-selection__arrow { + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; +} + +.select2-container--default .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; +} .select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear { - float: left; } + float: left; +} .select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow { - left: 1px; - right: auto; } + left: 1px; + right: auto; +} .select2-container--default.select2-container--disabled .select2-selection--single { - background-color: #eee; - cursor: default; } - .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear { - display: none; } + background-color: #eee; + cursor: default; +} + +.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear { + display: none; +} .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { - border-color: transparent transparent #888 transparent; - border-width: 0 4px 5px 4px; } + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; +} .select2-container--default .select2-selection--multiple { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - cursor: text; } - .select2-container--default .select2-selection--multiple .select2-selection__rendered { - box-sizing: border-box; - list-style: none; - margin: 0; - padding: 0 5px; - width: 100%; } - .select2-container--default .select2-selection--multiple .select2-selection__rendered li { - list-style: none; } - .select2-container--default .select2-selection--multiple .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; - margin-top: 5px; - margin-right: 10px; - padding: 1px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice { - background-color: #e4e4e4; - border: 1px solid #aaa; - border-radius: 4px; - cursor: default; - float: left; - margin-right: 5px; - margin-top: 5px; - padding: 0 5px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { - color: #999; - cursor: pointer; - display: inline-block; - font-weight: bold; - margin-right: 2px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { - color: #333; } + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + cursor: text; +} + +.select2-container--default .select2-selection--multiple .select2-selection__rendered { + box-sizing: border-box; + list-style: none; + margin: 0; + padding: 0 5px; + width: 100%; +} + +.select2-container--default .select2-selection--multiple .select2-selection__rendered li { + list-style: none; +} + +.select2-container--default .select2-selection--multiple .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin-top: 5px; + margin-right: 10px; + padding: 1px; +} + +.select2-container--default .select2-selection--multiple .select2-selection__choice { + background-color: #e4e4e4; + border: 1px solid #aaa; + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; +} + +.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { + color: #999; + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; +} + +.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { + color: #333; +} .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline { - float: right; } + float: right; +} .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice { - margin-left: 5px; - margin-right: auto; } + margin-left: 5px; + margin-right: auto; +} .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { - margin-left: 2px; - margin-right: auto; } + margin-left: 2px; + margin-right: auto; +} .select2-container--default.select2-container--focus .select2-selection--multiple { - border: solid black 1px; - outline: 0; } + border: solid black 1px; + outline: 0; +} .select2-container--default.select2-container--disabled .select2-selection--multiple { - background-color: #eee; - cursor: default; } + background-color: #eee; + cursor: default; +} .select2-container--default.select2-container--disabled .select2-selection__choice__remove { - display: none; } + display: none; +} .select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple { - border-top-left-radius: 0; - border-top-right-radius: 0; } + border-top-left-radius: 0; + border-top-right-radius: 0; +} .select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple { - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} .select2-container--default .select2-search--dropdown .select2-search__field { - border: 1px solid #aaa; } + border: 1px solid #aaa; +} .select2-container--default .select2-search--inline .select2-search__field { - background: transparent; - border: none; - outline: 0; - box-shadow: none; - -webkit-appearance: textfield; } + background: transparent; + border: none; + outline: 0; + box-shadow: none; + -webkit-appearance: textfield; +} .select2-container--default .select2-results > .select2-results__options { - max-height: 200px; - overflow-y: auto; } + max-height: 200px; + overflow-y: auto; +} .select2-container--default .select2-results__option[role=group] { - padding: 0; } + padding: 0; +} .select2-container--default .select2-results__option[aria-disabled=true] { - color: #999; } + color: #999; +} .select2-container--default .select2-results__option[aria-selected=true] { - background-color: #ddd; } + background-color: #ddd; +} .select2-container--default .select2-results__option .select2-results__option { - padding-left: 1em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__group { - padding-left: 0; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option { - margin-left: -1em; - padding-left: 2em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -2em; - padding-left: 3em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -3em; - padding-left: 4em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -4em; - padding-left: 5em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -5em; - padding-left: 6em; } + padding-left: 1em; +} + +.select2-container--default .select2-results__option .select2-results__option .select2-results__group { + padding-left: 0; +} + +.select2-container--default .select2-results__option .select2-results__option .select2-results__option { + margin-left: -1em; + padding-left: 2em; +} + +.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -2em; + padding-left: 3em; +} + +.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -3em; + padding-left: 4em; +} + +.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -4em; + padding-left: 5em; +} + +.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -5em; + padding-left: 6em; +} .select2-container--default .select2-results__option--highlighted[aria-selected] { - background-color: #5897fb; - color: white; } + background-color: #5897fb; + color: white; +} .select2-container--default .select2-results__group { - cursor: default; - display: block; - padding: 6px; } + cursor: default; + display: block; + padding: 6px; +} .select2-container--classic .select2-selection--single { - background-color: #f7f7f7; - border: 1px solid #aaa; - border-radius: 4px; - outline: 0; - background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%); - background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%); - background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } - .select2-container--classic .select2-selection--single:focus { - border: 1px solid #5897fb; } - .select2-container--classic .select2-selection--single .select2-selection__rendered { - color: #444; - line-height: 28px; } - .select2-container--classic .select2-selection--single .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; - margin-right: 10px; } - .select2-container--classic .select2-selection--single .select2-selection__placeholder { - color: #999; } - .select2-container--classic .select2-selection--single .select2-selection__arrow { - background-color: #ddd; - border: none; - border-left: 1px solid #aaa; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; - height: 26px; - position: absolute; - top: 1px; - right: 1px; - width: 20px; - background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%); - background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%); - background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); } - .select2-container--classic .select2-selection--single .select2-selection__arrow b { - border-color: #888 transparent transparent transparent; - border-style: solid; - border-width: 5px 4px 0 4px; - height: 0; - left: 50%; - margin-left: -4px; - margin-top: -2px; - position: absolute; - top: 50%; - width: 0; } + background-color: #f7f7f7; + border: 1px solid #aaa; + border-radius: 4px; + outline: 0; + background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%); + background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%); + background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); +} + +.select2-container--classic .select2-selection--single:focus { + border: 1px solid #5897fb; +} + +.select2-container--classic .select2-selection--single .select2-selection__rendered { + color: #444; + line-height: 28px; +} + +.select2-container--classic .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin-right: 10px; +} + +.select2-container--classic .select2-selection--single .select2-selection__placeholder { + color: #999; +} + +.select2-container--classic .select2-selection--single .select2-selection__arrow { + background-color: #ddd; + border: none; + border-left: 1px solid #aaa; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; + background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%); + background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%); + background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); +} + +.select2-container--classic .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; +} .select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear { - float: left; } + float: left; +} .select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow { - border: none; - border-right: 1px solid #aaa; - border-radius: 0; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; - left: 1px; - right: auto; } + border: none; + border-right: 1px solid #aaa; + border-radius: 0; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + left: 1px; + right: auto; +} .select2-container--classic.select2-container--open .select2-selection--single { - border: 1px solid #5897fb; } - .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow { - background: transparent; - border: none; } - .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b { - border-color: transparent transparent #888 transparent; - border-width: 0 4px 5px 4px; } + border: 1px solid #5897fb; +} + +.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow { + background: transparent; + border: none; +} + +.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b { + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; +} .select2-container--classic.select2-container--open.select2-container--above .select2-selection--single { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; - background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%); - background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%); - background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; + background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%); + background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%); + background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); +} .select2-container--classic.select2-container--open.select2-container--below .select2-selection--single { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; - background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%); - background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%); - background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); } + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%); + background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%); + background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); +} .select2-container--classic .select2-selection--multiple { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - cursor: text; - outline: 0; } - .select2-container--classic .select2-selection--multiple:focus { - border: 1px solid #5897fb; } - .select2-container--classic .select2-selection--multiple .select2-selection__rendered { - list-style: none; - margin: 0; - padding: 0 5px; } - .select2-container--classic .select2-selection--multiple .select2-selection__clear { - display: none; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice { - background-color: #e4e4e4; - border: 1px solid #aaa; - border-radius: 4px; - cursor: default; - float: left; - margin-right: 5px; - margin-top: 5px; - padding: 0 5px; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove { - color: #888; - cursor: pointer; - display: inline-block; - font-weight: bold; - margin-right: 2px; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover { - color: #555; } + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + cursor: text; + outline: 0; +} + +.select2-container--classic .select2-selection--multiple:focus { + border: 1px solid #5897fb; +} + +.select2-container--classic .select2-selection--multiple .select2-selection__rendered { + list-style: none; + margin: 0; + padding: 0 5px; +} + +.select2-container--classic .select2-selection--multiple .select2-selection__clear { + display: none; +} + +.select2-container--classic .select2-selection--multiple .select2-selection__choice { + background-color: #e4e4e4; + border: 1px solid #aaa; + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; +} + +.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove { + color: #888; + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; +} + +.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover { + color: #555; +} .select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice { - float: right; - margin-left: 5px; - margin-right: auto; } + float: right; + margin-left: 5px; + margin-right: auto; +} .select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { - margin-left: 2px; - margin-right: auto; } + margin-left: 2px; + margin-right: auto; +} .select2-container--classic.select2-container--open .select2-selection--multiple { - border: 1px solid #5897fb; } + border: 1px solid #5897fb; +} .select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; } + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; +} .select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} .select2-container--classic .select2-search--dropdown .select2-search__field { - border: 1px solid #aaa; - outline: 0; } + border: 1px solid #aaa; + outline: 0; +} .select2-container--classic .select2-search--inline .select2-search__field { - outline: 0; - box-shadow: none; } + outline: 0; + box-shadow: none; +} .select2-container--classic .select2-dropdown { - background-color: white; - border: 1px solid transparent; } + background-color: white; + border: 1px solid transparent; +} .select2-container--classic .select2-dropdown--above { - border-bottom: none; } + border-bottom: none; +} .select2-container--classic .select2-dropdown--below { - border-top: none; } + border-top: none; +} .select2-container--classic .select2-results > .select2-results__options { - max-height: 200px; - overflow-y: auto; } + max-height: 200px; + overflow-y: auto; +} .select2-container--classic .select2-results__option[role=group] { - padding: 0; } + padding: 0; +} .select2-container--classic .select2-results__option[aria-disabled=true] { - color: grey; } + color: grey; +} .select2-container--classic .select2-results__option--highlighted[aria-selected] { - background-color: #3875d7; - color: white; } + background-color: #3875d7; + color: white; +} .select2-container--classic .select2-results__group { - cursor: default; - display: block; - padding: 6px; } + cursor: default; + display: block; + padding: 6px; +} .select2-container--classic.select2-container--open .select2-dropdown { - border-color: #5897fb; } + border-color: #5897fb; +} diff --git a/assets/js/gathercontent-general.js b/assets/js/gathercontent-general.js index 20b62abb..c7a29076 100644 --- a/assets/js/gathercontent-general.js +++ b/assets/js/gathercontent-general.js @@ -1,1747 +1,1808 @@ /** * Content Workflow (by Bynder) - v1.0.0 - 2024-06-05 - * + * * * Copyright (c) 2024 Content Workflow (by Bynder) * Licensed under the GPLv2 license. */ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0; - this.allChecked = this.totalChecked >= models.length; - this.sortKey = sortKey; - this.sortDirection = sortDirection; - this.sort(); - }, - - checkChecked: function checkChecked(model) { - if (model.changed.checked) { - this.totalChecked++; - } else { - if (this.totalChecked === this.length) { - this.allChecked = false; - } - this.totalChecked--; + var l = n[o] = {exports: {}}; + t[o][0].call(l.exports, function (e) { + var n = t[o][1][e]; + return s(n ? n : e) + }, l, l.exports, e, t, n, r) + } + return n[o].exports + } + + var i = typeof require == "function" && require; + for (var o = 0; o < r.length; o++) s(r[o]); + return s +})({ + 1: [function (require, module, exports) { + 'use strict'; + + module.exports = Backbone.Collection.extend({ + getById: function getById(id) { + return this.find(function (model) { + var modelId = model.get('id'); + return modelId === id || modelId && id && modelId == id; + }); } + }); - this.checkAllStatus(); - }, + }, {}], + 2: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + var sortKey = null; + var sortDirection = 'asc'; + var Collection = app.collections.base.extend({ + model: app.models.item, + totalChecked: 0, + allChecked: false, + syncEnabled: false, + processing: false, + sortKey: sortKey, + sortDirection: sortDirection, + + initialize: function initialize(models, options) { + this.listenTo(this, 'checkAll', this.toggleChecked); + this.listenTo(this, 'checkSome', this.toggleCheckedIf); + this.listenTo(this, 'change:checked', this.checkChecked); + this.listenTo(this, 'sortByColumn', this.sortByColumn); + + this.totalChecked = this.checked().length; + + if (options && options.reinit) { + this.reinit(models); + } + }, + + reinit: function reinit(models) { + this.totalChecked = this.checked(models).length; + this.syncEnabled = this.totalChecked > 0; + this.allChecked = this.totalChecked >= models.length; + this.sortKey = sortKey; + this.sortDirection = sortDirection; + this.sort(); + }, + + checkChecked: function checkChecked(model) { + if (model.changed.checked) { + this.totalChecked++; + } else { + if (this.totalChecked === this.length) { + this.allChecked = false; + } + this.totalChecked--; + } - checkAllStatus: function checkAllStatus(checked) { - var syncWasEnabled = this.syncEnabled; - this.syncEnabled = this.totalChecked > 0; + this.checkAllStatus(); + }, - if (syncWasEnabled !== this.syncEnabled) { - this.trigger('enabledChange', this.syncEnabled); - } + checkAllStatus: function checkAllStatus(checked) { + var syncWasEnabled = this.syncEnabled; + this.syncEnabled = this.totalChecked > 0; - if (this.totalChecked < this.length) { - this.trigger('notAllChecked', false); - } - }, + if (syncWasEnabled !== this.syncEnabled) { + this.trigger('enabledChange', this.syncEnabled); + } - toggleCheckedIf: function toggleCheckedIf(checked) { - this.processing = true; + if (this.totalChecked < this.length) { + this.trigger('notAllChecked', false); + } + }, - this.stopListening(this, 'change:checked', this.checkChecked); - this.each(function (model) { - model.set('checked', Boolean('function' === typeof checked ? checked(model) : checked)); - }); - this.listenTo(this, 'change:checked', this.checkChecked); + toggleCheckedIf: function toggleCheckedIf(checked) { + this.processing = true; - this.totalChecked = this.checked().length; - this.allChecked = this.totalChecked >= this.length; - this.checkAllStatus(); + this.stopListening(this, 'change:checked', this.checkChecked); + this.each(function (model) { + model.set('checked', Boolean('function' === typeof checked ? checked(model) : checked)); + }); + this.listenTo(this, 'change:checked', this.checkChecked); - this.processing = false; + this.totalChecked = this.checked().length; + this.allChecked = this.totalChecked >= this.length; + this.checkAllStatus(); - this.trigger('render'); - }, + this.processing = false; - toggleChecked: function toggleChecked(checked) { - this.allChecked = checked; - this.toggleCheckedIf(checked); - }, + this.trigger('render'); + }, - checked: function checked(models) { - models = models || this; - return models.filter(function (model) { - return model.get('checked'); - }); - }, + toggleChecked: function toggleChecked(checked) { + this.allChecked = checked; + this.toggleCheckedIf(checked); + }, - comparator: function comparator(a, b) { - if (!this.sortKey) { - return; - } + checked: function checked(models) { + models = models || this; + return models.filter(function (model) { + return model.get('checked'); + }); + }, - var dataA = a.get(this.sortKey); - var dataB = b.get(this.sortKey); + comparator: function comparator(a, b) { + if (!this.sortKey) { + return; + } - if ('updated_at' === this.sortKey) { - dataA = dataA.date || dataA; - dataB = dataB.date || dataB; - } + var dataA = a.get(this.sortKey); + var dataB = b.get(this.sortKey); - if ('status' === this.sortKey) { - dataA = dataA.name || dataA; - dataB = dataB.name || dataB; - } + if ('updated_at' === this.sortKey) { + dataA = dataA.date || dataA; + dataB = dataB.date || dataB; + } - if ('asc' === this.sortDirection) { - if (dataA > dataB) { - return -1; - } - if (dataB > dataA) { - return 1; - } - return 0; - } else { + if ('status' === this.sortKey) { + dataA = dataA.name || dataA; + dataB = dataB.name || dataB; + } - if (dataA < dataB) { - return -1; - } - if (dataB < dataA) { - return 1; - } + if ('asc' === this.sortDirection) { + if (dataA > dataB) { + return -1; + } + if (dataB > dataA) { + return 1; + } + return 0; + } else { + + if (dataA < dataB) { + return -1; + } + if (dataB < dataA) { + return 1; + } + + return 0; + } + }, - return 0; - } - }, + sortByColumn: function sortByColumn(column, direction) { + this.sortKey = sortKey = column; + this.sortDirection = sortDirection = direction; + this.sort(); + } - sortByColumn: function sortByColumn(column, direction) { - this.sortKey = sortKey = column; - this.sortDirection = sortDirection = direction; - this.sort(); - } + }); - }); + return require('./../collections/search-extension.js')(Collection); + }; - return require('./../collections/search-extension.js')(Collection); -}; + }, {"./../collections/search-extension.js": 5}], + 3: [function (require, module, exports) { + 'use strict'; -},{"./../collections/search-extension.js":5}],3:[function(require,module,exports){ -'use strict'; + module.exports = function (app) { + return app.collections.base.extend({ + model: app.models.navItem, -module.exports = function (app) { - return app.collections.base.extend({ - model: app.models.navItem, + initialize: function initialize() { + this.listenTo(this, 'activate', this.activate); + }, - initialize: function initialize() { - this.listenTo(this, 'activate', this.activate); - }, + getActive: function getActive() { + return this.find(function (model) { + return !model.get('hidden'); + }); + }, - getActive: function getActive() { - return this.find(function (model) { - return !model.get('hidden'); + activate: function activate(id) { + this.each(function (model) { + model.set('hidden', true); + }); + this.getById(id).set('hidden', false); + this.trigger('render'); + } }); - }, + }; - activate: function activate(id) { - this.each(function (model) { - model.set('hidden', true); - }); - this.getById(id).set('hidden', false); - this.trigger('render'); - } - }); -}; + }, {}], + 4: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + var items = require('./../collections/items.js')(app); + + return require('./../collections/search-extension.js')(items.extend({ + model: app.models.post, + + initialize: function initialize(models, options) { + items.prototype.initialize.call(this, models, options); + + this.listenTo(this, 'updateItems', this.updateItems); + }, + + updateItems: function updateItems(data) { + this.each(function (model) { + var id = model.get('id'); + if (id in data) { + if (data[id].status) { + model.set('status', data[id].status); + } + if (data[id].itemName) { + model.set('itemName', data[id].itemName); + } + if (data[id].updated_at) { + model.set('updated_at', data[id].updated_at); + } + } + }); + }, + + checkedCan: function checkedCan(pushOrPull) { + switch (pushOrPull) { + case 'pull': + pushOrPull = 'canPull'; + break; + case 'assign': + pushOrPull = 'disabled'; + break; + // case 'push': + default: + pushOrPull = 'canPush'; + break; + } -},{}],4:[function(require,module,exports){ -'use strict'; + var can = this.find(function (model) { + return model.get(pushOrPull) && model.get('checked'); + }); -module.exports = function (app) { - var items = require('./../collections/items.js')(app); + return can; + } - return require('./../collections/search-extension.js')(items.extend({ - model: app.models.post, + })); + }; - initialize: function initialize(models, options) { - items.prototype.initialize.call(this, models, options); + }, {"./../collections/items.js": 2, "./../collections/search-extension.js": 5}], + 5: [function (require, module, exports) { + 'use strict'; - this.listenTo(this, 'updateItems', this.updateItems); - }, + module.exports = function (Collection) { - updateItems: function updateItems(data) { - this.each(function (model) { - var id = model.get('id'); - if (id in data) { - if (data[id].status) { - model.set('status', data[id].status); - } - if (data[id].itemName) { - model.set('itemName', data[id].itemName); - } - if (data[id].updated_at) { - model.set('updated_at', data[id].updated_at); - } - } - }); - }, - - checkedCan: function checkedCan(pushOrPull) { - switch (pushOrPull) { - case 'pull': - pushOrPull = 'canPull'; - break; - case 'assign': - pushOrPull = 'disabled'; - break; - // case 'push': - default: - pushOrPull = 'canPush'; - break; - } + _.extend(Collection.prototype, { - var can = this.find(function (model) { - return model.get(pushOrPull) && model.get('checked'); - }); + //_Cache + _searchResults: null, - return can; - } + //@ Search wrapper function + search: function search(keyword, attributes) { + var results = this._doSearch(keyword, attributes); + + this.trigger('search', results); - })); -}; + // For use of returning un-async + return results; + }, -},{"./../collections/items.js":2,"./../collections/search-extension.js":5}],5:[function(require,module,exports){ -'use strict'; + //@ Search function + _doSearch: function _doSearch(keyword, attributes) { + attributes = attributes && attributes.length ? attributes : false; -module.exports = function (Collection) { + // If collection empty get out + if (!this.models.length) { + return []; + } - _.extend(Collection.prototype, { + // Filter + var matcher = this.matcher; + var results = !keyword ? this.models : this.filter(function (model) { + attributes = attributes ? attributes : model.searchAttributes || _.keys(model.attributes); + return _.some(attributes, function (attribute) { + return matcher(keyword, model.get(attribute)); + }); + }); - //_Cache - _searchResults: null, + this.trigger('searchResults', results); - //@ Search wrapper function - search: function search(keyword, attributes) { - var results = this._doSearch(keyword, attributes); + // Instantiate new Collection + var collection = new Collection(results, {reinit: true}); - this.trigger('search', results); + collection.searching = { + keyword: keyword, + attributes: attributes + }; - // For use of returning un-async - return results; - }, + collection.getSearchQuery = function () { + return this.searching; + }; - //@ Search function - _doSearch: function _doSearch(keyword, attributes) { - attributes = attributes && attributes.length ? attributes : false; + // Cache the recently searched metadata + this._searchResults = collection; - // If collection empty get out - if (!this.models.length) { - return []; - } + this.trigger('search', collection); + + // For use of returning un-async + return collection; + }, + + //@ Default Matcher - may be overwritten + matcher: function matcher(needle, haystack) { + if (!needle || !haystack) { + return; + } + needle = needle.toString().toLowerCase(); + haystack = haystack.toString().toLowerCase(); + return haystack.indexOf(needle) >= 0; + }, + + //@ Get recent search value + getSearchValue: function getSearchValue() { + return this.getSearchQuery().keyword; + }, + + //@ Get recent search query + getSearchQuery: function getSearchQuery() { + return this._searchResults && this._searchResults.getSearchQuery() || {}; + }, + + //@ Get recent search results + getSearchResults: function getSearchResults() { + return this._searchResults; + }, + + current: function current() { + return this._searchResults || this; + } - // Filter - var matcher = this.matcher; - var results = !keyword ? this.models : this.filter(function (model) { - attributes = attributes ? attributes : model.searchAttributes || _.keys(model.attributes); - return _.some(attributes, function (attribute) { - return matcher(keyword, model.get(attribute)); - }); }); - this.trigger('searchResults', results); + return Collection; + }; - // Instantiate new Collection - var collection = new Collection(results, { reinit: true }); + }, {}], + 6: [function (require, module, exports) { + 'use strict'; - collection.searching = { - keyword: keyword, - attributes: attributes - }; + window.GatherContent = window.GatherContent || {}; - collection.getSearchQuery = function () { - return this.searching; - }; + (function (window, document, $, gc, undefined) { + 'use strict'; - // Cache the recently searched metadata - this._searchResults = collection; + gc.general = gc.general || {}; + var app = gc.general; - this.trigger('search', collection); + // Initiate base objects. + require('./initiate-objects.js')(app); - // For use of returning un-async - return collection; - }, + /* + * Posts + */ - //@ Default Matcher - may be overwritten - matcher: function matcher(needle, haystack) { - if (!needle || !haystack) { - return; - } - needle = needle.toString().toLowerCase(); - haystack = haystack.toString().toLowerCase(); - return haystack.indexOf(needle) >= 0; - }, - - //@ Get recent search value - getSearchValue: function getSearchValue() { - return this.getSearchQuery().keyword; - }, - - //@ Get recent search query - getSearchQuery: function getSearchQuery() { - return this._searchResults && this._searchResults.getSearchQuery() || {}; - }, - - //@ Get recent search results - getSearchResults: function getSearchResults() { - return this._searchResults; - }, - - current: function current() { - return this._searchResults || this; - } + app.models.post = require('./models/post.js')(gc); + app.collections.posts = require('./collections/posts.js')(app); + app.views.postRow = require('./views/post-row.js')(app, gc); + app.views.statusSelect2 = require('./views/status-select2.js')(app); + app.views.postRows = require('./views/post-rows.js')(app, gc, $); - }); + /* + * Nav Items + */ + app.models.navItem = require('./models/modal-nav-item.js')(app); + app.collections.navItems = require('./collections/modal-nav-items.js')(app); - return Collection; -}; + app.views.tableBase = require('./views/table-base.js')(app, $, gc); + app.views.modalPostRow = require('./views/modal-post-row.js')(app, gc); + app.views.modal = require('./views/modal.js')(app, gc, $); -},{}],6:[function(require,module,exports){ -'use strict'; + app.monkeyPatchQuickEdit = function (cb) { + // we create a copy of the WP inline edit post function + var edit = window.inlineEditPost.edit; -window.GatherContent = window.GatherContent || {}; + // and then we overwrite the function with our own code + window.inlineEditPost.edit = function () { + // "call" the original WP edit function + // we don't want to leave WordPress hanging + edit.apply(this, arguments); -(function (window, document, $, gc, undefined) { - 'use strict'; + // now we take care of our business + cb.apply(this, arguments); + }; + }; - gc.general = gc.general || {}; - var app = gc.general; + app.triggerModal = function (evt) { + evt.preventDefault(); - // Initiate base objects. - require('./initiate-objects.js')(app); + var posts = app.getChecked(); + if (!posts.length) { + return; + } - /* - * Posts - */ + if (app.modalView === undefined) { + app.modalView = new app.views.modal({ + collection: app.generalView.collection + }); + app.modalView.checked(posts); + app.generalView.listenTo(app.modalView, 'updateModels', app.generalView.updatePosts); + } + }; - app.models.post = require('./models/post.js')(gc); - app.collections.posts = require('./collections/posts.js')(app); - app.views.postRow = require('./views/post-row.js')(app, gc); - app.views.statusSelect2 = require('./views/status-select2.js')(app); - app.views.postRows = require('./views/post-rows.js')(app, gc, $); + app.getChecked = function () { + return $('tbody th.check-column input[type="checkbox"]:checked').map(function () { + return parseInt($(this).val(), 10); + }).get(); + }; - /* - * Nav Items - */ - app.models.navItem = require('./models/modal-nav-item.js')(app); - app.collections.navItems = require('./collections/modal-nav-items.js')(app); + app.init = function () { + $(document.body).addClass('gathercontent-admin-select2').on('click', '#gc-sync-modal', app.triggerModal); - app.views.tableBase = require('./views/table-base.js')(app, $, gc); - app.views.modalPostRow = require('./views/modal-post-row.js')(app, gc); - app.views.modal = require('./views/modal.js')(app, gc, $); + $(document).ajaxSend(function (evt, request, settings) { + if (settings.data && -1 !== settings.data.indexOf('&action=inline-save')) { + app.generalView.trigger('quickEditSend', request, settings); + } + }); - app.monkeyPatchQuickEdit = function (cb) { - // we create a copy of the WP inline edit post function - var edit = window.inlineEditPost.edit; + app.generalView = new app.views.postRows({ + collection: new app.collections.posts(gc._posts) + }); - // and then we overwrite the function with our own code - window.inlineEditPost.edit = function () { - // "call" the original WP edit function - // we don't want to leave WordPress hanging - edit.apply(this, arguments); + app.monkeyPatchQuickEdit(function () { + app.generalView.trigger('quickEdit', arguments, this); + }); + }; - // now we take care of our business - cb.apply(this, arguments); + $(app.init); + })(window, document, jQuery, window.GatherContent); + + }, { + "./collections/modal-nav-items.js": 3, + "./collections/posts.js": 4, + "./initiate-objects.js": 7, + "./models/modal-nav-item.js": 10, + "./models/post.js": 12, + "./views/modal-post-row.js": 18, + "./views/modal.js": 19, + "./views/post-row.js": 20, + "./views/post-rows.js": 21, + "./views/status-select2.js": 22, + "./views/table-base.js": 23 + }], + 7: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + app.models = {base: require('./models/base.js')}; + app.collections = {base: require('./collections/base.js')}; + app.views = {base: require('./views/base.js')}; }; - }; - app.triggerModal = function (evt) { - evt.preventDefault(); + }, {"./collections/base.js": 1, "./models/base.js": 9, "./views/base.js": 13}], + 8: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, defaults) { + defaults = jQuery.extend({}, { + action: 'gc_sync_items', + data: '', + percent: 0, + nonce: '', + id: '', + stopSync: true, + flush_cache: false + }, defaults); + + return app.models.base.extend({ + defaults: defaults, + + initialize: function initialize() { + this.listenTo(this, 'send', this.send); + }, + + reset: function reset() { + this.clear().set(this.defaults); + return this; + }, + + send: function send(formData, cb, percent, failcb) { + if (percent) { + this.set('percent', percent); + } - var posts = app.getChecked(); - if (!posts.length) { - return; - } + jQuery.post(window.ajaxurl, { + action: this.get('action'), + percent: this.get('percent'), + nonce: this.get('nonce'), + id: this.get('id'), + data: formData, + flush_cache: this.get('flush_cache') + }, (function (response) { + this.trigger('response', response, formData); + + if (response.success) { + return cb(response); + } + + if (failcb) { + return failcb(response); + } + }).bind(this)); + + return this; + } - if (app.modalView === undefined) { - app.modalView = new app.views.modal({ - collection: app.generalView.collection }); - app.modalView.checked(posts); - app.generalView.listenTo(app.modalView, 'updateModels', app.generalView.updatePosts); - } - }; - - app.getChecked = function () { - return $('tbody th.check-column input[type="checkbox"]:checked').map(function () { - return parseInt($(this).val(), 10); - }).get(); - }; + }; - app.init = function () { - $(document.body).addClass('gathercontent-admin-select2').on('click', '#gc-sync-modal', app.triggerModal); + }, {}], + 9: [function (require, module, exports) { + "use strict"; - $(document).ajaxSend(function (evt, request, settings) { - if (settings.data && -1 !== settings.data.indexOf('&action=inline-save')) { - app.generalView.trigger('quickEditSend', request, settings); + module.exports = Backbone.Model.extend({ + sync: function sync() { + return false; } }); - app.generalView = new app.views.postRows({ - collection: new app.collections.posts(gc._posts) - }); + }, {}], + 10: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + return app.models.base.extend({ + defaults: { + label: '', + id: '', + hidden: true, + rendered: false + } + }); + }; - app.monkeyPatchQuickEdit(function () { - app.generalView.trigger('quickEdit', arguments, this); - }); - }; - - $(app.init); -})(window, document, jQuery, window.GatherContent); - -},{"./collections/modal-nav-items.js":3,"./collections/posts.js":4,"./initiate-objects.js":7,"./models/modal-nav-item.js":10,"./models/post.js":12,"./views/modal-post-row.js":18,"./views/modal.js":19,"./views/post-row.js":20,"./views/post-rows.js":21,"./views/status-select2.js":22,"./views/table-base.js":23}],7:[function(require,module,exports){ -'use strict'; - -module.exports = function (app) { - app.models = { base: require('./models/base.js') }; - app.collections = { base: require('./collections/base.js') }; - app.views = { base: require('./views/base.js') }; -}; - -},{"./collections/base.js":1,"./models/base.js":9,"./views/base.js":13}],8:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, defaults) { - defaults = jQuery.extend({}, { - action: 'gc_sync_items', - data: '', - percent: 0, - nonce: '', - id: '', - stopSync: true, - flush_cache: false - }, defaults); - - return app.models.base.extend({ - defaults: defaults, - - initialize: function initialize() { - this.listenTo(this, 'send', this.send); - }, - - reset: function reset() { - this.clear().set(this.defaults); - return this; - }, - - send: function send(formData, cb, percent, failcb) { - if (percent) { - this.set('percent', percent); - } + }, {}], + 11: [function (require, module, exports) { + 'use strict'; - jQuery.post(window.ajaxurl, { - action: this.get('action'), - percent: this.get('percent'), - nonce: this.get('nonce'), - id: this.get('id'), - data: formData, - flush_cache: this.get('flush_cache') - }, (function (response) { - this.trigger('response', response, formData); - - if (response.success) { - return cb(response); - } + module.exports = function (model) { - if (failcb) { - return failcb(response); + model.prototype._get = function (value, attribute) { + if (this['_get_' + attribute]) { + value = this['_get_' + attribute](value); } - }).bind(this)); + return value; + }; - return this; - } + model.prototype.get = function (attribute) { + return this._get(Backbone.Model.prototype.get.call(this, attribute), attribute); + }; - }); -}; + // hijack the toJSON method and overwrite the data that is sent back to the view. + model.prototype.toJSON = function () { + return _.mapObject(Backbone.Model.prototype.toJSON.call(this), _.bind(this._get, this)); + }; -},{}],9:[function(require,module,exports){ -"use strict"; + return model; + }; -module.exports = Backbone.Model.extend({ - sync: function sync() { - return false; - } -}); - -},{}],10:[function(require,module,exports){ -'use strict'; - -module.exports = function (app) { - return app.models.base.extend({ - defaults: { - label: '', - id: '', - hidden: true, - rendered: false - } - }); -}; + }, {}], + 12: [function (require, module, exports) { + 'use strict'; + + module.exports = function (gc) { + return require('./../models/modify-json.js')(Backbone.Model.extend({ + defaults: { + id: 0, + item: 0, + itemName: '', + updated_at: '', + current: true, + editLink: '', + mapping: 0, + mappingName: '', + mappingLink: '', + mappingStatus: '', + mappingStatusId: '', + status: {}, + checked: false, + disabled: false, + canPull: false, + canPush: false, + statuses: [], + statusesChecked: false, + ptLabel: false + }, + + searchAttributes: ['itemName', 'mappingName', 'post_title'], + + url: function url() { + var url = window.ajaxurl + '?action=gc_fetch_js_post&id=' + this.get('id'); + if (this.get('uncached')) { + this.set('uncached', false); + url += '&flush_cache=force'; + } + return url; + }, -},{}],11:[function(require,module,exports){ -'use strict'; + _get_disabled: function _get_disabled(value) { + return !this.get('mapping'); + }, -module.exports = function (model) { + _get_canPull: function _get_canPull(value) { + return this.get('item') > 0 && this.get('mapping') > 0; + }, - model.prototype._get = function (value, attribute) { - if (this['_get_' + attribute]) { - value = this['_get_' + attribute](value); - } - return value; - }; - - model.prototype.get = function (attribute) { - return this._get(Backbone.Model.prototype.get.call(this, attribute), attribute); - }; - - // hijack the toJSON method and overwrite the data that is sent back to the view. - model.prototype.toJSON = function () { - return _.mapObject(Backbone.Model.prototype.toJSON.call(this), _.bind(this._get, this)); - }; - - return model; -}; - -},{}],12:[function(require,module,exports){ -'use strict'; - -module.exports = function (gc) { - return require('./../models/modify-json.js')(Backbone.Model.extend({ - defaults: { - id: 0, - item: 0, - itemName: '', - updated_at: '', - current: true, - editLink: '', - mapping: 0, - mappingName: '', - mappingLink: '', - mappingStatus: '', - mappingStatusId: '', - status: {}, - checked: false, - disabled: false, - canPull: false, - canPush: false, - statuses: [], - statusesChecked: false, - ptLabel: false - }, - - searchAttributes: ['itemName', 'mappingName', 'post_title'], - - url: function url() { - var url = window.ajaxurl + '?action=gc_fetch_js_post&id=' + this.get('id'); - if (this.get('uncached')) { - this.set('uncached', false); - url += '&flush_cache=force'; - } - return url; - }, + _get_canPush: function _get_canPush(value) { + return this.get('mapping') > 0; + }, - _get_disabled: function _get_disabled(value) { - return !this.get('mapping'); - }, + _get_mappingLink: function _get_mappingLink(value) { + if ('failed' === Backbone.Model.prototype.get.call(this, 'mappingStatus')) { + value += '&sync-items=1'; + } + return value; + }, - _get_canPull: function _get_canPull(value) { - return this.get('item') > 0 && this.get('mapping') > 0; - }, + _get_mappingStatus: function _get_mappingStatus(value) { + return gc._statuses[value] ? gc._statuses[value] : ''; + }, - _get_canPush: function _get_canPush(value) { - return this.get('mapping') > 0; - }, + _get_mappingStatusId: function _get_mappingStatusId(value) { + return Backbone.Model.prototype.get.call(this, 'mappingStatus'); + } + })); + }; - _get_mappingLink: function _get_mappingLink(value) { - if ('failed' === Backbone.Model.prototype.get.call(this, 'mappingStatus')) { - value += '&sync-items=1'; - } - return value; - }, + }, {"./../models/modify-json.js": 11}], + 13: [function (require, module, exports) { + 'use strict'; - _get_mappingStatus: function _get_mappingStatus(value) { - return gc._statuses[value] ? gc._statuses[value] : ''; - }, + module.exports = Backbone.View.extend({ + toggleExpanded: function toggleExpanded(evt) { + this.model.set('expanded', !this.model.get('expanded')); + }, - _get_mappingStatusId: function _get_mappingStatusId(value) { - return Backbone.Model.prototype.get.call(this, 'mappingStatus'); - } - })); -}; + getRenderedModels: function getRenderedModels(View, models) { + models = models || this.collection; + var addedElements = document.createDocumentFragment(); -},{"./../models/modify-json.js":11}],13:[function(require,module,exports){ -'use strict'; + models.each(function (model) { + var view = new View({model: model}).render(); + addedElements.appendChild(view.el); + }); -module.exports = Backbone.View.extend({ - toggleExpanded: function toggleExpanded(evt) { - this.model.set('expanded', !this.model.get('expanded')); - }, + return addedElements; + }, - getRenderedModels: function getRenderedModels(View, models) { - models = models || this.collection; - var addedElements = document.createDocumentFragment(); + render: function render() { + this.$el.html(this.template(this.model.toJSON())); + return this; + }, - models.each(function (model) { - var view = new View({ model: model }).render(); - addedElements.appendChild(view.el); + close: function close() { + this.remove(); + this.unbind(); + if (this.onClose) { + this.onClose(); + } + } }); - return addedElements; - }, - - render: function render() { - this.$el.html(this.template(this.model.toJSON())); - return this; - }, + }, {}], + 14: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + return app.views.base.extend({ + template: wp.template('gc-item'), + tagName: 'tr', + className: 'gc-item gc-enabled', + id: function id() { + return this.model.get('id'); + }, + + events: { + 'change .gc-check-column input': 'toggleCheck', + 'click .gc-reveal-items': 'toggleExpanded', + 'click .gc-status-column': 'toggleCheckAndRender' + }, + + initialize: function initialize() { + this.listenTo(this.model, 'change:checked', this.render); + }, + + toggleCheck: function toggleCheck() { + this.model.set('checked', !this.model.get('checked')); + }, + + toggleCheckAndRender: function toggleCheckAndRender(evt) { + this.toggleCheck(); + this.render(); + } + }); + }; - close: function close() { - this.remove(); - this.unbind(); - if (this.onClose) { - this.onClose(); - } - } -}); - -},{}],14:[function(require,module,exports){ -'use strict'; - -module.exports = function (app) { - return app.views.base.extend({ - template: wp.template('gc-item'), - tagName: 'tr', - className: 'gc-item gc-enabled', - id: function id() { - return this.model.get('id'); - }, - - events: { - 'change .gc-check-column input': 'toggleCheck', - 'click .gc-reveal-items': 'toggleExpanded', - 'click .gc-status-column': 'toggleCheckAndRender' - }, - - initialize: function initialize() { - this.listenTo(this.model, 'change:checked', this.render); - }, - - toggleCheck: function toggleCheck() { - this.model.set('checked', !this.model.get('checked')); - }, - - toggleCheckAndRender: function toggleCheckAndRender(evt) { - this.toggleCheck(); - this.render(); - } - }); -}; - -},{}],15:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, $, gc) { - var thisView; - var base = require('./../views/metabox-base.js')(app, $, gc); - return base.extend({ - template: wp.template('gc-mapping-metabox'), - stepArgs: false, - events: { - 'click #gc-map': 'step', - 'change #select-gc-next-step': 'setProperty', - 'click #gc-map-cancel': 'cancel' - }, - - initialize: function initialize() { - thisView = this; - this.listenTo(this.model, 'change:waiting', this.toggleWaitingRender); - this.listenTo(this.model, 'change', this.maybeEnableAndRender); - this.listenTo(this.model, 'change:step', this.changeStep); - this.listenTo(this, 'cancel', this.resetAndRender); - this.render(); - this.$el.removeClass('no-js').addClass('gc-mapping-metabox'); - }, - - changeStep: function changeStep(model) { - if ('accounts' === model.changed.step) { - this.$el.addClass('gc-mapping-started'); - } + }, {}], + 15: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + var thisView; + var base = require('./../views/metabox-base.js')(app, $, gc); + return base.extend({ + template: wp.template('gc-mapping-metabox'), + stepArgs: false, + events: { + 'click #gc-map': 'step', + 'change #select-gc-next-step': 'setProperty', + 'click #gc-map-cancel': 'cancel' + }, + + initialize: function initialize() { + thisView = this; + this.listenTo(this.model, 'change:waiting', this.toggleWaitingRender); + this.listenTo(this.model, 'change', this.maybeEnableAndRender); + this.listenTo(this.model, 'change:step', this.changeStep); + this.listenTo(this, 'cancel', this.resetAndRender); + this.render(); + this.$el.removeClass('no-js').addClass('gc-mapping-metabox'); + }, + + changeStep: function changeStep(model) { + if ('accounts' === model.changed.step) { + this.$el.addClass('gc-mapping-started'); + } - if (model.changed.step) { - this.stepArgs = this['step_' + model.changed.step](); - } - }, + if (model.changed.step) { + this.stepArgs = this['step_' + model.changed.step](); + } + }, - setProperty: function setProperty(evt) { - var value = $(evt.target).val(); + setProperty: function setProperty(evt) { + var value = $(evt.target).val(); - this.model.set(this.stepArgs.property, value); + this.model.set(this.stepArgs.property, value); - if ('account' === this.stepArgs.property || 'project' === this.stepArgs.property) { - // Autoclick "next" for user. - this.step(); - } - }, + if ('account' === this.stepArgs.property || 'project' === this.stepArgs.property) { + // Autoclick "next" for user. + this.step(); + } + }, - setMapping: function setMapping() { - var success = function success(data) { - this.model.set('waiting', false); + setMapping: function setMapping() { + var success = function success(data) { + this.model.set('waiting', false); - // Goodbye - this.trigger('complete', this.model, data); - }; + // Goodbye + this.trigger('complete', this.model, data); + }; - this.ajax({ - action: 'gc_save_mapping_id' - }, success, this.failMsg); - }, + this.ajax({ + action: 'gc_save_mapping_id' + }, success, this.failMsg); + }, - maybeEnableAndRender: function maybeEnableAndRender(model) { - if (model.changed.account || model.changed.project || model.changed.mapping) { - this.model.set('btnDisabled', false); - this.render(); - } - }, + maybeEnableAndRender: function maybeEnableAndRender(model) { + if (model.changed.account || model.changed.project || model.changed.mapping) { + this.model.set('btnDisabled', false); + this.render(); + } + }, - toggleWaitingRender: function toggleWaitingRender(model) { - if (model.changed.waiting) { - this.model.set('btnDisabled', true); - } - this.render(); - }, + toggleWaitingRender: function toggleWaitingRender(model) { + if (model.changed.waiting) { + this.model.set('btnDisabled', true); + } + this.render(); + }, - step: function step() { - this.model.set('waiting', true); + step: function step() { + this.model.set('waiting', true); - if ('mapping' === this.stepArgs.property) { - return this.setMapping(); - } + if ('mapping' === this.stepArgs.property) { + return this.setMapping(); + } - this.setStep(); + this.setStep(); - var properties = this.model.get(this.stepArgs.properties); + var properties = this.model.get(this.stepArgs.properties); - if (properties && properties.length) { + if (properties && properties.length) { - this.successHandler(properties); - } else { + this.successHandler(properties); + } else { - this.ajax({ - action: 'gc_wp_filter_mappings', - property: this.stepArgs.property - }, this.successHandler, this.failMsg); - } + this.ajax({ + action: 'gc_wp_filter_mappings', + property: this.stepArgs.property + }, this.successHandler, this.failMsg); + } - return this; - }, + return this; + }, - failMsg: function failMsg(msg) { - msg = 'string' === typeof msg ? msg : gc._errors.unknown; - window.alert(msg); - thisView.model.set('waiting', false); - }, + failMsg: function failMsg(msg) { + msg = 'string' === typeof msg ? msg : gc._errors.unknown; + window.alert(msg); + thisView.model.set('waiting', false); + }, - successHandler: function successHandler(objects) { - this.model.set(this.stepArgs.properties, objects); - if (objects.length < 2) { - this.model.set('btnDisabled', false); - } - this.model.set('waiting', false); - }, + successHandler: function successHandler(objects) { + this.model.set(this.stepArgs.properties, objects); + if (objects.length < 2) { + this.model.set('btnDisabled', false); + } + this.model.set('waiting', false); + }, - setStep: function setStep() { - if (!this.model.get('step')) { - return this.model.set('step', 'accounts'); - } + setStep: function setStep() { + if (!this.model.get('step')) { + return this.model.set('step', 'accounts'); + } - if ('accounts' === this.model.get('step')) { - return this.model.set('step', 'projects'); - } + if ('accounts' === this.model.get('step')) { + return this.model.set('step', 'projects'); + } - if ('projects' === this.model.get('step')) { - return this.model.set('step', 'mappings'); - } - }, + if ('projects' === this.model.get('step')) { + return this.model.set('step', 'mappings'); + } + }, + + step_accounts: function step_accounts() { + return { + property: 'account', + properties: 'accounts' + }; + }, + + step_projects: function step_projects() { + return { + property: 'project', + properties: 'projects' + }; + }, + + step_mappings: function step_mappings() { + return { + property: 'mapping', + properties: 'mappings' + }; + }, + + cancel: function cancel(evt) { + this.trigger('cancel', evt); + }, + + resetModel: function resetModel() { + this.stepArgs = false; + this.model.set({ + 'step': false, + 'account': 0, + 'project': 0, + 'mapping': 0 + }); + return this.model; + }, + + resetAndRender: function resetAndRender() { + this.resetModel(); + this.render(); + }, + + render: function render() { + var json = this.model.toJSON(); + if (this.stepArgs) { + json.label = gc._step_labels[json.step]; + json.property = this.stepArgs.property; + } + this.$el.html(this.template(json)); + return this; + } - step_accounts: function step_accounts() { - return { - property: 'account', - properties: 'accounts' - }; - }, + }); + }; - step_projects: function step_projects() { - return { - property: 'project', - properties: 'projects' - }; - }, + }, {"./../views/metabox-base.js": 16}], + 16: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + return app.views.base.extend({ + el: '#gc-related-data', + + ajax: function ajax(args, successcb, failcb) { + var view = this; + var success = function success(response) { + if (response.success) { + successcb.call(view, response.data); + } else if (failcb) { + failcb.call(view, response.data); + } + }; + + var promise = $.post(window.ajaxurl, $.extend({ + action: '', + post: this.model.toJSON(), + nonce: gc.$id('gc-edit-nonce').val(), + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, args), success); + + if (failcb) { + promise.fail(function () { + failcb.call(view); + }); + } - step_mappings: function step_mappings() { - return { - property: 'mapping', - properties: 'mappings' - }; - }, - - cancel: function cancel(evt) { - this.trigger('cancel', evt); - }, - - resetModel: function resetModel() { - this.stepArgs = false; - this.model.set({ - 'step': false, - 'account': 0, - 'project': 0, - 'mapping': 0 + return promise; + } }); - return this.model; - }, - - resetAndRender: function resetAndRender() { - this.resetModel(); - this.render(); - }, - - render: function render() { - var json = this.model.toJSON(); - if (this.stepArgs) { - json.label = gc._step_labels[json.step]; - json.property = this.stepArgs.property; - } - this.$el.html(this.template(json)); - return this; - } + }; - }); -}; + }, {}], + 17: [function (require, module, exports) { + 'use strict'; -},{"./../views/metabox-base.js":16}],16:[function(require,module,exports){ -'use strict'; + module.exports = function (app, $, gc) { + var base = require('./../views/mapping-metabox.js')(app, $, gc); -module.exports = function (app, $, gc) { - return app.views.base.extend({ - el: '#gc-related-data', + var model = new Backbone.Model({ + id: true, + cancelBtn: true, + accounts: [], + projects: [], + mappings: [] + }); - ajax: function ajax(args, successcb, failcb) { - var view = this; - var success = function success(response) { - if (response.success) { - successcb.call(view, response.data); - } else if (failcb) { - failcb.call(view, response.data); + var View = base.extend({ + close: function close() { + model = this.resetModel(); + base.prototype.close.call(this); } - }; + }); - var promise = $.post(window.ajaxurl, $.extend({ - action: '', - post: this.model.toJSON(), - nonce: gc.$id('gc-edit-nonce').val(), - flush_cache: gc.queryargs.flush_cache ? 1 : 0 - }, args), success); + return function (postIds) { + model.set('ids', postIds); - if (failcb) { - promise.fail(function () { - failcb.call(view); + var view = new View({ + model: model }); - } - return promise; - } - }); -}; - -},{}],17:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, $, gc) { - var base = require('./../views/mapping-metabox.js')(app, $, gc); - - var model = new Backbone.Model({ - id: true, - cancelBtn: true, - accounts: [], - projects: [], - mappings: [] - }); - - var View = base.extend({ - close: function close() { - model = this.resetModel(); - base.prototype.close.call(this); - } - }); - - return function (postIds) { - model.set('ids', postIds); + view.$el.addClass('postbox'); - var view = new View({ - model: model - }); + return view.step(); + }; + }; - view.$el.addClass('postbox'); - - return view.step(); - }; -}; - -},{"./../views/mapping-metabox.js":15}],18:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, gc) { - var item = require('./../views/item.js')(app); - return item.extend({ - template: wp.template('gc-item'), - - id: function id() { - return 'gc-modal-post-' + this.model.get('id'); - }, - - className: function className() { - return 'gc-item ' + (this.model.get('disabled') ? 'gc-disabled' : 'gc-enabled'); - }, - - events: { - 'change .gc-check-column input': 'toggleCheck', - 'click .gc-status-column': 'toggleCheckAndRender' - }, - - initialize: function initialize() { - this.listenTo(this.model, 'change:post_title', this.renderTitle); - this.listenTo(this.model, 'change:mappingStatus', this.render); - this.listenTo(this.model, 'render', this.render); - }, - - renderTitle: function renderTitle() { - var title = this.model.get('post_title'); - var id = this.model.get('id'); - gc.$id('post-' + id).find('.column-title .row-title').text(title); - gc.$id('edit-' + id).find('[name="post_title"]').text(title); - gc.$id('inline_' + id).find('.post_title').text(title); - } + }, {"./../views/mapping-metabox.js": 15}], + 18: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, gc) { + var item = require('./../views/item.js')(app); + return item.extend({ + template: wp.template('gc-item'), + + id: function id() { + return 'gc-modal-post-' + this.model.get('id'); + }, + + className: function className() { + return 'gc-item ' + (this.model.get('disabled') ? 'gc-disabled' : 'gc-enabled'); + }, + + events: { + 'change .gc-check-column input': 'toggleCheck', + 'click .gc-status-column': 'toggleCheckAndRender' + }, + + initialize: function initialize() { + this.listenTo(this.model, 'change:post_title', this.renderTitle); + this.listenTo(this.model, 'change:mappingStatus', this.render); + this.listenTo(this.model, 'render', this.render); + }, + + renderTitle: function renderTitle() { + var title = this.model.get('post_title'); + var id = this.model.get('id'); + gc.$id('post-' + id).find('.column-title .row-title').text(title); + gc.$id('edit-' + id).find('[name="post_title"]').text(title); + gc.$id('inline_' + id).find('.post_title').text(title); + } - }); -}; - -},{"./../views/item.js":14}],19:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, gc, $) { - app.modalView = undefined; - - var ESCAPE = 27; - var thisView; - /** - * Taken from https://github.com/aut0poietic/wp-admin-modal-example - */ - return app.views.tableBase.extend({ - id: 'gc-bb-modal-dialog', - template: wp.template('gc-modal-window'), - selected: [], - navItems: null, - btns: {}, - currID: 'select-items', - currNav: false, - metaboxView: null, - modelView: app.views.modalPostRow, - $search: gc.$id('gc-items-search'), - - events: { - 'click .gc-bb-modal-close': 'closeModal', - 'click #btn-cancel': 'closeModal', - 'click .gc-bb-modal-backdrop': 'closeModal', - 'click .gc-bb-modal-nav-tabs a': 'clickSelectTab', - 'change .gc-field-th.gc-check-column input': 'checkAll', - 'click #gc-btn-pull': 'startPull', - 'click #gc-btn-push': 'startPush', - 'click .gc-cloak': 'maybeResetMetaboxView', - 'click #gc-btn-assign-mapping': 'startAssignment', - 'click .gc-field-th.sortable': 'sortRowsByColumn' - }, - - /** - * Instantiates the Template object and triggers load. - */ - initialize: function initialize() { - thisView = this; - - if (!this.$search.length) { - $(document.body).append(''); - this.$search = gc.$id('gc-items-search'); - } + }); + }; - app.views.tableBase.prototype.initialize.call(this); + }, {"./../views/item.js": 14}], + 19: [function (require, module, exports) { + 'use strict'; - _.bindAll(this, 'render', 'preserveFocus', 'maybeClose', 'closeModal'); + module.exports = function (app, gc, $) { + app.modalView = undefined; - if (gc._nav_items) { - this.navItems = new app.collections.navItems(gc._nav_items); - this.currNav = this.navItems.getActive(); - this.listenTo(this.navItems, 'render', this.render); - } + var ESCAPE = 27; + var thisView; + /** + * Taken from https://github.com/aut0poietic/wp-admin-modal-example + */ + return app.views.tableBase.extend({ + id: 'gc-bb-modal-dialog', + template: wp.template('gc-modal-window'), + selected: [], + navItems: null, + btns: {}, + currID: 'select-items', + currNav: false, + metaboxView: null, + modelView: app.views.modalPostRow, + $search: gc.$id('gc-items-search'), + + events: { + 'click .gc-bb-modal-close': 'closeModal', + 'click #btn-cancel': 'closeModal', + 'click .gc-bb-modal-backdrop': 'closeModal', + 'click .gc-bb-modal-nav-tabs a': 'clickSelectTab', + 'change .gc-field-th.gc-check-column input': 'checkAll', + 'click #gc-btn-pull': 'startPull', + 'click #gc-btn-push': 'startPush', + 'click .gc-cloak': 'maybeResetMetaboxView', + 'click #gc-btn-assign-mapping': 'startAssignment', + 'click .gc-field-th.sortable': 'sortRowsByColumn' + }, + + /** + * Instantiates the Template object and triggers load. + */ + initialize: function initialize() { + thisView = this; + + if (!this.$search.length) { + $(document.body).append(''); + this.$search = gc.$id('gc-items-search'); + } - this.btns = new app.collections.base(gc._modal_btns); + app.views.tableBase.prototype.initialize.call(this); - this.listenTo(this.collection, 'updateItems', this.maybeRender); - this.listenTo(this.collection, 'change:checked', this.checkEnableButton); - this.listenTo(this.collection, 'search', this.render); + _.bindAll(this, 'render', 'preserveFocus', 'maybeClose', 'closeModal'); - this.initMetaboxView = require('./../views/modal-assign-mapping.js')(app, $, gc); - }, + if (gc._nav_items) { + this.navItems = new app.collections.navItems(gc._nav_items); + this.currNav = this.navItems.getActive(); + this.listenTo(this.navItems, 'render', this.render); + } - checked: function checked(selected) { - this.selected = selected; - if (!selected.length) { - return; - } + this.btns = new app.collections.base(gc._modal_btns); - if (selected.length === this.collection.length) { - return this.collection.trigger('checkAll', true); - } + this.listenTo(this.collection, 'updateItems', this.maybeRender); + this.listenTo(this.collection, 'change:checked', this.checkEnableButton); + this.listenTo(this.collection, 'search', this.render); - this.collection.trigger('checkSome', function (model) { - return -1 !== _.indexOf(thisView.selected, model.get('id')) && !model.get('disabled'); - }); + this.initMetaboxView = require('./../views/modal-assign-mapping.js')(app, $, gc); + }, - return this; - }, + checked: function checked(selected) { + this.selected = selected; + if (!selected.length) { + return; + } - setupAjax: function setupAjax() { - var Ajax = require('./../models/ajax.js')(app, { - action: 'gc_pull_items', - nonce: gc._edit_nonce, - flush_cache: gc.queryargs.flush_cache ? 1 : 0 - }); + if (selected.length === this.collection.length) { + return this.collection.trigger('checkAll', true); + } - this.ajax = new Ajax(); - }, - - /** - * Assembles the UI from loaded templates. - * @internal Obviously, if the templates fail to load, our modal never launches. - */ - render: function render() { - var collection = this.collection.current(); - - // Build the base window and backdrop, attaching them to the $el. - // Setting the tab index allows us to capture focus and redirect it in Application.preserveFocus - this.$el.removeClass('gc-set-mapping').attr('tabindex', '0').html(this.template({ - btns: this.btns.toJSON(), - navItems: this.navItems ? this.navItems.toJSON() : [], - currID: this.currNav ? this.currNav.get('id') : 'select-items', - checked: collection.allChecked, - sortKey: collection.sortKey, - sortDirection: collection.sortDirection - })).append('
 
'); - - app.views.tableBase.prototype.render.call(this); - - $(document) - // Handle any attempt to move focus out of the modal. - .on('focusin', this.preserveFocus) - // Close modal on escape key. - .on('keyup', this.maybeClose); - - // set overflow to "hidden" on the body so that it ignores any scroll events - $(document.body).addClass('gc-modal-open'); - - // Add modal before the search input. - this.$search.before(this.$el); - - // Position search input. (After the above line, where we render the modal) - this.$search.css(jQuery('#gc-tablenav').offset()); - - // If we're not focused on the search input... - if (!this.isSearch(document.activeElement)) { - - // Then set focus on the modal to prevent accidental actions in the underlying page. - this.$el.focus(); - } + this.collection.trigger('checkSome', function (model) { + return -1 !== _.indexOf(thisView.selected, model.get('id')) && !model.get('disabled'); + }); - return this; - }, - - /** - * Ensures that keyboard focus remains within the Modal dialog or search input. - * @param evt {object} A jQuery-normalized event object. - */ - preserveFocus: function preserveFocus(evt) { - var isOk = this.$el[0] === evt.target || this.$el.has(evt.target).length || this.isSearch(evt.target); - if (!isOk) { - this.$el.focus(); - } - }, - - /** - * Closes modal if escape key is hit. - * @param evt {object} A jQuery-normalized event object. - */ - maybeClose: function maybeClose(evt) { - if (ESCAPE === evt.keyCode && !this.isSearch(evt.target)) { - this.closeModal(evt); - } - }, - - isSearch: function isSearch(el) { - return this.$search[0] === el || this.$search.has(el).length; - }, - - /** - * Closes the modal and cleans up after the instance. - * @param evt {object} A jQuery-normalized event object. - */ - closeModal: function closeModal(evt) { - evt.preventDefault(); - this.resetMetaboxView(); - this.undelegateEvents(); - $(document).off('focusin'); - $(document).off('keyup', this.maybeClose); - $(document.body).removeClass('gc-modal-open'); - this.remove(); - - gc.$id('bulk-edit').find('button.cancel').trigger('click'); - app.modalView = undefined; - }, + return this; + }, - clickSelectTab: function clickSelectTab(evt) { - evt.preventDefault(); + setupAjax: function setupAjax() { + var Ajax = require('./../models/ajax.js')(app, { + action: 'gc_pull_items', + nonce: gc._edit_nonce, + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }); - this.selectTab($(evt.target).data('id')); - }, + this.ajax = new Ajax(); + }, + + /** + * Assembles the UI from loaded templates. + * @internal Obviously, if the templates fail to load, our modal never launches. + */ + render: function render() { + var collection = this.collection.current(); + + // Build the base window and backdrop, attaching them to the $el. + // Setting the tab index allows us to capture focus and redirect it in Application.preserveFocus + this.$el.removeClass('gc-set-mapping').attr('tabindex', '0').html(this.template({ + btns: this.btns.toJSON(), + navItems: this.navItems ? this.navItems.toJSON() : [], + currID: this.currNav ? this.currNav.get('id') : 'select-items', + checked: collection.allChecked, + sortKey: collection.sortKey, + sortDirection: collection.sortDirection + })).append('
 
'); + + app.views.tableBase.prototype.render.call(this); + + $(document) + // Handle any attempt to move focus out of the modal. + .on('focusin', this.preserveFocus) + // Close modal on escape key. + .on('keyup', this.maybeClose); + + // set overflow to "hidden" on the body so that it ignores any scroll events + $(document.body).addClass('gc-modal-open'); + + // Add modal before the search input. + this.$search.before(this.$el); + + // Position search input. (After the above line, where we render the modal) + this.$search.css(jQuery('#gc-tablenav').offset()); + + // If we're not focused on the search input... + if (!this.isSearch(document.activeElement)) { + + // Then set focus on the modal to prevent accidental actions in the underlying page. + this.$el.focus(); + } - selectTab: function selectTab(id) { - this.currID = id; - this.currNav = this.navItems.getById(id); - this.navItems.trigger('activate', id); - }, + return this; + }, + + /** + * Ensures that keyboard focus remains within the Modal dialog or search input. + * @param evt {object} A jQuery-normalized event object. + */ + preserveFocus: function preserveFocus(evt) { + var isOk = this.$el[0] === evt.target || this.$el.has(evt.target).length || this.isSearch(evt.target); + if (!isOk) { + this.$el.focus(); + } + }, + + /** + * Closes modal if escape key is hit. + * @param evt {object} A jQuery-normalized event object. + */ + maybeClose: function maybeClose(evt) { + if (ESCAPE === evt.keyCode && !this.isSearch(evt.target)) { + this.closeModal(evt); + } + }, + + isSearch: function isSearch(el) { + return this.$search[0] === el || this.$search.has(el).length; + }, + + /** + * Closes the modal and cleans up after the instance. + * @param evt {object} A jQuery-normalized event object. + */ + closeModal: function closeModal(evt) { + evt.preventDefault(); + this.resetMetaboxView(); + this.undelegateEvents(); + $(document).off('focusin'); + $(document).off('keyup', this.maybeClose); + $(document.body).removeClass('gc-modal-open'); + this.remove(); + + gc.$id('bulk-edit').find('button.cancel').trigger('click'); + app.modalView = undefined; + }, + + clickSelectTab: function clickSelectTab(evt) { + evt.preventDefault(); + + this.selectTab($(evt.target).data('id')); + }, + + selectTab: function selectTab(id) { + this.currID = id; + this.currNav = this.navItems.getById(id); + this.navItems.trigger('activate', id); + }, + + checkEnableButton: function checkEnableButton(btnEnabled) { + this.buttonStatus(btnEnabled); + }, + + buttonStatus: function buttonStatus(enable) { + if (this.collection.processing) { + return; + } + if (!enable) { + this.$('.media-toolbar button').prop('disabled', true); + } else { + this.$('#gc-btn-assign-mapping').prop('disabled', !this.collection.checkedCan('assign')); + this.$('#gc-btn-push').prop('disabled', !this.collection.checkedCan('push')); + this.$('#gc-btn-pull').prop('disabled', !this.collection.checkedCan('pull')); + } + }, - checkEnableButton: function checkEnableButton(btnEnabled) { - this.buttonStatus(btnEnabled); - }, + startPull: function startPull(evt) { + evt.preventDefault(); + this.startSync('pull'); + }, - buttonStatus: function buttonStatus(enable) { - if (this.collection.processing) { - return; - } - if (!enable) { - this.$('.media-toolbar button').prop('disabled', true); - } else { - this.$('#gc-btn-assign-mapping').prop('disabled', !this.collection.checkedCan('assign')); - this.$('#gc-btn-push').prop('disabled', !this.collection.checkedCan('push')); - this.$('#gc-btn-pull').prop('disabled', !this.collection.checkedCan('pull')); - } - }, - - startPull: function startPull(evt) { - evt.preventDefault(); - this.startSync('pull'); - }, - - startPush: function startPush(evt) { - evt.preventDefault(); - this.startSync('push'); - }, - - startSync: function startSync(direction) { - var toCheck = 'push' === direction ? 'canPush' : 'canPull'; - var selected = this.selectiveGet(toCheck); - - if (window.confirm(gc._sure[direction])) { - selected = _.map(selected, function (model) { - model.set('mappingStatus', 'starting'); - return model.toJSON(); - }); + startPush: function startPush(evt) { + evt.preventDefault(); + this.startSync('push'); + }, - this.doAjax(selected, direction); - } - }, + startSync: function startSync(direction) { + var toCheck = 'push' === direction ? 'canPush' : 'canPull'; + var selected = this.selectiveGet(toCheck); - startAssignment: function startAssignment(evt) { - var postIds = _.map(this.selectiveGet('disabled'), function (model) { - return model.get('id'); - }); + if (window.confirm(gc._sure[direction])) { + selected = _.map(selected, function (model) { + model.set('mappingStatus', 'starting'); + return model.toJSON(); + }); - this.resetMetaboxView(); + this.doAjax(selected, direction); + } + }, - this.$el.addClass('gc-set-mapping'); + startAssignment: function startAssignment(evt) { + var postIds = _.map(this.selectiveGet('disabled'), function (model) { + return model.get('id'); + }); - this.$('#gc-btn-assign-mapping').prop('disabled', true); + this.resetMetaboxView(); - this.metaboxView = this.initMetaboxView(postIds); - this.listenTo(this.metaboxView, 'cancel', this.maybeResetMetaboxView); - this.listenTo(this.metaboxView, 'complete', function (model, data) { - model.set('waiting', true); + this.$el.addClass('gc-set-mapping'); - this.collection.map(function (model) { - if (model.get('id') in data.ids) { - model.set('mapping', data.mapping); - model.set('mappingName', data.mappingName); - model.set('mappingLink', data.mappingLink); - } - }); + this.$('#gc-btn-assign-mapping').prop('disabled', true); - this.render(); - }); - }, + this.metaboxView = this.initMetaboxView(postIds); + this.listenTo(this.metaboxView, 'cancel', this.maybeResetMetaboxView); + this.listenTo(this.metaboxView, 'complete', function (model, data) { + model.set('waiting', true); - maybeResetMetaboxView: function maybeResetMetaboxView() { - if (this.metaboxView) { - this.resetMetaboxView(); - this.buttonStatus(true); - } - }, + this.collection.map(function (model) { + if (model.get('id') in data.ids) { + model.set('mapping', data.mapping); + model.set('mappingName', data.mappingName); + model.set('mappingLink', data.mappingLink); + } + }); - resetMetaboxView: function resetMetaboxView() { - if (this.metaboxView) { - this.stopListening(this.metaboxView); - this.metaboxView.close(); - this.$el.removeClass('gc-set-mapping'); - } - }, + this.render(); + }); + }, - selectiveGet: function selectiveGet(toCheck) { - var selected = []; - var staysChecked; + maybeResetMetaboxView: function maybeResetMetaboxView() { + if (this.metaboxView) { + this.resetMetaboxView(); + this.buttonStatus(true); + } + }, - this.collection.trigger('checkSome', function (model) { - staysChecked = model.get('checked') && model.get(toCheck); - if (staysChecked) { - selected.push(model); - } + resetMetaboxView: function resetMetaboxView() { + if (this.metaboxView) { + this.stopListening(this.metaboxView); + this.metaboxView.close(); + this.$el.removeClass('gc-set-mapping'); + } + }, - return staysChecked; - }); + selectiveGet: function selectiveGet(toCheck) { + var selected = []; + var staysChecked; - return selected; - }, + this.collection.trigger('checkSome', function (model) { + staysChecked = model.get('checked') && model.get(toCheck); + if (staysChecked) { + selected.push(model); + } - getChecked: function getChecked(cb) { - this.collection.filter(function (model) { - var shouldGet = model.get('checked'); - if (shouldGet && cb) { - cb(model); - } - return shouldGet; - }); - }, + return staysChecked; + }); - ajaxSuccess: function ajaxSuccess(response) { - if (!response.data.mappings) { - return this.ajaxFail(); - } + return selected; + }, - var mappings = []; + getChecked: function getChecked(cb) { + this.collection.filter(function (model) { + var shouldGet = model.get('checked'); + if (shouldGet && cb) { + cb(model); + } + return shouldGet; + }); + }, - var toCheck = 'push' === response.data.direction ? 'canPush' : 'canPull'; - var checked = this.getChecked(function (model) { - if (!model.get(toCheck)) { - return; - } + ajaxSuccess: function ajaxSuccess(response) { + if (!response.data.mappings) { + return this.ajaxFail(); + } - if (response.data.mappings.length && -1 !== _.indexOf(response.data.mappings, model.get('mapping'))) { - model.set('mappingStatus', 'syncing'); - mappings.push(model.get('mapping')); - } else { - model.set('checked', false); - model.set('mappingStatus', 'complete'); - model.fetch().done(function () { - model.trigger('render'); + var mappings = []; + + var toCheck = 'push' === response.data.direction ? 'canPush' : 'canPull'; + var checked = this.getChecked(function (model) { + if (!model.get(toCheck)) { + return; + } + + if (response.data.mappings.length && -1 !== _.indexOf(response.data.mappings, model.get('mapping'))) { + model.set('mappingStatus', 'syncing'); + mappings.push(model.get('mapping')); + } else { + model.set('checked', false); + model.set('mappingStatus', 'complete'); + model.fetch().done(function () { + model.trigger('render'); + }); + } }); - } - }); - if (!mappings.length) { - return this.clearTimeout(); - } + if (!mappings.length) { + return this.clearTimeout(); + } - this.checkStatus(mappings, response.data.direction); - }, + this.checkStatus(mappings, response.data.direction); + }, - ajaxFail: function ajaxFail(response) { - this.setSelectedMappingStatus('failed'); - this.clearTimeout(); - }, + ajaxFail: function ajaxFail(response) { + this.setSelectedMappingStatus('failed'); + this.clearTimeout(); + }, - setSelectedMappingStatus: function setSelectedMappingStatus(status) { - return this.getChecked(function (model) { - model.set('mappingStatus', status); - }); - }, + setSelectedMappingStatus: function setSelectedMappingStatus(status) { + return this.getChecked(function (model) { + model.set('mappingStatus', status); + }); + }, - checkStatus: function checkStatus(mappings, direction) { - this.clearTimeout(); - this.setTimeout(function () { - thisView.doAjax({ check: mappings }, direction); - }); - }, + checkStatus: function checkStatus(mappings, direction) { + this.clearTimeout(); + this.setTimeout(function () { + thisView.doAjax({check: mappings}, direction); + }); + }, - doAjax: function doAjax(formData, direction) { - this.ajax.set('action', 'gc_' + direction + '_items'); + doAjax: function doAjax(formData, direction) { + this.ajax.set('action', 'gc_' + direction + '_items'); - this.ajax.send(formData, this.ajaxSuccess.bind(this), 0, this.ajaxFail.bind(this)); - }, + this.ajax.send(formData, this.ajaxSuccess.bind(this), 0, this.ajaxFail.bind(this)); + }, - maybeRender: function maybeRender() { - if (!this.metaboxView) { - this.render(); - } - } + maybeRender: function maybeRender() { + if (!this.metaboxView) { + this.render(); + } + } - }); -}; + }); + }; -},{"./../models/ajax.js":8,"./../views/modal-assign-mapping.js":17}],20:[function(require,module,exports){ -'use strict'; + }, {"./../models/ajax.js": 8, "./../views/modal-assign-mapping.js": 17}], + 20: [function (require, module, exports) { + 'use strict'; -module.exports = function (app, gc) { - return app.views.base.extend({ - template: wp.template('gc-post-column-row'), - tagName: 'span', - className: 'gc-status-column', - id: function id() { - return 'gc-status-row-' + this.model.get('id'); - }, + module.exports = function (app, gc) { + return app.views.base.extend({ + template: wp.template('gc-post-column-row'), + tagName: 'span', + className: 'gc-status-column', + id: function id() { + return 'gc-status-row-' + this.model.get('id'); + }, - initialize: function initialize() { - this.listenTo(this.model, 'change:status', this.render); - }, + initialize: function initialize() { + this.listenTo(this.model, 'change:status', this.render); + }, - html: function html() { - return this.template(this.model.toJSON()); - }, + html: function html() { + return this.template(this.model.toJSON()); + }, - render: function render() { - var $td = gc.$id('post-' + this.model.get('id')).find('.column-gathercontent'); - $td.html(this.html()); + render: function render() { + var $td = gc.$id('post-' + this.model.get('id')).find('.column-gathercontent'); + $td.html(this.html()); - return this; - } - }); -}; - -},{}],21:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, gc, $) { - var thisView; - return app.views.statusSelect2.extend({ - template: wp.template('gc-status-select2'), - - el: '#posts-filter tbody', - - width: '200px', - - initialize: function initialize() { - thisView = this; - this.listenTo(this, 'quickEdit', this.edit); - this.listenTo(this, 'quickEditSend', this.sending); - this.render(); - this.updatePosts(); - }, - - updatePosts: function updatePosts() { - // Trigger an un-cached update for the posts - $.post(window.ajaxurl, { - action: 'gc_get_posts', - posts: gc._posts, - flush_cache: gc.queryargs.flush_cache ? 1 : 0 - }, function (response) { - if ((response.success, response.data)) { - thisView.collection.trigger('updateItems', response.data); + return this; } }); - }, - - sending: function sending(request, settings) { - var data = this.parseQueryString(settings.data); - if (data.post_ID && data.gc_status) { - var model = this.collection.getById(data.post_ID); - - var status = _.find(model.get('statuses'), function (status) { - return parseInt(status.id, 10) === parseInt(data.gc_status, 10); - }); - - model.set('status', status); - } - }, - - edit: function edit(id, inlineEdit) { - // get the post ID - var postId = 0; - if ('object' === typeof id) { - postId = parseInt(inlineEdit.getId(id), 10); - } + }; - this.waitSpinner(postId); + }, {}], + 21: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, gc, $) { + var thisView; + return app.views.statusSelect2.extend({ + template: wp.template('gc-status-select2'), + + el: '#posts-filter tbody', + + width: '200px', + + initialize: function initialize() { + thisView = this; + this.listenTo(this, 'quickEdit', this.edit); + this.listenTo(this, 'quickEditSend', this.sending); + this.render(); + this.updatePosts(); + }, + + updatePosts: function updatePosts() { + // Trigger an un-cached update for the posts + $.post(window.ajaxurl, { + action: 'gc_get_posts', + posts: gc._posts, + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, function (response) { + if ((response.success, response.data)) { + thisView.collection.trigger('updateItems', response.data); + } + }); + }, - if (!postId) { - return; - } + sending: function sending(request, settings) { + var data = this.parseQueryString(settings.data); + if (data.post_ID && data.gc_status) { + var model = this.collection.getById(data.post_ID); - var model = this.collection.getById(postId); + var status = _.find(model.get('statuses'), function (status) { + return parseInt(status.id, 10) === parseInt(data.gc_status, 10); + }); - if (model.get('statusesChecked')) { - return this.renderStatuses(model); - } + model.set('status', status); + } + }, - $.post(window.ajaxurl, { - action: 'gc_get_post_statuses', - postId: postId, - flush_cache: gc.queryargs.flush_cache ? 1 : 0 - }, this.ajaxResponse).done(function () { - thisView.renderStatuses(model); - }); - }, + edit: function edit(id, inlineEdit) { + // get the post ID + var postId = 0; + if ('object' === typeof id) { + postId = parseInt(inlineEdit.getId(id), 10); + } - ajaxResponse: function ajaxResponse(response) { - if (!response.data) { - return; - } + this.waitSpinner(postId); - var model = thisView.collection.getById(response.data.postId); - if (!model) { - return; - } + if (!postId) { + return; + } - model.set('statusesChecked', true); + var model = this.collection.getById(postId); - if (response.success) { - model.set('statuses', response.data.statuses); + if (model.get('statusesChecked')) { + return this.renderStatuses(model); + } - if (model.get('statuses').length) { - thisView.$('.gc-select2').each(function () { - $(this).select2('destroy'); + $.post(window.ajaxurl, { + action: 'gc_get_post_statuses', + postId: postId, + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, this.ajaxResponse).done(function () { + thisView.renderStatuses(model); }); + }, - thisView.renderStatuses(model); - } - } - }, + ajaxResponse: function ajaxResponse(response) { + if (!response.data) { + return; + } - renderStatuses: function renderStatuses(model) { - var postId = model.get('id'); - this.editSelect(postId).html(this.template(model.toJSON())); - if (model.get('statuses').length) { - this.renderSelect2(gc.$id('edit-' + postId)); - } - }, + var model = thisView.collection.getById(response.data.postId); + if (!model) { + return; + } - waitSpinner: function waitSpinner(postId) { - this.editSelect(postId).html(''); - }, + model.set('statusesChecked', true); - editSelect: function editSelect(postId) { - return gc.$id('edit-' + postId).find('.inline-edit-group .gc-status-select2'); - }, + if (response.success) { + model.set('statuses', response.data.statuses); - render: function render() { - this.collection.each(function (model) { - new app.views.postRow({ model: model }).render(); - }); - return this; - }, - - /** - * Parse query string. - * ?a=b&c=d to {a: b, c: d} - * @param {String} (option) queryString - * @return {Object} query params - */ - parseQueryString: function parseQueryString(string) { - if (!string) { - return {}; - } - return _.chain(string.split('&')).map(function (params) { - var p = params.split('='); - return [p[0], decodeURIComponent(p[1])]; - }).object().value(); - } + if (model.get('statuses').length) { + thisView.$('.gc-select2').each(function () { + $(this).select2('destroy'); + }); - }); -}; + thisView.renderStatuses(model); + } + } + }, -},{}],22:[function(require,module,exports){ -'use strict'; + renderStatuses: function renderStatuses(model) { + var postId = model.get('id'); + this.editSelect(postId).html(this.template(model.toJSON())); + if (model.get('statuses').length) { + this.renderSelect2(gc.$id('edit-' + postId)); + } + }, -module.exports = function (app) { - var thisView; - return app.views.base.extend({ - select2ItemTemplate: wp.template('gc-select2-item'), - width: '250px', + waitSpinner: function waitSpinner(postId) { + this.editSelect(postId).html(''); + }, - renderSelect2: function renderSelect2($context) { - var $selector = $context ? $context.find('.gc-select2') : this.$('.gc-select2'); - thisView = this; + editSelect: function editSelect(postId) { + return gc.$id('edit-' + postId).find('.inline-edit-group .gc-status-select2'); + }, - $selector.each(function () { - var $this = jQuery(this); - var data = $this.data(); - $this.select2(thisView.select2Args(data)); - var s2Data = $this.data('select2'); + render: function render() { + this.collection.each(function (model) { + new app.views.postRow({model: model}).render(); + }); + return this; + }, + + /** + * Parse query string. + * ?a=b&c=d to {a: b, c: d} + * @param {String} (option) queryString + * @return {Object} query params + */ + parseQueryString: function parseQueryString(string) { + if (!string) { + return {}; + } + return _.chain(string.split('&')).map(function (params) { + var p = params.split('='); + return [p[0], decodeURIComponent(p[1])]; + }).object().value(); + } - // Add classes for styling. - s2Data.$results.addClass('select2-' + data.column); - s2Data.$container.addClass('select2-' + data.column); }); + }; - return this; - }, - - select2Args: function select2Args(data) { - var args = { - width: thisView.width - }; - - args.templateResult = (function (status, showDesc) { - var data = jQuery.extend(status, jQuery(status.element).data()); - data.description = false === showDesc ? false : data.description || ''; - return jQuery(thisView.select2ItemTemplate(status)); - }).bind(thisView); - - args.templateSelection = function (status) { - return args.templateResult(status, false); - }; - - return args; - } + }, {}], + 22: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + var thisView; + return app.views.base.extend({ + select2ItemTemplate: wp.template('gc-select2-item'), + width: '250px', + + renderSelect2: function renderSelect2($context) { + var $selector = $context ? $context.find('.gc-select2') : this.$('.gc-select2'); + thisView = this; + + $selector.each(function () { + var $this = jQuery(this); + var data = $this.data(); + $this.select2(thisView.select2Args(data)); + var s2Data = $this.data('select2'); + + // Add classes for styling. + s2Data.$results.addClass('select2-' + data.column); + s2Data.$container.addClass('select2-' + data.column); + }); - }); -}; + return this; + }, -},{}],23:[function(require,module,exports){ -'use strict'; + select2Args: function select2Args(data) { + var args = { + width: thisView.width + }; -module.exports = function (app, $, gc) { - app.views.tableSearch = require('./../views/table-search.js')(app, $, gc); - app.views.tableNav = require('./../views/table-nav.js')(app, $, gc); + args.templateResult = (function (status, showDesc) { + var data = jQuery.extend(status, jQuery(status.element).data()); + data.description = false === showDesc ? false : data.description || ''; + return jQuery(thisView.select2ItemTemplate(status)); + }).bind(thisView); - return app.views.base.extend({ - timeoutID: null, - ajax: null, - tableNavView: null, - searchView: null, - modelView: null, // Need to override. - timeoutTime: 1000, + args.templateSelection = function (status) { + return args.templateResult(status, false); + }; - events: { - 'click .gc-field-th.sortable': 'sortRowsByColumn', - 'change .gc-field-th.gc-check-column input': 'checkAll' - }, + return args; + } - initialize: function initialize() { - this.setupAjax(); + }); + }; - this.listenTo(this.collection, 'render', this.render); - this.listenTo(this.collection, 'notAllChecked', this.allCheckedStatus); - this.listenTo(this.collection, 'change:checked', this.renderNav); - this.listenTo(this, 'render', this.render); + }, {}], + 23: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + app.views.tableSearch = require('./../views/table-search.js')(app, $, gc); + app.views.tableNav = require('./../views/table-nav.js')(app, $, gc); + + return app.views.base.extend({ + timeoutID: null, + ajax: null, + tableNavView: null, + searchView: null, + modelView: null, // Need to override. + timeoutTime: 1000, + + events: { + 'click .gc-field-th.sortable': 'sortRowsByColumn', + 'change .gc-field-th.gc-check-column input': 'checkAll' + }, + + initialize: function initialize() { + this.setupAjax(); + + this.listenTo(this.collection, 'render', this.render); + this.listenTo(this.collection, 'notAllChecked', this.allCheckedStatus); + this.listenTo(this.collection, 'change:checked', this.renderNav); + this.listenTo(this, 'render', this.render); + + this.tableNavView = new app.views.tableNav({ + collection: this.collection + }); - this.tableNavView = new app.views.tableNav({ - collection: this.collection - }); + this.searchView = new app.views.tableSearch({ + collection: this.collection + }); + }, - this.searchView = new app.views.tableSearch({ - collection: this.collection - }); - }, + // Need to override. + setupAjax: function setupAjax() { + }, - // Need to override. - setupAjax: function setupAjax() {}, + sortRowsByColumn: function sortRowsByColumn(evt) { + evt.preventDefault(); + var collection = this.collection.current(); - sortRowsByColumn: function sortRowsByColumn(evt) { - evt.preventDefault(); - var collection = this.collection.current(); + var $this = $(evt.currentTarget); + var column = $this.find('a').data('id'); + var direction = false; - var $this = $(evt.currentTarget); - var column = $this.find('a').data('id'); - var direction = false; + if ($this.hasClass('asc')) { + direction = 'desc'; + } - if ($this.hasClass('asc')) { - direction = 'desc'; - } + if ($this.hasClass('desc')) { + direction = 'asc'; + } - if ($this.hasClass('desc')) { - direction = 'asc'; - } + if (!direction) { + direction = collection.sortDirection; + } - if (!direction) { - direction = collection.sortDirection; - } + if ('asc' === direction) { + $this.addClass('desc').removeClass('asc'); + } else { + $this.addClass('asc').removeClass('desc'); + } - if ('asc' === direction) { - $this.addClass('desc').removeClass('asc'); - } else { - $this.addClass('asc').removeClass('desc'); - } + collection.trigger('sortByColumn', column, direction); + this.sortRender(); + }, - collection.trigger('sortByColumn', column, direction); - this.sortRender(); - }, + buttonStatus: function buttonStatus(enable) { + this.$('.button-primary').prop('disabled', !enable); + }, - buttonStatus: function buttonStatus(enable) { - this.$('.button-primary').prop('disabled', !enable); - }, + allCheckedStatus: function allCheckedStatus() { + this.$('.gc-field-th.gc-check-column input').prop('checked', this.collection.allChecked); + }, - allCheckedStatus: function allCheckedStatus() { - this.$('.gc-field-th.gc-check-column input').prop('checked', this.collection.allChecked); - }, + checkAll: function checkAll(evt) { + this.collection.trigger('checkAll', $(evt.target).is(':checked')); + }, - checkAll: function checkAll(evt) { - this.collection.trigger('checkAll', $(evt.target).is(':checked')); - }, + doSpinner: function doSpinner() { + var html = this.blankRow(''); + this.renderRows(html); + }, - doSpinner: function doSpinner() { - var html = this.blankRow(''); - this.renderRows(html); - }, + setTimeout: function setTimeout(callback) { + this.timeoutID = window.setTimeout(callback, this.timeoutTime); + }, - setTimeout: function setTimeout(callback) { - this.timeoutID = window.setTimeout(callback, this.timeoutTime); - }, + clearTimeout: function clearTimeout() { + window.clearTimeout(this.timeoutID); + this.timeoutID = null; + }, - clearTimeout: function clearTimeout() { - window.clearTimeout(this.timeoutID); - this.timeoutID = null; - }, + getRenderedRows: function getRenderedRows() { + var rows; - getRenderedRows: function getRenderedRows() { - var rows; + if (this.collection.current().length) { + rows = this.getRenderedModels(this.modelView, this.collection.current()); + } else { + rows = this.blankRow(gc._text.no_items); + } - if (this.collection.current().length) { - rows = this.getRenderedModels(this.modelView, this.collection.current()); - } else { - rows = this.blankRow(gc._text.no_items); - } + return rows; + }, - return rows; - }, + sortRender: function sortRender() { + this.render(); + }, - sortRender: function sortRender() { - this.render(); - }, + blankRow: function blankRow(html) { + var cols = this.$('thead tr > *').length; + return '' + html + ''; + }, - blankRow: function blankRow(html) { - var cols = this.$('thead tr > *').length; - return '' + html + ''; - }, + renderRows: function renderRows(html) { + this.$('tbody').html(html || this.getRenderedRows()); + }, - renderRows: function renderRows(html) { - this.$('tbody').html(html || this.getRenderedRows()); - }, + renderNav: function renderNav() { + this.$('#gc-tablenav').html(this.tableNavView.render().el); + }, - renderNav: function renderNav() { - this.$('#gc-tablenav').html(this.tableNavView.render().el); - }, + render: function render() { + var collection = this.collection.current(); - render: function render() { - var collection = this.collection.current(); + // Re-render and replace table rows. + this.renderRows(); - // Re-render and replace table rows. - this.renderRows(); + // Re-render table nav + this.renderNav(); - // Re-render table nav - this.renderNav(); + // Make sync button enabled/disabled + this.buttonStatus(collection.syncEnabled); - // Make sync button enabled/disabled - this.buttonStatus(collection.syncEnabled); + // Make check-all inputs checked/unchecked + this.allCheckedStatus(collection.allChecked); - // Make check-all inputs checked/unchecked - this.allCheckedStatus(collection.allChecked); + return this; + } - return this; - } + }); + }; - }); -}; + }, {"./../views/table-nav.js": 24, "./../views/table-search.js": 25}], + 24: [function (require, module, exports) { + 'use strict'; -},{"./../views/table-nav.js":24,"./../views/table-search.js":25}],24:[function(require,module,exports){ -'use strict'; + module.exports = function (app, $, gc) { + return app.views.base.extend({ + template: wp.template('gc-table-nav'), -module.exports = function (app, $, gc) { - return app.views.base.extend({ - template: wp.template('gc-table-nav'), + render: function render() { + var collection = this.collection.current(); - render: function render() { - var collection = this.collection.current(); + this.$el.html(this.template({ + count: collection.length, + selected: collection.checked ? collection.checked().length : 0 + })); - this.$el.html(this.template({ - count: collection.length, - selected: collection.checked ? collection.checked().length : 0 - })); + return this; + } + }); + }; - return this; - } - }); -}; - -},{}],25:[function(require,module,exports){ -'use strict'; - -module.exports = function (app) { - return Backbone.View.extend({ - el: '#gc-items-search', - template: wp.template('gc-table-search'), - events: { - 'keyup #gc-search-input': 'filterCollection', - 'search #gc-search-input': 'filterCollection' - }, - - initialize: function initialize() { - this.render(); - }, - - filterCollection: _.debounce(function (evt) { - this.collection.search(evt.target.value); - }, 100), - - render: function render() { - this.$el.html(this.template()); - return this; - } + }, {}], + 25: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + return Backbone.View.extend({ + el: '#gc-items-search', + template: wp.template('gc-table-search'), + events: { + 'keyup #gc-search-input': 'filterCollection', + 'search #gc-search-input': 'filterCollection' + }, + + initialize: function initialize() { + this.render(); + }, + + filterCollection: _.debounce(function (evt) { + this.collection.search(evt.target.value); + }, 100), + + render: function render() { + this.$el.html(this.template()); + return this; + } - }); -}; + }); + }; -},{}]},{},[6]); + }, {}] +}, {}, [6]); diff --git a/assets/js/gathercontent-mapping.js b/assets/js/gathercontent-mapping.js index 16f4acea..c70ec50f 100644 --- a/assets/js/gathercontent-mapping.js +++ b/assets/js/gathercontent-mapping.js @@ -1,893 +1,946 @@ /** * Content Workflow (by Bynder) - v1.0.0 - 2024-06-05 - * + * * * Copyright (c) 2024 Content Workflow (by Bynder) * Licensed under the GPLv2 license. */ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o WP status table if initialized. - if (!this.model.get('initial')) { - json.table_id = 'gc-status-mappings'; - delete json.label; - json.col_headings = table_headings.status; + render: function render() { + var json = this.model.toJSON(); - html += '
'; - html += this.template(json); - } + this.$el.html(this.htmlWrap(json)); + this.$el.find('tbody').first().html(this.defaultTabTemplate(json)); + this.$el.find('#gc-status-mappings tbody').html(this.statusMappingsTemplate(json)); - return html; - }, - - select2Args: function select2Args(_data) { - var args = {}; - - switch (_data.column) { - case 'gc_status': - args = app.views.statusSelect2.prototype.select2Args.call(this, _data); - break; - - case 'post_author': - args.width = '250px'; - args.minimumInputLength = 2; - args.ajax = { - url: _data.url, - data: function data(params) { - return { - q: params.term, - column: _data.column + this.renderSelect2(); + + return this; + }, + + htmlWrap: function htmlWrap(json) { + var html = this.template(json); + + // Only add the GatherContent status => WP status table if initialized. + if (!this.model.get('initial')) { + json.table_id = 'gc-status-mappings'; + delete json.label; + json.col_headings = table_headings.status; + + html += '
'; + html += this.template(json); + } + + return html; + }, + + select2Args: function select2Args(_data) { + var args = {}; + + switch (_data.column) { + case 'gc_status': + args = app.views.statusSelect2.prototype.select2Args.call(this, _data); + break; + + case 'post_author': + args.width = '250px'; + args.minimumInputLength = 2; + args.ajax = { + url: _data.url, + data: function data(params) { + return { + q: params.term, + column: _data.column + }; + }, + delay: 250, + cache: true }; - }, - delay: 250, - cache: true - }; - break; - } + break; + } - return args; - } + return args; + } + + }); + }; + + }, {}], + 12: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + var thisView; + return app.views.base.extend({ + select2ItemTemplate: wp.template('gc-select2-item'), + width: '250px', + + renderSelect2: function renderSelect2($context) { + var $selector = $context ? $context.find('.gc-select2') : this.$('.gc-select2'); + thisView = this; + + $selector.each(function () { + var $this = jQuery(this); + var data = $this.data(); + $this.select2(thisView.select2Args(data)); + var s2Data = $this.data('select2'); + + // Add classes for styling. + s2Data.$results.addClass('select2-' + data.column); + s2Data.$container.addClass('select2-' + data.column); + }); - }); -}; + return this; + }, -},{}],12:[function(require,module,exports){ -'use strict'; + select2Args: function select2Args(data) { + var args = { + width: thisView.width + }; -module.exports = function (app) { - var thisView; - return app.views.base.extend({ - select2ItemTemplate: wp.template('gc-select2-item'), - width: '250px', + args.templateResult = (function (status, showDesc) { + var data = jQuery.extend(status, jQuery(status.element).data()); + data.description = false === showDesc ? false : data.description || ''; + return jQuery(thisView.select2ItemTemplate(status)); + }).bind(thisView); - renderSelect2: function renderSelect2($context) { - var $selector = $context ? $context.find('.gc-select2') : this.$('.gc-select2'); - thisView = this; + args.templateSelection = function (status) { + return args.templateResult(status, false); + }; - $selector.each(function () { - var $this = jQuery(this); - var data = $this.data(); - $this.select2(thisView.select2Args(data)); - var s2Data = $this.data('select2'); + return args; + } - // Add classes for styling. - s2Data.$results.addClass('select2-' + data.column); - s2Data.$container.addClass('select2-' + data.column); }); + }; - return this; - }, + }, {}], + 13: [function (require, module, exports) { + 'use strict'; - select2Args: function select2Args(data) { - var args = { - width: thisView.width - }; + module.exports = function (app) { + return app.views.base.extend({ + tagName: 'a', - args.templateResult = (function (status, showDesc) { - var data = jQuery.extend(status, jQuery(status.element).data()); - data.description = false === showDesc ? false : data.description || ''; - return jQuery(thisView.select2ItemTemplate(status)); - }).bind(thisView); + id: function id() { + return 'tabtrigger-' + this.model.get('id'); + }, - args.templateSelection = function (status) { - return args.templateResult(status, false); - }; + className: function className() { + return 'nav-tab ' + (this.model.get('hidden') ? '' : 'nav-tab-active') + ' ' + this.model.get('navClasses'); + }, - return args; - } + render: function render() { + this.$el.text(this.model.get('label')).attr('href', '#' + this.model.get('id')); - }); -}; + return this; + } -},{}],13:[function(require,module,exports){ -'use strict'; + }); + }; + + }, {}], + 14: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, _meta_keys) { + return app.views.base.extend({ + tagName: 'tr', + template: wp.template('gc-mapping-tab-row'), + + events: { + 'change .wp-type-select': 'changeType', + 'change .wp-type-value-select': 'changeValue', + 'change .wp-type-field-select': 'changeField', + 'change .wp-subfield-select': 'changeSubfield', + 'click .gc-reveal-items': 'toggleExpanded' + }, -module.exports = function (app) { - return app.views.base.extend({ - tagName: 'a', + initialize: function initialize() { + this.listenTo(this.model, 'change:field_type', this.render); + + // Initiate the metaKeys collection. + this.metaKeys = new (app.collections.base.extend({ + model: app.models.base.extend({ + defaults: { + value: '', + field: '', + subfields: '' + } + }), + getByValue: function getByValue(value) { + return this.find(function (model) { + return model.get('value') === value; + }); + }, + getByField: function getByField(field) { + return this.find(function (model) { + return model.get('field') === field; + }); + }, + getBySubfields: function getBySubfields(subfields) { + return this.find(function (model) { + return model.get('subfields') === subfields; + }); + } + }))(_meta_keys); + }, - id: function id() { - return 'tabtrigger-' + this.model.get('id'); - }, + /** + * 1st Dropdown - event change + */ + changeType: function changeType(evt) { + this.model.set('field_type', jQuery(evt.target).val()); + }, - className: function className() { - return 'nav-tab ' + (this.model.get('hidden') ? '' : 'nav-tab-active') + ' ' + this.model.get('navClasses'); - }, + /** + * 2nd Dropdown - event change + */ + changeValue: function changeValue(evt) { + var component = jQuery(evt.target).closest('.component-table-wrapper').attr('id'); + var value = jQuery(evt.target).val(); + var type = this.model.get('type'); + var fieldType = this.model.get('field_type'); + if ('' === value) { + this.model.set('field_type', ''); + this.model.set('field_value', ''); + this.model.set('field_field', ''); + this.model.set('field_subfields', {}); + jQuery('#' + component + ' .component-table-inner ').find('select').html("").val(""); + } else { + this.model.set('field_value', value); + // Components - Update "Field" + if ("component" === type) { + this.updateAjax_Field(component, value, false); + } + // Repeaters - Update "Field" + else if ("wp-type-acf" === fieldType) { + var id = jQuery(evt.target).closest('td').attr('id'); + this.updateAjax_Field(id, value, false); + } + } + }, - render: function render() { - this.$el.text(this.model.get('label')).attr('href', '#' + this.model.get('id')); + /** + * 3rd Dropdown - event change + */ + changeField: function changeField(evt) { + var value = jQuery(evt.target).val(); + var component = jQuery(evt.target).closest('.component-table-wrapper').attr('id'); + // Update Data + this.model.set('field_subfields', {}); + if ('' === value) { + this.model.set('field_field', ''); + jQuery('#' + component + ' .component-table-inner ').find('select').html("").val(""); + } else { + this.model.set('field_field', value); + // Update subfields + this.updateAjax_ComponentSubfields(component, value, false); + } + }, - return this; - } + /** + * LVL 2: Subfield Dropdown - event change + */ + changeSubfield: function changeSubfield(evt) { + var value = jQuery(evt.target).val(); + var index = jQuery(evt.target).attr('data-index'); + var subfield_data = this.model.get('field_subfields'); + if (!subfield_data) { + subfield_data = {}; + } + subfield_data[index] = value; + this.model.set('field_subfields', subfield_data); + }, - }); -}; - -},{}],14:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, _meta_keys) { - return app.views.base.extend({ - tagName: 'tr', - template: wp.template('gc-mapping-tab-row'), - - events: { - 'change .wp-type-select': 'changeType', - 'change .wp-type-value-select': 'changeValue', - 'change .wp-type-field-select': 'changeField', - 'change .wp-subfield-select': 'changeSubfield', - 'click .gc-reveal-items': 'toggleExpanded' - }, - - initialize: function initialize() { - this.listenTo(this.model, 'change:field_type', this.render); - - // Initiate the metaKeys collection. - this.metaKeys = new (app.collections.base.extend({ - model: app.models.base.extend({ defaults: { - value: '', - field: '', - subfields: '' - } }), - getByValue: function getByValue(value) { - return this.find(function (model) { - return model.get('value') === value; + /** + * Helper function: build option html elements for AJAX funtions + */ + optionBuilder: function optionBuilder(data) { + var options_html = ""; + jQuery.each(data.field_data, function (i, field) { + options_html += ""; }); + return options_html; }, - getByField: function getByField(field) { - return this.find(function (model) { - return model.get('field') === field; + + /** + * AJAX Update: "Field" - ACF Field group's field + * - "Field" refers to the 3rd dropdown of the component fields top level + * - After selecting the field group from the 2nd dropdown, call WP_AJAX to get the relevent fields from the group selected and populate the 3rd dropdown (aka "Field") + * + * @param {string} component - ID without the "#" of the component parent row + * @param {string} field_name - Parent field name/key of the sub fields, should be a repeater + * @param {object} saved_fields - OPTIONAL: Pass saved subfields if you want to set pre-existing values + */ + updateAjax_Field: function updateAjax_Field(component, field_name, saved_fields) { + saved_fields = typeof saved_fields !== 'undefined' ? saved_fields : ""; + var $this = this; + + // Update UI + jQuery('#' + component + ' .wp-type-field-select ~ span.select2').addClass('ajax-disabled'); + // Get Updated Data + jQuery.post(window.ajaxurl, { + action: 'gc_component_subfields', + subfields_data: { + name: field_name + } + }, function (response) { + // Update UI + jQuery('#' + component + ' .wp-type-field-select ~ span.select2').removeClass('ajax-disabled'); + + // SUCCESS + if (response.success) { + // Ensure response has subfield data + if (response.data.field_data && response.data.field_data.length) { + // Build options HTML: + var options_html = $this.optionBuilder(response.data); + // Inject into select fields + jQuery('#' + component).find('.wp-type-field-select').html(options_html); + + // If existing subfields are passed, update specific dropdown options + if (saved_fields) { + jQuery('#' + component).find('.wp-type-field-select').val(saved_fields); + } + } + } + // ERROR + else { + window.alert('Please refresh and try again. If the issue persists, reach out to support'); + } }); }, - getBySubfields: function getBySubfields(subfields) { - return this.find(function (model) { - return model.get('subfields') === subfields; + + /** + * AJAX Update: "Subfields" - ACF Field group's repeater subfields + * - "Subfields" are in the component accordion + * - After selecting the field group from the 3rd dropdown, call WP_AJAX to get the relevent subfields from the ACF Repeater selected and populate the subfields + * + * @param {string} component - ID without the "#" of the component parent row + * @param {string} field_name - Parent field name/key of the sub fields, should be a repeater + * @param {object} saved_fields - OPTIONAL: Pass saved subfields if you want to set pre-existing values + */ + updateAjax_ComponentSubfields: function updateAjax_ComponentSubfields(component, field_name, saved_fields) { + saved_fields = typeof saved_fields !== 'undefined' ? saved_fields : {}; + var $this = this; + + // Update UI + jQuery('#' + component + ' .component-table-inner').find('select').addClass('ajax-disabled'); + // Get Updated Data + jQuery.post(window.ajaxurl, { + action: 'gc_component_subfields', + subfields_data: { + name: field_name + } + }, function (response) { + // Update UI + jQuery('#' + component + ' .component-table-inner').find('select').removeClass('ajax-disabled'); + + // SUCCESS + if (response.success) { + // Ensure response has subfield data + if (response.data.field_data && response.data.field_data.length) { + // Build options HTML: + var options_html = $this.optionBuilder(response.data); + // Inject into select fields + jQuery('#' + component).find('.component-table-inner select').html(options_html); + + // If existing subfields are passed, update specific dropdown options + if (Object.keys(saved_fields).length) { + var dropdowns = jQuery('#' + component).find('.component-table-inner select').toArray(); + jQuery.each(dropdowns, function (i, dropdown) { + i++; + jQuery(dropdown).val(saved_fields[i]); + }); + } + } + } + // ERROR + else { + window.alert('Please refresh and try again. If the issue persists, reach out to support'); + } }); - } - }))(_meta_keys); - }, - - /** - * 1st Dropdown - event change - */ - changeType: function changeType(evt) { - this.model.set('field_type', jQuery(evt.target).val()); - }, - - /** - * 2nd Dropdown - event change - */ - changeValue: function changeValue(evt) { - var component = jQuery(evt.target).closest('.component-table-wrapper').attr('id'); - var value = jQuery(evt.target).val(); - var type = this.model.get('type'); - var fieldType = this.model.get('field_type'); - if ('' === value) { - this.model.set('field_type', ''); - this.model.set('field_value', ''); - this.model.set('field_field', ''); - this.model.set('field_subfields', {}); - jQuery('#' + component + ' .component-table-inner ').find('select').html("").val(""); - } else { - this.model.set('field_value', value); - // Components - Update "Field" - if ("component" === type) { - this.updateAjax_Field(component, value, false); - } - // Repeaters - Update "Field" - else if ("wp-type-acf" === fieldType) { - var id = jQuery(evt.target).closest('td').attr('id'); - this.updateAjax_Field(id, value, false); + }, + + /** + * Init + */ + render: function render() { + var val = this.model.get('field_value'); + var valField = this.model.get('field_field'); + var valSubfields = this.model.get('field_subfields'); + var component; + + if (val && !this.metaKeys.getByValue(val)) { + this.metaKeys.add({value: val}); } - } - }, - - /** - * 3rd Dropdown - event change - */ - changeField: function changeField(evt) { - var value = jQuery(evt.target).val(); - var component = jQuery(evt.target).closest('.component-table-wrapper').attr('id'); - // Update Data - this.model.set('field_subfields', {}); - if ('' === value) { - this.model.set('field_field', ''); - jQuery('#' + component + ' .component-table-inner ').find('select').html("").val(""); - } else { - this.model.set('field_field', value); - // Update subfields - this.updateAjax_ComponentSubfields(component, value, false); - } - }, - - /** - * LVL 2: Subfield Dropdown - event change - */ - changeSubfield: function changeSubfield(evt) { - var value = jQuery(evt.target).val(); - var index = jQuery(evt.target).attr('data-index'); - var subfield_data = this.model.get('field_subfields'); - if (!subfield_data) { - subfield_data = {}; - } - subfield_data[index] = value; - this.model.set('field_subfields', subfield_data); - }, - - /** - * Helper function: build option html elements for AJAX funtions - */ - optionBuilder: function optionBuilder(data) { - var options_html = ""; - jQuery.each(data.field_data, function (i, field) { - options_html += ""; - }); - return options_html; - }, - - /** - * AJAX Update: "Field" - ACF Field group's field - * - "Field" refers to the 3rd dropdown of the component fields top level - * - After selecting the field group from the 2nd dropdown, call WP_AJAX to get the relevent fields from the group selected and populate the 3rd dropdown (aka "Field") - * - * @param {string} component - ID without the "#" of the component parent row - * @param {string} field_name - Parent field name/key of the sub fields, should be a repeater - * @param {object} saved_fields - OPTIONAL: Pass saved subfields if you want to set pre-existing values - */ - updateAjax_Field: function updateAjax_Field(component, field_name, saved_fields) { - saved_fields = typeof saved_fields !== 'undefined' ? saved_fields : ""; - var $this = this; - - // Update UI - jQuery('#' + component + ' .wp-type-field-select ~ span.select2').addClass('ajax-disabled'); - // Get Updated Data - jQuery.post(window.ajaxurl, { - action: 'gc_component_subfields', - subfields_data: { - name: field_name - } - }, function (response) { - // Update UI - jQuery('#' + component + ' .wp-type-field-select ~ span.select2').removeClass('ajax-disabled'); - - // SUCCESS - if (response.success) { - // Ensure response has subfield data - if (response.data.field_data && response.data.field_data.length) { - // Build options HTML: - var options_html = $this.optionBuilder(response.data); - // Inject into select fields - jQuery('#' + component).find('.wp-type-field-select').html(options_html); - - // If existing subfields are passed, update specific dropdown options - if (saved_fields) { - jQuery('#' + component).find('.wp-type-field-select').val(saved_fields); - } + if (valField && !this.metaKeys.getByField(valField)) { + this.metaKeys.add({field: valField}); } - } - // ERROR - else { - window.alert('Please refresh and try again. If the issue persists, reach out to support'); + if (valSubfields && !this.metaKeys.getBySubfields(valSubfields)) { + this.metaKeys.add({subfields: valSubfields}); } - }); - }, - - /** - * AJAX Update: "Subfields" - ACF Field group's repeater subfields - * - "Subfields" are in the component accordion - * - After selecting the field group from the 3rd dropdown, call WP_AJAX to get the relevent subfields from the ACF Repeater selected and populate the subfields - * - * @param {string} component - ID without the "#" of the component parent row - * @param {string} field_name - Parent field name/key of the sub fields, should be a repeater - * @param {object} saved_fields - OPTIONAL: Pass saved subfields if you want to set pre-existing values - */ - updateAjax_ComponentSubfields: function updateAjax_ComponentSubfields(component, field_name, saved_fields) { - saved_fields = typeof saved_fields !== 'undefined' ? saved_fields : {}; - var $this = this; - - // Update UI - jQuery('#' + component + ' .component-table-inner').find('select').addClass('ajax-disabled'); - // Get Updated Data - jQuery.post(window.ajaxurl, { - action: 'gc_component_subfields', - subfields_data: { - name: field_name - } - }, function (response) { - // Update UI - jQuery('#' + component + ' .component-table-inner').find('select').removeClass('ajax-disabled'); - - // SUCCESS - if (response.success) { - // Ensure response has subfield data - if (response.data.field_data && response.data.field_data.length) { - // Build options HTML: - var options_html = $this.optionBuilder(response.data); - // Inject into select fields - jQuery('#' + component).find('.component-table-inner select').html(options_html); - - // If existing subfields are passed, update specific dropdown options - if (Object.keys(saved_fields).length) { - var dropdowns = jQuery('#' + component).find('.component-table-inner select').toArray(); - jQuery.each(dropdowns, function (i, dropdown) { - i++; - jQuery(dropdown).val(saved_fields[i]); - }); + + // Init subfields + if (valField) { + component = this.model.get('name'); + if (valSubfields) { + this.updateAjax_ComponentSubfields(component, valField, valSubfields); } } - } - // ERROR - else { - window.alert('Please refresh and try again. If the issue persists, reach out to support'); - } - }); - }, - - /** - * Init - */ - render: function render() { - var val = this.model.get('field_value'); - var valField = this.model.get('field_field'); - var valSubfields = this.model.get('field_subfields'); - var component; - - if (val && !this.metaKeys.getByValue(val)) { - this.metaKeys.add({ value: val }); - } - if (valField && !this.metaKeys.getByField(valField)) { - this.metaKeys.add({ field: valField }); - } - if (valSubfields && !this.metaKeys.getBySubfields(valSubfields)) { - this.metaKeys.add({ subfields: valSubfields }); - } - // Init subfields - if (valField) { - component = this.model.get('name'); - if (valSubfields) { - this.updateAjax_ComponentSubfields(component, valField, valSubfields); - } - } + var json = this.model.toJSON(); + json.metaKeys = this.metaKeys.toJSON(); - var json = this.model.toJSON(); - json.metaKeys = this.metaKeys.toJSON(); + this.$el.html(this.template(json)); - this.$el.html(this.template(json)); + this.$('.gc-select2').each(function () { + var $this = jQuery(this); + var args = { + width: '250px' + }; - this.$('.gc-select2').each(function () { - var $this = jQuery(this); - var args = { - width: '250px' - }; + if ($this.hasClass('gc-select2-add-new')) { + args.tags = true; + } + + $this.select2(args); + }); - if ($this.hasClass('gc-select2-add-new')) { - args.tags = true; + return this; } - $this.select2(args); }); + }; - return this; - } - - }); -}; - -},{}],15:[function(require,module,exports){ -'use strict'; + }, {}], + 15: [function (require, module, exports) { + 'use strict'; -module.exports = function (app) { - return app.views.statusSelect2.extend({ - template: wp.template('gc-tab-wrapper'), + module.exports = function (app) { + return app.views.statusSelect2.extend({ + template: wp.template('gc-tab-wrapper'), - tagName: 'fieldset', + tagName: 'fieldset', - id: function id() { - return this.model.get('id'); - }, + id: function id() { + return this.model.get('id'); + }, - className: function className() { - return 'gc-template-tab ' + (this.model.get('hidden') ? 'hidden' : ''); - }, + className: function className() { + return 'gc-template-tab ' + (this.model.get('hidden') ? 'hidden' : ''); + }, - render: function render() { - this.$el.html(this.template(this.model.toJSON())); + render: function render() { + this.$el.html(this.template(this.model.toJSON())); - var rendered = this.getRenderedModels(app.views.tabRow, this.model.rows); + var rendered = this.getRenderedModels(app.views.tabRow, this.model.rows); - this.$el.find('tbody').html(rendered); + this.$el.find('tbody').html(rendered); - return this; - } - }); -}; + return this; + } + }); + }; -},{}],16:[function(require,module,exports){ -'use strict'; + }, {}], + 16: [function (require, module, exports) { + 'use strict'; -module.exports = function (app, $, gc) { - return app.views.base.extend({ - initial: gc._initial, - el: '#mapping-tabs', + module.exports = function (app, $, gc) { + return app.views.base.extend({ + initial: gc._initial, + el: '#mapping-tabs', - template: wp.template('gc-tabs-wrapper'), + template: wp.template('gc-tabs-wrapper'), - events: { - 'click .nav-tab': 'tabClick', - 'click .nav-tab-link': 'triggerClick' - }, + events: { + 'click .nav-tab': 'tabClick', + 'click .nav-tab-link': 'triggerClick' + }, - initialize: function initialize() { - this.listenTo(this.collection, 'render', this.render); - this.listenTo(this, 'render', this.render); - this.listenTo(this, 'saveEnabled', this.enableSave); - this.listenTo(this, 'saveDisabled', this.disableSave); + initialize: function initialize() { + this.listenTo(this.collection, 'render', this.render); + this.listenTo(this, 'render', this.render); + this.listenTo(this, 'saveEnabled', this.enableSave); + this.listenTo(this, 'saveDisabled', this.disableSave); - if (this.initial) { - // Listen for initialization - this.listenTo(this.collection, 'change:post_type', this.initMapping); - } + if (this.initial) { + // Listen for initialization + this.listenTo(this.collection, 'change:post_type', this.initMapping); + } - this.defaultTab = this.collection.getById('mapping-defaults'); - this.render(); + this.defaultTab = this.collection.getById('mapping-defaults'); + this.render(); - if (!this.initial && gc._pointers.refresh_connection) { - window.setTimeout((function () { - this.pointer($('.submit .gc-refresh-connection'), 'refresh_connection', { - position: { - edge: 'top' - } - }); + if (!this.initial && gc._pointers.refresh_connection) { + window.setTimeout((function () { + this.pointer($('.submit .gc-refresh-connection'), 'refresh_connection', { + position: { + edge: 'top' + } + }); - $('.gc-wp-pointer.refresh_connection').css({ 'margin-left': '-41px' }); - }).bind(this), 500); - } - }, + $('.gc-wp-pointer.refresh_connection').css({'margin-left': '-41px'}); + }).bind(this), 500); + } + }, - initMapping: function initMapping() { - this.initial = false; + initMapping: function initMapping() { + this.initial = false; - this.stopListening(this.collection, 'change:post_type', this.initMapping); - this.listenTo(this.collection, 'rowChange', this.triggerSaveEnabled); + this.stopListening(this.collection, 'change:post_type', this.initMapping); + this.listenTo(this.collection, 'rowChange', this.triggerSaveEnabled); - this.defaultTab.set('initial', this.initial); - this.render(); + this.defaultTab.set('initial', this.initial); + this.render(); - if (gc._tabs && gc._tabs.length > 0) { - var firstTabId = gc._tabs[0].id; - if (firstTabId) { - this.setTab(firstTabId); - this.$('.nav-tab[href="#' + firstTabId + '"]').trigger('click'); - } - } + if (gc._tabs && gc._tabs.length > 0) { + var firstTabId = gc._tabs[0].id; + if (firstTabId) { + this.setTab(firstTabId); + this.$('.nav-tab[href="#' + firstTabId + '"]').trigger('click'); + } + } - if (gc._pointers.select_tab_how_to) { - this.pointer('.gc-nav-tab-wrapper-bb', 'select_tab_how_to'); - this.pointer('#gc-status-mappings', 'map_status_how_to'); - } - }, + if (gc._pointers.select_tab_how_to) { + this.pointer('.gc-nav-tab-wrapper-bb', 'select_tab_how_to'); + this.pointer('#gc-status-mappings', 'map_status_how_to'); + } + }, - triggerSaveEnabled: function triggerSaveEnabled(model) { - if (model.changed.field_value) { - this.trigger('saveEnabled'); - this.stopListening(this.collection, 'rowChange'); - } - }, + triggerSaveEnabled: function triggerSaveEnabled(model) { + if (model.changed.field_value) { + this.trigger('saveEnabled'); + this.stopListening(this.collection, 'rowChange'); + } + }, - triggerClick: function triggerClick(evt) { - evt.preventDefault(); + triggerClick: function triggerClick(evt) { + evt.preventDefault(); - this.$('.nav-tab[href="' + $(evt.target).attr('href') + '"]').trigger('click'); - }, + this.$('.nav-tab[href="' + $(evt.target).attr('href') + '"]').trigger('click'); + }, - tabClick: function tabClick(evt) { - evt.preventDefault(); - this.setTab($(evt.target).attr('href').substring(1)); - this.render(); - }, + tabClick: function tabClick(evt) { + evt.preventDefault(); + this.setTab($(evt.target).attr('href').substring(1)); + this.render(); + }, - setTab: function setTab(id) { - this.$el.attr('class', id); - this.collection.invoke('set', { 'hidden': true }); - this.collection.getById(id).set('hidden', false); - }, + setTab: function setTab(id) { + this.$el.attr('class', id); + this.collection.invoke('set', {'hidden': true}); + this.collection.getById(id).set('hidden', false); + }, - render: function render() { - this.$('.gc-select2').each(function () { - $(this).select2('destroy'); - }); + render: function render() { + this.$('.gc-select2').each(function () { + $(this).select2('destroy'); + }); - this.$el.html(this.template()); + this.$el.html(this.template()); - // Add tab links - this.renderNav(); + // Add tab links + this.renderNav(); - // Add tab content - this.renderTabs(); + // Add tab content + this.renderTabs(); - if (this.initial) { - this.renderInitial(); - } + if (this.initial) { + this.renderInitial(); + } - return this; - }, + return this; + }, - renderNav: function renderNav() { - var toAppend; + renderNav: function renderNav() { + var toAppend; - if (this.initial) { - this.setTab(this.defaultTab.get('id')); - toAppend = new app.views.tabLink({ model: this.defaultTab }).render().el; - } else { - toAppend = this.getRenderedModels(app.views.tabLink); - } + if (this.initial) { + this.setTab(this.defaultTab.get('id')); + toAppend = new app.views.tabLink({model: this.defaultTab}).render().el; + } else { + toAppend = this.getRenderedModels(app.views.tabLink); + } - this.$el.find('.nav-tab-wrapper').append(toAppend); - }, + this.$el.find('.nav-tab-wrapper').append(toAppend); + }, - renderTabs: function renderTabs() { - var frag = document.createDocumentFragment(); - if (this.initial) { + renderTabs: function renderTabs() { + var frag = document.createDocumentFragment(); + if (this.initial) { - this.defaultTab.set('initial', this.initial); - var view = new app.views.defaultTab({ model: this.defaultTab }); - frag.appendChild(view.render().el); - } else { + this.defaultTab.set('initial', this.initial); + var view = new app.views.defaultTab({model: this.defaultTab}); + frag.appendChild(view.render().el); + } else { - this.collection.each(function (model) { - var viewid = 'mapping-defaults' === model.get('id') ? 'defaultTab' : 'tab'; - var view = new app.views[viewid]({ model: model }); + this.collection.each(function (model) { + var viewid = 'mapping-defaults' === model.get('id') ? 'defaultTab' : 'tab'; + var view = new app.views[viewid]({model: model}); - frag.appendChild(view.render().el); - }); - } + frag.appendChild(view.render().el); + }); + } - this.$el.find('.gc-template-tab-group').append(frag); - }, + this.$el.find('.gc-template-tab-group').append(frag); + }, - renderInitial: function renderInitial() { - // Show the "select post-type" pointer. - this.pointer('[data-column="post_type"]', 'select_type', { - dismissable: false, - position: { - edge: 'bottom', - align: 'left' - } - }); + renderInitial: function renderInitial() { + // Show the "select post-type" pointer. + this.pointer('[data-column="post_type"]', 'select_type', { + dismissable: false, + position: { + edge: 'bottom', + align: 'left' + } + }); - this.trigger('saveDisabled'); - }, + this.trigger('saveDisabled'); + }, - enableSave: function enableSave() { - // Enable save button. - $('.submit .button-primary').prop('disabled', false); - }, + enableSave: function enableSave() { + // Enable save button. + $('.submit .button-primary').prop('disabled', false); + }, - disableSave: function disableSave() { - // Disable save button. - $('.submit .button-primary').prop('disabled', true); - }, + disableSave: function disableSave() { + // Disable save button. + $('.submit .button-primary').prop('disabled', true); + }, - pointer: function pointer($selector, key, args) { - args = args || {}; - var defaults = { - content: gc._pointers[key], - pointerClass: 'wp-pointer gc-wp-pointer ' + key - }; + pointer: function pointer($selector, key, args) { + args = args || {}; + var defaults = { + content: gc._pointers[key], + pointerClass: 'wp-pointer gc-wp-pointer ' + key + }; - if (false !== args.dismissable) { - defaults.close = function () { - $.post(window.ajaxurl, { - pointer: 'gc_' + key, - action: 'dismiss-wp-pointer' - }); - }; - } + if (false !== args.dismissable) { + defaults.close = function () { + $.post(window.ajaxurl, { + pointer: 'gc_' + key, + action: 'dismiss-wp-pointer' + }); + }; + } - if (args.position) { - defaults.position = args.position; - } + if (args.position) { + defaults.position = args.position; + } - $selector = $selector instanceof jQuery ? $selector : this.$($selector); - return $selector.pointer(defaults).pointer('open'); - } + $selector = $selector instanceof jQuery ? $selector : this.$($selector); + return $selector.pointer(defaults).pointer('open'); + } - }); -}; + }); + }; -},{}]},{},[5]); + }, {}] +}, {}, [5]); diff --git a/assets/js/gathercontent-single.js b/assets/js/gathercontent-single.js index 20115d17..88a44a09 100644 --- a/assets/js/gathercontent-single.js +++ b/assets/js/gathercontent-single.js @@ -1,774 +1,815 @@ /** * Content Workflow (by Bynder) - v1.0.0 - 2024-06-05 - * + * * * Copyright (c) 2024 Content Workflow (by Bynder) * Licensed under the GPLv2 license. */ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0 && this.get('mapping') > 0; - }, - - _get_canPush: function _get_canPush(value) { - return this.get('mapping') > 0; - }, - - _get_mappingLink: function _get_mappingLink(value) { - if ('failed' === Backbone.Model.prototype.get.call(this, 'mappingStatus')) { - value += '&sync-items=1'; +(function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var a = typeof require == "function" && require; + if (!u && a) return a(o, !0); + if (i) return i(o, !0); + var f = new Error("Cannot find module '" + o + "'"); + throw f.code = "MODULE_NOT_FOUND", f } - return value; - }, - - _get_mappingStatus: function _get_mappingStatus(value) { - return gc._statuses[value] ? gc._statuses[value] : ''; - }, - - _get_mappingStatusId: function _get_mappingStatusId(value) { - return Backbone.Model.prototype.get.call(this, 'mappingStatus'); - } - })); -}; - -},{"./../models/modify-json.js":4}],6:[function(require,module,exports){ -'use strict'; - -window.GatherContent = window.GatherContent || {}; - -(function (window, document, $, gc, undefined) { - 'use strict'; - - gc.single = gc.single || {}; - var app = gc.single; - - // Initiate base objects. - require('./initiate-objects.js')(app); - - /* - * Posts - */ - - app.models.post = require('./models/post.js')(gc); - app.views.statusSelect2 = require('./views/status-select2.js')(app); - - app.init = function () { - if (gc._post.mapping) { - app.views.metabox = require('./views/metabox.js')(app, $, gc); - app.metaboxView = new app.views.metabox({ - model: new app.models.post(gc._post) - }); - } else { - app.views.metabox = require('./views/mapping-metabox.js')(app, $, gc); - app.metaboxView = new app.views.metabox({ - model: new app.models.post(gc._post) - }); - app.metaboxView.on('complete', app.reinit); - } - }; - - app.reinit = function (model) { - app.metaboxView.unbind(); - if (app.metaboxView.onClose) { - app.metaboxView.onClose(); - } - - app.views.metabox = require('./views/metabox.js')(app, $, gc); - app.metaboxView = new app.views.metabox({ - model: model - }); - }; - - // Kick it off. - $(app.init); -})(window, document, jQuery, window.GatherContent); - -},{"./initiate-objects.js":2,"./models/post.js":5,"./views/mapping-metabox.js":8,"./views/metabox.js":11,"./views/status-select2.js":12}],7:[function(require,module,exports){ -'use strict'; - -module.exports = Backbone.View.extend({ - toggleExpanded: function toggleExpanded(evt) { - this.model.set('expanded', !this.model.get('expanded')); - }, - - getRenderedModels: function getRenderedModels(View, models) { - models = models || this.collection; - var addedElements = document.createDocumentFragment(); - - models.each(function (model) { - var view = new View({ model: model }).render(); - addedElements.appendChild(view.el); - }); - - return addedElements; - }, - - render: function render() { - this.$el.html(this.template(this.model.toJSON())); - return this; - }, - - close: function close() { - this.remove(); - this.unbind(); - if (this.onClose) { - this.onClose(); + var l = n[o] = {exports: {}}; + t[o][0].call(l.exports, function (e) { + var n = t[o][1][e]; + return s(n ? n : e) + }, l, l.exports, e, t, n, r) } + return n[o].exports } -}); - -},{}],8:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, $, gc) { - var thisView; - var base = require('./../views/metabox-base.js')(app, $, gc); - return base.extend({ - template: wp.template('gc-mapping-metabox'), - stepArgs: false, - events: { - 'click #gc-map': 'step', - 'change #select-gc-next-step': 'setProperty', - 'click #gc-map-cancel': 'cancel' - }, - - initialize: function initialize() { - thisView = this; - this.listenTo(this.model, 'change:waiting', this.toggleWaitingRender); - this.listenTo(this.model, 'change', this.maybeEnableAndRender); - this.listenTo(this.model, 'change:step', this.changeStep); - this.listenTo(this, 'cancel', this.resetAndRender); - this.render(); - this.$el.removeClass('no-js').addClass('gc-mapping-metabox'); - }, - - changeStep: function changeStep(model) { - if ('accounts' === model.changed.step) { - this.$el.addClass('gc-mapping-started'); - } - - if (model.changed.step) { - this.stepArgs = this['step_' + model.changed.step](); - } - }, - - setProperty: function setProperty(evt) { - var value = $(evt.target).val(); - - this.model.set(this.stepArgs.property, value); - if ('account' === this.stepArgs.property || 'project' === this.stepArgs.property) { - // Autoclick "next" for user. - this.step(); + var i = typeof require == "function" && require; + for (var o = 0; o < r.length; o++) s(r[o]); + return s +})({ + 1: [function (require, module, exports) { + 'use strict'; + + module.exports = Backbone.Collection.extend({ + getById: function getById(id) { + return this.find(function (model) { + var modelId = model.get('id'); + return modelId === id || modelId && id && modelId == id; + }); } - }, - - setMapping: function setMapping() { - var success = function success(data) { - this.model.set('waiting', false); - - // Goodbye - this.trigger('complete', this.model, data); - }; + }); - this.ajax({ - action: 'gc_save_mapping_id' - }, success, this.failMsg); - }, + }, {}], + 2: [function (require, module, exports) { + 'use strict'; - maybeEnableAndRender: function maybeEnableAndRender(model) { - if (model.changed.account || model.changed.project || model.changed.mapping) { - this.model.set('btnDisabled', false); - this.render(); - } - }, + module.exports = function (app) { + app.models = {base: require('./models/base.js')}; + app.collections = {base: require('./collections/base.js')}; + app.views = {base: require('./views/base.js')}; + }; - toggleWaitingRender: function toggleWaitingRender(model) { - if (model.changed.waiting) { - this.model.set('btnDisabled', true); - } - this.render(); - }, + }, {"./collections/base.js": 1, "./models/base.js": 3, "./views/base.js": 7}], + 3: [function (require, module, exports) { + "use strict"; - step: function step() { - this.model.set('waiting', true); - - if ('mapping' === this.stepArgs.property) { - return this.setMapping(); + module.exports = Backbone.Model.extend({ + sync: function sync() { + return false; } + }); - this.setStep(); - - var properties = this.model.get(this.stepArgs.properties); - - if (properties && properties.length) { - - this.successHandler(properties); - } else { + }, {}], + 4: [function (require, module, exports) { + 'use strict'; - this.ajax({ - action: 'gc_wp_filter_mappings', - property: this.stepArgs.property - }, this.successHandler, this.failMsg); - } + module.exports = function (model) { - return this; - }, - - failMsg: function failMsg(msg) { - msg = 'string' === typeof msg ? msg : gc._errors.unknown; - window.alert(msg); - thisView.model.set('waiting', false); - }, + model.prototype._get = function (value, attribute) { + if (this['_get_' + attribute]) { + value = this['_get_' + attribute](value); + } + return value; + }; - successHandler: function successHandler(objects) { - this.model.set(this.stepArgs.properties, objects); - if (objects.length < 2) { - this.model.set('btnDisabled', false); - } - this.model.set('waiting', false); - }, + model.prototype.get = function (attribute) { + return this._get(Backbone.Model.prototype.get.call(this, attribute), attribute); + }; - setStep: function setStep() { - if (!this.model.get('step')) { - return this.model.set('step', 'accounts'); - } + // hijack the toJSON method and overwrite the data that is sent back to the view. + model.prototype.toJSON = function () { + return _.mapObject(Backbone.Model.prototype.toJSON.call(this), _.bind(this._get, this)); + }; - if ('accounts' === this.model.get('step')) { - return this.model.set('step', 'projects'); - } + return model; + }; + + }, {}], + 5: [function (require, module, exports) { + 'use strict'; + + module.exports = function (gc) { + return require('./../models/modify-json.js')(Backbone.Model.extend({ + defaults: { + id: 0, + item: 0, + itemName: '', + updated_at: '', + current: true, + editLink: '', + mapping: 0, + mappingName: '', + mappingLink: '', + mappingStatus: '', + mappingStatusId: '', + status: {}, + checked: false, + disabled: false, + canPull: false, + canPush: false, + statuses: [], + statusesChecked: false, + ptLabel: false + }, + + searchAttributes: ['itemName', 'mappingName', 'post_title'], + + url: function url() { + var url = window.ajaxurl + '?action=gc_fetch_js_post&id=' + this.get('id'); + if (this.get('uncached')) { + this.set('uncached', false); + url += '&flush_cache=force'; + } + return url; + }, + + _get_disabled: function _get_disabled(value) { + return !this.get('mapping'); + }, + + _get_canPull: function _get_canPull(value) { + return this.get('item') > 0 && this.get('mapping') > 0; + }, + + _get_canPush: function _get_canPush(value) { + return this.get('mapping') > 0; + }, + + _get_mappingLink: function _get_mappingLink(value) { + if ('failed' === Backbone.Model.prototype.get.call(this, 'mappingStatus')) { + value += '&sync-items=1'; + } + return value; + }, + + _get_mappingStatus: function _get_mappingStatus(value) { + return gc._statuses[value] ? gc._statuses[value] : ''; + }, + + _get_mappingStatusId: function _get_mappingStatusId(value) { + return Backbone.Model.prototype.get.call(this, 'mappingStatus'); + } + })); + }; - if ('projects' === this.model.get('step')) { - return this.model.set('step', 'mappings'); - } - }, + }, {"./../models/modify-json.js": 4}], + 6: [function (require, module, exports) { + 'use strict'; - step_accounts: function step_accounts() { - return { - property: 'account', - properties: 'accounts' - }; - }, + window.GatherContent = window.GatherContent || {}; - step_projects: function step_projects() { - return { - property: 'project', - properties: 'projects' - }; - }, + (function (window, document, $, gc, undefined) { + 'use strict'; - step_mappings: function step_mappings() { - return { - property: 'mapping', - properties: 'mappings' - }; - }, - - cancel: function cancel(evt) { - this.trigger('cancel', evt); - }, - - resetModel: function resetModel() { - this.stepArgs = false; - this.model.set({ - 'step': false, - 'account': 0, - 'project': 0, - 'mapping': 0 - }); - return this.model; - }, - - resetAndRender: function resetAndRender() { - this.resetModel(); - this.render(); - }, - - render: function render() { - var json = this.model.toJSON(); - if (this.stepArgs) { - json.label = gc._step_labels[json.step]; - json.property = this.stepArgs.property; - } - this.$el.html(this.template(json)); - return this; - } + gc.single = gc.single || {}; + var app = gc.single; - }); -}; + // Initiate base objects. + require('./initiate-objects.js')(app); -},{"./../views/metabox-base.js":9}],9:[function(require,module,exports){ -'use strict'; + /* + * Posts + */ -module.exports = function (app, $, gc) { - return app.views.base.extend({ - el: '#gc-related-data', + app.models.post = require('./models/post.js')(gc); + app.views.statusSelect2 = require('./views/status-select2.js')(app); - ajax: function ajax(args, successcb, failcb) { - var view = this; - var success = function success(response) { - if (response.success) { - successcb.call(view, response.data); - } else if (failcb) { - failcb.call(view, response.data); + app.init = function () { + if (gc._post.mapping) { + app.views.metabox = require('./views/metabox.js')(app, $, gc); + app.metaboxView = new app.views.metabox({ + model: new app.models.post(gc._post) + }); + } else { + app.views.metabox = require('./views/mapping-metabox.js')(app, $, gc); + app.metaboxView = new app.views.metabox({ + model: new app.models.post(gc._post) + }); + app.metaboxView.on('complete', app.reinit); } }; - var promise = $.post(window.ajaxurl, $.extend({ - action: '', - post: this.model.toJSON(), - nonce: gc.$id('gc-edit-nonce').val(), - flush_cache: gc.queryargs.flush_cache ? 1 : 0 - }, args), success); + app.reinit = function (model) { + app.metaboxView.unbind(); + if (app.metaboxView.onClose) { + app.metaboxView.onClose(); + } - if (failcb) { - promise.fail(function () { - failcb.call(view); + app.views.metabox = require('./views/metabox.js')(app, $, gc); + app.metaboxView = new app.views.metabox({ + model: model }); - } - - return promise; - } - }); -}; - -},{}],10:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, $, gc) { - var thisView; - return app.views.statusSelect2.extend({ - className: 'misc-pub-section', - select2template: wp.template('gc-status-select2'), - template: wp.template('gc-metabox-statuses'), - isOpen: false, - rendered: false, - - initialize: function initialize() { - thisView = this; - this.listenTo(this, 'render', this.render); - this.listenTo(this, 'statusesOpen', this.statusesOpen); - this.listenTo(this, 'statusesClose', this.statusesClose); - }, - - statusesOpen: function statusesOpen() { - this.isOpen = true; - if (!this.model.get('statusesChecked')) { - this.asyncInit(); - } - this.$('.edit-gc-status').addClass('hidden'); - this.$('#gc-post-status-select').slideDown('fast' /*, function() { - thisView.$( '#gc-set-status' ).focus(); - }*/); - }, - - statusesClose: function statusesClose() { - this.isOpen = false; - this.$('.edit-gc-status').removeClass('hidden'); - this.$('#gc-post-status-select').slideUp('fast'); - }, - - asyncInit: function asyncInit() { - this.rendered = false; - $.post(window.ajaxurl, { - action: 'gc_get_post_statuses', - postId: this.model.get('id'), - flush_cache: gc.queryargs.flush_cache ? 1 : 0 - }, this.ajaxResponse.bind(this)).done(function () { - thisView.firstToRender(); - }).fail(function () { - thisView.model.set('statusesChecked', false); - }); - - this.model.set('statusesChecked', true); - }, - - ajaxResponse: function ajaxResponse(response) { - if (!response.data || !response.success) { - this.model.set('statusesChecked', false); - return; - } - - this.model.set('statusesChecked', true); - this.model.set('statuses', response.data.statuses); + }; - if (this.model.get('statuses').length) { - thisView.$('.gc-select2').each(function () { - $(this).select2('destroy'); + // Kick it off. + $(app.init); + })(window, document, jQuery, window.GatherContent); + + }, { + "./initiate-objects.js": 2, + "./models/post.js": 5, + "./views/mapping-metabox.js": 8, + "./views/metabox.js": 11, + "./views/status-select2.js": 12 + }], + 7: [function (require, module, exports) { + 'use strict'; + + module.exports = Backbone.View.extend({ + toggleExpanded: function toggleExpanded(evt) { + this.model.set('expanded', !this.model.get('expanded')); + }, + + getRenderedModels: function getRenderedModels(View, models) { + models = models || this.collection; + var addedElements = document.createDocumentFragment(); + + models.each(function (model) { + var view = new View({model: model}).render(); + addedElements.appendChild(view.el); }); - thisView.firstToRender(); - } - }, + return addedElements; + }, - firstToRender: function firstToRender() { - if (!thisView.rendered) { - thisView.renderStatuses(); - thisView.rendered = true; - } - }, + render: function render() { + this.$el.html(this.template(this.model.toJSON())); + return this; + }, - renderStatuses: function renderStatuses() { - var postId = this.model.get('id'); - this.$('#gc-status-selec2').html(this.select2template(this.model.toJSON())); - if (this.model.get('statuses').length) { - this.renderSelect2(this.$el); + close: function close() { + this.remove(); + this.unbind(); + if (this.onClose) { + this.onClose(); + } } - }, + }); - render: function render() { - this.$el.html(this.template(this.model.toJSON())); - if (this.model.get('statusesChecked')) { - thisView.renderStatuses(); - } - return this; - } + }, {}], + 8: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + var thisView; + var base = require('./../views/metabox-base.js')(app, $, gc); + return base.extend({ + template: wp.template('gc-mapping-metabox'), + stepArgs: false, + events: { + 'click #gc-map': 'step', + 'change #select-gc-next-step': 'setProperty', + 'click #gc-map-cancel': 'cancel' + }, + + initialize: function initialize() { + thisView = this; + this.listenTo(this.model, 'change:waiting', this.toggleWaitingRender); + this.listenTo(this.model, 'change', this.maybeEnableAndRender); + this.listenTo(this.model, 'change:step', this.changeStep); + this.listenTo(this, 'cancel', this.resetAndRender); + this.render(); + this.$el.removeClass('no-js').addClass('gc-mapping-metabox'); + }, + + changeStep: function changeStep(model) { + if ('accounts' === model.changed.step) { + this.$el.addClass('gc-mapping-started'); + } + + if (model.changed.step) { + this.stepArgs = this['step_' + model.changed.step](); + } + }, + + setProperty: function setProperty(evt) { + var value = $(evt.target).val(); + + this.model.set(this.stepArgs.property, value); + + if ('account' === this.stepArgs.property || 'project' === this.stepArgs.property) { + // Autoclick "next" for user. + this.step(); + } + }, + + setMapping: function setMapping() { + var success = function success(data) { + this.model.set('waiting', false); + + // Goodbye + this.trigger('complete', this.model, data); + }; + + this.ajax({ + action: 'gc_save_mapping_id' + }, success, this.failMsg); + }, + + maybeEnableAndRender: function maybeEnableAndRender(model) { + if (model.changed.account || model.changed.project || model.changed.mapping) { + this.model.set('btnDisabled', false); + this.render(); + } + }, + + toggleWaitingRender: function toggleWaitingRender(model) { + if (model.changed.waiting) { + this.model.set('btnDisabled', true); + } + this.render(); + }, + + step: function step() { + this.model.set('waiting', true); + + if ('mapping' === this.stepArgs.property) { + return this.setMapping(); + } + + this.setStep(); + + var properties = this.model.get(this.stepArgs.properties); + + if (properties && properties.length) { + + this.successHandler(properties); + } else { + + this.ajax({ + action: 'gc_wp_filter_mappings', + property: this.stepArgs.property + }, this.successHandler, this.failMsg); + } + + return this; + }, + + failMsg: function failMsg(msg) { + msg = 'string' === typeof msg ? msg : gc._errors.unknown; + window.alert(msg); + thisView.model.set('waiting', false); + }, + + successHandler: function successHandler(objects) { + this.model.set(this.stepArgs.properties, objects); + if (objects.length < 2) { + this.model.set('btnDisabled', false); + } + this.model.set('waiting', false); + }, + + setStep: function setStep() { + if (!this.model.get('step')) { + return this.model.set('step', 'accounts'); + } + + if ('accounts' === this.model.get('step')) { + return this.model.set('step', 'projects'); + } + + if ('projects' === this.model.get('step')) { + return this.model.set('step', 'mappings'); + } + }, + + step_accounts: function step_accounts() { + return { + property: 'account', + properties: 'accounts' + }; + }, + + step_projects: function step_projects() { + return { + property: 'project', + properties: 'projects' + }; + }, + + step_mappings: function step_mappings() { + return { + property: 'mapping', + properties: 'mappings' + }; + }, + + cancel: function cancel(evt) { + this.trigger('cancel', evt); + }, + + resetModel: function resetModel() { + this.stepArgs = false; + this.model.set({ + 'step': false, + 'account': 0, + 'project': 0, + 'mapping': 0 + }); + return this.model; + }, + + resetAndRender: function resetAndRender() { + this.resetModel(); + this.render(); + }, + + render: function render() { + var json = this.model.toJSON(); + if (this.stepArgs) { + json.label = gc._step_labels[json.step]; + json.property = this.stepArgs.property; + } + this.$el.html(this.template(json)); + return this; + } - }); -}; - -},{}],11:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, $, gc) { - var thisView; - var base = require('./../views/metabox-base.js')(app, $, gc); - var StatusesView = require('./../views/metabox-statuses.js')(app, $, gc); - - return base.extend({ - template: wp.template('gc-metabox'), - statusesView: null, - timeoutID: null, - events: { - 'click .edit-gc-status': 'editStatus', - 'click .cancel-gc-status': 'cancelEditStatus', - 'click .save-gc-status': 'saveStatus', - 'click #gc-pull': 'pull', - 'click #gc-push': 'push', - 'click #gc-disconnect': 'disconnect' - }, - - initialize: function initialize() { - thisView = this; - this.listenTo(this.model, 'change:status', this.renderStatusView); - this.listenTo(this.model, 'change:mappingStatus', this.render); - this.listenTo(this.model, 'render', this.render); - - this.statusesView = new StatusesView({ - model: this.model }); - - this.render(); - this.$el.removeClass('no-js'); - - this.refreshData(); - }, - - refreshData: function refreshData() { - // Trigger an un-cached update for the item data - this.model.set('uncached', true); - this.model.fetch().done(function (data) { - if (!thisView.statusesView.isOpen) { - thisView.render(); + }; + + }, {"./../views/metabox-base.js": 9}], + 9: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + return app.views.base.extend({ + el: '#gc-related-data', + + ajax: function ajax(args, successcb, failcb) { + var view = this; + var success = function success(response) { + if (response.success) { + successcb.call(view, response.data); + } else if (failcb) { + failcb.call(view, response.data); + } + }; + + var promise = $.post(window.ajaxurl, $.extend({ + action: '', + post: this.model.toJSON(), + nonce: gc.$id('gc-edit-nonce').val(), + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, args), success); + + if (failcb) { + promise.fail(function () { + failcb.call(view); + }); + } + + return promise; } }); - }, - - updateModel: function updateModel(data) { - var id = this.model.get('id'); - if (id in data) { - if (data[id].status) { - this.model.set('status', data[id].status); - } - if (data[id].itemName) { - this.model.set('itemName', data[id].itemName); - } - if (data[id].updated_at) { - this.model.set('updated_at', data[id].updated_at); + }; + + }, {}], + 10: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + var thisView; + return app.views.statusSelect2.extend({ + className: 'misc-pub-section', + select2template: wp.template('gc-status-select2'), + template: wp.template('gc-metabox-statuses'), + isOpen: false, + rendered: false, + + initialize: function initialize() { + thisView = this; + this.listenTo(this, 'render', this.render); + this.listenTo(this, 'statusesOpen', this.statusesOpen); + this.listenTo(this, 'statusesClose', this.statusesClose); + }, + + statusesOpen: function statusesOpen() { + this.isOpen = true; + if (!this.model.get('statusesChecked')) { + this.asyncInit(); + } + this.$('.edit-gc-status').addClass('hidden'); + this.$('#gc-post-status-select').slideDown('fast' /*, function() { + thisView.$( '#gc-set-status' ).focus(); + }*/); + }, + + statusesClose: function statusesClose() { + this.isOpen = false; + this.$('.edit-gc-status').removeClass('hidden'); + this.$('#gc-post-status-select').slideUp('fast'); + }, + + asyncInit: function asyncInit() { + this.rendered = false; + $.post(window.ajaxurl, { + action: 'gc_get_post_statuses', + postId: this.model.get('id'), + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, this.ajaxResponse.bind(this)).done(function () { + thisView.firstToRender(); + }).fail(function () { + thisView.model.set('statusesChecked', false); + }); + + this.model.set('statusesChecked', true); + }, + + ajaxResponse: function ajaxResponse(response) { + if (!response.data || !response.success) { + this.model.set('statusesChecked', false); + return; + } + + this.model.set('statusesChecked', true); + this.model.set('statuses', response.data.statuses); + + if (this.model.get('statuses').length) { + thisView.$('.gc-select2').each(function () { + $(this).select2('destroy'); + }); + + thisView.firstToRender(); + } + }, + + firstToRender: function firstToRender() { + if (!thisView.rendered) { + thisView.renderStatuses(); + thisView.rendered = true; + } + }, + + renderStatuses: function renderStatuses() { + var postId = this.model.get('id'); + this.$('#gc-status-selec2').html(this.select2template(this.model.toJSON())); + if (this.model.get('statuses').length) { + this.renderSelect2(this.$el); + } + }, + + render: function render() { + this.$el.html(this.template(this.model.toJSON())); + if (this.model.get('statusesChecked')) { + thisView.renderStatuses(); + } + return this; } - } - }, - - editStatus: function editStatus(evt) { - evt.preventDefault(); - this.statusesView.trigger('statusesOpen'); - }, - - cancelEditStatus: function cancelEditStatus(evt) { - evt.preventDefault(); - this.statusesView.trigger('statusesClose'); - }, - - saveStatus: function saveStatus() { - var newStatusId = this.$('.gc-default-mapping-select').val(); - var oldStatus = this.model.get('status'); - var oldStatusId = oldStatus && oldStatus.id ? oldStatus.id : false; - var newStatus, statuses; - - if (newStatusId === oldStatusId) { - return this.statusesView.trigger('statusesClose'); - } - statuses = this.model.get('statuses'); - newStatus = _.find(statuses, function (status) { - return parseInt(newStatusId, 10) === parseInt(status.id, 10); }); + }; + + }, {}], + 11: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + var thisView; + var base = require('./../views/metabox-base.js')(app, $, gc); + var StatusesView = require('./../views/metabox-statuses.js')(app, $, gc); + + return base.extend({ + template: wp.template('gc-metabox'), + statusesView: null, + timeoutID: null, + events: { + 'click .edit-gc-status': 'editStatus', + 'click .cancel-gc-status': 'cancelEditStatus', + 'click .save-gc-status': 'saveStatus', + 'click #gc-pull': 'pull', + 'click #gc-push': 'push', + 'click #gc-disconnect': 'disconnect' + }, + + initialize: function initialize() { + thisView = this; + this.listenTo(this.model, 'change:status', this.renderStatusView); + this.listenTo(this.model, 'change:mappingStatus', this.render); + this.listenTo(this.model, 'render', this.render); + + this.statusesView = new StatusesView({ + model: this.model + }); + + this.render(); + this.$el.removeClass('no-js'); + + this.refreshData(); + }, + + refreshData: function refreshData() { + // Trigger an un-cached update for the item data + this.model.set('uncached', true); + this.model.fetch().done(function (data) { + if (!thisView.statusesView.isOpen) { + thisView.render(); + } + }); + }, + + updateModel: function updateModel(data) { + var id = this.model.get('id'); + if (id in data) { + if (data[id].status) { + this.model.set('status', data[id].status); + } + if (data[id].itemName) { + this.model.set('itemName', data[id].itemName); + } + if (data[id].updated_at) { + this.model.set('updated_at', data[id].updated_at); + } + } + }, + + editStatus: function editStatus(evt) { + evt.preventDefault(); + this.statusesView.trigger('statusesOpen'); + }, + + cancelEditStatus: function cancelEditStatus(evt) { + evt.preventDefault(); + this.statusesView.trigger('statusesClose'); + }, + + saveStatus: function saveStatus() { + var newStatusId = this.$('.gc-default-mapping-select').val(); + var oldStatus = this.model.get('status'); + var oldStatusId = oldStatus && oldStatus.id ? oldStatus.id : false; + var newStatus, statuses; + + if (newStatusId === oldStatusId) { + return this.statusesView.trigger('statusesClose'); + } + + statuses = this.model.get('statuses'); + newStatus = _.find(statuses, function (status) { + return parseInt(newStatusId, 10) === parseInt(status.id, 10); + }); + + this.statusesView.trigger('statusesClose'); + this.model.set('status', newStatus); + + this.ajax({ + action: 'set_gc_status', + status: newStatusId + }, this.refreshData, function () { + this.model.set('status', oldStatus); + }); + }, + + disconnect: function disconnect() { + if (window.confirm(gc._sure.disconnect)) { + thisView.model.set('mappingStatus', 'starting'); + this.ajax({ + action: 'gc_disconnect_post', + data: thisView.model.toJSON(), + nonce: gc._edit_nonce + }, this.disconnectResponse, this.syncFail); + } + }, + + pull: function pull() { + if (window.confirm(gc._sure.pull)) { + thisView.model.set('mappingStatus', 'starting'); + this.doSync('pull'); + } + }, + + push: function push() { + var msg = this.model.get('item') ? gc._sure.push : gc._sure.push_no_item; + if (window.confirm(msg)) { + thisView.model.set('mappingStatus', 'starting'); + this.doSync('push'); + } + }, + + syncFail: function syncFail(msg) { + msg = 'string' === typeof msg ? msg : gc._errors.unknown; + window.alert(msg); + this.model.set('mappingStatus', 'failed'); + this.clearTimeout(); + }, + + disconnectResponse: function disconnectResponse(data) { + this.clearTimeout(); + this.$el.html(wp.template('gc-mapping-metabox')); + }, + + syncResponse: function syncResponse(data) { + if (data.mappings) { + if (data.mappings.length && -1 !== _.indexOf(data.mappings, this.model.get('mapping'))) { + + this.model.set('mappingStatus', 'syncing'); + this.checkStatus(data.direction); + } else { + this.finishedSync(data.direction); + } + } else { + this.syncFail(data); + } + }, + + doSync: function doSync(direction, data) { + this.ajax({ + action: 'gc_' + direction + '_items', + // action : 'glsjlfjs', + data: data || [this.model.toJSON()], + nonce: gc._edit_nonce + }, this.syncResponse, this.syncFail); + }, + + finishedSync: function finishedSync(direction) { + this.clearTimeout(); + this.model.set('mappingStatus', 'complete'); + if ('push' === direction) { + window.setTimeout(function () { + // Give DB time to catch up, and avoid race condtions. + thisView.refreshData(); + }, 800); + } else { + window.location.href = window.location.href; + } + }, + + checkStatus: function checkStatus(direction) { + this.clearTimeout(); + this.timeoutID = window.setTimeout(function () { + thisView.doSync(direction, {check: [thisView.model.get('mapping')]}); + }, 1000); + }, + + clearTimeout: function clearTimeout() { + window.clearTimeout(this.timeoutID); + this.timeoutID = null; + }, + + render: function render() { + this.$el.html(this.template(this.model.toJSON())); + + // This needs to happen after rendering. + this.$('.misc-pub-section.gc-item-name').after(this.statusesView.render().el); + + return this; + }, + + renderStatusView: function renderStatusView() { + this.statusesView.$el.replaceWith(this.statusesView.render().el); + } - this.statusesView.trigger('statusesClose'); - this.model.set('status', newStatus); - - this.ajax({ - action: 'set_gc_status', - status: newStatusId - }, this.refreshData, function () { - this.model.set('status', oldStatus); }); - }, - - disconnect: function disconnect() { - if (window.confirm(gc._sure.disconnect)) { - thisView.model.set('mappingStatus', 'starting'); - this.ajax({ - action: 'gc_disconnect_post', - data: thisView.model.toJSON(), - nonce: gc._edit_nonce - }, this.disconnectResponse, this.syncFail); - } - }, - - pull: function pull() { - if (window.confirm(gc._sure.pull)) { - thisView.model.set('mappingStatus', 'starting'); - this.doSync('pull'); - } - }, - - push: function push() { - var msg = this.model.get('item') ? gc._sure.push : gc._sure.push_no_item; - if (window.confirm(msg)) { - thisView.model.set('mappingStatus', 'starting'); - this.doSync('push'); - } - }, - - syncFail: function syncFail(msg) { - msg = 'string' === typeof msg ? msg : gc._errors.unknown; - window.alert(msg); - this.model.set('mappingStatus', 'failed'); - this.clearTimeout(); - }, - - disconnectResponse: function disconnectResponse(data) { - this.clearTimeout(); - this.$el.html(wp.template('gc-mapping-metabox')); - }, - - syncResponse: function syncResponse(data) { - if (data.mappings) { - if (data.mappings.length && -1 !== _.indexOf(data.mappings, this.model.get('mapping'))) { - - this.model.set('mappingStatus', 'syncing'); - this.checkStatus(data.direction); - } else { - this.finishedSync(data.direction); + }; + + }, {"./../views/metabox-base.js": 9, "./../views/metabox-statuses.js": 10}], + 12: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + var thisView; + return app.views.base.extend({ + select2ItemTemplate: wp.template('gc-select2-item'), + width: '250px', + + renderSelect2: function renderSelect2($context) { + var $selector = $context ? $context.find('.gc-select2') : this.$('.gc-select2'); + thisView = this; + + $selector.each(function () { + var $this = jQuery(this); + var data = $this.data(); + $this.select2(thisView.select2Args(data)); + var s2Data = $this.data('select2'); + + // Add classes for styling. + s2Data.$results.addClass('select2-' + data.column); + s2Data.$container.addClass('select2-' + data.column); + }); + + return this; + }, + + select2Args: function select2Args(data) { + var args = { + width: thisView.width + }; + + args.templateResult = (function (status, showDesc) { + var data = jQuery.extend(status, jQuery(status.element).data()); + data.description = false === showDesc ? false : data.description || ''; + return jQuery(thisView.select2ItemTemplate(status)); + }).bind(thisView); + + args.templateSelection = function (status) { + return args.templateResult(status, false); + }; + + return args; } - } else { - this.syncFail(data); - } - }, - - doSync: function doSync(direction, data) { - this.ajax({ - action: 'gc_' + direction + '_items', - // action : 'glsjlfjs', - data: data || [this.model.toJSON()], - nonce: gc._edit_nonce - }, this.syncResponse, this.syncFail); - }, - - finishedSync: function finishedSync(direction) { - this.clearTimeout(); - this.model.set('mappingStatus', 'complete'); - if ('push' === direction) { - window.setTimeout(function () { - // Give DB time to catch up, and avoid race condtions. - thisView.refreshData(); - }, 800); - } else { - window.location.href = window.location.href; - } - }, - - checkStatus: function checkStatus(direction) { - this.clearTimeout(); - this.timeoutID = window.setTimeout(function () { - thisView.doSync(direction, { check: [thisView.model.get('mapping')] }); - }, 1000); - }, - - clearTimeout: function clearTimeout() { - window.clearTimeout(this.timeoutID); - this.timeoutID = null; - }, - - render: function render() { - this.$el.html(this.template(this.model.toJSON())); - - // This needs to happen after rendering. - this.$('.misc-pub-section.gc-item-name').after(this.statusesView.render().el); - return this; - }, - - renderStatusView: function renderStatusView() { - this.statusesView.$el.replaceWith(this.statusesView.render().el); - } - - }); -}; - -},{"./../views/metabox-base.js":9,"./../views/metabox-statuses.js":10}],12:[function(require,module,exports){ -'use strict'; - -module.exports = function (app) { - var thisView; - return app.views.base.extend({ - select2ItemTemplate: wp.template('gc-select2-item'), - width: '250px', - - renderSelect2: function renderSelect2($context) { - var $selector = $context ? $context.find('.gc-select2') : this.$('.gc-select2'); - thisView = this; - - $selector.each(function () { - var $this = jQuery(this); - var data = $this.data(); - $this.select2(thisView.select2Args(data)); - var s2Data = $this.data('select2'); - - // Add classes for styling. - s2Data.$results.addClass('select2-' + data.column); - s2Data.$container.addClass('select2-' + data.column); }); + }; - return this; - }, - - select2Args: function select2Args(data) { - var args = { - width: thisView.width - }; - - args.templateResult = (function (status, showDesc) { - var data = jQuery.extend(status, jQuery(status.element).data()); - data.description = false === showDesc ? false : data.description || ''; - return jQuery(thisView.select2ItemTemplate(status)); - }).bind(thisView); - - args.templateSelection = function (status) { - return args.templateResult(status, false); - }; - - return args; - } - - }); -}; - -},{}]},{},[6]); + }, {}] +}, {}, [6]); diff --git a/assets/js/gathercontent-sync.js b/assets/js/gathercontent-sync.js index 15c44d78..bc661012 100644 --- a/assets/js/gathercontent-sync.js +++ b/assets/js/gathercontent-sync.js @@ -1,920 +1,967 @@ /** * Content Workflow (by Bynder) - v1.0.0 - 2024-06-05 - * + * * * Copyright (c) 2024 Content Workflow (by Bynder) * Licensed under the GPLv2 license. */ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0; - this.allChecked = this.totalChecked >= models.length; - this.sortKey = sortKey; - this.sortDirection = sortDirection; - this.sort(); - }, - - checkChecked: function checkChecked(model) { - if (model.changed.checked) { - this.totalChecked++; - } else { - if (this.totalChecked === this.length) { - this.allChecked = false; - } - this.totalChecked--; - } - - this.checkAllStatus(); - }, - - checkAllStatus: function checkAllStatus(checked) { - var syncWasEnabled = this.syncEnabled; - this.syncEnabled = this.totalChecked > 0; - - if (syncWasEnabled !== this.syncEnabled) { - this.trigger('enabledChange', this.syncEnabled); +(function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var a = typeof require == "function" && require; + if (!u && a) return a(o, !0); + if (i) return i(o, !0); + var f = new Error("Cannot find module '" + o + "'"); + throw f.code = "MODULE_NOT_FOUND", f } + var l = n[o] = {exports: {}}; + t[o][0].call(l.exports, function (e) { + var n = t[o][1][e]; + return s(n ? n : e) + }, l, l.exports, e, t, n, r) + } + return n[o].exports + } - if (this.totalChecked < this.length) { - this.trigger('notAllChecked', false); + var i = typeof require == "function" && require; + for (var o = 0; o < r.length; o++) s(r[o]); + return s +})({ + 1: [function (require, module, exports) { + 'use strict'; + + module.exports = Backbone.Collection.extend({ + getById: function getById(id) { + return this.find(function (model) { + var modelId = model.get('id'); + return modelId === id || modelId && id && modelId == id; + }); } - }, - - toggleCheckedIf: function toggleCheckedIf(checked) { - this.processing = true; - - this.stopListening(this, 'change:checked', this.checkChecked); - this.each(function (model) { - model.set('checked', Boolean('function' === typeof checked ? checked(model) : checked)); - }); - this.listenTo(this, 'change:checked', this.checkChecked); - - this.totalChecked = this.checked().length; - this.allChecked = this.totalChecked >= this.length; - this.checkAllStatus(); + }); - this.processing = false; + }, {}], + 2: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + var sortKey = null; + var sortDirection = 'asc'; + var Collection = app.collections.base.extend({ + model: app.models.item, + totalChecked: 0, + allChecked: false, + syncEnabled: false, + processing: false, + sortKey: sortKey, + sortDirection: sortDirection, + + initialize: function initialize(models, options) { + this.listenTo(this, 'checkAll', this.toggleChecked); + this.listenTo(this, 'checkSome', this.toggleCheckedIf); + this.listenTo(this, 'change:checked', this.checkChecked); + this.listenTo(this, 'sortByColumn', this.sortByColumn); + + this.totalChecked = this.checked().length; + + if (options && options.reinit) { + this.reinit(models); + } + }, + + reinit: function reinit(models) { + this.totalChecked = this.checked(models).length; + this.syncEnabled = this.totalChecked > 0; + this.allChecked = this.totalChecked >= models.length; + this.sortKey = sortKey; + this.sortDirection = sortDirection; + this.sort(); + }, + + checkChecked: function checkChecked(model) { + if (model.changed.checked) { + this.totalChecked++; + } else { + if (this.totalChecked === this.length) { + this.allChecked = false; + } + this.totalChecked--; + } - this.trigger('render'); - }, + this.checkAllStatus(); + }, - toggleChecked: function toggleChecked(checked) { - this.allChecked = checked; - this.toggleCheckedIf(checked); - }, + checkAllStatus: function checkAllStatus(checked) { + var syncWasEnabled = this.syncEnabled; + this.syncEnabled = this.totalChecked > 0; - checked: function checked(models) { - models = models || this; - return models.filter(function (model) { - return model.get('checked'); - }); - }, + if (syncWasEnabled !== this.syncEnabled) { + this.trigger('enabledChange', this.syncEnabled); + } - comparator: function comparator(a, b) { - if (!this.sortKey) { - return; - } + if (this.totalChecked < this.length) { + this.trigger('notAllChecked', false); + } + }, - var dataA = a.get(this.sortKey); - var dataB = b.get(this.sortKey); + toggleCheckedIf: function toggleCheckedIf(checked) { + this.processing = true; - if ('updated_at' === this.sortKey) { - dataA = dataA.date || dataA; - dataB = dataB.date || dataB; - } + this.stopListening(this, 'change:checked', this.checkChecked); + this.each(function (model) { + model.set('checked', Boolean('function' === typeof checked ? checked(model) : checked)); + }); + this.listenTo(this, 'change:checked', this.checkChecked); - if ('status' === this.sortKey) { - dataA = dataA.name || dataA; - dataB = dataB.name || dataB; - } - - if ('asc' === this.sortDirection) { - if (dataA > dataB) { - return -1; - } - if (dataB > dataA) { - return 1; - } - return 0; - } else { + this.totalChecked = this.checked().length; + this.allChecked = this.totalChecked >= this.length; + this.checkAllStatus(); - if (dataA < dataB) { - return -1; - } - if (dataB < dataA) { - return 1; - } + this.processing = false; - return 0; - } - }, + this.trigger('render'); + }, - sortByColumn: function sortByColumn(column, direction) { - this.sortKey = sortKey = column; - this.sortDirection = sortDirection = direction; - this.sort(); - } + toggleChecked: function toggleChecked(checked) { + this.allChecked = checked; + this.toggleCheckedIf(checked); + }, - }); + checked: function checked(models) { + models = models || this; + return models.filter(function (model) { + return model.get('checked'); + }); + }, - return require('./../collections/search-extension.js')(Collection); -}; + comparator: function comparator(a, b) { + if (!this.sortKey) { + return; + } -},{"./../collections/search-extension.js":3}],3:[function(require,module,exports){ -'use strict'; + var dataA = a.get(this.sortKey); + var dataB = b.get(this.sortKey); -module.exports = function (Collection) { + if ('updated_at' === this.sortKey) { + dataA = dataA.date || dataA; + dataB = dataB.date || dataB; + } - _.extend(Collection.prototype, { + if ('status' === this.sortKey) { + dataA = dataA.name || dataA; + dataB = dataB.name || dataB; + } - //_Cache - _searchResults: null, + if ('asc' === this.sortDirection) { + if (dataA > dataB) { + return -1; + } + if (dataB > dataA) { + return 1; + } + return 0; + } else { - //@ Search wrapper function - search: function search(keyword, attributes) { - var results = this._doSearch(keyword, attributes); + if (dataA < dataB) { + return -1; + } + if (dataB < dataA) { + return 1; + } - this.trigger('search', results); + return 0; + } + }, - // For use of returning un-async - return results; - }, + sortByColumn: function sortByColumn(column, direction) { + this.sortKey = sortKey = column; + this.sortDirection = sortDirection = direction; + this.sort(); + } - //@ Search function - _doSearch: function _doSearch(keyword, attributes) { - attributes = attributes && attributes.length ? attributes : false; + }); - // If collection empty get out - if (!this.models.length) { - return []; - } + return require('./../collections/search-extension.js')(Collection); + }; - // Filter - var matcher = this.matcher; - var results = !keyword ? this.models : this.filter(function (model) { - attributes = attributes ? attributes : model.searchAttributes || _.keys(model.attributes); - return _.some(attributes, function (attribute) { - return matcher(keyword, model.get(attribute)); - }); - }); + }, {"./../collections/search-extension.js": 3}], + 3: [function (require, module, exports) { + 'use strict'; - this.trigger('searchResults', results); + module.exports = function (Collection) { - // Instantiate new Collection - var collection = new Collection(results, { reinit: true }); + _.extend(Collection.prototype, { - collection.searching = { - keyword: keyword, - attributes: attributes - }; + //_Cache + _searchResults: null, - collection.getSearchQuery = function () { - return this.searching; - }; + //@ Search wrapper function + search: function search(keyword, attributes) { + var results = this._doSearch(keyword, attributes); - // Cache the recently searched metadata - this._searchResults = collection; + this.trigger('search', results); - this.trigger('search', collection); + // For use of returning un-async + return results; + }, - // For use of returning un-async - return collection; - }, + //@ Search function + _doSearch: function _doSearch(keyword, attributes) { + attributes = attributes && attributes.length ? attributes : false; - //@ Default Matcher - may be overwritten - matcher: function matcher(needle, haystack) { - if (!needle || !haystack) { - return; - } - needle = needle.toString().toLowerCase(); - haystack = haystack.toString().toLowerCase(); - return haystack.indexOf(needle) >= 0; - }, - - //@ Get recent search value - getSearchValue: function getSearchValue() { - return this.getSearchQuery().keyword; - }, - - //@ Get recent search query - getSearchQuery: function getSearchQuery() { - return this._searchResults && this._searchResults.getSearchQuery() || {}; - }, - - //@ Get recent search results - getSearchResults: function getSearchResults() { - return this._searchResults; - }, - - current: function current() { - return this._searchResults || this; - } + // If collection empty get out + if (!this.models.length) { + return []; + } - }); - - return Collection; -}; - -},{}],4:[function(require,module,exports){ -'use strict'; - -module.exports = function (app) { - app.models = { base: require('./models/base.js') }; - app.collections = { base: require('./collections/base.js') }; - app.views = { base: require('./views/base.js') }; -}; - -},{"./collections/base.js":1,"./models/base.js":6,"./views/base.js":10}],5:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, defaults) { - defaults = jQuery.extend({}, { - action: 'gc_sync_items', - data: '', - percent: 0, - nonce: '', - id: '', - stopSync: true, - flush_cache: false - }, defaults); - - return app.models.base.extend({ - defaults: defaults, - - initialize: function initialize() { - this.listenTo(this, 'send', this.send); - }, - - reset: function reset() { - this.clear().set(this.defaults); - return this; - }, - - send: function send(formData, cb, percent, failcb) { - if (percent) { - this.set('percent', percent); - } + // Filter + var matcher = this.matcher; + var results = !keyword ? this.models : this.filter(function (model) { + attributes = attributes ? attributes : model.searchAttributes || _.keys(model.attributes); + return _.some(attributes, function (attribute) { + return matcher(keyword, model.get(attribute)); + }); + }); - jQuery.post(window.ajaxurl, { - action: this.get('action'), - percent: this.get('percent'), - nonce: this.get('nonce'), - id: this.get('id'), - data: formData, - flush_cache: this.get('flush_cache') - }, (function (response) { - this.trigger('response', response, formData); - - if (response.success) { - return cb(response); - } + this.trigger('searchResults', results); - if (failcb) { - return failcb(response); - } - }).bind(this)); + // Instantiate new Collection + var collection = new Collection(results, {reinit: true}); - return this; - } + collection.searching = { + keyword: keyword, + attributes: attributes + }; - }); -}; + collection.getSearchQuery = function () { + return this.searching; + }; -},{}],6:[function(require,module,exports){ -"use strict"; + // Cache the recently searched metadata + this._searchResults = collection; -module.exports = Backbone.Model.extend({ - sync: function sync() { - return false; - } -}); - -},{}],7:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, gc) { - return require('./../models/modify-json.js')(app.models.base.extend({ - defaults: { - id: 0, - item: 0, - itemName: 0, - project_id: 0, - parent_id: 0, - template_id: 0, - custom_state_id: 0, - position: 0, - name: '', - config: '', - notes: '', - type: '', - typeName: '', - overdue: false, - archived_by: '', - archived_at: '', - created_at: null, - updated_at: null, - status: null, - due_dates: null, - expanded: false, - checked: false, - post_title: false, - ptLabel: false - }, - - searchAttributes: ['itemName', 'post_title'], - - _get_item: function _get_item(value) { - return this.get('id'); - }, - - _get_typeName: function _get_typeName(value) { - if (!value) { - value = Backbone.Model.prototype.get.call(this, 'type'); - } - return gc._type_names[value] ? gc._type_names[value] : value; - } - })); -}; + this.trigger('search', collection); -},{"./../models/modify-json.js":8}],8:[function(require,module,exports){ -'use strict'; + // For use of returning un-async + return collection; + }, -module.exports = function (model) { + //@ Default Matcher - may be overwritten + matcher: function matcher(needle, haystack) { + if (!needle || !haystack) { + return; + } + needle = needle.toString().toLowerCase(); + haystack = haystack.toString().toLowerCase(); + return haystack.indexOf(needle) >= 0; + }, + + //@ Get recent search value + getSearchValue: function getSearchValue() { + return this.getSearchQuery().keyword; + }, + + //@ Get recent search query + getSearchQuery: function getSearchQuery() { + return this._searchResults && this._searchResults.getSearchQuery() || {}; + }, + + //@ Get recent search results + getSearchResults: function getSearchResults() { + return this._searchResults; + }, + + current: function current() { + return this._searchResults || this; + } - model.prototype._get = function (value, attribute) { - if (this['_get_' + attribute]) { - value = this['_get_' + attribute](value); - } - return value; - }; + }); - model.prototype.get = function (attribute) { - return this._get(Backbone.Model.prototype.get.call(this, attribute), attribute); - }; + return Collection; + }; + + }, {}], + 4: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + app.models = {base: require('./models/base.js')}; + app.collections = {base: require('./collections/base.js')}; + app.views = {base: require('./views/base.js')}; + }; + + }, {"./collections/base.js": 1, "./models/base.js": 6, "./views/base.js": 10}], + 5: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, defaults) { + defaults = jQuery.extend({}, { + action: 'gc_sync_items', + data: '', + percent: 0, + nonce: '', + id: '', + stopSync: true, + flush_cache: false + }, defaults); + + return app.models.base.extend({ + defaults: defaults, + + initialize: function initialize() { + this.listenTo(this, 'send', this.send); + }, + + reset: function reset() { + this.clear().set(this.defaults); + return this; + }, + + send: function send(formData, cb, percent, failcb) { + if (percent) { + this.set('percent', percent); + } - // hijack the toJSON method and overwrite the data that is sent back to the view. - model.prototype.toJSON = function () { - return _.mapObject(Backbone.Model.prototype.toJSON.call(this), _.bind(this._get, this)); - }; + jQuery.post(window.ajaxurl, { + action: this.get('action'), + percent: this.get('percent'), + nonce: this.get('nonce'), + id: this.get('id'), + data: formData, + flush_cache: this.get('flush_cache') + }, (function (response) { + this.trigger('response', response, formData); + + if (response.success) { + return cb(response); + } + + if (failcb) { + return failcb(response); + } + }).bind(this)); + + return this; + } - return model; -}; + }); + }; -},{}],9:[function(require,module,exports){ -'use strict'; + }, {}], + 6: [function (require, module, exports) { + "use strict"; -window.GatherContent = window.GatherContent || {}; + module.exports = Backbone.Model.extend({ + sync: function sync() { + return false; + } + }); -(function (window, document, $, gc, undefined) { - 'use strict'; + }, {}], + 7: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, gc) { + return require('./../models/modify-json.js')(app.models.base.extend({ + defaults: { + id: 0, + item: 0, + itemName: 0, + project_id: 0, + parent_id: 0, + template_id: 0, + custom_state_id: 0, + position: 0, + name: '', + config: '', + notes: '', + type: '', + typeName: '', + overdue: false, + archived_by: '', + archived_at: '', + created_at: null, + updated_at: null, + status: null, + due_dates: null, + expanded: false, + checked: false, + post_title: false, + ptLabel: false + }, + + searchAttributes: ['itemName', 'post_title'], + + _get_item: function _get_item(value) { + return this.get('id'); + }, + + _get_typeName: function _get_typeName(value) { + if (!value) { + value = Backbone.Model.prototype.get.call(this, 'type'); + } + return gc._type_names[value] ? gc._type_names[value] : value; + } + })); + }; - gc.sync = gc.sync || {}; - var app = gc.sync; + }, {"./../models/modify-json.js": 8}], + 8: [function (require, module, exports) { + 'use strict'; - // Initiate base objects. - require('./initiate-objects.js')(app); + module.exports = function (model) { - app.views.tableBase = require('./views/table-base.js')(app, $, gc); + model.prototype._get = function (value, attribute) { + if (this['_get_' + attribute]) { + value = this['_get_' + attribute](value); + } + return value; + }; - /* - * Item setup - */ + model.prototype.get = function (attribute) { + return this._get(Backbone.Model.prototype.get.call(this, attribute), attribute); + }; - app.models.item = require('./models/item.js')(app, gc); - app.collections.items = require('./collections/items.js')(app); - app.views.item = require('./views/item.js')(app); - app.views.items = require('./views/items.js')(app, $, gc); + // hijack the toJSON method and overwrite the data that is sent back to the view. + model.prototype.toJSON = function () { + return _.mapObject(Backbone.Model.prototype.toJSON.call(this), _.bind(this._get, this)); + }; - app.init = function () { - // Kick it off. - app.syncView = new app.views.items({ - el: $('.gc-admin-wrap'), - collection: new app.collections.items(gc._items) - }); + return model; + }; - // Handle error notice dismissals. - $(document.body).on('click', '#setting-error-gc-import-last-error .notice-dismiss, #setting-error-gc-import-errors .notice-dismiss', function () { - var lastError = $(this).parents('#setting-error-gc-import-last-error').length > 0; - $.post(window.ajaxurl, { - action: 'gc_dismiss_notice', - lastError: lastError ? 1 : 0, - mapping: gc.queryargs.mapping - }, function (response) { - gc.log('response', response); - }); - }).on('click', '.gc-notice-dismiss', function () { - $(this).parents('.notice.is-dismissible').find('.notice-dismiss').trigger('click'); - }); - }; + }, {}], + 9: [function (require, module, exports) { + 'use strict'; - $(app.init); -})(window, document, jQuery, window.GatherContent); + window.GatherContent = window.GatherContent || {}; -},{"./collections/items.js":2,"./initiate-objects.js":4,"./models/item.js":7,"./views/item.js":11,"./views/items.js":12,"./views/table-base.js":13}],10:[function(require,module,exports){ -'use strict'; + (function (window, document, $, gc, undefined) { + 'use strict'; -module.exports = Backbone.View.extend({ - toggleExpanded: function toggleExpanded(evt) { - this.model.set('expanded', !this.model.get('expanded')); - }, + gc.sync = gc.sync || {}; + var app = gc.sync; - getRenderedModels: function getRenderedModels(View, models) { - models = models || this.collection; - var addedElements = document.createDocumentFragment(); + // Initiate base objects. + require('./initiate-objects.js')(app); - models.each(function (model) { - var view = new View({ model: model }).render(); - addedElements.appendChild(view.el); - }); + app.views.tableBase = require('./views/table-base.js')(app, $, gc); - return addedElements; - }, + /* + * Item setup + */ - render: function render() { - this.$el.html(this.template(this.model.toJSON())); - return this; - }, + app.models.item = require('./models/item.js')(app, gc); + app.collections.items = require('./collections/items.js')(app); + app.views.item = require('./views/item.js')(app); + app.views.items = require('./views/items.js')(app, $, gc); - close: function close() { - this.remove(); - this.unbind(); - if (this.onClose) { - this.onClose(); - } - } -}); - -},{}],11:[function(require,module,exports){ -'use strict'; - -module.exports = function (app) { - return app.views.base.extend({ - template: wp.template('gc-item'), - tagName: 'tr', - className: 'gc-item gc-enabled', - id: function id() { - return this.model.get('id'); - }, - - events: { - 'change .gc-check-column input': 'toggleCheck', - 'click .gc-reveal-items': 'toggleExpanded', - 'click .gc-status-column': 'toggleCheckAndRender' - }, - - initialize: function initialize() { - this.listenTo(this.model, 'change:checked', this.render); - }, - - toggleCheck: function toggleCheck() { - this.model.set('checked', !this.model.get('checked')); - }, - - toggleCheckAndRender: function toggleCheckAndRender(evt) { - this.toggleCheck(); - this.render(); - } - }); -}; - -},{}],12:[function(require,module,exports){ -'use strict'; - -module.exports = function (app, $, gc) { - var thisView; - var percent = gc.percent; - app.views.tableSearch = require('./../views/table-search.js')(app, $, gc); - app.views.tableNav = require('./../views/table-nav.js')(app, $, gc); - - return app.views.tableBase.extend({ - template: wp.template('gc-items-sync'), - progressTemplate: wp.template('gc-items-sync-progress'), - modelView: app.views.item, - - events: { - 'click .gc-cancel-sync': 'clickCancelSync', - 'click .gc-field-th.sortable': 'sortRowsByColumn', - 'change .gc-field-th.gc-check-column input': 'checkAll', - 'submit form': 'submit' - }, - - initialize: function initialize() { - thisView = this; - app.views.tableBase.prototype.initialize.call(this); - - this.listenTo(this.ajax, 'response', this.ajaxResponse); - this.listenTo(this.collection, 'enabledChange', this.checkEnableButton); - this.listenTo(this.collection, 'search', this.initRender); - - this.initRender(); - }, - - setupAjax: function setupAjax() { - var Ajax = require('./../models/ajax.js')(app, { - checkHits: 0, - time: 500, - nonce: gc.el('_wpnonce').value, - id: gc.el('gc-input-mapping_id').value, - flush_cache: gc.queryargs.flush_cache ? 1 : 0 - }); + app.init = function () { + // Kick it off. + app.syncView = new app.views.items({ + el: $('.gc-admin-wrap'), + collection: new app.collections.items(gc._items) + }); - this.ajax = new Ajax({ - percent: percent - }); - }, - - checkEnableButton: function checkEnableButton(syncEnabled) { - this.buttonStatus(syncEnabled); - }, - - clickCancelSync: function clickCancelSync(evt) { - evt.preventDefault(); - this.cancelSync(); - }, - - submit: function submit(evt) { - evt.preventDefault(); - this.startSync(this.$('form').serialize()); - }, - - startSync: function startSync(formData) { - this.doSpinner(); - this.ajax.reset().set('stopSync', false); - this.renderProgress(100 === window.parseInt(percent, 10) ? 0 : percent); - this.doAjax(formData, percent); - }, - - cancelSync: function cancelSync(url) { - percent = null; - - this.ajax.reset(); - this.clearTimeout(); - - if (url) { - this.doAjax('cancel', 0, function () { - window.location.href = url; + // Handle error notice dismissals. + $(document.body).on('click', '#setting-error-gc-import-last-error .notice-dismiss, #setting-error-gc-import-errors .notice-dismiss', function () { + var lastError = $(this).parents('#setting-error-gc-import-last-error').length > 0; + $.post(window.ajaxurl, { + action: 'gc_dismiss_notice', + lastError: lastError ? 1 : 0, + mapping: gc.queryargs.mapping + }, function (response) { + gc.log('response', response); + }); + }).on('click', '.gc-notice-dismiss', function () { + $(this).parents('.notice.is-dismissible').find('.notice-dismiss').trigger('click'); }); - } else { - this.doAjax('cancel', 0, function () {}); - this.initRender(); - } - }, + }; - doAjax: function doAjax(formData, completed, cb) { - cb = cb || this.ajaxSuccess.bind(this); - this.ajax.send(formData, cb, completed); - }, + $(app.init); + })(window, document, jQuery, window.GatherContent); + + }, { + "./collections/items.js": 2, + "./initiate-objects.js": 4, + "./models/item.js": 7, + "./views/item.js": 11, + "./views/items.js": 12, + "./views/table-base.js": 13 + }], + 10: [function (require, module, exports) { + 'use strict'; + + module.exports = Backbone.View.extend({ + toggleExpanded: function toggleExpanded(evt) { + this.model.set('expanded', !this.model.get('expanded')); + }, + + getRenderedModels: function getRenderedModels(View, models) { + models = models || this.collection; + var addedElements = document.createDocumentFragment(); + + models.each(function (model) { + var view = new View({model: model}).render(); + addedElements.appendChild(view.el); + }); - ajaxSuccess: function ajaxSuccess(response) { - if (this.ajax.get('stopSync')) { - return; - } + return addedElements; + }, - percent = response.data.percent || 1; - var hits = this.checkHits(); - var time = this.ajax.get('time'); + render: function render() { + this.$el.html(this.template(this.model.toJSON())); + return this; + }, - if (hits > 25 && time < 2000) { - this.clearTimeout(); - this.ajax.set('time', 2000); - } else if (hits > 50 && time < 5000) { - this.clearTimeout(); - this.ajax.set('time', 5000); + close: function close() { + this.remove(); + this.unbind(); + if (this.onClose) { + this.onClose(); + } } + }); - this.setTimeout(this.checkProgress.bind(this)); - - if (percent > 99) { - // This is to allow the slight css animation. - this.renderProgressUpdate(100); + }, {}], + 11: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + return app.views.base.extend({ + template: wp.template('gc-item'), + tagName: 'tr', + className: 'gc-item gc-enabled', + id: function id() { + return this.model.get('id'); + }, + + events: { + 'change .gc-check-column input': 'toggleCheck', + 'click .gc-reveal-items': 'toggleExpanded', + 'click .gc-status-column': 'toggleCheckAndRender' + }, + + initialize: function initialize() { + this.listenTo(this.model, 'change:checked', this.render); + }, + + toggleCheck: function toggleCheck() { + this.model.set('checked', !this.model.get('checked')); + }, + + toggleCheckAndRender: function toggleCheckAndRender(evt) { + this.toggleCheck(); + this.render(); + } + }); + }; + + }, {}], + 12: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + var thisView; + var percent = gc.percent; + app.views.tableSearch = require('./../views/table-search.js')(app, $, gc); + app.views.tableNav = require('./../views/table-nav.js')(app, $, gc); + + return app.views.tableBase.extend({ + template: wp.template('gc-items-sync'), + progressTemplate: wp.template('gc-items-sync-progress'), + modelView: app.views.item, + + events: { + 'click .gc-cancel-sync': 'clickCancelSync', + 'click .gc-field-th.sortable': 'sortRowsByColumn', + 'change .gc-field-th.gc-check-column input': 'checkAll', + 'submit form': 'submit' + }, + + initialize: function initialize() { + thisView = this; + app.views.tableBase.prototype.initialize.call(this); + + this.listenTo(this.ajax, 'response', this.ajaxResponse); + this.listenTo(this.collection, 'enabledChange', this.checkEnableButton); + this.listenTo(this.collection, 'search', this.initRender); + + this.initRender(); + }, + + setupAjax: function setupAjax() { + var Ajax = require('./../models/ajax.js')(app, { + checkHits: 0, + time: 500, + nonce: gc.el('_wpnonce').value, + id: gc.el('gc-input-mapping_id').value, + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }); + + this.ajax = new Ajax({ + percent: percent + }); + }, + + checkEnableButton: function checkEnableButton(syncEnabled) { + this.buttonStatus(syncEnabled); + }, + + clickCancelSync: function clickCancelSync(evt) { + evt.preventDefault(); + this.cancelSync(); + }, + + submit: function submit(evt) { + evt.preventDefault(); + this.startSync(this.$('form').serialize()); + }, + + startSync: function startSync(formData) { + this.doSpinner(); + this.ajax.reset().set('stopSync', false); + this.renderProgress(100 === window.parseInt(percent, 10) ? 0 : percent); + this.doAjax(formData, percent); + }, + + cancelSync: function cancelSync(url) { + percent = null; + + this.ajax.reset(); + this.clearTimeout(); + + if (url) { + this.doAjax('cancel', 0, function () { + window.location.href = url; + }); + } else { + this.doAjax('cancel', 0, function () { + }); + this.initRender(); + } + }, - // This is to render the loading spinner. Wait long enough for css animation to copmlete. - window.setTimeout(function () { - thisView.renderProgress(100, true); - }, 100); + doAjax: function doAjax(formData, completed, cb) { + cb = cb || this.ajaxSuccess.bind(this); + this.ajax.send(formData, cb, completed); + }, - // Finally, cancel the sync, and redirect. - this.cancelSync(window.location.href + '&updated=1&flush_cache=1&redirect=1'); - } else { - this.renderProgressUpdate(percent); - } - }, + ajaxSuccess: function ajaxSuccess(response) { + if (this.ajax.get('stopSync')) { + return; + } - setTimeout: function setTimeout(callback) { - this.timeoutID = window.setTimeout(callback, this.ajax.get('time')); - }, + percent = response.data.percent || 1; + var hits = this.checkHits(); + var time = this.ajax.get('time'); - checkProgress: function checkProgress() { - this.doAjax('check', percent); - }, + if (hits > 25 && time < 2000) { + this.clearTimeout(); + this.ajax.set('time', 2000); + } else if (hits > 50 && time < 5000) { + this.clearTimeout(); + this.ajax.set('time', 5000); + } - checkHits: function checkHits() { - return window.parseInt(this.ajax.get('checkHits'), 10); - }, + this.setTimeout(this.checkProgress.bind(this)); - ajaxResponse: function ajaxResponse(response, formData) { - gc.log('warn', 'hits/interval/response: ' + this.checkHits() + '/' + this.ajax.get('time') + '/', response.success ? response.data : response); + if (percent > 99) { + // This is to allow the slight css animation. + this.renderProgressUpdate(100); - if ('check' === formData) { - this.ajax.set('checkHits', this.checkHits() + 1); - } else if (response.data) { - this.ajax.set('checkHits', 0); - } + // This is to render the loading spinner. Wait long enough for css animation to copmlete. + window.setTimeout(function () { + thisView.renderProgress(100, true); + }, 100); - if (!response.success) { - this.renderProgressUpdate(0); - this.cancelSync(); - if (response.data) { - if (response.data.url) { - window.alert(response.data.message); - window.location.href = response.data.url; + // Finally, cancel the sync, and redirect. + this.cancelSync(window.location.href + '&updated=1&flush_cache=1&redirect=1'); } else { - window.alert(response.data); + this.renderProgressUpdate(percent); } - return; - } - } - }, - - renderProgressUpdate: function renderProgressUpdate(percent) { - this.$('.gc-progress-bar-partial').css({ width: percent + '%' }).find('span').text(percent + '%'); - }, - - renderProgress: function renderProgress(percent, showLoader) { - this.$el.addClass('gc-sync-progress'); - this.buttonStatus(false); - this.$('#sync-tabs').html(this.progressTemplate({ - percent: null === percent ? 0 : percent, - loader: true === showLoader - })); - }, - - renderRows: function renderRows(html) { - this.$('#sync-tabs tbody').html(html || this.getRenderedRows()); - }, - - sortRender: function sortRender() { - this.initRender(); - }, - - initRender: function initRender() { - var collection = this.collection.current(); - // If sync is going, show that status. - if (percent > 0 && percent < 100) { - this.startSync('check'); - } else { - this.$('#sync-tabs').html(this.template({ - checked: collection.allChecked, - sortKey: collection.sortKey, - sortDirection: collection.sortDirection - })); - this.render(); - } - }, - - render: function render() { - // Not syncing, so remove wrap-class - this.$el.removeClass('gc-sync-progress'); + }, - return app.views.tableBase.prototype.render.call(this); - } - - }); -}; + setTimeout: function setTimeout(callback) { + this.timeoutID = window.setTimeout(callback, this.ajax.get('time')); + }, -},{"./../models/ajax.js":5,"./../views/table-nav.js":14,"./../views/table-search.js":15}],13:[function(require,module,exports){ -'use strict'; + checkProgress: function checkProgress() { + this.doAjax('check', percent); + }, -module.exports = function (app, $, gc) { - app.views.tableSearch = require('./../views/table-search.js')(app, $, gc); - app.views.tableNav = require('./../views/table-nav.js')(app, $, gc); + checkHits: function checkHits() { + return window.parseInt(this.ajax.get('checkHits'), 10); + }, - return app.views.base.extend({ - timeoutID: null, - ajax: null, - tableNavView: null, - searchView: null, - modelView: null, // Need to override. - timeoutTime: 1000, + ajaxResponse: function ajaxResponse(response, formData) { + gc.log('warn', 'hits/interval/response: ' + this.checkHits() + '/' + this.ajax.get('time') + '/', response.success ? response.data : response); - events: { - 'click .gc-field-th.sortable': 'sortRowsByColumn', - 'change .gc-field-th.gc-check-column input': 'checkAll' - }, + if ('check' === formData) { + this.ajax.set('checkHits', this.checkHits() + 1); + } else if (response.data) { + this.ajax.set('checkHits', 0); + } - initialize: function initialize() { - this.setupAjax(); + if (!response.success) { + this.renderProgressUpdate(0); + this.cancelSync(); + if (response.data) { + if (response.data.url) { + window.alert(response.data.message); + window.location.href = response.data.url; + } else { + window.alert(response.data); + } + return; + } + } + }, + + renderProgressUpdate: function renderProgressUpdate(percent) { + this.$('.gc-progress-bar-partial').css({width: percent + '%'}).find('span').text(percent + '%'); + }, + + renderProgress: function renderProgress(percent, showLoader) { + this.$el.addClass('gc-sync-progress'); + this.buttonStatus(false); + this.$('#sync-tabs').html(this.progressTemplate({ + percent: null === percent ? 0 : percent, + loader: true === showLoader + })); + }, + + renderRows: function renderRows(html) { + this.$('#sync-tabs tbody').html(html || this.getRenderedRows()); + }, + + sortRender: function sortRender() { + this.initRender(); + }, + + initRender: function initRender() { + var collection = this.collection.current(); + // If sync is going, show that status. + if (percent > 0 && percent < 100) { + this.startSync('check'); + } else { + this.$('#sync-tabs').html(this.template({ + checked: collection.allChecked, + sortKey: collection.sortKey, + sortDirection: collection.sortDirection + })); + this.render(); + } + }, - this.listenTo(this.collection, 'render', this.render); - this.listenTo(this.collection, 'notAllChecked', this.allCheckedStatus); - this.listenTo(this.collection, 'change:checked', this.renderNav); - this.listenTo(this, 'render', this.render); + render: function render() { + // Not syncing, so remove wrap-class + this.$el.removeClass('gc-sync-progress'); - this.tableNavView = new app.views.tableNav({ - collection: this.collection - }); + return app.views.tableBase.prototype.render.call(this); + } - this.searchView = new app.views.tableSearch({ - collection: this.collection }); - }, - - // Need to override. - setupAjax: function setupAjax() {}, - - sortRowsByColumn: function sortRowsByColumn(evt) { - evt.preventDefault(); - var collection = this.collection.current(); - - var $this = $(evt.currentTarget); - var column = $this.find('a').data('id'); - var direction = false; - - if ($this.hasClass('asc')) { - direction = 'desc'; - } + }; + + }, {"./../models/ajax.js": 5, "./../views/table-nav.js": 14, "./../views/table-search.js": 15}], + 13: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app, $, gc) { + app.views.tableSearch = require('./../views/table-search.js')(app, $, gc); + app.views.tableNav = require('./../views/table-nav.js')(app, $, gc); + + return app.views.base.extend({ + timeoutID: null, + ajax: null, + tableNavView: null, + searchView: null, + modelView: null, // Need to override. + timeoutTime: 1000, + + events: { + 'click .gc-field-th.sortable': 'sortRowsByColumn', + 'change .gc-field-th.gc-check-column input': 'checkAll' + }, + + initialize: function initialize() { + this.setupAjax(); + + this.listenTo(this.collection, 'render', this.render); + this.listenTo(this.collection, 'notAllChecked', this.allCheckedStatus); + this.listenTo(this.collection, 'change:checked', this.renderNav); + this.listenTo(this, 'render', this.render); + + this.tableNavView = new app.views.tableNav({ + collection: this.collection + }); + + this.searchView = new app.views.tableSearch({ + collection: this.collection + }); + }, + + // Need to override. + setupAjax: function setupAjax() { + }, + + sortRowsByColumn: function sortRowsByColumn(evt) { + evt.preventDefault(); + var collection = this.collection.current(); + + var $this = $(evt.currentTarget); + var column = $this.find('a').data('id'); + var direction = false; + + if ($this.hasClass('asc')) { + direction = 'desc'; + } - if ($this.hasClass('desc')) { - direction = 'asc'; - } + if ($this.hasClass('desc')) { + direction = 'asc'; + } - if (!direction) { - direction = collection.sortDirection; - } + if (!direction) { + direction = collection.sortDirection; + } - if ('asc' === direction) { - $this.addClass('desc').removeClass('asc'); - } else { - $this.addClass('asc').removeClass('desc'); - } + if ('asc' === direction) { + $this.addClass('desc').removeClass('asc'); + } else { + $this.addClass('asc').removeClass('desc'); + } - collection.trigger('sortByColumn', column, direction); - this.sortRender(); - }, + collection.trigger('sortByColumn', column, direction); + this.sortRender(); + }, - buttonStatus: function buttonStatus(enable) { - this.$('.button-primary').prop('disabled', !enable); - }, + buttonStatus: function buttonStatus(enable) { + this.$('.button-primary').prop('disabled', !enable); + }, - allCheckedStatus: function allCheckedStatus() { - this.$('.gc-field-th.gc-check-column input').prop('checked', this.collection.allChecked); - }, + allCheckedStatus: function allCheckedStatus() { + this.$('.gc-field-th.gc-check-column input').prop('checked', this.collection.allChecked); + }, - checkAll: function checkAll(evt) { - this.collection.trigger('checkAll', $(evt.target).is(':checked')); - }, + checkAll: function checkAll(evt) { + this.collection.trigger('checkAll', $(evt.target).is(':checked')); + }, - doSpinner: function doSpinner() { - var html = this.blankRow(''); - this.renderRows(html); - }, + doSpinner: function doSpinner() { + var html = this.blankRow(''); + this.renderRows(html); + }, - setTimeout: function setTimeout(callback) { - this.timeoutID = window.setTimeout(callback, this.timeoutTime); - }, + setTimeout: function setTimeout(callback) { + this.timeoutID = window.setTimeout(callback, this.timeoutTime); + }, - clearTimeout: function clearTimeout() { - window.clearTimeout(this.timeoutID); - this.timeoutID = null; - }, + clearTimeout: function clearTimeout() { + window.clearTimeout(this.timeoutID); + this.timeoutID = null; + }, - getRenderedRows: function getRenderedRows() { - var rows; + getRenderedRows: function getRenderedRows() { + var rows; - if (this.collection.current().length) { - rows = this.getRenderedModels(this.modelView, this.collection.current()); - } else { - rows = this.blankRow(gc._text.no_items); - } + if (this.collection.current().length) { + rows = this.getRenderedModels(this.modelView, this.collection.current()); + } else { + rows = this.blankRow(gc._text.no_items); + } - return rows; - }, + return rows; + }, - sortRender: function sortRender() { - this.render(); - }, + sortRender: function sortRender() { + this.render(); + }, - blankRow: function blankRow(html) { - var cols = this.$('thead tr > *').length; - return '' + html + ''; - }, + blankRow: function blankRow(html) { + var cols = this.$('thead tr > *').length; + return '' + html + ''; + }, - renderRows: function renderRows(html) { - this.$('tbody').html(html || this.getRenderedRows()); - }, + renderRows: function renderRows(html) { + this.$('tbody').html(html || this.getRenderedRows()); + }, - renderNav: function renderNav() { - this.$('#gc-tablenav').html(this.tableNavView.render().el); - }, + renderNav: function renderNav() { + this.$('#gc-tablenav').html(this.tableNavView.render().el); + }, - render: function render() { - var collection = this.collection.current(); + render: function render() { + var collection = this.collection.current(); - // Re-render and replace table rows. - this.renderRows(); + // Re-render and replace table rows. + this.renderRows(); - // Re-render table nav - this.renderNav(); + // Re-render table nav + this.renderNav(); - // Make sync button enabled/disabled - this.buttonStatus(collection.syncEnabled); + // Make sync button enabled/disabled + this.buttonStatus(collection.syncEnabled); - // Make check-all inputs checked/unchecked - this.allCheckedStatus(collection.allChecked); + // Make check-all inputs checked/unchecked + this.allCheckedStatus(collection.allChecked); - return this; - } + return this; + } - }); -}; + }); + }; -},{"./../views/table-nav.js":14,"./../views/table-search.js":15}],14:[function(require,module,exports){ -'use strict'; + }, {"./../views/table-nav.js": 14, "./../views/table-search.js": 15}], + 14: [function (require, module, exports) { + 'use strict'; -module.exports = function (app, $, gc) { - return app.views.base.extend({ - template: wp.template('gc-table-nav'), + module.exports = function (app, $, gc) { + return app.views.base.extend({ + template: wp.template('gc-table-nav'), - render: function render() { - var collection = this.collection.current(); + render: function render() { + var collection = this.collection.current(); - this.$el.html(this.template({ - count: collection.length, - selected: collection.checked ? collection.checked().length : 0 - })); + this.$el.html(this.template({ + count: collection.length, + selected: collection.checked ? collection.checked().length : 0 + })); - return this; - } - }); -}; - -},{}],15:[function(require,module,exports){ -'use strict'; - -module.exports = function (app) { - return Backbone.View.extend({ - el: '#gc-items-search', - template: wp.template('gc-table-search'), - events: { - 'keyup #gc-search-input': 'filterCollection', - 'search #gc-search-input': 'filterCollection' - }, - - initialize: function initialize() { - this.render(); - }, - - filterCollection: _.debounce(function (evt) { - this.collection.search(evt.target.value); - }, 100), - - render: function render() { - this.$el.html(this.template()); - return this; - } + return this; + } + }); + }; + + }, {}], + 15: [function (require, module, exports) { + 'use strict'; + + module.exports = function (app) { + return Backbone.View.extend({ + el: '#gc-items-search', + template: wp.template('gc-table-search'), + events: { + 'keyup #gc-search-input': 'filterCollection', + 'search #gc-search-input': 'filterCollection' + }, + + initialize: function initialize() { + this.render(); + }, + + filterCollection: _.debounce(function (evt) { + this.collection.search(evt.target.value); + }, 100), + + render: function render() { + this.$el.html(this.template()); + return this; + } - }); -}; + }); + }; -},{}]},{},[9]); + }, {}] +}, {}, [9]); diff --git a/assets/js/gathercontent.js b/assets/js/gathercontent.js index ac48106c..37c0ae6a 100644 --- a/assets/js/gathercontent.js +++ b/assets/js/gathercontent.js @@ -1,117 +1,141 @@ /** * Content Workflow (by Bynder) - v1.0.0 - 2024-06-05 - * + * * * Copyright (c) 2024 Content Workflow (by Bynder) * Licensed under the GPLv2 license. */ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o Template Mapping: Field Description - * - Opens the drawer for a single field's description - */ - main.maybeReveal = function (evt) { - var $this = $(this); - evt.preventDefault(); - - if ($this.hasClass('dashicons-arrow-right')) { - $this.removeClass('dashicons-arrow-right').addClass('dashicons-arrow-down'); - $this.next().removeClass('hidden'); - } else { - $this.removeClass('dashicons-arrow-down').addClass('dashicons-arrow-right'); - $this.next().addClass('hidden'); - } - }; - - /** - * Accordion Toggle > Template Mapping: Component Fields - * - Opens the drawer for the component's description and subfields - */ - main.maybeRevealComponent = function (evt) { - var $this = $(this); - evt.preventDefault(); - - if ($this.hasClass('dashicons-arrow-right')) { - $this.closest('table').find('.gc-component-row').addClass('hidden'); - } else { - $this.closest('table').find('.gc-component-row').removeClass('hidden'); +(function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var a = typeof require == "function" && require; + if (!u && a) return a(o, !0); + if (i) return i(o, !0); + var f = new Error("Cannot find module '" + o + "'"); + throw f.code = "MODULE_NOT_FOUND", f + } + var l = n[o] = {exports: {}}; + t[o][0].call(l.exports, function (e) { + var n = t[o][1][e]; + return s(n ? n : e) + }, l, l.exports, e, t, n, r) } - }; - - $(main.init); - - window.onload = function () { - var textarea = jQuery('#system-info-textarea'); - if (textarea.length) { - textarea.css('height', jQuery(window).height() * 0.7 + 'px'); - } - }; - - document.addEventListener('DOMContentLoaded', function () { - if (typeof redirectData !== 'undefined' && redirectData.redirectUrl) { - window.location = redirectData.redirectUrl; - } - }); -})(window, document, jQuery, window.GatherContent); + return n[o].exports + } -},{"./log.js":1}]},{},[2]); + var i = typeof require == "function" && require; + for (var o = 0; o < r.length; o++) s(r[o]); + return s +})({ + 1: [function (require, module, exports) { + 'use strict'; + + module.exports = function log() { + var method = 'log'; + + if (arguments[0] in window.console) { + method = Array.prototype.shift.apply(arguments); + } + + log.history = log.history || []; + log.history.push(arguments); + + if (window.console && this.debug) { + window.console[method].apply(window.console, arguments); + } + }; + + }, {}], 2: [function (require, module, exports) { + 'use strict'; + + window.GatherContent = window.GatherContent || {}; + + (function (window, document, $, gc, undefined) { + 'use strict'; + + gc.el = function (id) { + return document.getElementById(id); + }; + + gc.$id = function (id) { + return $(gc.el(id)); + }; + + gc.log = require('./log.js').bind(gc); + + var main = gc.main = {}; + + main.init = function () { + $(document.body).on('click', '.gc-nav-tab-wrapper:not( .gc-nav-tab-wrapper-bb ) .nav-tab', main.changeTabs).on('click', '.gc-reveal-items', main.maybeReveal).on('click', '.gc-reveal-items-component', main.maybeRevealComponent); + + if (gc.queryargs.mapping) { + var $menu = gc.$id('toplevel_page_gathercontent-import'); + $menu.find('.current').removeClass('current'); + $menu.find('[href="edit.php?post_type=gc_templates"]').parent().addClass('current'); + } + }; + + main.changeTabs = function (evt) { + evt.preventDefault(); + + main.$tabNav = main.$tabNav || $('.gc-nav-tab-wrapper .nav-tab'); + main.$tabs = main.$tabs || $('.gc-template-tab'); + + main.$tabNav.removeClass('nav-tab-active'); + $(this).addClass('nav-tab-active'); + main.$tabs.addClass('hidden'); + gc.$id($(this).attr('href').substring(1)).removeClass('hidden'); + }; + + /** + * Accordion Toggle > Template Mapping: Field Description + * - Opens the drawer for a single field's description + */ + main.maybeReveal = function (evt) { + var $this = $(this); + evt.preventDefault(); + + if ($this.hasClass('dashicons-arrow-right')) { + $this.removeClass('dashicons-arrow-right').addClass('dashicons-arrow-down'); + $this.next().removeClass('hidden'); + } else { + $this.removeClass('dashicons-arrow-down').addClass('dashicons-arrow-right'); + $this.next().addClass('hidden'); + } + }; + + /** + * Accordion Toggle > Template Mapping: Component Fields + * - Opens the drawer for the component's description and subfields + */ + main.maybeRevealComponent = function (evt) { + var $this = $(this); + evt.preventDefault(); + + if ($this.hasClass('dashicons-arrow-right')) { + $this.closest('table').find('.gc-component-row').addClass('hidden'); + } else { + $this.closest('table').find('.gc-component-row').removeClass('hidden'); + } + }; + + $(main.init); + + window.onload = function () { + var textarea = jQuery('#system-info-textarea'); + if (textarea.length) { + textarea.css('height', jQuery(window).height() * 0.7 + 'px'); + } + }; + + document.addEventListener('DOMContentLoaded', function () { + if (typeof redirectData !== 'undefined' && redirectData.redirectUrl) { + window.location = redirectData.redirectUrl; + } + }); + })(window, document, jQuery, window.GatherContent); + + }, {"./log.js": 1}] +}, {}, [2]); diff --git a/assets/js/src/components/collections/base.js b/assets/js/src/components/collections/base.js index 88761eb8..798ed7f8 100644 --- a/assets/js/src/components/collections/base.js +++ b/assets/js/src/components/collections/base.js @@ -1,8 +1,8 @@ module.exports = Backbone.Collection.extend({ - getById : function( id ) { - return this.find( function( model ) { - var modelId = model.get( 'id' ); + getById: function (id) { + return this.find(function (model) { + var modelId = model.get('id'); return modelId === id || modelId && id && modelId == id; - } ); + }); }, }); diff --git a/assets/js/src/components/collections/items.js b/assets/js/src/components/collections/items.js index efa1d5fe..2d022c9e 100644 --- a/assets/js/src/components/collections/items.js +++ b/assets/js/src/components/collections/items.js @@ -1,42 +1,42 @@ -module.exports = function( app ) { - var sortKey = null; +module.exports = function (app) { + var sortKey = null; var sortDirection = 'asc'; var Collection = app.collections.base.extend({ - model : app.models.item, - totalChecked : 0, - allChecked : false, - syncEnabled : false, - processing : false, - sortKey : sortKey, - sortDirection : sortDirection, - - initialize: function( models, options ) { - this.listenTo( this, 'checkAll', this.toggleChecked ); - this.listenTo( this, 'checkSome', this.toggleCheckedIf ); - this.listenTo( this, 'change:checked', this.checkChecked ); - this.listenTo( this, 'sortByColumn', this.sortByColumn ); + model: app.models.item, + totalChecked: 0, + allChecked: false, + syncEnabled: false, + processing: false, + sortKey: sortKey, + sortDirection: sortDirection, + + initialize: function (models, options) { + this.listenTo(this, 'checkAll', this.toggleChecked); + this.listenTo(this, 'checkSome', this.toggleCheckedIf); + this.listenTo(this, 'change:checked', this.checkChecked); + this.listenTo(this, 'sortByColumn', this.sortByColumn); this.totalChecked = this.checked().length; - if ( options && options.reinit ) { - this.reinit( models ); + if (options && options.reinit) { + this.reinit(models); } }, - reinit: function( models ) { - this.totalChecked = this.checked( models ).length; - this.syncEnabled = this.totalChecked > 0; - this.allChecked = this.totalChecked >= models.length; - this.sortKey = sortKey; + reinit: function (models) { + this.totalChecked = this.checked(models).length; + this.syncEnabled = this.totalChecked > 0; + this.allChecked = this.totalChecked >= models.length; + this.sortKey = sortKey; this.sortDirection = sortDirection; this.sort(); }, - checkChecked: function( model ) { - if ( model.changed.checked ) { + checkChecked: function (model) { + if (model.changed.checked) { this.totalChecked++; } else { - if ( this.totalChecked === this.length ) { + if (this.totalChecked === this.length) { this.allChecked = false; } this.totalChecked--; @@ -45,82 +45,82 @@ module.exports = function( app ) { this.checkAllStatus(); }, - checkAllStatus: function( checked ) { + checkAllStatus: function (checked) { var syncWasEnabled = this.syncEnabled; this.syncEnabled = this.totalChecked > 0; - if ( syncWasEnabled !== this.syncEnabled ) { - this.trigger( 'enabledChange', this.syncEnabled ); + if (syncWasEnabled !== this.syncEnabled) { + this.trigger('enabledChange', this.syncEnabled); } - if ( this.totalChecked < this.length ) { - this.trigger( 'notAllChecked', false ); + if (this.totalChecked < this.length) { + this.trigger('notAllChecked', false); } }, - toggleCheckedIf: function( checked ) { + toggleCheckedIf: function (checked) { this.processing = true; - this.stopListening( this, 'change:checked', this.checkChecked ); - this.each( function( model ) { - model.set( 'checked', Boolean( 'function' === typeof checked ? checked( model ) : checked ) ); - } ); - this.listenTo( this, 'change:checked', this.checkChecked ); + this.stopListening(this, 'change:checked', this.checkChecked); + this.each(function (model) { + model.set('checked', Boolean('function' === typeof checked ? checked(model) : checked)); + }); + this.listenTo(this, 'change:checked', this.checkChecked); - this.totalChecked = this.checked().length; - this.allChecked = this.totalChecked >= this.length; + this.totalChecked = this.checked().length; + this.allChecked = this.totalChecked >= this.length; this.checkAllStatus(); this.processing = false; - this.trigger( 'render' ); + this.trigger('render'); }, - toggleChecked: function( checked ) { + toggleChecked: function (checked) { this.allChecked = checked; - this.toggleCheckedIf( checked ); + this.toggleCheckedIf(checked); }, - checked: function( models ) { + checked: function (models) { models = models || this; - return models.filter( function( model ) { - return model.get( 'checked' ); - } ); + return models.filter(function (model) { + return model.get('checked'); + }); }, - comparator: function( a, b ) { - if ( ! this.sortKey ) { + comparator: function (a, b) { + if (!this.sortKey) { return; } - var dataA = a.get( this.sortKey ); - var dataB = b.get( this.sortKey ); + var dataA = a.get(this.sortKey); + var dataB = b.get(this.sortKey); - if ( 'updated_at' === this.sortKey ) { + if ('updated_at' === this.sortKey) { dataA = dataA.date || dataA; dataB = dataB.date || dataB; } - if ( 'status' === this.sortKey ) { + if ('status' === this.sortKey) { dataA = dataA.name || dataA; dataB = dataB.name || dataB; } - if ( 'asc' === this.sortDirection ) { - if ( dataA > dataB ) { + if ('asc' === this.sortDirection) { + if (dataA > dataB) { return -1; } - if ( dataB > dataA ) { + if (dataB > dataA) { return 1; } return 0; } else { - if ( dataA < dataB ) { + if (dataA < dataB) { return -1; } - if ( dataB < dataA ) { + if (dataB < dataA) { return 1; } @@ -128,14 +128,14 @@ module.exports = function( app ) { } }, - sortByColumn: function( column, direction ) { + sortByColumn: function (column, direction) { this.sortKey = sortKey = column; this.sortDirection = sortDirection = direction; this.sort(); } - } ); + }); - return require( './../collections/search-extension.js' )( Collection ); + return require('./../collections/search-extension.js')(Collection); }; diff --git a/assets/js/src/components/collections/modal-nav-items.js b/assets/js/src/components/collections/modal-nav-items.js index 6b15c274..28bf3ece 100644 --- a/assets/js/src/components/collections/modal-nav-items.js +++ b/assets/js/src/components/collections/modal-nav-items.js @@ -1,23 +1,23 @@ -module.exports = function( app ) { +module.exports = function (app) { return app.collections.base.extend({ - model : app.models.navItem, + model: app.models.navItem, - initialize: function() { - this.listenTo( this, 'activate', this.activate ); + initialize: function () { + this.listenTo(this, 'activate', this.activate); }, - getActive: function() { - return this.find( function( model ) { - return ! model.get( 'hidden' ); + getActive: function () { + return this.find(function (model) { + return !model.get('hidden'); }); }, - activate: function( id ) { - this.each( function( model ) { - model.set( 'hidden', true ); + activate: function (id) { + this.each(function (model) { + model.set('hidden', true); }); - this.getById( id ).set( 'hidden', false ); - this.trigger( 'render' ); + this.getById(id).set('hidden', false); + this.trigger('render'); } }); }; diff --git a/assets/js/src/components/collections/posts.js b/assets/js/src/components/collections/posts.js index 03cf31a3..bd5b7e84 100644 --- a/assets/js/src/components/collections/posts.js +++ b/assets/js/src/components/collections/posts.js @@ -1,34 +1,34 @@ -module.exports = function( app ) { - var items = require( './../collections/items.js' )( app ); +module.exports = function (app) { + var items = require('./../collections/items.js')(app); - return require( './../collections/search-extension.js' )( items.extend( { - model : app.models.post, + return require('./../collections/search-extension.js')(items.extend({ + model: app.models.post, - initialize: function( models, options ) { - items.prototype.initialize.call( this, models, options ); + initialize: function (models, options) { + items.prototype.initialize.call(this, models, options); - this.listenTo( this, 'updateItems', this.updateItems ); + this.listenTo(this, 'updateItems', this.updateItems); }, - updateItems: function( data ) { - this.each( function( model ) { - var id = model.get( 'id' ); - if ( id in data ) { - if ( data[ id ].status ) { - model.set( 'status', data[ id ].status ); + updateItems: function (data) { + this.each(function (model) { + var id = model.get('id'); + if (id in data) { + if (data[id].status) { + model.set('status', data[id].status); } - if ( data[ id ].itemName ) { - model.set( 'itemName', data[ id ].itemName ); + if (data[id].itemName) { + model.set('itemName', data[id].itemName); } - if ( data[ id ].updated_at ) { - model.set( 'updated_at', data[ id ].updated_at ); + if (data[id].updated_at) { + model.set('updated_at', data[id].updated_at); } } - } ); + }); }, - checkedCan: function( pushOrPull ) { - switch( pushOrPull ) { + checkedCan: function (pushOrPull) { + switch (pushOrPull) { case 'pull' : pushOrPull = 'canPull'; break; @@ -41,12 +41,12 @@ module.exports = function( app ) { break; } - var can = this.find( function( model ){ - return model.get( pushOrPull ) && model.get( 'checked' ); - } ); + var can = this.find(function (model) { + return model.get(pushOrPull) && model.get('checked'); + }); return can; }, - } ) ); + })); }; diff --git a/assets/js/src/components/collections/search-extension.js b/assets/js/src/components/collections/search-extension.js index 4bbc5426..82930e15 100644 --- a/assets/js/src/components/collections/search-extension.js +++ b/assets/js/src/components/collections/search-extension.js @@ -1,91 +1,91 @@ -module.exports = function( Collection ) { +module.exports = function (Collection) { - _.extend( Collection.prototype, { + _.extend(Collection.prototype, { //_Cache _searchResults: null, //@ Search wrapper function - search: function( keyword, attributes ) { - var results = this._doSearch( keyword, attributes ); + search: function (keyword, attributes) { + var results = this._doSearch(keyword, attributes); - this.trigger( 'search', results ); + this.trigger('search', results); // For use of returning un-async return results; }, //@ Search function - _doSearch: function( keyword, attributes ) { + _doSearch: function (keyword, attributes) { attributes = attributes && attributes.length ? attributes : false; // If collection empty get out - if ( ! this.models.length ) { + if (!this.models.length) { return []; } // Filter var matcher = this.matcher; - var results = ! keyword ? this.models : this.filter( function( model ) { - attributes = attributes ? attributes : model.searchAttributes || _.keys( model.attributes ); - return _.some( attributes, function( attribute ) { - return matcher( keyword, model.get( attribute ) ); - } ); - } ); + var results = !keyword ? this.models : this.filter(function (model) { + attributes = attributes ? attributes : model.searchAttributes || _.keys(model.attributes); + return _.some(attributes, function (attribute) { + return matcher(keyword, model.get(attribute)); + }); + }); - this.trigger( 'searchResults', results ); + this.trigger('searchResults', results); // Instantiate new Collection - var collection = new Collection( results, { reinit : true } ); + var collection = new Collection(results, {reinit: true}); collection.searching = { keyword: keyword, attributes: attributes }; - collection.getSearchQuery = function() { + collection.getSearchQuery = function () { return this.searching; }; // Cache the recently searched metadata this._searchResults = collection; - this.trigger( 'search', collection ); + this.trigger('search', collection); // For use of returning un-async return collection; }, //@ Default Matcher - may be overwritten - matcher: function( needle, haystack ) { - if ( ! needle || ! haystack ) { + matcher: function (needle, haystack) { + if (!needle || !haystack) { return; } - needle = needle.toString().toLowerCase(); + needle = needle.toString().toLowerCase(); haystack = haystack.toString().toLowerCase(); - return haystack.indexOf( needle ) >= 0; + return haystack.indexOf(needle) >= 0; }, //@ Get recent search value - getSearchValue: function() { + getSearchValue: function () { return this.getSearchQuery().keyword; }, //@ Get recent search query - getSearchQuery: function() { + getSearchQuery: function () { return this._searchResults && this._searchResults.getSearchQuery() || {}; }, //@ Get recent search results - getSearchResults: function() { + getSearchResults: function () { return this._searchResults; }, - current: function() { + current: function () { return this._searchResults || this; } - } ); + }); return Collection; }; diff --git a/assets/js/src/components/collections/tab-rows.js b/assets/js/src/components/collections/tab-rows.js index 0a77227f..afbd5029 100644 --- a/assets/js/src/components/collections/tab-rows.js +++ b/assets/js/src/components/collections/tab-rows.js @@ -1,8 +1,8 @@ -module.exports = function( app ) { +module.exports = function (app) { return app.collections.base.extend({ - model : app.models.tabRow, + model: app.models.tabRow, - initialize: function( models, options ) { + initialize: function (models, options) { this.tab = options.tab; } }); diff --git a/assets/js/src/components/collections/tabs.js b/assets/js/src/components/collections/tabs.js index 44094e3f..ad3c182c 100644 --- a/assets/js/src/components/collections/tabs.js +++ b/assets/js/src/components/collections/tabs.js @@ -1,5 +1,5 @@ -module.exports = function( app ) { +module.exports = function (app) { return app.collections.base.extend({ - model : app.models.tab, + model: app.models.tab, }); }; diff --git a/assets/js/src/components/database.js b/assets/js/src/components/database.js index b3f6dc15..36a5f193 100644 --- a/assets/js/src/components/database.js +++ b/assets/js/src/components/database.js @@ -5,12 +5,12 @@ window.GatherContent = window.GatherContent || {}; * defined in \GatherContent\Importer\Admin\Mapping\Field_Types\Database */ -(function(window, document, $){ +(function (window, document, $) { /** * @param {HTMLElement} someElement * @returns {HTMLInputElement} */ - function getSiblingHiddenInput(someElement){ + function getSiblingHiddenInput(someElement) { return someElement.parentElement.querySelector('.hidden-database-table-name'); } @@ -21,12 +21,12 @@ window.GatherContent = window.GatherContent || {}; * @param {HTMLSelectElement} columnSelectElement * @param {string} tableName */ - function resetColumnSelector(columnSelectElement, tableName){ + function resetColumnSelector(columnSelectElement, tableName) { columnSelectElement.value = ''; - columnSelectElement.querySelectorAll('option').forEach(function(o){ - if(o.getAttribute('data-tablename') === tableName){ + columnSelectElement.querySelectorAll('option').forEach(function (o) { + if (o.getAttribute('data-tablename') === tableName) { o.style.display = 'block'; - }else{ + } else { o.style.display = 'none'; } }); @@ -40,17 +40,17 @@ window.GatherContent = window.GatherContent || {}; * @param {string|undefined} table * @param {string|undefined} column */ - function setHiddenValue(inputElement, table, column){ - if(!inputElement.value.includes('.')){ + function setHiddenValue(inputElement, table, column) { + if (!inputElement.value.includes('.')) { inputElement.value = '.'; } var parts = inputElement.value.split('.'); - if(typeof table === 'string') { + if (typeof table === 'string') { parts[0] = table; } - if(typeof column === 'string') { + if (typeof column === 'string') { parts[1] = column; } @@ -60,7 +60,7 @@ window.GatherContent = window.GatherContent || {}; /** * @param {Event} event */ - function columnSelectorChanged(event){ + function columnSelectorChanged(event) { /** @var {HTMLSelectElement} columnSelect */ var columnSelect = event.target; @@ -74,7 +74,7 @@ window.GatherContent = window.GatherContent || {}; /** * @param {Event} event */ - function tableSelectorChanged(event){ + function tableSelectorChanged(event) { /** @var {HTMLSelectElement} tableSelect */ var tableSelect = event.target; diff --git a/assets/js/src/components/general.js b/assets/js/src/components/general.js index 9de37181..be4f0ed0 100644 --- a/assets/js/src/components/general.js +++ b/assets/js/src/components/general.js @@ -1,93 +1,93 @@ window.GatherContent = window.GatherContent || {}; -( function( window, document, $, gc, undefined ) { +(function (window, document, $, gc, undefined) { 'use strict'; gc.general = gc.general || {}; var app = gc.general; // Initiate base objects. - require( './initiate-objects.js' )( app ); + require('./initiate-objects.js')(app); /* * Posts */ - app.models.post = require( './models/post.js' )( gc ); - app.collections.posts = require( './collections/posts.js' )( app ); - app.views.postRow = require( './views/post-row.js' )( app, gc ); - app.views.statusSelect2 = require( './views/status-select2.js' )( app ); - app.views.postRows = require( './views/post-rows.js' )( app, gc, $ ); + app.models.post = require('./models/post.js')(gc); + app.collections.posts = require('./collections/posts.js')(app); + app.views.postRow = require('./views/post-row.js')(app, gc); + app.views.statusSelect2 = require('./views/status-select2.js')(app); + app.views.postRows = require('./views/post-rows.js')(app, gc, $); /* * Nav Items */ - app.models.navItem = require( './models/modal-nav-item.js' )( app ); - app.collections.navItems = require( './collections/modal-nav-items.js' )( app ); + app.models.navItem = require('./models/modal-nav-item.js')(app); + app.collections.navItems = require('./collections/modal-nav-items.js')(app); - app.views.tableBase = require( './views/table-base.js' )( app, $, gc ); - app.views.modalPostRow = require( './views/modal-post-row.js' )( app, gc ); - app.views.modal = require( './views/modal.js' )( app, gc, $ ); + app.views.tableBase = require('./views/table-base.js')(app, $, gc); + app.views.modalPostRow = require('./views/modal-post-row.js')(app, gc); + app.views.modal = require('./views/modal.js')(app, gc, $); - app.monkeyPatchQuickEdit = function( cb ) { + app.monkeyPatchQuickEdit = function (cb) { // we create a copy of the WP inline edit post function var edit = window.inlineEditPost.edit; // and then we overwrite the function with our own code - window.inlineEditPost.edit = function() { + window.inlineEditPost.edit = function () { // "call" the original WP edit function // we don't want to leave WordPress hanging - edit.apply( this, arguments ); + edit.apply(this, arguments); // now we take care of our business - cb.apply( this, arguments ); + cb.apply(this, arguments); }; }; - app.triggerModal = function( evt ) { + app.triggerModal = function (evt) { evt.preventDefault(); var posts = app.getChecked(); - if ( ! posts.length ) { + if (!posts.length) { return; } - if ( app.modalView === undefined ) { - app.modalView = new app.views.modal( { - collection : app.generalView.collection - } ); - app.modalView.checked( posts ); - app.generalView.listenTo( app.modalView, 'updateModels', app.generalView.updatePosts ); + if (app.modalView === undefined) { + app.modalView = new app.views.modal({ + collection: app.generalView.collection + }); + app.modalView.checked(posts); + app.generalView.listenTo(app.modalView, 'updateModels', app.generalView.updatePosts); } }; - app.getChecked = function() { - return $( 'tbody th.check-column input[type="checkbox"]:checked' ).map( function() { - return parseInt( $( this ).val(), 10 ); + app.getChecked = function () { + return $('tbody th.check-column input[type="checkbox"]:checked').map(function () { + return parseInt($(this).val(), 10); }).get(); }; - app.init = function() { - $( document.body ) - .addClass( 'gathercontent-admin-select2' ) - .on( 'click', '#gc-sync-modal', app.triggerModal ); + app.init = function () { + $(document.body) + .addClass('gathercontent-admin-select2') + .on('click', '#gc-sync-modal', app.triggerModal); - $( document ).ajaxSend( function( evt, request, settings ) { - if ( settings.data && -1 !== settings.data.indexOf( '&action=inline-save' ) ) { - app.generalView.trigger( 'quickEditSend', request, settings ); + $(document).ajaxSend(function (evt, request, settings) { + if (settings.data && -1 !== settings.data.indexOf('&action=inline-save')) { + app.generalView.trigger('quickEditSend', request, settings); } - } ); + }); - app.generalView = new app.views.postRows( { - collection : new app.collections.posts( gc._posts ) - } ); + app.generalView = new app.views.postRows({ + collection: new app.collections.posts(gc._posts) + }); - app.monkeyPatchQuickEdit( function() { - app.generalView.trigger( 'quickEdit', arguments, this ); - } ); + app.monkeyPatchQuickEdit(function () { + app.generalView.trigger('quickEdit', arguments, this); + }); }; - $( app.init ); + $(app.init); -} )( window, document, jQuery, window.GatherContent ); +})(window, document, jQuery, window.GatherContent); diff --git a/assets/js/src/components/initiate-objects.js b/assets/js/src/components/initiate-objects.js index eaae3043..6dd88ca3 100644 --- a/assets/js/src/components/initiate-objects.js +++ b/assets/js/src/components/initiate-objects.js @@ -1,5 +1,5 @@ -module.exports = function( app ) { - app.models = { base : require( './models/base.js' ) }; - app.collections = { base : require( './collections/base.js' ) }; - app.views = { base : require( './views/base.js' ) }; +module.exports = function (app) { + app.models = {base: require('./models/base.js')}; + app.collections = {base: require('./collections/base.js')}; + app.views = {base: require('./views/base.js')}; }; diff --git a/assets/js/src/components/log.js b/assets/js/src/components/log.js index 8d5f4f42..c6e921c4 100644 --- a/assets/js/src/components/log.js +++ b/assets/js/src/components/log.js @@ -1,14 +1,14 @@ module.exports = function log() { var method = 'log'; - if ( arguments[0] in window.console ) { + if (arguments[0] in window.console) { method = Array.prototype.shift.apply(arguments); } log.history = log.history || []; - log.history.push( arguments ); + log.history.push(arguments); - if ( window.console && this.debug ) { - window.console[ method ].apply( window.console, arguments ); + if (window.console && this.debug) { + window.console[method].apply(window.console, arguments); } }; diff --git a/assets/js/src/components/main.js b/assets/js/src/components/main.js index cb9a7a29..0e2f14eb 100644 --- a/assets/js/src/components/main.js +++ b/assets/js/src/components/main.js @@ -1,59 +1,59 @@ window.GatherContent = window.GatherContent || {}; -( function( window, document, $, gc, undefined ) { +(function (window, document, $, gc, undefined) { 'use strict'; - gc.el = function( id ) { - return document.getElementById( id ); + gc.el = function (id) { + return document.getElementById(id); }; - gc.$id = function( id ) { - return $( gc.el( id ) ); + gc.$id = function (id) { + return $(gc.el(id)); }; - gc.log = require( './log.js' ).bind( gc ); + gc.log = require('./log.js').bind(gc); var main = gc.main = {}; - main.init = function() { - $( document.body ) - .on( 'click', '.gc-nav-tab-wrapper:not( .gc-nav-tab-wrapper-bb ) .nav-tab', main.changeTabs ) - .on( 'click', '.gc-reveal-items', main.maybeReveal ) - .on( 'click', '.gc-reveal-items-component', main.maybeRevealComponent ); + main.init = function () { + $(document.body) + .on('click', '.gc-nav-tab-wrapper:not( .gc-nav-tab-wrapper-bb ) .nav-tab', main.changeTabs) + .on('click', '.gc-reveal-items', main.maybeReveal) + .on('click', '.gc-reveal-items-component', main.maybeRevealComponent); - if ( gc.queryargs.mapping ) { - var $menu = gc.$id( 'toplevel_page_gathercontent-import' ); - $menu.find( '.current' ).removeClass( 'current' ); - $menu.find( '[href="edit.php?post_type=gc_templates"]' ).parent().addClass( 'current' ); + if (gc.queryargs.mapping) { + var $menu = gc.$id('toplevel_page_gathercontent-import'); + $menu.find('.current').removeClass('current'); + $menu.find('[href="edit.php?post_type=gc_templates"]').parent().addClass('current'); } }; - main.changeTabs = function( evt ) { + main.changeTabs = function (evt) { evt.preventDefault(); - main.$tabNav = main.$tabNav || $( '.gc-nav-tab-wrapper .nav-tab' ); - main.$tabs = main.$tabs || $( '.gc-template-tab' ); + main.$tabNav = main.$tabNav || $('.gc-nav-tab-wrapper .nav-tab'); + main.$tabs = main.$tabs || $('.gc-template-tab'); - main.$tabNav.removeClass( 'nav-tab-active' ); - $( this ).addClass( 'nav-tab-active' ); - main.$tabs.addClass( 'hidden' ); - gc.$id( $( this ).attr( 'href' ).substring(1) ).removeClass( 'hidden' ); + main.$tabNav.removeClass('nav-tab-active'); + $(this).addClass('nav-tab-active'); + main.$tabs.addClass('hidden'); + gc.$id($(this).attr('href').substring(1)).removeClass('hidden'); }; /** * Accordion Toggle > Template Mapping: Field Description * - Opens the drawer for a single field's description */ - main.maybeReveal = function( evt ) { - var $this = $( this ); + main.maybeReveal = function (evt) { + var $this = $(this); evt.preventDefault(); - if ( $this.hasClass( 'dashicons-arrow-right' ) ) { - $this.removeClass( 'dashicons-arrow-right' ).addClass( 'dashicons-arrow-down' ); - $this.next().removeClass( 'hidden' ); + if ($this.hasClass('dashicons-arrow-right')) { + $this.removeClass('dashicons-arrow-right').addClass('dashicons-arrow-down'); + $this.next().removeClass('hidden'); } else { - $this.removeClass( 'dashicons-arrow-down' ).addClass( 'dashicons-arrow-right' ); - $this.next().addClass( 'hidden' ); + $this.removeClass('dashicons-arrow-down').addClass('dashicons-arrow-right'); + $this.next().addClass('hidden'); } }; @@ -61,18 +61,18 @@ window.GatherContent = window.GatherContent || {}; * Accordion Toggle > Template Mapping: Component Fields * - Opens the drawer for the component's description and subfields */ - main.maybeRevealComponent = function( evt ) { - var $this = $( this ); + main.maybeRevealComponent = function (evt) { + var $this = $(this); evt.preventDefault(); - if ( $this.hasClass( 'dashicons-arrow-right' ) ) { - $this.closest('table').find('.gc-component-row').addClass( 'hidden' ); + if ($this.hasClass('dashicons-arrow-right')) { + $this.closest('table').find('.gc-component-row').addClass('hidden'); } else { - $this.closest('table').find('.gc-component-row').removeClass( 'hidden' ); + $this.closest('table').find('.gc-component-row').removeClass('hidden'); } }; - $( main.init ); + $(main.init); window.onload = function () { var textarea = jQuery('#system-info-textarea'); @@ -81,10 +81,10 @@ window.GatherContent = window.GatherContent || {}; } }; - document.addEventListener('DOMContentLoaded', function() { + document.addEventListener('DOMContentLoaded', function () { if (typeof redirectData !== 'undefined' && redirectData.redirectUrl) { window.location = redirectData.redirectUrl; } }); -} )( window, document, jQuery, window.GatherContent ); +})(window, document, jQuery, window.GatherContent); diff --git a/assets/js/src/components/mapping.js b/assets/js/src/components/mapping.js index 30a50c02..39244445 100644 --- a/assets/js/src/components/mapping.js +++ b/assets/js/src/components/mapping.js @@ -1,48 +1,48 @@ window.GatherContent = window.GatherContent || {}; -( function( window, document, $, gc, undefined ) { +(function (window, document, $, gc, undefined) { 'use strict'; gc.mapping = gc.mapping || {}; var app = gc.mapping; // Initiate base objects. - require( './initiate-objects.js' )( app ); - app.views.statusSelect2 = require( './views/status-select2.js' )( app ); + require('./initiate-objects.js')(app); + app.views.statusSelect2 = require('./views/status-select2.js')(app); /* * Tab Row setup */ - app.models.tabRow = require( './models/tab-row.js' )( app, gc ); - app.collections.tabRows = require( './collections/tab-rows.js' )( app ); - app.views.tabRow = require( './views/tab-row.js' )( app, gc._meta_keys ); + app.models.tabRow = require('./models/tab-row.js')(app, gc); + app.collections.tabRows = require('./collections/tab-rows.js')(app); + app.views.tabRow = require('./views/tab-row.js')(app, gc._meta_keys); /* * Tab setup */ - app.models.tab = require( './models/tab.js' )( app, gc._table_headings ); - app.collections.tabs = require( './collections/tabs.js' )( app ); - app.views.tab = require( './views/tab.js' )( app ); + app.models.tab = require('./models/tab.js')(app, gc._table_headings); + app.collections.tabs = require('./collections/tabs.js')(app); + app.views.tab = require('./views/tab.js')(app); - app.views.tabLink = require( './views/tab-link.js' )( app ); + app.views.tabLink = require('./views/tab-link.js')(app); - app.views.defaultTab = require( './views/default-tab.js' )( app, gc._table_headings ); + app.views.defaultTab = require('./views/default-tab.js')(app, gc._table_headings); /* * Overall view setup */ - app.views.tabs = require( './views/tabs.js' )( app, $, gc ); + app.views.tabs = require('./views/tabs.js')(app, $, gc); - app.init = function() { + app.init = function () { // Kick it off. - app.mappingView = new app.views.tabs( { - collection : new app.collections.tabs( gc._tabs ) - } ); + app.mappingView = new app.views.tabs({ + collection: new app.collections.tabs(gc._tabs) + }); }; - $( app.init ); + $(app.init); -} )( window, document, jQuery, window.GatherContent ); +})(window, document, jQuery, window.GatherContent); diff --git a/assets/js/src/components/models/ajax.js b/assets/js/src/components/models/ajax.js index e7a5b533..12d4a8ea 100644 --- a/assets/js/src/components/models/ajax.js +++ b/assets/js/src/components/models/ajax.js @@ -1,52 +1,52 @@ -module.exports = function( app, defaults ) { - defaults = jQuery.extend( {}, { - action : 'gc_sync_items', - data : '', - percent : 0, - nonce : '', - id : '', - stopSync : true, - flush_cache : false, - }, defaults ); +module.exports = function (app, defaults) { + defaults = jQuery.extend({}, { + action: 'gc_sync_items', + data: '', + percent: 0, + nonce: '', + id: '', + stopSync: true, + flush_cache: false, + }, defaults); return app.models.base.extend({ defaults: defaults, - initialize: function() { - this.listenTo( this, 'send', this.send ); + initialize: function () { + this.listenTo(this, 'send', this.send); }, - reset: function() { - this.clear().set( this.defaults ); + reset: function () { + this.clear().set(this.defaults); return this; }, - send: function( formData, cb, percent, failcb ) { - if ( percent ) { - this.set( 'percent', percent ); + send: function (formData, cb, percent, failcb) { + if (percent) { + this.set('percent', percent); } jQuery.post( window.ajaxurl, { - action : this.get( 'action' ), - percent : this.get( 'percent' ), - nonce : this.get( 'nonce' ), - id : this.get( 'id' ), - data : formData, - flush_cache : this.get( 'flush_cache' ) + action: this.get('action'), + percent: this.get('percent'), + nonce: this.get('nonce'), + id: this.get('id'), + data: formData, + flush_cache: this.get('flush_cache') }, - function( response ) { - this.trigger( 'response', response, formData ); + function (response) { + this.trigger('response', response, formData); - if ( response.success ) { - return cb( response ); + if (response.success) { + return cb(response); } - if ( failcb ) { - return failcb( response ); + if (failcb) { + return failcb(response); } - }.bind( this ) + }.bind(this) ); return this; diff --git a/assets/js/src/components/models/base.js b/assets/js/src/components/models/base.js index 66081030..1d4a0f53 100644 --- a/assets/js/src/components/models/base.js +++ b/assets/js/src/components/models/base.js @@ -1,3 +1,5 @@ module.exports = Backbone.Model.extend({ - sync: function () { return false; } + sync: function () { + return false; + } }); diff --git a/assets/js/src/components/models/item.js b/assets/js/src/components/models/item.js index cee3f348..870acd92 100644 --- a/assets/js/src/components/models/item.js +++ b/assets/js/src/components/models/item.js @@ -1,30 +1,30 @@ -module.exports = function( app, gc ) { - return require( './../models/modify-json.js' )( app.models.base.extend({ +module.exports = function (app, gc) { + return require('./../models/modify-json.js')(app.models.base.extend({ defaults: { - id : 0, - item : 0, - itemName : 0, - project_id : 0, - parent_id : 0, - template_id : 0, - custom_state_id : 0, - position : 0, - name : '', - config : '', - notes : '', - type : '', - typeName : '', - overdue : false, - archived_by : '', - archived_at : '', - created_at : null, - updated_at : null, - status : null, - due_dates : null, - expanded : false, - checked : false, - post_title : false, - ptLabel : false, + id: 0, + item: 0, + itemName: 0, + project_id: 0, + parent_id: 0, + template_id: 0, + custom_state_id: 0, + position: 0, + name: '', + config: '', + notes: '', + type: '', + typeName: '', + overdue: false, + archived_by: '', + archived_at: '', + created_at: null, + updated_at: null, + status: null, + due_dates: null, + expanded: false, + checked: false, + post_title: false, + ptLabel: false, }, searchAttributes: [ @@ -32,15 +32,15 @@ module.exports = function( app, gc ) { 'post_title', ], - _get_item : function( value ) { - return this.get( 'id' ); + _get_item: function (value) { + return this.get('id'); }, - _get_typeName : function( value ) { - if ( ! value ) { - value = Backbone.Model.prototype.get.call( this, 'type' ); + _get_typeName: function (value) { + if (!value) { + value = Backbone.Model.prototype.get.call(this, 'type'); } - return gc._type_names[ value ] ? gc._type_names[ value ] : value; + return gc._type_names[value] ? gc._type_names[value] : value; } - } ) ); + })); }; diff --git a/assets/js/src/components/models/modal-nav-item.js b/assets/js/src/components/models/modal-nav-item.js index 6eab70b4..82ad2efa 100644 --- a/assets/js/src/components/models/modal-nav-item.js +++ b/assets/js/src/components/models/modal-nav-item.js @@ -1,10 +1,10 @@ -module.exports = function( app ) { +module.exports = function (app) { return app.models.base.extend({ defaults: { - label : '', - id : '', - hidden : true, - rendered : false + label: '', + id: '', + hidden: true, + rendered: false } }); }; diff --git a/assets/js/src/components/models/modify-json.js b/assets/js/src/components/models/modify-json.js index c4ad89af..feb01204 100644 --- a/assets/js/src/components/models/modify-json.js +++ b/assets/js/src/components/models/modify-json.js @@ -1,19 +1,19 @@ -module.exports = function( model ) { +module.exports = function (model) { - model.prototype._get = function( value, attribute ) { - if ( this[ '_get_' + attribute ] ) { - value = this[ '_get_' + attribute ]( value ); + model.prototype._get = function (value, attribute) { + if (this['_get_' + attribute]) { + value = this['_get_' + attribute](value); } return value; }; - model.prototype.get = function( attribute ) { - return this._get( Backbone.Model.prototype.get.call( this, attribute ), attribute ); + model.prototype.get = function (attribute) { + return this._get(Backbone.Model.prototype.get.call(this, attribute), attribute); }; // hijack the toJSON method and overwrite the data that is sent back to the view. - model.prototype.toJSON = function() { - return _.mapObject( Backbone.Model.prototype.toJSON.call( this ), _.bind( this._get, this ) ); + model.prototype.toJSON = function () { + return _.mapObject(Backbone.Model.prototype.toJSON.call(this), _.bind(this._get, this)); }; return model; diff --git a/assets/js/src/components/models/post.js b/assets/js/src/components/models/post.js index 216c64a3..78dce140 100644 --- a/assets/js/src/components/models/post.js +++ b/assets/js/src/components/models/post.js @@ -1,25 +1,25 @@ -module.exports = function( gc ) { - return require( './../models/modify-json.js' )( Backbone.Model.extend({ +module.exports = function (gc) { + return require('./../models/modify-json.js')(Backbone.Model.extend({ defaults: { - id : 0, - item : 0, - itemName : '', - updated_at : '', - current : true, - editLink : '', - mapping : 0, - mappingName : '', - mappingLink : '', - mappingStatus : '', - mappingStatusId : '', - status : {}, - checked : false, - disabled : false, - canPull : false, - canPush : false, - statuses : [], - statusesChecked : false, - ptLabel : false, + id: 0, + item: 0, + itemName: '', + updated_at: '', + current: true, + editLink: '', + mapping: 0, + mappingName: '', + mappingLink: '', + mappingStatus: '', + mappingStatusId: '', + status: {}, + checked: false, + disabled: false, + canPull: false, + canPush: false, + statuses: [], + statusesChecked: false, + ptLabel: false, }, searchAttributes: [ @@ -28,40 +28,40 @@ module.exports = function( gc ) { 'post_title', ], - url: function() { - var url = window.ajaxurl +'?action=gc_fetch_js_post&id='+ this.get( 'id' ); - if ( this.get( 'uncached' ) ) { - this.set( 'uncached', false ); + url: function () { + var url = window.ajaxurl + '?action=gc_fetch_js_post&id=' + this.get('id'); + if (this.get('uncached')) { + this.set('uncached', false); url += '&flush_cache=force'; } return url; }, - _get_disabled : function( value ) { - return ! this.get( 'mapping' ); + _get_disabled: function (value) { + return !this.get('mapping'); }, - _get_canPull : function( value ) { - return this.get( 'item' ) > 0 && this.get( 'mapping' ) > 0; + _get_canPull: function (value) { + return this.get('item') > 0 && this.get('mapping') > 0; }, - _get_canPush : function( value ) { - return this.get( 'mapping' ) > 0; + _get_canPush: function (value) { + return this.get('mapping') > 0; }, - _get_mappingLink : function( value ) { - if ( 'failed' === Backbone.Model.prototype.get.call( this, 'mappingStatus' ) ) { + _get_mappingLink: function (value) { + if ('failed' === Backbone.Model.prototype.get.call(this, 'mappingStatus')) { value += '&sync-items=1'; } return value; }, - _get_mappingStatus : function( value ) { - return gc._statuses[ value ] ? gc._statuses[ value ] : ''; + _get_mappingStatus: function (value) { + return gc._statuses[value] ? gc._statuses[value] : ''; }, - _get_mappingStatusId : function( value ) { - return Backbone.Model.prototype.get.call( this, 'mappingStatus' ); + _get_mappingStatusId: function (value) { + return Backbone.Model.prototype.get.call(this, 'mappingStatus'); } - } ) ); + })); }; diff --git a/assets/js/src/components/models/tab-row.js b/assets/js/src/components/models/tab-row.js index 0b58f057..342568ae 100644 --- a/assets/js/src/components/models/tab-row.js +++ b/assets/js/src/components/models/tab-row.js @@ -1,39 +1,39 @@ -module.exports = function( app, gc ) { - return require( './../models/modify-json.js' )( app.models.base.extend({ +module.exports = function (app, gc) { + return require('./../models/modify-json.js')(app.models.base.extend({ defaults: { - id : '', - label : '', - name : '', - field_type : '', - type : '', - typeName : '', - post_type : 'post', - field_value : false, - field_field : false, - field_subfields : false, - expanded : false, - required : false, - value : '', - microcopy : '', - limit_type : '', - limit : 0, - plain_text : false, + id: '', + label: '', + name: '', + field_type: '', + type: '', + typeName: '', + post_type: 'post', + field_value: false, + field_field: false, + field_subfields: false, + expanded: false, + required: false, + value: '', + microcopy: '', + limit_type: '', + limit: 0, + plain_text: false, }, - _get_post_type : function( value ) { - return app.mappingView ? app.mappingView.defaultTab.get( 'post_type' ) : value; + _get_post_type: function (value) { + return app.mappingView ? app.mappingView.defaultTab.get('post_type') : value; }, - _get_type : function( value ) { - if ( 'text' === value ) { - value = this.get( 'plain_text' ) ? 'text_plain' : 'text_rich'; + _get_type: function (value) { + if ('text' === value) { + value = this.get('plain_text') ? 'text_plain' : 'text_rich'; } return value; }, - _get_typeName : function( value ) { - value = this.get( 'type' ); - return gc._type_names[ value ] ? gc._type_names[ value ] : value; + _get_typeName: function (value) { + value = this.get('type'); + return gc._type_names[value] ? gc._type_names[value] : value; } - } ) ); + })); }; diff --git a/assets/js/src/components/models/tab.js b/assets/js/src/components/models/tab.js index ce86dc35..3f0f8d75 100644 --- a/assets/js/src/components/models/tab.js +++ b/assets/js/src/components/models/tab.js @@ -1,22 +1,22 @@ -module.exports = function( app, table_headings ) { +module.exports = function (app, table_headings) { return app.models.base.extend({ defaults: { - id : '', - label : '', - hidden : false, - navClasses : '', - rows : [], - table_id : '', - col_headings : table_headings.default, + id: '', + label: '', + hidden: false, + navClasses: '', + rows: [], + table_id: '', + col_headings: table_headings.default, }, - initialize: function() { - this.rows = new app.collections.tabRows( this.get( 'rows' ), { tab: this } ); - this.listenTo( this.rows, 'change', this.triggerRowChange ); + initialize: function () { + this.rows = new app.collections.tabRows(this.get('rows'), {tab: this}); + this.listenTo(this.rows, 'change', this.triggerRowChange); }, - triggerRowChange: function( rowModel ) { - this.trigger( 'rowChange', rowModel ); + triggerRowChange: function (rowModel) { + this.trigger('rowChange', rowModel); } }); }; diff --git a/assets/js/src/components/single.js b/assets/js/src/components/single.js index 74583ed6..d077b7c3 100644 --- a/assets/js/src/components/single.js +++ b/assets/js/src/components/single.js @@ -1,49 +1,49 @@ window.GatherContent = window.GatherContent || {}; -( function( window, document, $, gc, undefined ) { +(function (window, document, $, gc, undefined) { 'use strict'; gc.single = gc.single || {}; var app = gc.single; // Initiate base objects. - require( './initiate-objects.js' )( app ); + require('./initiate-objects.js')(app); /* * Posts */ - app.models.post = require( './models/post.js' )( gc ); - app.views.statusSelect2 = require( './views/status-select2.js' )( app ); + app.models.post = require('./models/post.js')(gc); + app.views.statusSelect2 = require('./views/status-select2.js')(app); - app.init = function() { - if ( gc._post.mapping ) { - app.views.metabox = require( './views/metabox.js' )( app, $, gc ); - app.metaboxView = new app.views.metabox( { - model : new app.models.post( gc._post ) - } ); + app.init = function () { + if (gc._post.mapping) { + app.views.metabox = require('./views/metabox.js')(app, $, gc); + app.metaboxView = new app.views.metabox({ + model: new app.models.post(gc._post) + }); } else { - app.views.metabox = require( './views/mapping-metabox.js' )( app, $, gc ); - app.metaboxView = new app.views.metabox( { - model : new app.models.post( gc._post ) - } ); - app.metaboxView.on( 'complete', app.reinit ); + app.views.metabox = require('./views/mapping-metabox.js')(app, $, gc); + app.metaboxView = new app.views.metabox({ + model: new app.models.post(gc._post) + }); + app.metaboxView.on('complete', app.reinit); } }; - app.reinit = function( model ) { + app.reinit = function (model) { app.metaboxView.unbind(); - if ( app.metaboxView.onClose ) { + if (app.metaboxView.onClose) { app.metaboxView.onClose(); } - app.views.metabox = require( './views/metabox.js' )( app, $, gc ); - app.metaboxView = new app.views.metabox( { - model : model - } ); + app.views.metabox = require('./views/metabox.js')(app, $, gc); + app.metaboxView = new app.views.metabox({ + model: model + }); }; // Kick it off. - $( app.init ); + $(app.init); -} )( window, document, jQuery, window.GatherContent ); +})(window, document, jQuery, window.GatherContent); diff --git a/assets/js/src/components/sync.js b/assets/js/src/components/sync.js index 3b37a364..786d58aa 100644 --- a/assets/js/src/components/sync.js +++ b/assets/js/src/components/sync.js @@ -1,49 +1,49 @@ window.GatherContent = window.GatherContent || {}; -( function( window, document, $, gc, undefined ) { +(function (window, document, $, gc, undefined) { 'use strict'; gc.sync = gc.sync || {}; var app = gc.sync; // Initiate base objects. - require( './initiate-objects.js' )( app ); + require('./initiate-objects.js')(app); - app.views.tableBase = require( './views/table-base.js' )( app, $, gc ); + app.views.tableBase = require('./views/table-base.js')(app, $, gc); /* * Item setup */ - app.models.item = require( './models/item.js' )( app, gc ); - app.collections.items = require( './collections/items.js' )( app ); - app.views.item = require( './views/item.js' )( app ); - app.views.items = require( './views/items.js' )( app, $, gc ); + app.models.item = require('./models/item.js')(app, gc); + app.collections.items = require('./collections/items.js')(app); + app.views.item = require('./views/item.js')(app); + app.views.items = require('./views/items.js')(app, $, gc); - app.init = function() { + app.init = function () { // Kick it off. - app.syncView = new app.views.items( { - el : $( '.gc-admin-wrap' ), - collection : new app.collections.items( gc._items ) - } ); + app.syncView = new app.views.items({ + el: $('.gc-admin-wrap'), + collection: new app.collections.items(gc._items) + }); // Handle error notice dismissals. - $( document.body ) - .on( 'click', '#setting-error-gc-import-last-error .notice-dismiss, #setting-error-gc-import-errors .notice-dismiss', function() { - var lastError = $( this ).parents( '#setting-error-gc-import-last-error' ).length > 0; - $.post( window.ajaxurl, { - action : 'gc_dismiss_notice', - lastError : lastError ? 1 : 0, - mapping : gc.queryargs.mapping, - }, function( response ) { - gc.log( 'response', response ); - } ); - } ) - .on( 'click', '.gc-notice-dismiss', function() { - $( this ).parents( '.notice.is-dismissible' ).find( '.notice-dismiss' ).trigger( 'click' ); - } ); + $(document.body) + .on('click', '#setting-error-gc-import-last-error .notice-dismiss, #setting-error-gc-import-errors .notice-dismiss', function () { + var lastError = $(this).parents('#setting-error-gc-import-last-error').length > 0; + $.post(window.ajaxurl, { + action: 'gc_dismiss_notice', + lastError: lastError ? 1 : 0, + mapping: gc.queryargs.mapping, + }, function (response) { + gc.log('response', response); + }); + }) + .on('click', '.gc-notice-dismiss', function () { + $(this).parents('.notice.is-dismissible').find('.notice-dismiss').trigger('click'); + }); }; - $( app.init ); + $(app.init); -} )( window, document, jQuery, window.GatherContent ); +})(window, document, jQuery, window.GatherContent); diff --git a/assets/js/src/components/views/base.js b/assets/js/src/components/views/base.js index d3471828..b9defad3 100644 --- a/assets/js/src/components/views/base.js +++ b/assets/js/src/components/views/base.js @@ -1,29 +1,29 @@ module.exports = Backbone.View.extend({ - toggleExpanded: function( evt ) { - this.model.set( 'expanded', ! this.model.get( 'expanded' ) ); + toggleExpanded: function (evt) { + this.model.set('expanded', !this.model.get('expanded')); }, - getRenderedModels : function( View, models ) { + getRenderedModels: function (View, models) { models = models || this.collection; var addedElements = document.createDocumentFragment(); - models.each( function( model ) { - var view = ( new View({ model: model }) ).render(); - addedElements.appendChild( view.el ); + models.each(function (model) { + var view = (new View({model: model})).render(); + addedElements.appendChild(view.el); }); return addedElements; }, - render : function() { - this.$el.html( this.template( this.model.toJSON() ) ); + render: function () { + this.$el.html(this.template(this.model.toJSON())); return this; }, - close : function() { + close: function () { this.remove(); this.unbind(); - if ( this.onClose ) { + if (this.onClose) { this.onClose(); } } diff --git a/assets/js/src/components/views/default-tab.js b/assets/js/src/components/views/default-tab.js index 4046b825..df9c5aac 100644 --- a/assets/js/src/components/views/default-tab.js +++ b/assets/js/src/components/views/default-tab.js @@ -1,63 +1,63 @@ -module.exports = function( app, table_headings ) { +module.exports = function (app, table_headings) { return app.views.tab.extend({ - events : { - 'change select' : 'changeDefault', - 'click .gc-reveal-items' : 'toggleExpanded' + events: { + 'change select': 'changeDefault', + 'click .gc-reveal-items': 'toggleExpanded' }, - defaultTabTemplate : wp.template( 'gc-mapping-defaults-tab' ), - statusMappingsTemplate : wp.template( 'gc-mapping-defaults-tab-status-mappings' ), + defaultTabTemplate: wp.template('gc-mapping-defaults-tab'), + statusMappingsTemplate: wp.template('gc-mapping-defaults-tab-status-mappings'), - changeDefault: function( evt ) { - var $this = jQuery( evt.target ); + changeDefault: function (evt) { + var $this = jQuery(evt.target); var value = $this.val(); - var column = $this.data( 'column' ); + var column = $this.data('column'); - if ( value ) { - if ( $this.data( 'select2' ) ) { - var data = $this.select2( 'data' )[0]; - if ( data.text ) { - this.model.set( 'select2:'+ column +':'+ value, data.text ); + if (value) { + if ($this.data('select2')) { + var data = $this.select2('data')[0]; + if (data.text) { + this.model.set('select2:' + column + ':' + value, data.text); } } - this.model.set( column, value ); + this.model.set(column, value); } }, - render : function() { + render: function () { var json = this.model.toJSON(); - this.$el.html( this.htmlWrap( json ) ); - this.$el.find( 'tbody' ).first().html( this.defaultTabTemplate( json ) ); - this.$el.find( '#gc-status-mappings tbody' ).html( this.statusMappingsTemplate( json ) ); + this.$el.html(this.htmlWrap(json)); + this.$el.find('tbody').first().html(this.defaultTabTemplate(json)); + this.$el.find('#gc-status-mappings tbody').html(this.statusMappingsTemplate(json)); this.renderSelect2(); return this; }, - htmlWrap: function( json ) { - var html = this.template( json ); + htmlWrap: function (json) { + var html = this.template(json); // Only add the GatherContent status => WP status table if initialized. - if ( ! this.model.get( 'initial' ) ) { + if (!this.model.get('initial')) { json.table_id = 'gc-status-mappings'; delete json.label; json.col_headings = table_headings.status; html += '
'; - html += this.template( json ); + html += this.template(json); } return html; }, - select2Args: function( data ) { + select2Args: function (data) { var args = {}; - switch ( data.column ) { + switch (data.column) { case 'gc_status': - args = app.views.statusSelect2.prototype.select2Args.call( this, data ); + args = app.views.statusSelect2.prototype.select2Args.call(this, data); break; case 'post_author': @@ -65,7 +65,7 @@ module.exports = function( app, table_headings ) { args.minimumInputLength = 2; args.ajax = { url: data.url, - data: function ( params ) { + data: function (params) { return { q: params.term, column: data.column diff --git a/assets/js/src/components/views/item.js b/assets/js/src/components/views/item.js index 35f26201..c7593c6f 100644 --- a/assets/js/src/components/views/item.js +++ b/assets/js/src/components/views/item.js @@ -1,27 +1,27 @@ -module.exports = function( app ) { +module.exports = function (app) { return app.views.base.extend({ - template : wp.template( 'gc-item' ), - tagName : 'tr', - className : 'gc-item gc-enabled', - id : function() { - return this.model.get( 'id' ); + template: wp.template('gc-item'), + tagName: 'tr', + className: 'gc-item gc-enabled', + id: function () { + return this.model.get('id'); }, - events : { - 'change .gc-check-column input' : 'toggleCheck', - 'click .gc-reveal-items' : 'toggleExpanded', - 'click .gc-status-column' : 'toggleCheckAndRender' + events: { + 'change .gc-check-column input': 'toggleCheck', + 'click .gc-reveal-items': 'toggleExpanded', + 'click .gc-status-column': 'toggleCheckAndRender' }, - initialize: function() { - this.listenTo( this.model, 'change:checked', this.render ); + initialize: function () { + this.listenTo(this.model, 'change:checked', this.render); }, - toggleCheck : function() { - this.model.set( 'checked', ! this.model.get( 'checked' ) ); + toggleCheck: function () { + this.model.set('checked', !this.model.get('checked')); }, - toggleCheckAndRender: function( evt ) { + toggleCheckAndRender: function (evt) { this.toggleCheck(); this.render(); } diff --git a/assets/js/src/components/views/items.js b/assets/js/src/components/views/items.js index 8f72c4be..eaaf8b10 100644 --- a/assets/js/src/components/views/items.js +++ b/assets/js/src/components/views/items.js @@ -1,202 +1,203 @@ -module.exports = function( app, $, gc ) { +module.exports = function (app, $, gc) { var thisView; var percent = gc.percent; - app.views.tableSearch = require( './../views/table-search.js' )( app, $, gc ); - app.views.tableNav = require( './../views/table-nav.js' )( app, $, gc ); + app.views.tableSearch = require('./../views/table-search.js')(app, $, gc); + app.views.tableNav = require('./../views/table-nav.js')(app, $, gc); return app.views.tableBase.extend({ - template : wp.template( 'gc-items-sync' ), - progressTemplate : wp.template( 'gc-items-sync-progress' ), - modelView : app.views.item, + template: wp.template('gc-items-sync'), + progressTemplate: wp.template('gc-items-sync-progress'), + modelView: app.views.item, - events : { - 'click .gc-cancel-sync' : 'clickCancelSync', - 'click .gc-field-th.sortable' : 'sortRowsByColumn', - 'change .gc-field-th.gc-check-column input' : 'checkAll', - 'submit form' : 'submit' + events: { + 'click .gc-cancel-sync': 'clickCancelSync', + 'click .gc-field-th.sortable': 'sortRowsByColumn', + 'change .gc-field-th.gc-check-column input': 'checkAll', + 'submit form': 'submit' }, - initialize: function() { + initialize: function () { thisView = this; - app.views.tableBase.prototype.initialize.call( this ); + app.views.tableBase.prototype.initialize.call(this); - this.listenTo( this.ajax, 'response', this.ajaxResponse ); - this.listenTo( this.collection, 'enabledChange', this.checkEnableButton ); - this.listenTo( this.collection, 'search', this.initRender ); + this.listenTo(this.ajax, 'response', this.ajaxResponse); + this.listenTo(this.collection, 'enabledChange', this.checkEnableButton); + this.listenTo(this.collection, 'search', this.initRender); this.initRender(); }, - setupAjax: function() { - var Ajax = require( './../models/ajax.js' )( app, { - checkHits : 0, - time : 500, - nonce : gc.el( '_wpnonce' ).value, - id : gc.el( 'gc-input-mapping_id' ).value, - flush_cache : gc.queryargs.flush_cache ? 1 : 0 - } ); + setupAjax: function () { + var Ajax = require('./../models/ajax.js')(app, { + checkHits: 0, + time: 500, + nonce: gc.el('_wpnonce').value, + id: gc.el('gc-input-mapping_id').value, + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }); - this.ajax = new Ajax( { - percent : percent - } ); + this.ajax = new Ajax({ + percent: percent + }); }, - checkEnableButton: function( syncEnabled ) { - this.buttonStatus( syncEnabled ); + checkEnableButton: function (syncEnabled) { + this.buttonStatus(syncEnabled); }, - clickCancelSync: function( evt ) { + clickCancelSync: function (evt) { evt.preventDefault(); this.cancelSync(); }, - submit: function( evt ) { + submit: function (evt) { evt.preventDefault(); - this.startSync( this.$( 'form' ).serialize() ); + this.startSync(this.$('form').serialize()); }, - startSync: function( formData ) { + startSync: function (formData) { this.doSpinner(); - this.ajax.reset().set( 'stopSync', false ); - this.renderProgress( 100 === window.parseInt( percent, 10 ) ? 0 : percent ); - this.doAjax( formData, percent ); + this.ajax.reset().set('stopSync', false); + this.renderProgress(100 === window.parseInt(percent, 10) ? 0 : percent); + this.doAjax(formData, percent); }, - cancelSync: function( url ) { + cancelSync: function (url) { percent = null; this.ajax.reset(); this.clearTimeout(); - if ( url ) { - this.doAjax( 'cancel', 0, function() { + if (url) { + this.doAjax('cancel', 0, function () { window.location.href = url; - } ); + }); } else { - this.doAjax( 'cancel', 0, function(){} ); + this.doAjax('cancel', 0, function () { + }); this.initRender(); } }, - doAjax: function( formData, completed, cb ) { - cb = cb || this.ajaxSuccess.bind( this ); - this.ajax.send( formData, cb, completed ); + doAjax: function (formData, completed, cb) { + cb = cb || this.ajaxSuccess.bind(this); + this.ajax.send(formData, cb, completed); }, - ajaxSuccess: function( response ) { - if ( this.ajax.get( 'stopSync' ) ) { + ajaxSuccess: function (response) { + if (this.ajax.get('stopSync')) { return; } percent = response.data.percent || 1; var hits = this.checkHits(); - var time = this.ajax.get( 'time' ); + var time = this.ajax.get('time'); - if ( hits > 25 && time < 2000 ) { + if (hits > 25 && time < 2000) { this.clearTimeout(); - this.ajax.set( 'time', 2000 ); - } else if ( hits > 50 && time < 5000 ) { + this.ajax.set('time', 2000); + } else if (hits > 50 && time < 5000) { this.clearTimeout(); - this.ajax.set( 'time', 5000 ); + this.ajax.set('time', 5000); } - this.setTimeout( this.checkProgress.bind( this ) ); + this.setTimeout(this.checkProgress.bind(this)); - if ( percent > 99 ) { + if (percent > 99) { // This is to allow the slight css animation. - this.renderProgressUpdate( 100 ); + this.renderProgressUpdate(100); // This is to render the loading spinner. Wait long enough for css animation to copmlete. - window.setTimeout( function() { - thisView.renderProgress( 100, true ); - }, 100 ); + window.setTimeout(function () { + thisView.renderProgress(100, true); + }, 100); // Finally, cancel the sync, and redirect. - this.cancelSync( window.location.href + '&updated=1&flush_cache=1&redirect=1' ); + this.cancelSync(window.location.href + '&updated=1&flush_cache=1&redirect=1'); } else { - this.renderProgressUpdate( percent ); + this.renderProgressUpdate(percent); } }, - setTimeout: function( callback ) { - this.timeoutID = window.setTimeout( callback, this.ajax.get( 'time' ) ); + setTimeout: function (callback) { + this.timeoutID = window.setTimeout(callback, this.ajax.get('time')); }, - checkProgress: function() { - this.doAjax( 'check', percent ); + checkProgress: function () { + this.doAjax('check', percent); }, - checkHits: function() { - return window.parseInt( this.ajax.get( 'checkHits' ), 10 ); + checkHits: function () { + return window.parseInt(this.ajax.get('checkHits'), 10); }, - ajaxResponse: function( response, formData ) { - gc.log( 'warn', 'hits/interval/response: ' + this.checkHits() +'/' + this.ajax.get( 'time' ) +'/', response.success ? response.data : response ); + ajaxResponse: function (response, formData) { + gc.log('warn', 'hits/interval/response: ' + this.checkHits() + '/' + this.ajax.get('time') + '/', response.success ? response.data : response); - if ( 'check' === formData ) { - this.ajax.set( 'checkHits', this.checkHits() + 1 ); - } else if ( response.data ) { - this.ajax.set( 'checkHits', 0 ); + if ('check' === formData) { + this.ajax.set('checkHits', this.checkHits() + 1); + } else if (response.data) { + this.ajax.set('checkHits', 0); } - if ( ! response.success ) { - this.renderProgressUpdate( 0 ); + if (!response.success) { + this.renderProgressUpdate(0); this.cancelSync(); - if ( response.data ) { - if ( response.data.url ) { - window.alert( response.data.message ); + if (response.data) { + if (response.data.url) { + window.alert(response.data.message); window.location.href = response.data.url; } else { - window.alert( response.data ); + window.alert(response.data); } return; } } }, - renderProgressUpdate: function( percent ) { - this.$( '.gc-progress-bar-partial' ) - .css({ width: percent + '%' }) - .find( 'span' ).text( percent + '%' ); + renderProgressUpdate: function (percent) { + this.$('.gc-progress-bar-partial') + .css({width: percent + '%'}) + .find('span').text(percent + '%'); }, - renderProgress: function( percent, showLoader ) { - this.$el.addClass( 'gc-sync-progress' ); - this.buttonStatus( false ); - this.$( '#sync-tabs' ).html( this.progressTemplate( { + renderProgress: function (percent, showLoader) { + this.$el.addClass('gc-sync-progress'); + this.buttonStatus(false); + this.$('#sync-tabs').html(this.progressTemplate({ percent: null === percent ? 0 : percent, loader: true === showLoader - } ) ); + })); }, - renderRows: function( html ) { - this.$( '#sync-tabs tbody' ).html( html || this.getRenderedRows() ); + renderRows: function (html) { + this.$('#sync-tabs tbody').html(html || this.getRenderedRows()); }, - sortRender: function() { + sortRender: function () { this.initRender(); }, - initRender: function() { + initRender: function () { var collection = this.collection.current(); // If sync is going, show that status. - if ( percent > 0 && percent < 100 ) { - this.startSync( 'check' ); + if (percent > 0 && percent < 100) { + this.startSync('check'); } else { - this.$( '#sync-tabs' ).html( this.template( { - checked : collection.allChecked, - sortKey : collection.sortKey, - sortDirection : collection.sortDirection, - } ) ); + this.$('#sync-tabs').html(this.template({ + checked: collection.allChecked, + sortKey: collection.sortKey, + sortDirection: collection.sortDirection, + })); this.render(); } }, - render: function() { + render: function () { // Not syncing, so remove wrap-class - this.$el.removeClass( 'gc-sync-progress' ); + this.$el.removeClass('gc-sync-progress'); - return app.views.tableBase.prototype.render.call( this ); + return app.views.tableBase.prototype.render.call(this); }, }); diff --git a/assets/js/src/components/views/mapping-metabox.js b/assets/js/src/components/views/mapping-metabox.js index fbf899e4..941a2b55 100644 --- a/assets/js/src/components/views/mapping-metabox.js +++ b/assets/js/src/components/views/mapping-metabox.js @@ -1,176 +1,176 @@ -module.exports = function( app, $, gc ) { +module.exports = function (app, $, gc) { var thisView; - var base = require( './../views/metabox-base.js' )( app, $, gc ); + var base = require('./../views/metabox-base.js')(app, $, gc); return base.extend({ - template : wp.template( 'gc-mapping-metabox' ), - stepArgs : false, - events : { - 'click #gc-map' : 'step', - 'change #select-gc-next-step' : 'setProperty', - 'click #gc-map-cancel' : 'cancel' + template: wp.template('gc-mapping-metabox'), + stepArgs: false, + events: { + 'click #gc-map': 'step', + 'change #select-gc-next-step': 'setProperty', + 'click #gc-map-cancel': 'cancel' }, - initialize: function() { + initialize: function () { thisView = this; - this.listenTo( this.model, 'change:waiting', this.toggleWaitingRender ); - this.listenTo( this.model, 'change', this.maybeEnableAndRender ); - this.listenTo( this.model, 'change:step', this.changeStep ); - this.listenTo( this, 'cancel', this.resetAndRender ); + this.listenTo(this.model, 'change:waiting', this.toggleWaitingRender); + this.listenTo(this.model, 'change', this.maybeEnableAndRender); + this.listenTo(this.model, 'change:step', this.changeStep); + this.listenTo(this, 'cancel', this.resetAndRender); this.render(); - this.$el.removeClass( 'no-js' ).addClass( 'gc-mapping-metabox' ); + this.$el.removeClass('no-js').addClass('gc-mapping-metabox'); }, - changeStep: function( model ) { - if ( 'accounts' === model.changed.step ) { - this.$el.addClass( 'gc-mapping-started' ); + changeStep: function (model) { + if ('accounts' === model.changed.step) { + this.$el.addClass('gc-mapping-started'); } - if ( model.changed.step ) { - this.stepArgs = this[ 'step_'+ model.changed.step ](); + if (model.changed.step) { + this.stepArgs = this['step_' + model.changed.step](); } }, - setProperty: function( evt ) { - var value = $( evt.target ).val(); + setProperty: function (evt) { + var value = $(evt.target).val(); - this.model.set( this.stepArgs.property, value ); + this.model.set(this.stepArgs.property, value); - if ( 'account' === this.stepArgs.property || 'project' === this.stepArgs.property ) { + if ('account' === this.stepArgs.property || 'project' === this.stepArgs.property) { // Autoclick "next" for user. this.step(); } }, - setMapping: function() { - var success = function( data ) { - this.model.set( 'waiting', false ); + setMapping: function () { + var success = function (data) { + this.model.set('waiting', false); // Goodbye - this.trigger( 'complete', this.model, data ); + this.trigger('complete', this.model, data); }; - this.ajax( { - action : 'gc_save_mapping_id', - }, success, this.failMsg ); + this.ajax({ + action: 'gc_save_mapping_id', + }, success, this.failMsg); }, - maybeEnableAndRender: function( model ) { - if ( model.changed.account || model.changed.project || model.changed.mapping ) { - this.model.set( 'btnDisabled', false ); + maybeEnableAndRender: function (model) { + if (model.changed.account || model.changed.project || model.changed.mapping) { + this.model.set('btnDisabled', false); this.render(); } }, - toggleWaitingRender: function( model ) { - if ( model.changed.waiting ) { - this.model.set( 'btnDisabled', true ); + toggleWaitingRender: function (model) { + if (model.changed.waiting) { + this.model.set('btnDisabled', true); } this.render(); }, - step: function() { - this.model.set( 'waiting', true ); + step: function () { + this.model.set('waiting', true); - if ( 'mapping' === this.stepArgs.property ) { + if ('mapping' === this.stepArgs.property) { return this.setMapping(); } this.setStep(); - var properties = this.model.get( this.stepArgs.properties ); + var properties = this.model.get(this.stepArgs.properties); - if ( properties && properties.length ) { + if (properties && properties.length) { - this.successHandler( properties ); + this.successHandler(properties); } else { - this.ajax( { - action : 'gc_wp_filter_mappings', - property : this.stepArgs.property - }, this.successHandler, this.failMsg ); + this.ajax({ + action: 'gc_wp_filter_mappings', + property: this.stepArgs.property + }, this.successHandler, this.failMsg); } return this; }, - failMsg: function( msg ) { + failMsg: function (msg) { msg = 'string' === typeof msg ? msg : gc._errors.unknown; - window.alert( msg ); - thisView.model.set( 'waiting', false ); + window.alert(msg); + thisView.model.set('waiting', false); }, - successHandler: function( objects ) { - this.model.set( this.stepArgs.properties, objects ); - if ( objects.length < 2 ) { - this.model.set( 'btnDisabled', false ); + successHandler: function (objects) { + this.model.set(this.stepArgs.properties, objects); + if (objects.length < 2) { + this.model.set('btnDisabled', false); } - this.model.set( 'waiting', false ); + this.model.set('waiting', false); }, - setStep: function() { - if ( ! this.model.get( 'step' ) ) { - return this.model.set( 'step', 'accounts' ); + setStep: function () { + if (!this.model.get('step')) { + return this.model.set('step', 'accounts'); } - if ( 'accounts' === this.model.get( 'step' ) ) { - return this.model.set( 'step', 'projects' ); + if ('accounts' === this.model.get('step')) { + return this.model.set('step', 'projects'); } - if ( 'projects' === this.model.get( 'step' ) ) { - return this.model.set( 'step', 'mappings' ); + if ('projects' === this.model.get('step')) { + return this.model.set('step', 'mappings'); } }, - step_accounts: function() { + step_accounts: function () { return { - property : 'account', - properties : 'accounts', + property: 'account', + properties: 'accounts', }; }, - step_projects: function() { + step_projects: function () { return { - property : 'project', - properties : 'projects', + property: 'project', + properties: 'projects', }; }, - step_mappings: function() { + step_mappings: function () { return { - property : 'mapping', - properties : 'mappings', + property: 'mapping', + properties: 'mappings', }; }, - cancel: function( evt ) { - this.trigger( 'cancel', evt ); + cancel: function (evt) { + this.trigger('cancel', evt); }, - resetModel : function() { + resetModel: function () { this.stepArgs = false; - this.model.set( { - 'step' : false, - 'account' : 0, - 'project' : 0, - 'mapping' : 0, - } ); + this.model.set({ + 'step': false, + 'account': 0, + 'project': 0, + 'mapping': 0, + }); return this.model; }, - resetAndRender : function() { + resetAndRender: function () { this.resetModel(); this.render(); }, - render : function() { + render: function () { var json = this.model.toJSON(); - if ( this.stepArgs ) { - json.label = gc._step_labels[ json.step ]; + if (this.stepArgs) { + json.label = gc._step_labels[json.step]; json.property = this.stepArgs.property; } - this.$el.html( this.template( json ) ); + this.$el.html(this.template(json)); return this; }, diff --git a/assets/js/src/components/views/metabox-base.js b/assets/js/src/components/views/metabox-base.js index 3fa38493..0485c7dd 100644 --- a/assets/js/src/components/views/metabox-base.js +++ b/assets/js/src/components/views/metabox-base.js @@ -1,28 +1,28 @@ -module.exports = function( app, $, gc ) { +module.exports = function (app, $, gc) { return app.views.base.extend({ - el : '#gc-related-data', + el: '#gc-related-data', - ajax: function( args, successcb, failcb ) { + ajax: function (args, successcb, failcb) { var view = this; - var success = function( response ) { - if ( response.success ) { - successcb.call( view, response.data ); - } else if ( failcb ) { - failcb.call( view, response.data ); + var success = function (response) { + if (response.success) { + successcb.call(view, response.data); + } else if (failcb) { + failcb.call(view, response.data); } }; - var promise = $.post( window.ajaxurl, $.extend( { - action : '', - post : this.model.toJSON(), - nonce : gc.$id( 'gc-edit-nonce' ).val(), - flush_cache : gc.queryargs.flush_cache ? 1 : 0 - }, args ), success ); + var promise = $.post(window.ajaxurl, $.extend({ + action: '', + post: this.model.toJSON(), + nonce: gc.$id('gc-edit-nonce').val(), + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, args), success); - if ( failcb ) { - promise.fail( function() { - failcb.call( view ); - } ); + if (failcb) { + promise.fail(function () { + failcb.call(view); + }); } return promise; diff --git a/assets/js/src/components/views/metabox-statuses.js b/assets/js/src/components/views/metabox-statuses.js index 6bb1913d..28da0cee 100644 --- a/assets/js/src/components/views/metabox-statuses.js +++ b/assets/js/src/components/views/metabox-statuses.js @@ -1,87 +1,87 @@ -module.exports = function( app, $, gc ) { +module.exports = function (app, $, gc) { var thisView; return app.views.statusSelect2.extend({ - className : 'misc-pub-section', - select2template : wp.template( 'gc-status-select2' ), - template : wp.template( 'gc-metabox-statuses' ), - isOpen : false, - rendered : false, + className: 'misc-pub-section', + select2template: wp.template('gc-status-select2'), + template: wp.template('gc-metabox-statuses'), + isOpen: false, + rendered: false, - initialize: function() { + initialize: function () { thisView = this; - this.listenTo( this, 'render', this.render ); - this.listenTo( this, 'statusesOpen', this.statusesOpen ); - this.listenTo( this, 'statusesClose', this.statusesClose ); + this.listenTo(this, 'render', this.render); + this.listenTo(this, 'statusesOpen', this.statusesOpen); + this.listenTo(this, 'statusesClose', this.statusesClose); }, - statusesOpen: function() { + statusesOpen: function () { this.isOpen = true; - if ( ! this.model.get( 'statusesChecked' ) ) { + if (!this.model.get('statusesChecked')) { this.asyncInit(); } - this.$( '.edit-gc-status' ).addClass( 'hidden' ); - this.$( '#gc-post-status-select' ).slideDown( 'fast'/*, function() { + this.$('.edit-gc-status').addClass('hidden'); + this.$('#gc-post-status-select').slideDown('fast'/*, function() { thisView.$( '#gc-set-status' ).focus(); - }*/ ); + }*/); }, - statusesClose: function() { + statusesClose: function () { this.isOpen = false; - this.$( '.edit-gc-status' ).removeClass( 'hidden' ); - this.$( '#gc-post-status-select' ).slideUp( 'fast' ); + this.$('.edit-gc-status').removeClass('hidden'); + this.$('#gc-post-status-select').slideUp('fast'); }, - asyncInit: function() { + asyncInit: function () { this.rendered = false; - $.post( window.ajaxurl, { - action : 'gc_get_post_statuses', - postId : this.model.get( 'id' ), - flush_cache : gc.queryargs.flush_cache ? 1 : 0 - }, this.ajaxResponse.bind( this ) ).done( function() { + $.post(window.ajaxurl, { + action: 'gc_get_post_statuses', + postId: this.model.get('id'), + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, this.ajaxResponse.bind(this)).done(function () { thisView.firstToRender(); - } ).fail( function() { - thisView.model.set( 'statusesChecked', false ); + }).fail(function () { + thisView.model.set('statusesChecked', false); }); - this.model.set( 'statusesChecked', true ); + this.model.set('statusesChecked', true); }, - ajaxResponse : function( response ) { - if ( ! response.data || ! response.success ) { - this.model.set( 'statusesChecked', false ); + ajaxResponse: function (response) { + if (!response.data || !response.success) { + this.model.set('statusesChecked', false); return; } - this.model.set( 'statusesChecked', true ); - this.model.set( 'statuses', response.data.statuses ); + this.model.set('statusesChecked', true); + this.model.set('statuses', response.data.statuses); - if ( this.model.get( 'statuses' ).length ) { - thisView.$( '.gc-select2' ).each( function() { - $( this ).select2( 'destroy' ); - } ); + if (this.model.get('statuses').length) { + thisView.$('.gc-select2').each(function () { + $(this).select2('destroy'); + }); thisView.firstToRender(); } }, - firstToRender: function() { - if ( ! thisView.rendered ) { + firstToRender: function () { + if (!thisView.rendered) { thisView.renderStatuses(); thisView.rendered = true; } }, - renderStatuses: function() { - var postId = this.model.get( 'id' ); - this.$( '#gc-status-selec2' ).html( this.select2template( this.model.toJSON() ) ); - if ( this.model.get( 'statuses' ).length ) { - this.renderSelect2( this.$el ); + renderStatuses: function () { + var postId = this.model.get('id'); + this.$('#gc-status-selec2').html(this.select2template(this.model.toJSON())); + if (this.model.get('statuses').length) { + this.renderSelect2(this.$el); } }, - render : function() { - this.$el.html( this.template( this.model.toJSON() ) ); - if ( this.model.get( 'statusesChecked' ) ) { + render: function () { + this.$el.html(this.template(this.model.toJSON())); + if (this.model.get('statusesChecked')) { thisView.renderStatuses(); } return this; diff --git a/assets/js/src/components/views/metabox.js b/assets/js/src/components/views/metabox.js index 9eda3f74..71dd74d6 100644 --- a/assets/js/src/components/views/metabox.js +++ b/assets/js/src/components/views/metabox.js @@ -1,196 +1,196 @@ -module.exports = function( app, $, gc ) { +module.exports = function (app, $, gc) { var thisView; - var base = require( './../views/metabox-base.js' )( app, $, gc ); - var StatusesView = require( './../views/metabox-statuses.js' )( app, $, gc ); + var base = require('./../views/metabox-base.js')(app, $, gc); + var StatusesView = require('./../views/metabox-statuses.js')(app, $, gc); return base.extend({ - template : wp.template( 'gc-metabox' ), - statusesView : null, - timeoutID : null, - events : { - 'click .edit-gc-status' : 'editStatus', - 'click .cancel-gc-status' : 'cancelEditStatus', - 'click .save-gc-status' : 'saveStatus', - 'click #gc-pull' : 'pull', - 'click #gc-push' : 'push', - 'click #gc-disconnect' : 'disconnect', - }, - - initialize: function() { + template: wp.template('gc-metabox'), + statusesView: null, + timeoutID: null, + events: { + 'click .edit-gc-status': 'editStatus', + 'click .cancel-gc-status': 'cancelEditStatus', + 'click .save-gc-status': 'saveStatus', + 'click #gc-pull': 'pull', + 'click #gc-push': 'push', + 'click #gc-disconnect': 'disconnect', + }, + + initialize: function () { thisView = this; - this.listenTo( this.model, 'change:status', this.renderStatusView ); - this.listenTo( this.model, 'change:mappingStatus', this.render ); - this.listenTo( this.model, 'render', this.render ); + this.listenTo(this.model, 'change:status', this.renderStatusView); + this.listenTo(this.model, 'change:mappingStatus', this.render); + this.listenTo(this.model, 'render', this.render); - this.statusesView = new StatusesView( { - model : this.model - } ); + this.statusesView = new StatusesView({ + model: this.model + }); this.render(); - this.$el.removeClass( 'no-js' ); + this.$el.removeClass('no-js'); this.refreshData(); }, - refreshData: function() { + refreshData: function () { // Trigger an un-cached update for the item data - this.model.set( 'uncached', true ); - this.model.fetch().done( function( data ) { - if ( ! thisView.statusesView.isOpen ) { + this.model.set('uncached', true); + this.model.fetch().done(function (data) { + if (!thisView.statusesView.isOpen) { thisView.render(); } - } ); + }); }, - updateModel: function( data ) { - var id = this.model.get( 'id' ); - if ( id in data ) { - if ( data[ id ].status ) { - this.model.set( 'status', data[ id ].status ); + updateModel: function (data) { + var id = this.model.get('id'); + if (id in data) { + if (data[id].status) { + this.model.set('status', data[id].status); } - if ( data[ id ].itemName ) { - this.model.set( 'itemName', data[ id ].itemName ); + if (data[id].itemName) { + this.model.set('itemName', data[id].itemName); } - if ( data[ id ].updated_at ) { - this.model.set( 'updated_at', data[ id ].updated_at ); + if (data[id].updated_at) { + this.model.set('updated_at', data[id].updated_at); } } }, - editStatus: function( evt ) { + editStatus: function (evt) { evt.preventDefault(); - this.statusesView.trigger( 'statusesOpen' ); + this.statusesView.trigger('statusesOpen'); }, - cancelEditStatus: function( evt ) { + cancelEditStatus: function (evt) { evt.preventDefault(); - this.statusesView.trigger( 'statusesClose' ); + this.statusesView.trigger('statusesClose'); }, - saveStatus: function() { - var newStatusId = this.$( '.gc-default-mapping-select' ).val(); - var oldStatus = this.model.get( 'status' ); + saveStatus: function () { + var newStatusId = this.$('.gc-default-mapping-select').val(); + var oldStatus = this.model.get('status'); var oldStatusId = oldStatus && oldStatus.id ? oldStatus.id : false; var newStatus, statuses; - if ( newStatusId === oldStatusId ) { - return this.statusesView.trigger( 'statusesClose' ); + if (newStatusId === oldStatusId) { + return this.statusesView.trigger('statusesClose'); } - statuses = this.model.get( 'statuses' ); - newStatus = _.find( statuses, function( status ) { - return parseInt( newStatusId, 10 ) === parseInt( status.id, 10 ); - } ); - - this.statusesView.trigger( 'statusesClose' ); - this.model.set( 'status', newStatus ); - - this.ajax( { - action : 'set_gc_status', - status : newStatusId, - }, this.refreshData, function() { - this.model.set( 'status', oldStatus ); - } ); - }, - - disconnect: function() { - if ( window.confirm( gc._sure.disconnect ) ) { - thisView.model.set( 'mappingStatus', 'starting' ); - this.ajax( { - action : 'gc_disconnect_post', - data : thisView.model.toJSON(), - nonce : gc._edit_nonce, - }, this.disconnectResponse, this.syncFail ); + statuses = this.model.get('statuses'); + newStatus = _.find(statuses, function (status) { + return parseInt(newStatusId, 10) === parseInt(status.id, 10); + }); + + this.statusesView.trigger('statusesClose'); + this.model.set('status', newStatus); + + this.ajax({ + action: 'set_gc_status', + status: newStatusId, + }, this.refreshData, function () { + this.model.set('status', oldStatus); + }); + }, + + disconnect: function () { + if (window.confirm(gc._sure.disconnect)) { + thisView.model.set('mappingStatus', 'starting'); + this.ajax({ + action: 'gc_disconnect_post', + data: thisView.model.toJSON(), + nonce: gc._edit_nonce, + }, this.disconnectResponse, this.syncFail); } }, - pull: function() { - if ( window.confirm( gc._sure.pull ) ) { - thisView.model.set( 'mappingStatus', 'starting' ); - this.doSync( 'pull' ); + pull: function () { + if (window.confirm(gc._sure.pull)) { + thisView.model.set('mappingStatus', 'starting'); + this.doSync('pull'); } }, - push: function() { - var msg = this.model.get( 'item' ) ? gc._sure.push : gc._sure.push_no_item; - if ( window.confirm( msg ) ) { - thisView.model.set( 'mappingStatus', 'starting' ); - this.doSync( 'push' ); + push: function () { + var msg = this.model.get('item') ? gc._sure.push : gc._sure.push_no_item; + if (window.confirm(msg)) { + thisView.model.set('mappingStatus', 'starting'); + this.doSync('push'); } }, - syncFail: function( msg ) { + syncFail: function (msg) { msg = 'string' === typeof msg ? msg : gc._errors.unknown; - window.alert( msg ); - this.model.set( 'mappingStatus', 'failed' ); + window.alert(msg); + this.model.set('mappingStatus', 'failed'); this.clearTimeout(); }, - disconnectResponse: function( data ) { + disconnectResponse: function (data) { this.clearTimeout(); - this.$el.html( wp.template( 'gc-mapping-metabox' ) ); + this.$el.html(wp.template('gc-mapping-metabox')); }, - syncResponse: function( data ) { - if ( data.mappings ) { - if ( data.mappings.length && -1 !== _.indexOf( data.mappings, this.model.get( 'mapping' ) ) ) { + syncResponse: function (data) { + if (data.mappings) { + if (data.mappings.length && -1 !== _.indexOf(data.mappings, this.model.get('mapping'))) { - this.model.set( 'mappingStatus', 'syncing' ); - this.checkStatus( data.direction ); + this.model.set('mappingStatus', 'syncing'); + this.checkStatus(data.direction); } else { - this.finishedSync( data.direction ); + this.finishedSync(data.direction); } } else { - this.syncFail( data ); + this.syncFail(data); } }, - doSync: function( direction, data ) { - this.ajax( { - action : 'gc_'+ direction +'_items', + doSync: function (direction, data) { + this.ajax({ + action: 'gc_' + direction + '_items', // action : 'glsjlfjs', - data : data || [ this.model.toJSON() ], - nonce : gc._edit_nonce, - }, this.syncResponse, this.syncFail ); + data: data || [this.model.toJSON()], + nonce: gc._edit_nonce, + }, this.syncResponse, this.syncFail); }, - finishedSync: function( direction ) { + finishedSync: function (direction) { this.clearTimeout(); - this.model.set( 'mappingStatus', 'complete' ); - if ( 'push' === direction ) { - window.setTimeout( function() { + this.model.set('mappingStatus', 'complete'); + if ('push' === direction) { + window.setTimeout(function () { // Give DB time to catch up, and avoid race condtions. thisView.refreshData(); - }, 800 ); + }, 800); } else { window.location.href = window.location.href; } }, - checkStatus: function( direction ) { + checkStatus: function (direction) { this.clearTimeout(); - this.timeoutID = window.setTimeout( function() { - thisView.doSync( direction, { check : [ thisView.model.get( 'mapping' ) ] } ); - }, 1000 ); + this.timeoutID = window.setTimeout(function () { + thisView.doSync(direction, {check: [thisView.model.get('mapping')]}); + }, 1000); }, - clearTimeout: function() { - window.clearTimeout( this.timeoutID ); + clearTimeout: function () { + window.clearTimeout(this.timeoutID); this.timeoutID = null; }, - render : function() { - this.$el.html( this.template( this.model.toJSON() ) ); + render: function () { + this.$el.html(this.template(this.model.toJSON())); // This needs to happen after rendering. - this.$( '.misc-pub-section.gc-item-name' ).after( this.statusesView.render().el ); + this.$('.misc-pub-section.gc-item-name').after(this.statusesView.render().el); return this; }, - renderStatusView: function() { - this.statusesView.$el.replaceWith( this.statusesView.render().el ); + renderStatusView: function () { + this.statusesView.$el.replaceWith(this.statusesView.render().el); } diff --git a/assets/js/src/components/views/modal-assign-mapping.js b/assets/js/src/components/views/modal-assign-mapping.js index 9065ce6f..9736b3a9 100644 --- a/assets/js/src/components/views/modal-assign-mapping.js +++ b/assets/js/src/components/views/modal-assign-mapping.js @@ -1,29 +1,29 @@ -module.exports = function( app, $, gc ) { - var base = require( './../views/mapping-metabox.js' )( app, $, gc ); +module.exports = function (app, $, gc) { + var base = require('./../views/mapping-metabox.js')(app, $, gc); - var model = new Backbone.Model( { - id : true, - cancelBtn : true, - accounts : [], - projects : [], - mappings : [] - } ); + var model = new Backbone.Model({ + id: true, + cancelBtn: true, + accounts: [], + projects: [], + mappings: [] + }); var View = base.extend({ - close: function() { + close: function () { model = this.resetModel(); - base.prototype.close.call( this ); + base.prototype.close.call(this); } - } ); + }); - return function( postIds ) { - model.set( 'ids', postIds ); + return function (postIds) { + model.set('ids', postIds); - var view = new View( { - model : model - } ); + var view = new View({ + model: model + }); - view.$el.addClass( 'postbox' ); + view.$el.addClass('postbox'); return view.step(); }; diff --git a/assets/js/src/components/views/modal-post-row.js b/assets/js/src/components/views/modal-post-row.js index 2076a517..e684ed0d 100644 --- a/assets/js/src/components/views/modal-post-row.js +++ b/assets/js/src/components/views/modal-post-row.js @@ -1,33 +1,33 @@ -module.exports = function( app, gc ) { - var item = require( './../views/item.js' )( app ); +module.exports = function (app, gc) { + var item = require('./../views/item.js')(app); return item.extend({ - template : wp.template( 'gc-item' ), + template: wp.template('gc-item'), - id : function() { - return 'gc-modal-post-' + this.model.get( 'id' ); + id: function () { + return 'gc-modal-post-' + this.model.get('id'); }, - className : function() { - return 'gc-item ' + ( this.model.get( 'disabled' ) ? 'gc-disabled' : 'gc-enabled' ); + className: function () { + return 'gc-item ' + (this.model.get('disabled') ? 'gc-disabled' : 'gc-enabled'); }, events: { - 'change .gc-check-column input' : 'toggleCheck', - 'click .gc-status-column' : 'toggleCheckAndRender', - }, + 'change .gc-check-column input': 'toggleCheck', + 'click .gc-status-column': 'toggleCheckAndRender', + }, initialize: function () { - this.listenTo( this.model, 'change:post_title', this.renderTitle ); - this.listenTo( this.model, 'change:mappingStatus', this.render ); - this.listenTo( this.model, 'render', this.render ); + this.listenTo(this.model, 'change:post_title', this.renderTitle); + this.listenTo(this.model, 'change:mappingStatus', this.render); + this.listenTo(this.model, 'render', this.render); }, - renderTitle: function() { - var title = this.model.get( 'post_title' ); - var id = this.model.get( 'id' ); - gc.$id( 'post-'+ id ).find( '.column-title .row-title' ).text( title ); - gc.$id( 'edit-'+ id ).find( '[name="post_title"]' ).text( title ); - gc.$id( 'inline_'+ id ).find( '.post_title' ).text( title ); + renderTitle: function () { + var title = this.model.get('post_title'); + var id = this.model.get('id'); + gc.$id('post-' + id).find('.column-title .row-title').text(title); + gc.$id('edit-' + id).find('[name="post_title"]').text(title); + gc.$id('inline_' + id).find('.post_title').text(title); }, }); diff --git a/assets/js/src/components/views/modal.js b/assets/js/src/components/views/modal.js index 8d9fa68d..55e47c90 100644 --- a/assets/js/src/components/views/modal.js +++ b/assets/js/src/components/views/modal.js @@ -1,35 +1,34 @@ +module.exports = function (app, gc, $) { + app.modalView = undefined; - module.exports = function( app, gc, $ ) { - app.modalView = undefined; - - var ESCAPE = 27; - var thisView; + var ESCAPE = 27; + var thisView; /** * Taken from https://github.com/aut0poietic/wp-admin-modal-example */ - return app.views.tableBase.extend( { - id : 'gc-bb-modal-dialog', - template : wp.template( 'gc-modal-window' ), - selected : [], - navItems : null, - btns : {}, - currID : 'select-items', - currNav : false, - metaboxView : null, - modelView : app.views.modalPostRow, - $search : gc.$id( 'gc-items-search' ), + return app.views.tableBase.extend({ + id: 'gc-bb-modal-dialog', + template: wp.template('gc-modal-window'), + selected: [], + navItems: null, + btns: {}, + currID: 'select-items', + currNav: false, + metaboxView: null, + modelView: app.views.modalPostRow, + $search: gc.$id('gc-items-search'), events: { - 'click .gc-bb-modal-close' : 'closeModal', - 'click #btn-cancel' : 'closeModal', - 'click .gc-bb-modal-backdrop' : 'closeModal', - 'click .gc-bb-modal-nav-tabs a' : 'clickSelectTab', - 'change .gc-field-th.gc-check-column input' : 'checkAll', - 'click #gc-btn-pull' : 'startPull', - 'click #gc-btn-push' : 'startPush', - 'click .gc-cloak' : 'maybeResetMetaboxView', - 'click #gc-btn-assign-mapping' : 'startAssignment', - 'click .gc-field-th.sortable' : 'sortRowsByColumn', + 'click .gc-bb-modal-close': 'closeModal', + 'click #btn-cancel': 'closeModal', + 'click .gc-bb-modal-backdrop': 'closeModal', + 'click .gc-bb-modal-nav-tabs a': 'clickSelectTab', + 'change .gc-field-th.gc-check-column input': 'checkAll', + 'click #gc-btn-pull': 'startPull', + 'click #gc-btn-push': 'startPush', + 'click .gc-cloak': 'maybeResetMetaboxView', + 'click #gc-btn-assign-mapping': 'startAssignment', + 'click .gc-field-th.sortable': 'sortRowsByColumn', }, /** @@ -38,53 +37,53 @@ initialize: function () { thisView = this; - if ( ! this.$search.length ) { - $( document.body ).append( '' ); - this.$search = gc.$id( 'gc-items-search' ); + if (!this.$search.length) { + $(document.body).append(''); + this.$search = gc.$id('gc-items-search'); } - app.views.tableBase.prototype.initialize.call( this ); + app.views.tableBase.prototype.initialize.call(this); - _.bindAll( this, 'render', 'preserveFocus', 'maybeClose', 'closeModal' ); + _.bindAll(this, 'render', 'preserveFocus', 'maybeClose', 'closeModal'); - if ( gc._nav_items ) { - this.navItems = new app.collections.navItems( gc._nav_items ); - this.currNav = this.navItems.getActive(); - this.listenTo( this.navItems, 'render', this.render ); + if (gc._nav_items) { + this.navItems = new app.collections.navItems(gc._nav_items); + this.currNav = this.navItems.getActive(); + this.listenTo(this.navItems, 'render', this.render); } - this.btns = new app.collections.base( gc._modal_btns ); + this.btns = new app.collections.base(gc._modal_btns); - this.listenTo( this.collection, 'updateItems', this.maybeRender ); - this.listenTo( this.collection, 'change:checked', this.checkEnableButton ); - this.listenTo( this.collection, 'search', this.render ); + this.listenTo(this.collection, 'updateItems', this.maybeRender); + this.listenTo(this.collection, 'change:checked', this.checkEnableButton); + this.listenTo(this.collection, 'search', this.render); - this.initMetaboxView = require( './../views/modal-assign-mapping.js' )( app, $, gc ); + this.initMetaboxView = require('./../views/modal-assign-mapping.js')(app, $, gc); }, - checked: function( selected ) { + checked: function (selected) { this.selected = selected; - if ( ! selected.length ) { + if (!selected.length) { return; } - if ( selected.length === this.collection.length ) { - return this.collection.trigger( 'checkAll', true ); + if (selected.length === this.collection.length) { + return this.collection.trigger('checkAll', true); } - this.collection.trigger( 'checkSome', function( model ) { - return -1 !== _.indexOf( thisView.selected, model.get( 'id' ) ) && ! model.get( 'disabled' ); - } ); + this.collection.trigger('checkSome', function (model) { + return -1 !== _.indexOf(thisView.selected, model.get('id')) && !model.get('disabled'); + }); return this; }, - setupAjax: function() { - var Ajax = require( './../models/ajax.js' )( app, { - action : 'gc_pull_items', - nonce : gc._edit_nonce, - flush_cache : gc.queryargs.flush_cache ? 1 : 0, - } ); + setupAjax: function () { + var Ajax = require('./../models/ajax.js')(app, { + action: 'gc_pull_items', + nonce: gc._edit_nonce, + flush_cache: gc.queryargs.flush_cache ? 1 : 0, + }); this.ajax = new Ajax(); }, @@ -98,36 +97,36 @@ // Build the base window and backdrop, attaching them to the $el. // Setting the tab index allows us to capture focus and redirect it in Application.preserveFocus - this.$el.removeClass( 'gc-set-mapping' ).attr( 'tabindex', '0' ) - .html( this.template( { - btns : this.btns.toJSON(), - navItems : this.navItems ? this.navItems.toJSON() : [], - currID : this.currNav ? this.currNav.get( 'id' ) : 'select-items', - checked : collection.allChecked, - sortKey : collection.sortKey, - sortDirection : collection.sortDirection, - } ) ) - .append( '
 
' ); - - app.views.tableBase.prototype.render.call( this ); - - $( document ) + this.$el.removeClass('gc-set-mapping').attr('tabindex', '0') + .html(this.template({ + btns: this.btns.toJSON(), + navItems: this.navItems ? this.navItems.toJSON() : [], + currID: this.currNav ? this.currNav.get('id') : 'select-items', + checked: collection.allChecked, + sortKey: collection.sortKey, + sortDirection: collection.sortDirection, + })) + .append('
 
'); + + app.views.tableBase.prototype.render.call(this); + + $(document) // Handle any attempt to move focus out of the modal. - .on( 'focusin', this.preserveFocus ) + .on('focusin', this.preserveFocus) // Close modal on escape key. - .on( 'keyup', this.maybeClose ); + .on('keyup', this.maybeClose); // set overflow to "hidden" on the body so that it ignores any scroll events - $( document.body ).addClass( 'gc-modal-open' ); + $(document.body).addClass('gc-modal-open'); // Add modal before the search input. - this.$search.before( this.$el ); + this.$search.before(this.$el); // Position search input. (After the above line, where we render the modal) - this.$search.css( jQuery( '#gc-tablenav' ).offset() ); + this.$search.css(jQuery('#gc-tablenav').offset()); // If we're not focused on the search input... - if ( ! this.isSearch( document.activeElement ) ) { + if (!this.isSearch(document.activeElement)) { // Then set focus on the modal to prevent accidental actions in the underlying page. this.$el.focus(); @@ -140,9 +139,9 @@ * Ensures that keyboard focus remains within the Modal dialog or search input. * @param evt {object} A jQuery-normalized event object. */ - preserveFocus: function ( evt ) { - var isOk = this.$el[0] === evt.target || this.$el.has( evt.target ).length || this.isSearch( evt.target ); - if ( ! isOk ) { + preserveFocus: function (evt) { + var isOk = this.$el[0] === evt.target || this.$el.has(evt.target).length || this.isSearch(evt.target); + if (!isOk) { this.$el.focus(); } }, @@ -151,222 +150,222 @@ * Closes modal if escape key is hit. * @param evt {object} A jQuery-normalized event object. */ - maybeClose: function ( evt ) { - if ( ESCAPE === evt.keyCode && ! this.isSearch( evt.target ) ) { - this.closeModal( evt ); + maybeClose: function (evt) { + if (ESCAPE === evt.keyCode && !this.isSearch(evt.target)) { + this.closeModal(evt); } }, - isSearch: function( el ) { - return this.$search[0] === el || this.$search.has( el ).length; + isSearch: function (el) { + return this.$search[0] === el || this.$search.has(el).length; }, /** * Closes the modal and cleans up after the instance. * @param evt {object} A jQuery-normalized event object. */ - closeModal: function ( evt ) { + closeModal: function (evt) { evt.preventDefault(); this.resetMetaboxView(); this.undelegateEvents(); - $( document ).off( 'focusin' ); - $( document ).off( 'keyup', this.maybeClose ); - $( document.body ).removeClass( 'gc-modal-open' ); + $(document).off('focusin'); + $(document).off('keyup', this.maybeClose); + $(document.body).removeClass('gc-modal-open'); this.remove(); - gc.$id( 'bulk-edit' ).find( 'button.cancel' ).trigger( 'click' ); + gc.$id('bulk-edit').find('button.cancel').trigger('click'); app.modalView = undefined; }, - clickSelectTab: function( evt ) { + clickSelectTab: function (evt) { evt.preventDefault(); - this.selectTab( $( evt.target ).data( 'id' ) ); + this.selectTab($(evt.target).data('id')); }, - selectTab: function( id ) { + selectTab: function (id) { this.currID = id; - this.currNav = this.navItems.getById( id ); - this.navItems.trigger( 'activate', id ); + this.currNav = this.navItems.getById(id); + this.navItems.trigger('activate', id); }, - checkEnableButton: function( btnEnabled ) { - this.buttonStatus( btnEnabled ); + checkEnableButton: function (btnEnabled) { + this.buttonStatus(btnEnabled); }, - buttonStatus: function( enable ) { - if ( this.collection.processing ) { + buttonStatus: function (enable) { + if (this.collection.processing) { return; } - if ( ! enable ) { - this.$( '.media-toolbar button' ).prop( 'disabled', true ); + if (!enable) { + this.$('.media-toolbar button').prop('disabled', true); } else { - this.$( '#gc-btn-assign-mapping' ).prop( 'disabled', ! this.collection.checkedCan( 'assign' ) ); - this.$( '#gc-btn-push' ).prop( 'disabled', ! this.collection.checkedCan( 'push' ) ); - this.$( '#gc-btn-pull' ).prop( 'disabled', ! this.collection.checkedCan( 'pull' ) ); + this.$('#gc-btn-assign-mapping').prop('disabled', !this.collection.checkedCan('assign')); + this.$('#gc-btn-push').prop('disabled', !this.collection.checkedCan('push')); + this.$('#gc-btn-pull').prop('disabled', !this.collection.checkedCan('pull')); } }, - startPull: function( evt ) { + startPull: function (evt) { evt.preventDefault(); - this.startSync( 'pull' ); + this.startSync('pull'); }, - startPush: function( evt ) { + startPush: function (evt) { evt.preventDefault(); - this.startSync( 'push' ); + this.startSync('push'); }, - startSync: function( direction ) { + startSync: function (direction) { var toCheck = 'push' === direction ? 'canPush' : 'canPull'; - var selected = this.selectiveGet( toCheck ); + var selected = this.selectiveGet(toCheck); - if ( window.confirm( gc._sure[ direction ] ) ) { - selected = _.map( selected, function( model ) { - model.set( 'mappingStatus', 'starting' ); + if (window.confirm(gc._sure[direction])) { + selected = _.map(selected, function (model) { + model.set('mappingStatus', 'starting'); return model.toJSON(); - } ); + }); - this.doAjax( selected, direction ); + this.doAjax(selected, direction); } }, - startAssignment: function( evt ) { - var postIds = _.map( this.selectiveGet( 'disabled' ), function( model ) { - return model.get( 'id' ); - } ); + startAssignment: function (evt) { + var postIds = _.map(this.selectiveGet('disabled'), function (model) { + return model.get('id'); + }); this.resetMetaboxView(); - this.$el.addClass( 'gc-set-mapping' ); + this.$el.addClass('gc-set-mapping'); - this.$( '#gc-btn-assign-mapping' ).prop( 'disabled', true ); + this.$('#gc-btn-assign-mapping').prop('disabled', true); - this.metaboxView = this.initMetaboxView( postIds ); - this.listenTo( this.metaboxView, 'cancel', this.maybeResetMetaboxView ); - this.listenTo( this.metaboxView, 'complete', function( model, data ) { - model.set( 'waiting', true ); + this.metaboxView = this.initMetaboxView(postIds); + this.listenTo(this.metaboxView, 'cancel', this.maybeResetMetaboxView); + this.listenTo(this.metaboxView, 'complete', function (model, data) { + model.set('waiting', true); - this.collection.map( function( model ) { - if ( model.get( 'id' ) in data.ids ) { - model.set( 'mapping', data.mapping ); - model.set( 'mappingName', data.mappingName ); - model.set( 'mappingLink', data.mappingLink ); + this.collection.map(function (model) { + if (model.get('id') in data.ids) { + model.set('mapping', data.mapping); + model.set('mappingName', data.mappingName); + model.set('mappingLink', data.mappingLink); } - } ); + }); this.render(); - } ); + }); }, - maybeResetMetaboxView: function() { - if ( this.metaboxView ) { + maybeResetMetaboxView: function () { + if (this.metaboxView) { this.resetMetaboxView(); - this.buttonStatus( true ); + this.buttonStatus(true); } }, - resetMetaboxView: function() { - if ( this.metaboxView ) { - this.stopListening( this.metaboxView ); + resetMetaboxView: function () { + if (this.metaboxView) { + this.stopListening(this.metaboxView); this.metaboxView.close(); - this.$el.removeClass( 'gc-set-mapping' ); + this.$el.removeClass('gc-set-mapping'); } }, - selectiveGet: function( toCheck ) { + selectiveGet: function (toCheck) { var selected = []; var staysChecked; - this.collection.trigger( 'checkSome', function( model ) { - staysChecked = model.get( 'checked' ) && model.get( toCheck ); - if ( staysChecked ) { - selected.push( model ); + this.collection.trigger('checkSome', function (model) { + staysChecked = model.get('checked') && model.get(toCheck); + if (staysChecked) { + selected.push(model); } return staysChecked; - } ); + }); return selected; }, - getChecked: function( cb ) { - this.collection.filter( function( model ) { - var shouldGet = model.get( 'checked' ); - if ( shouldGet && cb ) { - cb( model ); + getChecked: function (cb) { + this.collection.filter(function (model) { + var shouldGet = model.get('checked'); + if (shouldGet && cb) { + cb(model); } return shouldGet; - } ); + }); }, - ajaxSuccess: function( response ) { - if ( ! response.data.mappings ) { + ajaxSuccess: function (response) { + if (!response.data.mappings) { return this.ajaxFail(); } var mappings = []; var toCheck = 'push' === response.data.direction ? 'canPush' : 'canPull'; - var checked = this.getChecked( function( model ) { - if ( ! model.get( toCheck ) ) { + var checked = this.getChecked(function (model) { + if (!model.get(toCheck)) { return; } - if ( response.data.mappings.length && -1 !== _.indexOf( response.data.mappings, model.get( 'mapping' ) ) ) { - model.set( 'mappingStatus', 'syncing' ); - mappings.push( model.get( 'mapping' ) ); + if (response.data.mappings.length && -1 !== _.indexOf(response.data.mappings, model.get('mapping'))) { + model.set('mappingStatus', 'syncing'); + mappings.push(model.get('mapping')); } else { - model.set( 'checked', false ); - model.set( 'mappingStatus', 'complete' ); - model.fetch().done( function() { - model.trigger( 'render' ); - } ); + model.set('checked', false); + model.set('mappingStatus', 'complete'); + model.fetch().done(function () { + model.trigger('render'); + }); } - } ); + }); - if ( ! mappings.length ) { + if (!mappings.length) { return this.clearTimeout(); } - this.checkStatus( mappings, response.data.direction ); + this.checkStatus(mappings, response.data.direction); }, - ajaxFail: function( response ) { - this.setSelectedMappingStatus( 'failed' ); + ajaxFail: function (response) { + this.setSelectedMappingStatus('failed'); this.clearTimeout(); }, - setSelectedMappingStatus: function( status ) { - return this.getChecked( function( model ) { - model.set( 'mappingStatus', status ); - } ); + setSelectedMappingStatus: function (status) { + return this.getChecked(function (model) { + model.set('mappingStatus', status); + }); }, - checkStatus: function( mappings, direction ) { + checkStatus: function (mappings, direction) { this.clearTimeout(); - this.setTimeout( function() { - thisView.doAjax( { check : mappings }, direction ); - } ); + this.setTimeout(function () { + thisView.doAjax({check: mappings}, direction); + }); }, - doAjax: function( formData, direction ) { - this.ajax.set( 'action', 'gc_'+ direction +'_items' ); + doAjax: function (formData, direction) { + this.ajax.set('action', 'gc_' + direction + '_items'); this.ajax.send( formData, - this.ajaxSuccess.bind( this ), + this.ajaxSuccess.bind(this), 0, - this.ajaxFail.bind( this ) + this.ajaxFail.bind(this) ); }, - maybeRender: function() { - if ( ! this.metaboxView ) { + maybeRender: function () { + if (!this.metaboxView) { this.render(); } }, - }); + }); }; diff --git a/assets/js/src/components/views/post-row.js b/assets/js/src/components/views/post-row.js index c822128b..ceb5670c 100644 --- a/assets/js/src/components/views/post-row.js +++ b/assets/js/src/components/views/post-row.js @@ -1,23 +1,23 @@ -module.exports = function( app, gc ) { +module.exports = function (app, gc) { return app.views.base.extend({ - template : wp.template( 'gc-post-column-row' ), - tagName : 'span', - className : 'gc-status-column', - id : function() { - return 'gc-status-row-' + this.model.get( 'id' ); + template: wp.template('gc-post-column-row'), + tagName: 'span', + className: 'gc-status-column', + id: function () { + return 'gc-status-row-' + this.model.get('id'); }, - initialize: function() { - this.listenTo( this.model, 'change:status', this.render ); + initialize: function () { + this.listenTo(this.model, 'change:status', this.render); }, - html: function() { - return this.template( this.model.toJSON() ); + html: function () { + return this.template(this.model.toJSON()); }, - render: function() { - var $td = gc.$id( 'post-'+ this.model.get( 'id' ) ).find( '.column-gathercontent' ); - $td.html( this.html() ); + render: function () { + var $td = gc.$id('post-' + this.model.get('id')).find('.column-gathercontent'); + $td.html(this.html()); return this; } diff --git a/assets/js/src/components/views/post-rows.js b/assets/js/src/components/views/post-rows.js index 0fee8028..96237c8e 100644 --- a/assets/js/src/components/views/post-rows.js +++ b/assets/js/src/components/views/post-rows.js @@ -1,120 +1,120 @@ -module.exports = function( app, gc, $ ) { +module.exports = function (app, gc, $) { var thisView; return app.views.statusSelect2.extend({ - template : wp.template( 'gc-status-select2' ), + template: wp.template('gc-status-select2'), - el : '#posts-filter tbody', + el: '#posts-filter tbody', width: '200px', - initialize: function() { + initialize: function () { thisView = this; - this.listenTo( this, 'quickEdit', this.edit ); - this.listenTo( this, 'quickEditSend', this.sending ); + this.listenTo(this, 'quickEdit', this.edit); + this.listenTo(this, 'quickEditSend', this.sending); this.render(); this.updatePosts(); }, - updatePosts: function() { + updatePosts: function () { // Trigger an un-cached update for the posts - $.post( window.ajaxurl, { - action : 'gc_get_posts', - posts : gc._posts, - flush_cache : gc.queryargs.flush_cache ? 1 : 0 - }, function( response ) { - if ( response.success, response.data ) { - thisView.collection.trigger( 'updateItems', response.data ); + $.post(window.ajaxurl, { + action: 'gc_get_posts', + posts: gc._posts, + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, function (response) { + if (response.success, response.data) { + thisView.collection.trigger('updateItems', response.data); } - } ); + }); }, - sending: function( request, settings ) { - var data = this.parseQueryString( settings.data ); - if ( data.post_ID && data.gc_status ) { - var model = this.collection.getById( data.post_ID ); + sending: function (request, settings) { + var data = this.parseQueryString(settings.data); + if (data.post_ID && data.gc_status) { + var model = this.collection.getById(data.post_ID); - var status = _.find( model.get( 'statuses' ), function( status ) { - return parseInt( status.id, 10 ) === parseInt( data.gc_status, 10 ); - } ); + var status = _.find(model.get('statuses'), function (status) { + return parseInt(status.id, 10) === parseInt(data.gc_status, 10); + }); - model.set( 'status', status ); + model.set('status', status); } }, - edit: function( id, inlineEdit ) { + edit: function (id, inlineEdit) { // get the post ID var postId = 0; - if ( 'object' === typeof( id ) ) { - postId = parseInt( inlineEdit.getId( id ), 10 ); + if ('object' === typeof (id)) { + postId = parseInt(inlineEdit.getId(id), 10); } - this.waitSpinner( postId ); + this.waitSpinner(postId); - if ( ! postId ) { + if (!postId) { return; } - var model = this.collection.getById( postId ); + var model = this.collection.getById(postId); - if ( model.get( 'statusesChecked' ) ) { - return this.renderStatuses( model ); + if (model.get('statusesChecked')) { + return this.renderStatuses(model); } - $.post( window.ajaxurl, { - action : 'gc_get_post_statuses', - postId : postId, - flush_cache : gc.queryargs.flush_cache ? 1 : 0 - }, this.ajaxResponse ).done( function() { - thisView.renderStatuses( model ); - } ); + $.post(window.ajaxurl, { + action: 'gc_get_post_statuses', + postId: postId, + flush_cache: gc.queryargs.flush_cache ? 1 : 0 + }, this.ajaxResponse).done(function () { + thisView.renderStatuses(model); + }); }, - ajaxResponse : function( response ) { - if ( ! response.data ) { + ajaxResponse: function (response) { + if (!response.data) { return; } - var model = thisView.collection.getById( response.data.postId ); - if ( ! model ) { + var model = thisView.collection.getById(response.data.postId); + if (!model) { return; } - model.set( 'statusesChecked', true ); + model.set('statusesChecked', true); - if ( response.success ) { - model.set( 'statuses', response.data.statuses ); + if (response.success) { + model.set('statuses', response.data.statuses); - if ( model.get( 'statuses' ).length ) { - thisView.$( '.gc-select2' ).each( function() { - $( this ).select2( 'destroy' ); - } ); + if (model.get('statuses').length) { + thisView.$('.gc-select2').each(function () { + $(this).select2('destroy'); + }); - thisView.renderStatuses( model ); + thisView.renderStatuses(model); } } }, - renderStatuses: function( model ) { - var postId = model.get( 'id' ); - this.editSelect( postId ).html( this.template( model.toJSON() ) ); - if ( model.get( 'statuses' ).length ) { - this.renderSelect2( gc.$id( 'edit-' + postId ) ); + renderStatuses: function (model) { + var postId = model.get('id'); + this.editSelect(postId).html(this.template(model.toJSON())); + if (model.get('statuses').length) { + this.renderSelect2(gc.$id('edit-' + postId)); } }, - waitSpinner: function( postId ) { - this.editSelect( postId ).html( '' ); + waitSpinner: function (postId) { + this.editSelect(postId).html(''); }, - editSelect: function( postId ) { - return gc.$id( 'edit-' + postId ).find( '.inline-edit-group .gc-status-select2' ); + editSelect: function (postId) { + return gc.$id('edit-' + postId).find('.inline-edit-group .gc-status-select2'); }, - render: function() { - this.collection.each( function( model ) { - ( new app.views.postRow({ model: model }) ).render(); - } ); + render: function () { + this.collection.each(function (model) { + (new app.views.postRow({model: model})).render(); + }); return this; }, @@ -124,13 +124,13 @@ module.exports = function( app, gc, $ ) { * @param {String} (option) queryString * @return {Object} query params */ - parseQueryString: function( string ) { - if ( ! string ) { + parseQueryString: function (string) { + if (!string) { return {}; } return _ .chain(string.split('&')) - .map(function(params) { + .map(function (params) { var p = params.split('='); return [p[0], decodeURIComponent(p[1])]; }) diff --git a/assets/js/src/components/views/status-select2.js b/assets/js/src/components/views/status-select2.js index 35e831dd..34b44a08 100644 --- a/assets/js/src/components/views/status-select2.js +++ b/assets/js/src/components/views/status-select2.js @@ -1,40 +1,40 @@ -module.exports = function( app ) { +module.exports = function (app) { var thisView; return app.views.base.extend({ - select2ItemTemplate : wp.template( 'gc-select2-item' ), + select2ItemTemplate: wp.template('gc-select2-item'), width: '250px', - renderSelect2 : function( $context ) { - var $selector = $context ? $context.find( '.gc-select2' ) : this.$( '.gc-select2' ); + renderSelect2: function ($context) { + var $selector = $context ? $context.find('.gc-select2') : this.$('.gc-select2'); thisView = this; - $selector.each( function() { - var $this = jQuery( this ); + $selector.each(function () { + var $this = jQuery(this); var data = $this.data(); - $this.select2( thisView.select2Args( data ) ); - var s2Data = $this.data( 'select2' ); + $this.select2(thisView.select2Args(data)); + var s2Data = $this.data('select2'); // Add classes for styling. - s2Data.$results.addClass( 'select2-'+ data.column ); - s2Data.$container.addClass( 'select2-'+ data.column ); - } ); + s2Data.$results.addClass('select2-' + data.column); + s2Data.$container.addClass('select2-' + data.column); + }); return this; }, - select2Args: function( data ) { + select2Args: function (data) { var args = { width: thisView.width }; - args.templateResult = function( status, showDesc ) { - var data = jQuery.extend( status, jQuery( status.element ).data() ); - data.description = false === showDesc ? false : ( data.description || '' ); - return jQuery( thisView.select2ItemTemplate( status ) ); - }.bind( thisView ); + args.templateResult = function (status, showDesc) { + var data = jQuery.extend(status, jQuery(status.element).data()); + data.description = false === showDesc ? false : (data.description || ''); + return jQuery(thisView.select2ItemTemplate(status)); + }.bind(thisView); - args.templateSelection = function( status ) { - return args.templateResult( status, false ); + args.templateSelection = function (status) { + return args.templateResult(status, false); }; return args; diff --git a/assets/js/src/components/views/tab-link.js b/assets/js/src/components/views/tab-link.js index 4a8f4cdd..221fe209 100644 --- a/assets/js/src/components/views/tab-link.js +++ b/assets/js/src/components/views/tab-link.js @@ -1,17 +1,17 @@ -module.exports = function( app ) { +module.exports = function (app) { return app.views.base.extend({ - tagName : 'a', + tagName: 'a', - id : function() { - return 'tabtrigger-' + this.model.get( 'id' ); + id: function () { + return 'tabtrigger-' + this.model.get('id'); }, - className : function() { - return 'nav-tab ' + ( this.model.get( 'hidden' ) ? '' : 'nav-tab-active' ) + ' ' + this.model.get( 'navClasses' ); + className: function () { + return 'nav-tab ' + (this.model.get('hidden') ? '' : 'nav-tab-active') + ' ' + this.model.get('navClasses'); }, - render : function() { - this.$el.text( this.model.get( 'label' ) ).attr( 'href', '#' + this.model.get( 'id' ) ); + render: function () { + this.$el.text(this.model.get('label')).attr('href', '#' + this.model.get('id')); return this; } diff --git a/assets/js/src/components/views/tab-row.js b/assets/js/src/components/views/tab-row.js index 342431b8..1772f762 100644 --- a/assets/js/src/components/views/tab-row.js +++ b/assets/js/src/components/views/tab-row.js @@ -1,74 +1,76 @@ -module.exports = function( app, _meta_keys ) { +module.exports = function (app, _meta_keys) { return app.views.base.extend({ - tagName : 'tr', - template : wp.template( 'gc-mapping-tab-row' ), + tagName: 'tr', + template: wp.template('gc-mapping-tab-row'), - events : { - 'change .wp-type-select' : 'changeType', - 'change .wp-type-value-select' : 'changeValue', - 'change .wp-type-field-select' : 'changeField', - 'change .wp-subfield-select' : 'changeSubfield', - 'click .gc-reveal-items' : 'toggleExpanded' + events: { + 'change .wp-type-select': 'changeType', + 'change .wp-type-value-select': 'changeValue', + 'change .wp-type-field-select': 'changeField', + 'change .wp-subfield-select': 'changeSubfield', + 'click .gc-reveal-items': 'toggleExpanded' }, - initialize: function() { - this.listenTo( this.model, 'change:field_type', this.render ); + initialize: function () { + this.listenTo(this.model, 'change:field_type', this.render); // Initiate the metaKeys collection. - this.metaKeys = new ( app.collections.base.extend( { - model : app.models.base.extend( { defaults: { - value : '', - field : '', - subfields : '', - } } ), - getByValue : function( value ) { - return this.find( function( model ) { - return model.get( 'value' ) === value; - } ); + this.metaKeys = new (app.collections.base.extend({ + model: app.models.base.extend({ + defaults: { + value: '', + field: '', + subfields: '', + } + }), + getByValue: function (value) { + return this.find(function (model) { + return model.get('value') === value; + }); }, - getByField : function( field ) { - return this.find( function( model ) { - return model.get( 'field' ) === field; - } ); + getByField: function (field) { + return this.find(function (model) { + return model.get('field') === field; + }); }, - getBySubfields : function( subfields ) { - return this.find( function( model ) { - return model.get( 'subfields' ) === subfields; - } ); + getBySubfields: function (subfields) { + return this.find(function (model) { + return model.get('subfields') === subfields; + }); }, - } ) )( _meta_keys ); + }))(_meta_keys); }, /** * 1st Dropdown - event change */ - changeType: function( evt ) { - this.model.set( 'field_type', jQuery( evt.target ).val() ); + changeType: function (evt) { + this.model.set('field_type', jQuery(evt.target).val()); }, /** * 2nd Dropdown - event change */ - changeValue: function( evt ) { - var component = jQuery( evt.target ).closest('.component-table-wrapper').attr('id'); - var value = jQuery( evt.target ).val(); - var type = this.model.get( 'type' ); - var fieldType = this.model.get( 'field_type' ); - if ( '' === value ) { - this.model.set( 'field_type', '' ); - this.model.set( 'field_value', '' ); - this.model.set( 'field_field', '' ); - this.model.set( 'field_subfields', {} ); - jQuery('#'+component+' .component-table-inner ').find('select').html("").val(""); + changeValue: function (evt) { + var component = jQuery(evt.target).closest('.component-table-wrapper').attr('id'); + var value = jQuery(evt.target).val(); + var type = this.model.get('type'); + var fieldType = this.model.get('field_type'); + if ('' === value) { + this.model.set('field_type', ''); + this.model.set('field_value', ''); + this.model.set('field_field', ''); + this.model.set('field_subfields', {}); + jQuery('#' + component + ' .component-table-inner ').find('select').html("").val(""); } else { - this.model.set( 'field_value', value ); + this.model.set('field_value', value); // Components - Update "Field" - if( "component" === type ){ + if ("component" === type) { this.updateAjax_Field(component, value, false); } // Repeaters - Update "Field" - else if( "wp-type-acf" === fieldType ){ - var id = jQuery( evt.target ).closest('td').attr('id'); + else if ("wp-type-acf" === fieldType) { + var id = jQuery(evt.target).closest('td').attr('id'); this.updateAjax_Field(id, value, false); } } @@ -77,16 +79,16 @@ module.exports = function( app, _meta_keys ) { /** * 3rd Dropdown - event change */ - changeField: function( evt ) { - var value = jQuery( evt.target ).val(); - var component = jQuery( evt.target ).closest('.component-table-wrapper').attr('id'); + changeField: function (evt) { + var value = jQuery(evt.target).val(); + var component = jQuery(evt.target).closest('.component-table-wrapper').attr('id'); // Update Data - this.model.set( 'field_subfields', {} ); - if ( '' === value ) { - this.model.set( 'field_field', '' ); - jQuery('#'+component+' .component-table-inner ').find('select').html("").val(""); + this.model.set('field_subfields', {}); + if ('' === value) { + this.model.set('field_field', ''); + jQuery('#' + component + ' .component-table-inner ').find('select').html("").val(""); } else { - this.model.set( 'field_field', value ); + this.model.set('field_field', value); // Update subfields this.updateAjax_ComponentSubfields(component, value, false); } @@ -95,22 +97,24 @@ module.exports = function( app, _meta_keys ) { /** * LVL 2: Subfield Dropdown - event change */ - changeSubfield: function( evt ) { - var value = jQuery( evt.target ).val(); - var index = jQuery( evt.target ).attr('data-index'); - var subfield_data = this.model.get( 'field_subfields'); - if(!subfield_data){ subfield_data = {}; } + changeSubfield: function (evt) { + var value = jQuery(evt.target).val(); + var index = jQuery(evt.target).attr('data-index'); + var subfield_data = this.model.get('field_subfields'); + if (!subfield_data) { + subfield_data = {}; + } subfield_data[index] = value; - this.model.set( 'field_subfields', subfield_data ); + this.model.set('field_subfields', subfield_data); }, /** * Helper function: build option html elements for AJAX funtions */ - optionBuilder: function( data ) { + optionBuilder: function (data) { var options_html = ""; - jQuery.each(data.field_data, function(i, field) { - options_html += ""; + jQuery.each(data.field_data, function (i, field) { + options_html += ""; }); return options_html; }, @@ -124,39 +128,39 @@ module.exports = function( app, _meta_keys ) { * @param {string} field_name - Parent field name/key of the sub fields, should be a repeater * @param {object} saved_fields - OPTIONAL: Pass saved subfields if you want to set pre-existing values */ - updateAjax_Field: function( component, field_name, saved_fields ) { + updateAjax_Field: function (component, field_name, saved_fields) { saved_fields = typeof saved_fields !== 'undefined' ? saved_fields : ""; var $this = this; // Update UI - jQuery('#'+component+' .wp-type-field-select ~ span.select2').addClass('ajax-disabled'); + jQuery('#' + component + ' .wp-type-field-select ~ span.select2').addClass('ajax-disabled'); // Get Updated Data - jQuery.post( window.ajaxurl, { + jQuery.post(window.ajaxurl, { action: 'gc_component_subfields', subfields_data: { name: field_name, } - }, function( response ) { + }, function (response) { // Update UI - jQuery('#'+component+' .wp-type-field-select ~ span.select2').removeClass('ajax-disabled'); + jQuery('#' + component + ' .wp-type-field-select ~ span.select2').removeClass('ajax-disabled'); // SUCCESS - if( response.success ){ + if (response.success) { // Ensure response has subfield data - if( response.data.field_data && response.data.field_data.length ){ + if (response.data.field_data && response.data.field_data.length) { // Build options HTML: var options_html = $this.optionBuilder(response.data); // Inject into select fields - jQuery('#'+component).find('.wp-type-field-select').html(options_html); + jQuery('#' + component).find('.wp-type-field-select').html(options_html); // If existing subfields are passed, update specific dropdown options - if(saved_fields){ - jQuery('#'+component).find('.wp-type-field-select').val(saved_fields); + if (saved_fields) { + jQuery('#' + component).find('.wp-type-field-select').val(saved_fields); } } } // ERROR - else{ + else { window.alert('Please refresh and try again. If the issue persists, reach out to support'); } }); @@ -171,35 +175,35 @@ module.exports = function( app, _meta_keys ) { * @param {string} field_name - Parent field name/key of the sub fields, should be a repeater * @param {object} saved_fields - OPTIONAL: Pass saved subfields if you want to set pre-existing values */ - updateAjax_ComponentSubfields: function( component, field_name, saved_fields ) { + updateAjax_ComponentSubfields: function (component, field_name, saved_fields) { saved_fields = typeof saved_fields !== 'undefined' ? saved_fields : {}; var $this = this; // Update UI - jQuery('#'+component+' .component-table-inner').find('select').addClass('ajax-disabled'); + jQuery('#' + component + ' .component-table-inner').find('select').addClass('ajax-disabled'); // Get Updated Data - jQuery.post( window.ajaxurl, { + jQuery.post(window.ajaxurl, { action: 'gc_component_subfields', subfields_data: { name: field_name, } - }, function( response ) { + }, function (response) { // Update UI - jQuery('#'+component+' .component-table-inner').find('select').removeClass('ajax-disabled'); + jQuery('#' + component + ' .component-table-inner').find('select').removeClass('ajax-disabled'); // SUCCESS - if( response.success ){ + if (response.success) { // Ensure response has subfield data - if( response.data.field_data && response.data.field_data.length ){ + if (response.data.field_data && response.data.field_data.length) { // Build options HTML: var options_html = $this.optionBuilder(response.data); // Inject into select fields - jQuery('#'+component).find('.component-table-inner select').html(options_html); + jQuery('#' + component).find('.component-table-inner select').html(options_html); // If existing subfields are passed, update specific dropdown options - if(Object.keys(saved_fields).length){ - var dropdowns = jQuery('#'+component).find('.component-table-inner select').toArray(); - jQuery.each(dropdowns, function(i, dropdown){ + if (Object.keys(saved_fields).length) { + var dropdowns = jQuery('#' + component).find('.component-table-inner select').toArray(); + jQuery.each(dropdowns, function (i, dropdown) { i++; jQuery(dropdown).val(saved_fields[i]); }); @@ -207,7 +211,7 @@ module.exports = function( app, _meta_keys ) { } } // ERROR - else{ + else { window.alert('Please refresh and try again. If the issue persists, reach out to support'); } }); @@ -216,26 +220,26 @@ module.exports = function( app, _meta_keys ) { /** * Init */ - render : function() { - var val = this.model.get( 'field_value' ); - var valField = this.model.get( 'field_field' ); - var valSubfields = this.model.get( 'field_subfields' ); + render: function () { + var val = this.model.get('field_value'); + var valField = this.model.get('field_field'); + var valSubfields = this.model.get('field_subfields'); var component; - if ( val && ! this.metaKeys.getByValue( val ) ) { - this.metaKeys.add( { value : val } ); + if (val && !this.metaKeys.getByValue(val)) { + this.metaKeys.add({value: val}); } - if ( valField && ! this.metaKeys.getByField( valField ) ) { - this.metaKeys.add( { field : valField } ); + if (valField && !this.metaKeys.getByField(valField)) { + this.metaKeys.add({field: valField}); } - if ( valSubfields && ! this.metaKeys.getBySubfields( valSubfields ) ) { - this.metaKeys.add( { subfields : valSubfields } ); + if (valSubfields && !this.metaKeys.getBySubfields(valSubfields)) { + this.metaKeys.add({subfields: valSubfields}); } // Init subfields - if(valField){ + if (valField) { component = this.model.get('name'); - if(valSubfields){ + if (valSubfields) { this.updateAjax_ComponentSubfields(component, valField, valSubfields); } } @@ -243,20 +247,20 @@ module.exports = function( app, _meta_keys ) { var json = this.model.toJSON(); json.metaKeys = this.metaKeys.toJSON(); - this.$el.html( this.template( json ) ); + this.$el.html(this.template(json)); - this.$( '.gc-select2' ).each( function() { - var $this = jQuery( this ); + this.$('.gc-select2').each(function () { + var $this = jQuery(this); var args = { width: '250px' }; - if ( $this.hasClass( 'gc-select2-add-new' ) ) { + if ($this.hasClass('gc-select2-add-new')) { args.tags = true; } - $this.select2( args ); - } ); + $this.select2(args); + }); return this; } diff --git a/assets/js/src/components/views/tab.js b/assets/js/src/components/views/tab.js index afc291be..084db76b 100644 --- a/assets/js/src/components/views/tab.js +++ b/assets/js/src/components/views/tab.js @@ -1,23 +1,23 @@ -module.exports = function( app ) { +module.exports = function (app) { return app.views.statusSelect2.extend({ - template : wp.template( 'gc-tab-wrapper' ), + template: wp.template('gc-tab-wrapper'), - tagName : 'fieldset', + tagName: 'fieldset', - id : function() { - return this.model.get( 'id' ); + id: function () { + return this.model.get('id'); }, - className : function() { - return 'gc-template-tab ' + ( this.model.get( 'hidden' ) ? 'hidden' : '' ); + className: function () { + return 'gc-template-tab ' + (this.model.get('hidden') ? 'hidden' : ''); }, - render : function() { - this.$el.html( this.template( this.model.toJSON() ) ); + render: function () { + this.$el.html(this.template(this.model.toJSON())); - var rendered = this.getRenderedModels( app.views.tabRow, this.model.rows ); + var rendered = this.getRenderedModels(app.views.tabRow, this.model.rows); - this.$el.find( 'tbody' ).html( rendered ); + this.$el.find('tbody').html(rendered); return this; } diff --git a/assets/js/src/components/views/table-base.js b/assets/js/src/components/views/table-base.js index ab2d195b..4e4e92d4 100644 --- a/assets/js/src/components/views/table-base.js +++ b/assets/js/src/components/views/table-base.js @@ -1,126 +1,127 @@ -module.exports = function( app, $, gc ) { - app.views.tableSearch = require( './../views/table-search.js' )( app, $, gc ); - app.views.tableNav = require( './../views/table-nav.js' )( app, $, gc ); +module.exports = function (app, $, gc) { + app.views.tableSearch = require('./../views/table-search.js')(app, $, gc); + app.views.tableNav = require('./../views/table-nav.js')(app, $, gc); return app.views.base.extend({ - timeoutID : null, - ajax : null, - tableNavView : null, - searchView : null, - modelView : null, // Need to override. - timeoutTime : 1000, - - events : { - 'click .gc-field-th.sortable' : 'sortRowsByColumn', - 'change .gc-field-th.gc-check-column input' : 'checkAll' + timeoutID: null, + ajax: null, + tableNavView: null, + searchView: null, + modelView: null, // Need to override. + timeoutTime: 1000, + + events: { + 'click .gc-field-th.sortable': 'sortRowsByColumn', + 'change .gc-field-th.gc-check-column input': 'checkAll' }, - initialize: function() { + initialize: function () { this.setupAjax(); - this.listenTo( this.collection, 'render', this.render ); - this.listenTo( this.collection, 'notAllChecked', this.allCheckedStatus ); - this.listenTo( this.collection, 'change:checked', this.renderNav ); - this.listenTo( this, 'render', this.render ); + this.listenTo(this.collection, 'render', this.render); + this.listenTo(this.collection, 'notAllChecked', this.allCheckedStatus); + this.listenTo(this.collection, 'change:checked', this.renderNav); + this.listenTo(this, 'render', this.render); - this.tableNavView = new app.views.tableNav( { - collection : this.collection - } ); + this.tableNavView = new app.views.tableNav({ + collection: this.collection + }); - this.searchView = new app.views.tableSearch( { - collection : this.collection - } ); + this.searchView = new app.views.tableSearch({ + collection: this.collection + }); }, // Need to override. - setupAjax: function() {}, + setupAjax: function () { + }, - sortRowsByColumn: function( evt ) { + sortRowsByColumn: function (evt) { evt.preventDefault(); var collection = this.collection.current(); - var $this = $( evt.currentTarget ); - var column = $this.find( 'a' ).data( 'id' ); + var $this = $(evt.currentTarget); + var column = $this.find('a').data('id'); var direction = false; - if ( $this.hasClass( 'asc' ) ) { + if ($this.hasClass('asc')) { direction = 'desc'; } - if ( $this.hasClass( 'desc' ) ) { + if ($this.hasClass('desc')) { direction = 'asc'; } - if ( ! direction ) { + if (!direction) { direction = collection.sortDirection; } - if ( 'asc' === direction ) { - $this.addClass( 'desc' ).removeClass( 'asc' ); + if ('asc' === direction) { + $this.addClass('desc').removeClass('asc'); } else { - $this.addClass( 'asc' ).removeClass( 'desc' ); + $this.addClass('asc').removeClass('desc'); } - collection.trigger( 'sortByColumn', column, direction ); + collection.trigger('sortByColumn', column, direction); this.sortRender(); }, - buttonStatus: function( enable ) { - this.$( '.button-primary' ).prop( 'disabled', ! enable ); + buttonStatus: function (enable) { + this.$('.button-primary').prop('disabled', !enable); }, - allCheckedStatus: function() { - this.$( '.gc-field-th.gc-check-column input' ).prop( 'checked', this.collection.allChecked ); + allCheckedStatus: function () { + this.$('.gc-field-th.gc-check-column input').prop('checked', this.collection.allChecked); }, - checkAll: function( evt ) { - this.collection.trigger( 'checkAll', $( evt.target ).is( ':checked' ) ); + checkAll: function (evt) { + this.collection.trigger('checkAll', $(evt.target).is(':checked')); }, - doSpinner: function() { - var html = this.blankRow( '' ); - this.renderRows( html ); + doSpinner: function () { + var html = this.blankRow(''); + this.renderRows(html); }, - setTimeout: function( callback ) { - this.timeoutID = window.setTimeout( callback, this.timeoutTime ); + setTimeout: function (callback) { + this.timeoutID = window.setTimeout(callback, this.timeoutTime); }, - clearTimeout: function() { - window.clearTimeout( this.timeoutID ); + clearTimeout: function () { + window.clearTimeout(this.timeoutID); this.timeoutID = null; }, - getRenderedRows: function() { + getRenderedRows: function () { var rows; - if ( this.collection.current().length ) { - rows = this.getRenderedModels( this.modelView, this.collection.current() ) ; + if (this.collection.current().length) { + rows = this.getRenderedModels(this.modelView, this.collection.current()); } else { - rows = this.blankRow( gc._text.no_items ); + rows = this.blankRow(gc._text.no_items); } return rows; }, - sortRender: function() { + sortRender: function () { this.render(); }, - blankRow: function( html ) { - var cols = this.$( 'thead tr > *' ).length; - return ''+ html +''; + blankRow: function (html) { + var cols = this.$('thead tr > *').length; + return '' + html + ''; }, - renderRows: function( html ) { - this.$( 'tbody' ).html( html || this.getRenderedRows() ); + renderRows: function (html) { + this.$('tbody').html(html || this.getRenderedRows()); }, - renderNav: function() { - this.$( '#gc-tablenav' ).html( this.tableNavView.render().el ); + renderNav: function () { + this.$('#gc-tablenav').html(this.tableNavView.render().el); }, - render: function() { + render: function () { var collection = this.collection.current(); // Re-render and replace table rows. @@ -130,10 +131,10 @@ module.exports = function( app, $, gc ) { this.renderNav(); // Make sync button enabled/disabled - this.buttonStatus( collection.syncEnabled ); + this.buttonStatus(collection.syncEnabled); // Make check-all inputs checked/unchecked - this.allCheckedStatus( collection.allChecked ); + this.allCheckedStatus(collection.allChecked); return this; } diff --git a/assets/js/src/components/views/table-nav.js b/assets/js/src/components/views/table-nav.js index 8a2301ad..2cc0bdfb 100644 --- a/assets/js/src/components/views/table-nav.js +++ b/assets/js/src/components/views/table-nav.js @@ -1,14 +1,14 @@ -module.exports = function( app, $, gc ) { +module.exports = function (app, $, gc) { return app.views.base.extend({ - template : wp.template( 'gc-table-nav' ), + template: wp.template('gc-table-nav'), - render : function() { + render: function () { var collection = this.collection.current(); - this.$el.html( this.template( { - count : collection.length, - selected : collection.checked ? collection.checked().length : 0, - } ) ); + this.$el.html(this.template({ + count: collection.length, + selected: collection.checked ? collection.checked().length : 0, + })); return this; }, diff --git a/assets/js/src/components/views/table-search.js b/assets/js/src/components/views/table-search.js index 883a5e2e..e958ede9 100644 --- a/assets/js/src/components/views/table-search.js +++ b/assets/js/src/components/views/table-search.js @@ -1,22 +1,22 @@ -module.exports = function( app ) { +module.exports = function (app) { return Backbone.View.extend({ - el : '#gc-items-search', - template : wp.template( 'gc-table-search' ), - events : { - 'keyup #gc-search-input' : 'filterCollection', - 'search #gc-search-input' : 'filterCollection', + el: '#gc-items-search', + template: wp.template('gc-table-search'), + events: { + 'keyup #gc-search-input': 'filterCollection', + 'search #gc-search-input': 'filterCollection', }, - initialize: function() { + initialize: function () { this.render(); }, - filterCollection: _.debounce( function( evt ) { - this.collection.search( evt.target.value ); - }, 100 ), + filterCollection: _.debounce(function (evt) { + this.collection.search(evt.target.value); + }, 100), - render: function() { - this.$el.html( this.template() ); + render: function () { + this.$el.html(this.template()); return this; } diff --git a/assets/js/src/components/views/tabs.js b/assets/js/src/components/views/tabs.js index abc47fda..97082a4f 100644 --- a/assets/js/src/components/views/tabs.js +++ b/assets/js/src/components/views/tabs.js @@ -1,96 +1,96 @@ -module.exports = function( app, $, gc ) { +module.exports = function (app, $, gc) { return app.views.base.extend({ - initial : gc._initial, - el : '#mapping-tabs', + initial: gc._initial, + el: '#mapping-tabs', - template : wp.template( 'gc-tabs-wrapper' ), + template: wp.template('gc-tabs-wrapper'), - events : { - 'click .nav-tab' : 'tabClick', - 'click .nav-tab-link' : 'triggerClick' + events: { + 'click .nav-tab': 'tabClick', + 'click .nav-tab-link': 'triggerClick' }, - initialize: function() { - this.listenTo( this.collection, 'render', this.render ); - this.listenTo( this, 'render', this.render ); - this.listenTo( this, 'saveEnabled', this.enableSave ); - this.listenTo( this, 'saveDisabled', this.disableSave ); + initialize: function () { + this.listenTo(this.collection, 'render', this.render); + this.listenTo(this, 'render', this.render); + this.listenTo(this, 'saveEnabled', this.enableSave); + this.listenTo(this, 'saveDisabled', this.disableSave); - if ( this.initial ) { + if (this.initial) { // Listen for initialization - this.listenTo( this.collection, 'change:post_type', this.initMapping ); + this.listenTo(this.collection, 'change:post_type', this.initMapping); } - this.defaultTab = this.collection.getById( 'mapping-defaults' ); + this.defaultTab = this.collection.getById('mapping-defaults'); this.render(); - if ( ! this.initial && gc._pointers.refresh_connection ) { - window.setTimeout( function() { - this.pointer( $( '.submit .gc-refresh-connection' ), 'refresh_connection', { + if (!this.initial && gc._pointers.refresh_connection) { + window.setTimeout(function () { + this.pointer($('.submit .gc-refresh-connection'), 'refresh_connection', { position: { edge: 'top' } - } ); + }); - $( '.gc-wp-pointer.refresh_connection' ).css( { 'margin-left': '-41px' } ); - }.bind( this ), 500 ); + $('.gc-wp-pointer.refresh_connection').css({'margin-left': '-41px'}); + }.bind(this), 500); } }, - initMapping: function() { + initMapping: function () { this.initial = false; - this.stopListening( this.collection, 'change:post_type', this.initMapping ); - this.listenTo( this.collection, 'rowChange', this.triggerSaveEnabled ); + this.stopListening(this.collection, 'change:post_type', this.initMapping); + this.listenTo(this.collection, 'rowChange', this.triggerSaveEnabled); - this.defaultTab.set( 'initial', this.initial ); + this.defaultTab.set('initial', this.initial); this.render(); - if(gc._tabs && gc._tabs.length > 0){ + if (gc._tabs && gc._tabs.length > 0) { var firstTabId = gc._tabs[0].id; - if(firstTabId){ + if (firstTabId) { this.setTab(firstTabId); this.$('.nav-tab[href="#' + firstTabId + '"]').trigger('click'); } } - if ( gc._pointers.select_tab_how_to ) { - this.pointer( '.gc-nav-tab-wrapper-bb', 'select_tab_how_to' ); - this.pointer( '#gc-status-mappings', 'map_status_how_to' ); + if (gc._pointers.select_tab_how_to) { + this.pointer('.gc-nav-tab-wrapper-bb', 'select_tab_how_to'); + this.pointer('#gc-status-mappings', 'map_status_how_to'); } }, - triggerSaveEnabled: function( model ) { - if ( model.changed.field_value ) { - this.trigger( 'saveEnabled' ); - this.stopListening( this.collection, 'rowChange' ); + triggerSaveEnabled: function (model) { + if (model.changed.field_value) { + this.trigger('saveEnabled'); + this.stopListening(this.collection, 'rowChange'); } }, - triggerClick: function( evt ) { + triggerClick: function (evt) { evt.preventDefault(); - this.$( '.nav-tab[href="' + $( evt.target ).attr( 'href' ) + '"]' ).trigger( 'click' ); + this.$('.nav-tab[href="' + $(evt.target).attr('href') + '"]').trigger('click'); }, - tabClick: function( evt ) { + tabClick: function (evt) { evt.preventDefault(); - this.setTab( $( evt.target ).attr( 'href' ).substring(1) ); + this.setTab($(evt.target).attr('href').substring(1)); this.render(); }, - setTab: function( id ) { - this.$el.attr( 'class', id ); - this.collection.invoke( 'set', { 'hidden': true } ); - this.collection.getById( id ).set( 'hidden', false ); + setTab: function (id) { + this.$el.attr('class', id); + this.collection.invoke('set', {'hidden': true}); + this.collection.getById(id).set('hidden', false); }, - render: function() { - this.$( '.gc-select2' ).each( function() { - $( this ).select2( 'destroy' ); - } ); + render: function () { + this.$('.gc-select2').each(function () { + $(this).select2('destroy'); + }); - this.$el.html( this.template() ); + this.$el.html(this.template()); // Add tab links this.renderNav(); @@ -98,93 +98,93 @@ module.exports = function( app, $, gc ) { // Add tab content this.renderTabs(); - if ( this.initial ) { + if (this.initial) { this.renderInitial(); } return this; }, - renderNav: function() { + renderNav: function () { var toAppend; - if ( this.initial ) { - this.setTab( this.defaultTab.get( 'id' ) ); - toAppend = (new app.views.tabLink({ model: this.defaultTab })).render().el; + if (this.initial) { + this.setTab(this.defaultTab.get('id')); + toAppend = (new app.views.tabLink({model: this.defaultTab})).render().el; } else { - toAppend = this.getRenderedModels( app.views.tabLink ); + toAppend = this.getRenderedModels(app.views.tabLink); } - this.$el.find( '.nav-tab-wrapper' ).append( toAppend ); + this.$el.find('.nav-tab-wrapper').append(toAppend); }, - renderTabs: function() { + renderTabs: function () { var frag = document.createDocumentFragment(); - if ( this.initial ) { + if (this.initial) { - this.defaultTab.set( 'initial', this.initial ); - var view = new app.views.defaultTab({ model: this.defaultTab }); - frag.appendChild( view.render().el ); + this.defaultTab.set('initial', this.initial); + var view = new app.views.defaultTab({model: this.defaultTab}); + frag.appendChild(view.render().el); } else { - this.collection.each( function( model ) { - var viewid = 'mapping-defaults' === model.get( 'id' ) ? 'defaultTab' : 'tab'; - var view = new app.views[ viewid ]({ model: model }); + this.collection.each(function (model) { + var viewid = 'mapping-defaults' === model.get('id') ? 'defaultTab' : 'tab'; + var view = new app.views[viewid]({model: model}); - frag.appendChild( view.render().el ); + frag.appendChild(view.render().el); }); } - this.$el.find( '.gc-template-tab-group' ).append( frag ); + this.$el.find('.gc-template-tab-group').append(frag); }, - renderInitial: function() { + renderInitial: function () { // Show the "select post-type" pointer. - this.pointer( '[data-column="post_type"]', 'select_type', { - dismissable : false, + this.pointer('[data-column="post_type"]', 'select_type', { + dismissable: false, position: { edge: 'bottom', align: 'left' } - } ); + }); - this.trigger( 'saveDisabled' ); + this.trigger('saveDisabled'); }, - enableSave: function() { + enableSave: function () { // Enable save button. - $( '.submit .button-primary' ).prop( 'disabled', false ); + $('.submit .button-primary').prop('disabled', false); }, - disableSave: function() { + disableSave: function () { // Disable save button. - $( '.submit .button-primary' ).prop( 'disabled', true ); + $('.submit .button-primary').prop('disabled', true); }, - pointer: function( $selector, key, args ) { + pointer: function ($selector, key, args) { args = args || {}; var defaults = { - content: gc._pointers[ key ], - pointerClass : 'wp-pointer gc-wp-pointer '+ key + content: gc._pointers[key], + pointerClass: 'wp-pointer gc-wp-pointer ' + key }; - if ( false !== args.dismissable ) { - defaults.close = function() { - $.post( window.ajaxurl, { + if (false !== args.dismissable) { + defaults.close = function () { + $.post(window.ajaxurl, { pointer: 'gc_' + key, action: 'dismiss-wp-pointer' - } ); + }); }; } - if ( args.position ) { + if (args.position) { defaults.position = args.position; } - $selector = ( $selector instanceof jQuery ) ? $selector : this.$( $selector ); - return $selector.pointer( defaults ).pointer( 'open' ); + $selector = ($selector instanceof jQuery) ? $selector : this.$($selector); + return $selector.pointer(defaults).pointer('open'); } }); diff --git a/assets/js/vendor/select2-4.0.13/select2.js b/assets/js/vendor/select2-4.0.13/select2.js index fcfb5ab4..abe5cb00 100644 --- a/assets/js/vendor/select2-4.0.13/select2.js +++ b/assets/js/vendor/select2-4.0.13/select2.js @@ -6,6103 +6,6096 @@ * https://github.com/select2/select2/blob/master/LICENSE.md */ ;(function (factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['jquery'], factory); - } else if (typeof module === 'object' && module.exports) { - // Node/CommonJS - module.exports = function (root, jQuery) { - if (jQuery === undefined) { - // require('jQuery') returns a factory that requires window to - // build a jQuery instance, we normalize how we use modules - // that require this pattern but the window provided is a noop - // if it's defined (how jquery works) - if (typeof window !== 'undefined') { - jQuery = require('jquery'); - } - else { - jQuery = require('jquery')(root); - } - } - factory(jQuery); - return jQuery; - }; - } else { - // Browser globals - factory(jQuery); - } -} (function (jQuery) { - // This is needed so we can catch the AMD loader configuration and use it - // The inner file should be wrapped (by `banner.start.js`) in a function that - // returns the AMD loader references. - var S2 =(function () { - // Restore the Select2 AMD loader so it can be used - // Needed mostly in the language files, where the loader is not inserted - if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) { - var S2 = jQuery.fn.select2.amd; - } -var S2;(function () { if (!S2 || !S2.requirejs) { -if (!S2) { S2 = {}; } else { require = S2; } -/** - * @license almond 0.3.3 Copyright jQuery Foundation and other contributors. - * Released under MIT license, http://github.com/requirejs/almond/LICENSE - */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof module === 'object' && module.exports) { + // Node/CommonJS + module.exports = function (root, jQuery) { + if (jQuery === undefined) { + // require('jQuery') returns a factory that requires window to + // build a jQuery instance, we normalize how we use modules + // that require this pattern but the window provided is a noop + // if it's defined (how jquery works) + if (typeof window !== 'undefined') { + jQuery = require('jquery'); + } else { + jQuery = require('jquery')(root); + } + } + factory(jQuery); + return jQuery; + }; + } else { + // Browser globals + factory(jQuery); + } +}(function (jQuery) { + // This is needed so we can catch the AMD loader configuration and use it + // The inner file should be wrapped (by `banner.start.js`) in a function that + // returns the AMD loader references. + var S2 = (function () { + // Restore the Select2 AMD loader so it can be used + // Needed mostly in the language files, where the loader is not inserted + if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) { + var S2 = jQuery.fn.select2.amd; + } + var S2; + (function () { + if (!S2 || !S2.requirejs) { + if (!S2) { + S2 = {}; + } else { + require = S2; + } + /** + * @license almond 0.3.3 Copyright jQuery Foundation and other contributors. + * Released under MIT license, http://github.com/requirejs/almond/LICENSE + */ //Going sloppy to avoid 'use strict' string cost, but strict practices should //be followed. -/*global setTimeout: false */ - -var requirejs, require, define; -(function (undef) { - var main, req, makeMap, handlers, - defined = {}, - waiting = {}, - config = {}, - defining = {}, - hasOwn = Object.prototype.hasOwnProperty, - aps = [].slice, - jsSuffixRegExp = /\.js$/; - - function hasProp(obj, prop) { - return hasOwn.call(obj, prop); - } - - /** - * Given a relative module name, like ./something, normalize it to - * a real name that can be mapped to a path. - * @param {String} name the relative name - * @param {String} baseName a real name that the name arg is relative - * to. - * @returns {String} normalized name - */ - function normalize(name, baseName) { - var nameParts, nameSegment, mapValue, foundMap, lastIndex, - foundI, foundStarMap, starI, i, j, part, normalizedBaseParts, - baseParts = baseName && baseName.split("/"), - map = config.map, - starMap = (map && map['*']) || {}; - - //Adjust any relative paths. - if (name) { - name = name.split('/'); - lastIndex = name.length - 1; - - // If wanting node ID compatibility, strip .js from end - // of IDs. Have to do this here, and not in nameToUrl - // because node allows either .js or non .js to map - // to same file. - if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { - name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); - } - - // Starts with a '.' so need the baseName - if (name[0].charAt(0) === '.' && baseParts) { - //Convert baseName to array, and lop off the last part, - //so that . matches that 'directory' and not name of the baseName's - //module. For instance, baseName of 'one/two/three', maps to - //'one/two/three.js', but we want the directory, 'one/two' for - //this normalization. - normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); - name = normalizedBaseParts.concat(name); - } - - //start trimDots - for (i = 0; i < name.length; i++) { - part = name[i]; - if (part === '.') { - name.splice(i, 1); - i -= 1; - } else if (part === '..') { - // If at the start, or previous value is still .., - // keep them so that when converted to a path it may - // still work when converted to a path, even though - // as an ID it is less than ideal. In larger point - // releases, may be better to just kick out an error. - if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') { - continue; - } else if (i > 0) { - name.splice(i - 1, 2); - i -= 2; - } - } - } - //end trimDots - - name = name.join('/'); - } - - //Apply map config if available. - if ((baseParts || starMap) && map) { - nameParts = name.split('/'); - - for (i = nameParts.length; i > 0; i -= 1) { - nameSegment = nameParts.slice(0, i).join("/"); - - if (baseParts) { - //Find the longest baseName segment match in the config. - //So, do joins on the biggest to smallest lengths of baseParts. - for (j = baseParts.length; j > 0; j -= 1) { - mapValue = map[baseParts.slice(0, j).join('/')]; - - //baseName segment has config, find if it has one for - //this name. - if (mapValue) { - mapValue = mapValue[nameSegment]; - if (mapValue) { - //Match, update name to the new value. - foundMap = mapValue; - foundI = i; - break; - } - } - } - } - - if (foundMap) { - break; - } - - //Check for a star map match, but just hold on to it, - //if there is a shorter segment match later in a matching - //config, then favor over this star map. - if (!foundStarMap && starMap && starMap[nameSegment]) { - foundStarMap = starMap[nameSegment]; - starI = i; - } - } - - if (!foundMap && foundStarMap) { - foundMap = foundStarMap; - foundI = starI; - } - - if (foundMap) { - nameParts.splice(0, foundI, foundMap); - name = nameParts.join('/'); - } - } - - return name; - } - - function makeRequire(relName, forceSync) { - return function () { - //A version of a require function that passes a moduleName - //value for items that may need to - //look up paths relative to the moduleName - var args = aps.call(arguments, 0); - - //If first arg is not require('string'), and there is only - //one arg, it is the array form without a callback. Insert - //a null so that the following concat is correct. - if (typeof args[0] !== 'string' && args.length === 1) { - args.push(null); - } - return req.apply(undef, args.concat([relName, forceSync])); - }; - } - - function makeNormalize(relName) { - return function (name) { - return normalize(name, relName); - }; - } - - function makeLoad(depName) { - return function (value) { - defined[depName] = value; - }; - } - - function callDep(name) { - if (hasProp(waiting, name)) { - var args = waiting[name]; - delete waiting[name]; - defining[name] = true; - main.apply(undef, args); - } - - if (!hasProp(defined, name) && !hasProp(defining, name)) { - throw new Error('No ' + name); - } - return defined[name]; - } - - //Turns a plugin!resource to [plugin, resource] - //with the plugin being undefined if the name - //did not have a plugin prefix. - function splitPrefix(name) { - var prefix, - index = name ? name.indexOf('!') : -1; - if (index > -1) { - prefix = name.substring(0, index); - name = name.substring(index + 1, name.length); - } - return [prefix, name]; - } - - //Creates a parts array for a relName where first part is plugin ID, - //second part is resource ID. Assumes relName has already been normalized. - function makeRelParts(relName) { - return relName ? splitPrefix(relName) : []; - } - - /** - * Makes a name map, normalizing the name, and using a plugin - * for normalization if necessary. Grabs a ref to plugin - * too, as an optimization. - */ - makeMap = function (name, relParts) { - var plugin, - parts = splitPrefix(name), - prefix = parts[0], - relResourceName = relParts[1]; - - name = parts[1]; - - if (prefix) { - prefix = normalize(prefix, relResourceName); - plugin = callDep(prefix); - } - - //Normalize according - if (prefix) { - if (plugin && plugin.normalize) { - name = plugin.normalize(name, makeNormalize(relResourceName)); - } else { - name = normalize(name, relResourceName); - } - } else { - name = normalize(name, relResourceName); - parts = splitPrefix(name); - prefix = parts[0]; - name = parts[1]; - if (prefix) { - plugin = callDep(prefix); - } - } - - //Using ridiculous property names for space reasons - return { - f: prefix ? prefix + '!' + name : name, //fullName - n: name, - pr: prefix, - p: plugin - }; - }; - - function makeConfig(name) { - return function () { - return (config && config.config && config.config[name]) || {}; - }; - } - - handlers = { - require: function (name) { - return makeRequire(name); - }, - exports: function (name) { - var e = defined[name]; - if (typeof e !== 'undefined') { - return e; - } else { - return (defined[name] = {}); - } - }, - module: function (name) { - return { - id: name, - uri: '', - exports: defined[name], - config: makeConfig(name) - }; - } - }; - - main = function (name, deps, callback, relName) { - var cjsModule, depName, ret, map, i, relParts, - args = [], - callbackType = typeof callback, - usingExports; - - //Use name if no relName - relName = relName || name; - relParts = makeRelParts(relName); - - //Call the callback to define the module, if necessary. - if (callbackType === 'undefined' || callbackType === 'function') { - //Pull out the defined dependencies and pass the ordered - //values to the callback. - //Default to [require, exports, module] if no deps - deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; - for (i = 0; i < deps.length; i += 1) { - map = makeMap(deps[i], relParts); - depName = map.f; - - //Fast path CommonJS standard dependencies. - if (depName === "require") { - args[i] = handlers.require(name); - } else if (depName === "exports") { - //CommonJS module spec 1.1 - args[i] = handlers.exports(name); - usingExports = true; - } else if (depName === "module") { - //CommonJS module spec 1.1 - cjsModule = args[i] = handlers.module(name); - } else if (hasProp(defined, depName) || - hasProp(waiting, depName) || - hasProp(defining, depName)) { - args[i] = callDep(depName); - } else if (map.p) { - map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); - args[i] = defined[depName]; - } else { - throw new Error(name + ' missing ' + depName); - } - } - - ret = callback ? callback.apply(defined[name], args) : undefined; - - if (name) { - //If setting exports via "module" is in play, - //favor that over return value and exports. After that, - //favor a non-undefined return value over exports use. - if (cjsModule && cjsModule.exports !== undef && - cjsModule.exports !== defined[name]) { - defined[name] = cjsModule.exports; - } else if (ret !== undef || !usingExports) { - //Use the return value from the function. - defined[name] = ret; - } - } - } else if (name) { - //May just be an object definition for the module. Only - //worry about defining if have a module name. - defined[name] = callback; - } - }; - - requirejs = require = req = function (deps, callback, relName, forceSync, alt) { - if (typeof deps === "string") { - if (handlers[deps]) { - //callback in this case is really relName - return handlers[deps](callback); - } - //Just return the module wanted. In this scenario, the - //deps arg is the module name, and second arg (if passed) - //is just the relName. - //Normalize module name, if it contains . or .. - return callDep(makeMap(deps, makeRelParts(callback)).f); - } else if (!deps.splice) { - //deps is a config object, not an array. - config = deps; - if (config.deps) { - req(config.deps, config.callback); - } - if (!callback) { - return; - } - - if (callback.splice) { - //callback is an array, which means it is a dependency list. - //Adjust args if there are dependencies - deps = callback; - callback = relName; - relName = null; - } else { - deps = undef; - } - } - - //Support require(['a']) - callback = callback || function () {}; - - //If relName is a function, it is an errback handler, - //so remove it. - if (typeof relName === 'function') { - relName = forceSync; - forceSync = alt; - } - - //Simulate async callback; - if (forceSync) { - main(undef, deps, callback, relName); - } else { - //Using a non-zero value because of concern for what old browsers - //do, and latest browsers "upgrade" to 4 if lower value is used: - //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: - //If want a value immediately, use require('id') instead -- something - //that works in almond on the global level, but not guaranteed and - //unlikely to work in other AMD implementations. - setTimeout(function () { - main(undef, deps, callback, relName); - }, 4); - } - - return req; - }; - - /** - * Just drops the config on the floor, but returns req in case - * the config return value is used. - */ - req.config = function (cfg) { - return req(cfg); - }; - - /** - * Expose module registry for debugging and tooling - */ - requirejs._defined = defined; - - define = function (name, deps, callback) { - if (typeof name !== 'string') { - throw new Error('See almond README: incorrect module build, no module name'); - } - - //This module may not have dependencies - if (!deps.splice) { - //deps is not an array, so probably means - //an object literal or factory function for - //the value. Adjust args. - callback = deps; - deps = []; - } - - if (!hasProp(defined, name) && !hasProp(waiting, name)) { - waiting[name] = [name, deps, callback]; - } - }; - - define.amd = { - jQuery: true - }; -}()); - -S2.requirejs = requirejs;S2.require = require;S2.define = define; -} -}()); -S2.define("almond", function(){}); - -/* global jQuery:false, $:false */ -S2.define('jquery',[],function () { - var _$ = jQuery || $; - - if (_$ == null && console && console.error) { - console.error( - 'Select2: An instance of jQuery or a jQuery-compatible library was not ' + - 'found. Make sure that you are including jQuery before Select2 on your ' + - 'web page.' - ); - } - - return _$; -}); - -S2.define('select2/utils',[ - 'jquery' -], function ($) { - var Utils = {}; - - Utils.Extend = function (ChildClass, SuperClass) { - var __hasProp = {}.hasOwnProperty; - - function BaseConstructor () { - this.constructor = ChildClass; - } - - for (var key in SuperClass) { - if (__hasProp.call(SuperClass, key)) { - ChildClass[key] = SuperClass[key]; - } - } - - BaseConstructor.prototype = SuperClass.prototype; - ChildClass.prototype = new BaseConstructor(); - ChildClass.__super__ = SuperClass.prototype; - - return ChildClass; - }; - - function getMethods (theClass) { - var proto = theClass.prototype; - - var methods = []; - - for (var methodName in proto) { - var m = proto[methodName]; - - if (typeof m !== 'function') { - continue; - } - - if (methodName === 'constructor') { - continue; - } - - methods.push(methodName); - } - - return methods; - } - - Utils.Decorate = function (SuperClass, DecoratorClass) { - var decoratedMethods = getMethods(DecoratorClass); - var superMethods = getMethods(SuperClass); - - function DecoratedClass () { - var unshift = Array.prototype.unshift; - - var argCount = DecoratorClass.prototype.constructor.length; - - var calledConstructor = SuperClass.prototype.constructor; - - if (argCount > 0) { - unshift.call(arguments, SuperClass.prototype.constructor); - - calledConstructor = DecoratorClass.prototype.constructor; - } - - calledConstructor.apply(this, arguments); - } - - DecoratorClass.displayName = SuperClass.displayName; - - function ctr () { - this.constructor = DecoratedClass; - } - - DecoratedClass.prototype = new ctr(); - - for (var m = 0; m < superMethods.length; m++) { - var superMethod = superMethods[m]; - - DecoratedClass.prototype[superMethod] = - SuperClass.prototype[superMethod]; - } - - var calledMethod = function (methodName) { - // Stub out the original method if it's not decorating an actual method - var originalMethod = function () {}; - - if (methodName in DecoratedClass.prototype) { - originalMethod = DecoratedClass.prototype[methodName]; - } - - var decoratedMethod = DecoratorClass.prototype[methodName]; - - return function () { - var unshift = Array.prototype.unshift; - - unshift.call(arguments, originalMethod); - - return decoratedMethod.apply(this, arguments); - }; - }; - - for (var d = 0; d < decoratedMethods.length; d++) { - var decoratedMethod = decoratedMethods[d]; - - DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod); - } - - return DecoratedClass; - }; - - var Observable = function () { - this.listeners = {}; - }; - - Observable.prototype.on = function (event, callback) { - this.listeners = this.listeners || {}; - - if (event in this.listeners) { - this.listeners[event].push(callback); - } else { - this.listeners[event] = [callback]; - } - }; - - Observable.prototype.trigger = function (event) { - var slice = Array.prototype.slice; - var params = slice.call(arguments, 1); - - this.listeners = this.listeners || {}; + /*global setTimeout: false */ + + var requirejs, require, define; + (function (undef) { + var main, req, makeMap, handlers, + defined = {}, + waiting = {}, + config = {}, + defining = {}, + hasOwn = Object.prototype.hasOwnProperty, + aps = [].slice, + jsSuffixRegExp = /\.js$/; + + function hasProp(obj, prop) { + return hasOwn.call(obj, prop); + } + + /** + * Given a relative module name, like ./something, normalize it to + * a real name that can be mapped to a path. + * @param {String} name the relative name + * @param {String} baseName a real name that the name arg is relative + * to. + * @returns {String} normalized name + */ + function normalize(name, baseName) { + var nameParts, nameSegment, mapValue, foundMap, lastIndex, + foundI, foundStarMap, starI, i, j, part, normalizedBaseParts, + baseParts = baseName && baseName.split("/"), + map = config.map, + starMap = (map && map['*']) || {}; + + //Adjust any relative paths. + if (name) { + name = name.split('/'); + lastIndex = name.length - 1; + + // If wanting node ID compatibility, strip .js from end + // of IDs. Have to do this here, and not in nameToUrl + // because node allows either .js or non .js to map + // to same file. + if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { + name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); + } + + // Starts with a '.' so need the baseName + if (name[0].charAt(0) === '.' && baseParts) { + //Convert baseName to array, and lop off the last part, + //so that . matches that 'directory' and not name of the baseName's + //module. For instance, baseName of 'one/two/three', maps to + //'one/two/three.js', but we want the directory, 'one/two' for + //this normalization. + normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); + name = normalizedBaseParts.concat(name); + } + + //start trimDots + for (i = 0; i < name.length; i++) { + part = name[i]; + if (part === '.') { + name.splice(i, 1); + i -= 1; + } else if (part === '..') { + // If at the start, or previous value is still .., + // keep them so that when converted to a path it may + // still work when converted to a path, even though + // as an ID it is less than ideal. In larger point + // releases, may be better to just kick out an error. + if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') { + continue; + } else if (i > 0) { + name.splice(i - 1, 2); + i -= 2; + } + } + } + //end trimDots + + name = name.join('/'); + } + + //Apply map config if available. + if ((baseParts || starMap) && map) { + nameParts = name.split('/'); + + for (i = nameParts.length; i > 0; i -= 1) { + nameSegment = nameParts.slice(0, i).join("/"); + + if (baseParts) { + //Find the longest baseName segment match in the config. + //So, do joins on the biggest to smallest lengths of baseParts. + for (j = baseParts.length; j > 0; j -= 1) { + mapValue = map[baseParts.slice(0, j).join('/')]; + + //baseName segment has config, find if it has one for + //this name. + if (mapValue) { + mapValue = mapValue[nameSegment]; + if (mapValue) { + //Match, update name to the new value. + foundMap = mapValue; + foundI = i; + break; + } + } + } + } + + if (foundMap) { + break; + } + + //Check for a star map match, but just hold on to it, + //if there is a shorter segment match later in a matching + //config, then favor over this star map. + if (!foundStarMap && starMap && starMap[nameSegment]) { + foundStarMap = starMap[nameSegment]; + starI = i; + } + } + + if (!foundMap && foundStarMap) { + foundMap = foundStarMap; + foundI = starI; + } + + if (foundMap) { + nameParts.splice(0, foundI, foundMap); + name = nameParts.join('/'); + } + } + + return name; + } + + function makeRequire(relName, forceSync) { + return function () { + //A version of a require function that passes a moduleName + //value for items that may need to + //look up paths relative to the moduleName + var args = aps.call(arguments, 0); + + //If first arg is not require('string'), and there is only + //one arg, it is the array form without a callback. Insert + //a null so that the following concat is correct. + if (typeof args[0] !== 'string' && args.length === 1) { + args.push(null); + } + return req.apply(undef, args.concat([relName, forceSync])); + }; + } + + function makeNormalize(relName) { + return function (name) { + return normalize(name, relName); + }; + } + + function makeLoad(depName) { + return function (value) { + defined[depName] = value; + }; + } + + function callDep(name) { + if (hasProp(waiting, name)) { + var args = waiting[name]; + delete waiting[name]; + defining[name] = true; + main.apply(undef, args); + } + + if (!hasProp(defined, name) && !hasProp(defining, name)) { + throw new Error('No ' + name); + } + return defined[name]; + } + + //Turns a plugin!resource to [plugin, resource] + //with the plugin being undefined if the name + //did not have a plugin prefix. + function splitPrefix(name) { + var prefix, + index = name ? name.indexOf('!') : -1; + if (index > -1) { + prefix = name.substring(0, index); + name = name.substring(index + 1, name.length); + } + return [prefix, name]; + } + + //Creates a parts array for a relName where first part is plugin ID, + //second part is resource ID. Assumes relName has already been normalized. + function makeRelParts(relName) { + return relName ? splitPrefix(relName) : []; + } + + /** + * Makes a name map, normalizing the name, and using a plugin + * for normalization if necessary. Grabs a ref to plugin + * too, as an optimization. + */ + makeMap = function (name, relParts) { + var plugin, + parts = splitPrefix(name), + prefix = parts[0], + relResourceName = relParts[1]; + + name = parts[1]; + + if (prefix) { + prefix = normalize(prefix, relResourceName); + plugin = callDep(prefix); + } + + //Normalize according + if (prefix) { + if (plugin && plugin.normalize) { + name = plugin.normalize(name, makeNormalize(relResourceName)); + } else { + name = normalize(name, relResourceName); + } + } else { + name = normalize(name, relResourceName); + parts = splitPrefix(name); + prefix = parts[0]; + name = parts[1]; + if (prefix) { + plugin = callDep(prefix); + } + } + + //Using ridiculous property names for space reasons + return { + f: prefix ? prefix + '!' + name : name, //fullName + n: name, + pr: prefix, + p: plugin + }; + }; + + function makeConfig(name) { + return function () { + return (config && config.config && config.config[name]) || {}; + }; + } + + handlers = { + require: function (name) { + return makeRequire(name); + }, + exports: function (name) { + var e = defined[name]; + if (typeof e !== 'undefined') { + return e; + } else { + return (defined[name] = {}); + } + }, + module: function (name) { + return { + id: name, + uri: '', + exports: defined[name], + config: makeConfig(name) + }; + } + }; + + main = function (name, deps, callback, relName) { + var cjsModule, depName, ret, map, i, relParts, + args = [], + callbackType = typeof callback, + usingExports; + + //Use name if no relName + relName = relName || name; + relParts = makeRelParts(relName); + + //Call the callback to define the module, if necessary. + if (callbackType === 'undefined' || callbackType === 'function') { + //Pull out the defined dependencies and pass the ordered + //values to the callback. + //Default to [require, exports, module] if no deps + deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; + for (i = 0; i < deps.length; i += 1) { + map = makeMap(deps[i], relParts); + depName = map.f; + + //Fast path CommonJS standard dependencies. + if (depName === "require") { + args[i] = handlers.require(name); + } else if (depName === "exports") { + //CommonJS module spec 1.1 + args[i] = handlers.exports(name); + usingExports = true; + } else if (depName === "module") { + //CommonJS module spec 1.1 + cjsModule = args[i] = handlers.module(name); + } else if (hasProp(defined, depName) || + hasProp(waiting, depName) || + hasProp(defining, depName)) { + args[i] = callDep(depName); + } else if (map.p) { + map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); + args[i] = defined[depName]; + } else { + throw new Error(name + ' missing ' + depName); + } + } + + ret = callback ? callback.apply(defined[name], args) : undefined; + + if (name) { + //If setting exports via "module" is in play, + //favor that over return value and exports. After that, + //favor a non-undefined return value over exports use. + if (cjsModule && cjsModule.exports !== undef && + cjsModule.exports !== defined[name]) { + defined[name] = cjsModule.exports; + } else if (ret !== undef || !usingExports) { + //Use the return value from the function. + defined[name] = ret; + } + } + } else if (name) { + //May just be an object definition for the module. Only + //worry about defining if have a module name. + defined[name] = callback; + } + }; + + requirejs = require = req = function (deps, callback, relName, forceSync, alt) { + if (typeof deps === "string") { + if (handlers[deps]) { + //callback in this case is really relName + return handlers[deps](callback); + } + //Just return the module wanted. In this scenario, the + //deps arg is the module name, and second arg (if passed) + //is just the relName. + //Normalize module name, if it contains . or .. + return callDep(makeMap(deps, makeRelParts(callback)).f); + } else if (!deps.splice) { + //deps is a config object, not an array. + config = deps; + if (config.deps) { + req(config.deps, config.callback); + } + if (!callback) { + return; + } + + if (callback.splice) { + //callback is an array, which means it is a dependency list. + //Adjust args if there are dependencies + deps = callback; + callback = relName; + relName = null; + } else { + deps = undef; + } + } + + //Support require(['a']) + callback = callback || function () { + }; + + //If relName is a function, it is an errback handler, + //so remove it. + if (typeof relName === 'function') { + relName = forceSync; + forceSync = alt; + } + + //Simulate async callback; + if (forceSync) { + main(undef, deps, callback, relName); + } else { + //Using a non-zero value because of concern for what old browsers + //do, and latest browsers "upgrade" to 4 if lower value is used: + //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: + //If want a value immediately, use require('id') instead -- something + //that works in almond on the global level, but not guaranteed and + //unlikely to work in other AMD implementations. + setTimeout(function () { + main(undef, deps, callback, relName); + }, 4); + } + + return req; + }; + + /** + * Just drops the config on the floor, but returns req in case + * the config return value is used. + */ + req.config = function (cfg) { + return req(cfg); + }; + + /** + * Expose module registry for debugging and tooling + */ + requirejs._defined = defined; + + define = function (name, deps, callback) { + if (typeof name !== 'string') { + throw new Error('See almond README: incorrect module build, no module name'); + } + + //This module may not have dependencies + if (!deps.splice) { + //deps is not an array, so probably means + //an object literal or factory function for + //the value. Adjust args. + callback = deps; + deps = []; + } + + if (!hasProp(defined, name) && !hasProp(waiting, name)) { + waiting[name] = [name, deps, callback]; + } + }; + + define.amd = { + jQuery: true + }; + }()); + + S2.requirejs = requirejs; + S2.require = require; + S2.define = define; + } + }()); + S2.define("almond", function () { + }); + + /* global jQuery:false, $:false */ + S2.define('jquery', [], function () { + var _$ = jQuery || $; + + if (_$ == null && console && console.error) { + console.error( + 'Select2: An instance of jQuery or a jQuery-compatible library was not ' + + 'found. Make sure that you are including jQuery before Select2 on your ' + + 'web page.' + ); + } + + return _$; + }); + + S2.define('select2/utils', [ + 'jquery' + ], function ($) { + var Utils = {}; + + Utils.Extend = function (ChildClass, SuperClass) { + var __hasProp = {}.hasOwnProperty; + + function BaseConstructor() { + this.constructor = ChildClass; + } + + for (var key in SuperClass) { + if (__hasProp.call(SuperClass, key)) { + ChildClass[key] = SuperClass[key]; + } + } + + BaseConstructor.prototype = SuperClass.prototype; + ChildClass.prototype = new BaseConstructor(); + ChildClass.__super__ = SuperClass.prototype; + + return ChildClass; + }; + + function getMethods(theClass) { + var proto = theClass.prototype; + + var methods = []; - // Params should always come in as an array - if (params == null) { - params = []; - } + for (var methodName in proto) { + var m = proto[methodName]; - // If there are no arguments to the event, use a temporary object - if (params.length === 0) { - params.push({}); - } + if (typeof m !== 'function') { + continue; + } - // Set the `_type` of the first object to the event - params[0]._type = event; + if (methodName === 'constructor') { + continue; + } - if (event in this.listeners) { - this.invoke(this.listeners[event], slice.call(arguments, 1)); - } + methods.push(methodName); + } - if ('*' in this.listeners) { - this.invoke(this.listeners['*'], arguments); - } - }; + return methods; + } - Observable.prototype.invoke = function (listeners, params) { - for (var i = 0, len = listeners.length; i < len; i++) { - listeners[i].apply(this, params); - } - }; + Utils.Decorate = function (SuperClass, DecoratorClass) { + var decoratedMethods = getMethods(DecoratorClass); + var superMethods = getMethods(SuperClass); - Utils.Observable = Observable; + function DecoratedClass() { + var unshift = Array.prototype.unshift; - Utils.generateChars = function (length) { - var chars = ''; + var argCount = DecoratorClass.prototype.constructor.length; - for (var i = 0; i < length; i++) { - var randomChar = Math.floor(Math.random() * 36); - chars += randomChar.toString(36); - } + var calledConstructor = SuperClass.prototype.constructor; - return chars; - }; + if (argCount > 0) { + unshift.call(arguments, SuperClass.prototype.constructor); - Utils.bind = function (func, context) { - return function () { - func.apply(context, arguments); - }; - }; + calledConstructor = DecoratorClass.prototype.constructor; + } - Utils._convertData = function (data) { - for (var originalKey in data) { - var keys = originalKey.split('-'); - - var dataLevel = data; - - if (keys.length === 1) { - continue; - } - - for (var k = 0; k < keys.length; k++) { - var key = keys[k]; - - // Lowercase the first letter - // By default, dash-separated becomes camelCase - key = key.substring(0, 1).toLowerCase() + key.substring(1); - - if (!(key in dataLevel)) { - dataLevel[key] = {}; - } - - if (k == keys.length - 1) { - dataLevel[key] = data[originalKey]; - } - - dataLevel = dataLevel[key]; - } - - delete data[originalKey]; - } - - return data; - }; - - Utils.hasScroll = function (index, el) { - // Adapted from the function created by @ShadowScripter - // and adapted by @BillBarry on the Stack Exchange Code Review website. - // The original code can be found at - // http://codereview.stackexchange.com/q/13338 - // and was designed to be used with the Sizzle selector engine. - - var $el = $(el); - var overflowX = el.style.overflowX; - var overflowY = el.style.overflowY; - - //Check both x and y declarations - if (overflowX === overflowY && - (overflowY === 'hidden' || overflowY === 'visible')) { - return false; - } - - if (overflowX === 'scroll' || overflowY === 'scroll') { - return true; - } - - return ($el.innerHeight() < el.scrollHeight || - $el.innerWidth() < el.scrollWidth); - }; - - Utils.escapeMarkup = function (markup) { - var replaceMap = { - '\\': '\', - '&': '&', - '<': '<', - '>': '>', - '"': '"', - '\'': ''', - '/': '/' - }; - - // Do not try to escape the markup if it's not a string - if (typeof markup !== 'string') { - return markup; - } - - return String(markup).replace(/[&<>"'\/\\]/g, function (match) { - return replaceMap[match]; - }); - }; - - // Append an array of jQuery nodes to a given element. - Utils.appendMany = function ($element, $nodes) { - // jQuery 1.7.x does not support $.fn.append() with an array - // Fall back to a jQuery object collection using $.fn.add() - if ($.fn.jquery.substr(0, 3) === '1.7') { - var $jqNodes = $(); - - $.map($nodes, function (node) { - $jqNodes = $jqNodes.add(node); - }); - - $nodes = $jqNodes; - } - - $element.append($nodes); - }; - - // Cache objects in Utils.__cache instead of $.data (see #4346) - Utils.__cache = {}; - - var id = 0; - Utils.GetUniqueElementId = function (element) { - // Get a unique element Id. If element has no id, - // creates a new unique number, stores it in the id - // attribute and returns the new id. - // If an id already exists, it simply returns it. - - var select2Id = element.getAttribute('data-select2-id'); - if (select2Id == null) { - // If element has id, use it. - if (element.id) { - select2Id = element.id; - element.setAttribute('data-select2-id', select2Id); - } else { - element.setAttribute('data-select2-id', ++id); - select2Id = id.toString(); - } - } - return select2Id; - }; - - Utils.StoreData = function (element, name, value) { - // Stores an item in the cache for a specified element. - // name is the cache key. - var id = Utils.GetUniqueElementId(element); - if (!Utils.__cache[id]) { - Utils.__cache[id] = {}; - } - - Utils.__cache[id][name] = value; - }; - - Utils.GetData = function (element, name) { - // Retrieves a value from the cache by its key (name) - // name is optional. If no name specified, return - // all cache items for the specified element. - // and for a specified element. - var id = Utils.GetUniqueElementId(element); - if (name) { - if (Utils.__cache[id]) { - if (Utils.__cache[id][name] != null) { - return Utils.__cache[id][name]; - } - return $(element).data(name); // Fallback to HTML5 data attribs. - } - return $(element).data(name); // Fallback to HTML5 data attribs. - } else { - return Utils.__cache[id]; - } - }; - - Utils.RemoveData = function (element) { - // Removes all cached items for a specified element. - var id = Utils.GetUniqueElementId(element); - if (Utils.__cache[id] != null) { - delete Utils.__cache[id]; - } - - element.removeAttribute('data-select2-id'); - }; - - return Utils; -}); - -S2.define('select2/results',[ - 'jquery', - './utils' -], function ($, Utils) { - function Results ($element, options, dataAdapter) { - this.$element = $element; - this.data = dataAdapter; - this.options = options; - - Results.__super__.constructor.call(this); - } - - Utils.Extend(Results, Utils.Observable); - - Results.prototype.render = function () { - var $results = $( - '
    ' - ); - - if (this.options.get('multiple')) { - $results.attr('aria-multiselectable', 'true'); - } - - this.$results = $results; - - return $results; - }; - - Results.prototype.clear = function () { - this.$results.empty(); - }; - - Results.prototype.displayMessage = function (params) { - var escapeMarkup = this.options.get('escapeMarkup'); - - this.clear(); - this.hideLoading(); - - var $message = $( - '' - ); - - var message = this.options.get('translations').get(params.message); - - $message.append( - escapeMarkup( - message(params.args) - ) - ); - - $message[0].className += ' select2-results__message'; - - this.$results.append($message); - }; - - Results.prototype.hideMessages = function () { - this.$results.find('.select2-results__message').remove(); - }; - - Results.prototype.append = function (data) { - this.hideLoading(); - - var $options = []; + calledConstructor.apply(this, arguments); + } - if (data.results == null || data.results.length === 0) { - if (this.$results.children().length === 0) { - this.trigger('results:message', { - message: 'noResults' - }); - } + DecoratorClass.displayName = SuperClass.displayName; - return; - } + function ctr() { + this.constructor = DecoratedClass; + } - data.results = this.sort(data.results); + DecoratedClass.prototype = new ctr(); - for (var d = 0; d < data.results.length; d++) { - var item = data.results[d]; + for (var m = 0; m < superMethods.length; m++) { + var superMethod = superMethods[m]; - var $option = this.option(item); + DecoratedClass.prototype[superMethod] = + SuperClass.prototype[superMethod]; + } - $options.push($option); - } + var calledMethod = function (methodName) { + // Stub out the original method if it's not decorating an actual method + var originalMethod = function () { + }; - this.$results.append($options); - }; + if (methodName in DecoratedClass.prototype) { + originalMethod = DecoratedClass.prototype[methodName]; + } - Results.prototype.position = function ($results, $dropdown) { - var $resultsContainer = $dropdown.find('.select2-results'); - $resultsContainer.append($results); - }; + var decoratedMethod = DecoratorClass.prototype[methodName]; - Results.prototype.sort = function (data) { - var sorter = this.options.get('sorter'); + return function () { + var unshift = Array.prototype.unshift; - return sorter(data); - }; + unshift.call(arguments, originalMethod); - Results.prototype.highlightFirstItem = function () { - var $options = this.$results - .find('.select2-results__option[aria-selected]'); + return decoratedMethod.apply(this, arguments); + }; + }; - var $selected = $options.filter('[aria-selected=true]'); + for (var d = 0; d < decoratedMethods.length; d++) { + var decoratedMethod = decoratedMethods[d]; - // Check if there are any selected options - if ($selected.length > 0) { - // If there are selected options, highlight the first - $selected.first().trigger('mouseenter'); - } else { - // If there are no selected options, highlight the first option - // in the dropdown - $options.first().trigger('mouseenter'); - } + DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod); + } - this.ensureHighlightVisible(); - }; + return DecoratedClass; + }; - Results.prototype.setClasses = function () { - var self = this; + var Observable = function () { + this.listeners = {}; + }; - this.data.current(function (selected) { - var selectedIds = $.map(selected, function (s) { - return s.id.toString(); - }); + Observable.prototype.on = function (event, callback) { + this.listeners = this.listeners || {}; - var $options = self.$results - .find('.select2-results__option[aria-selected]'); + if (event in this.listeners) { + this.listeners[event].push(callback); + } else { + this.listeners[event] = [callback]; + } + }; - $options.each(function () { - var $option = $(this); + Observable.prototype.trigger = function (event) { + var slice = Array.prototype.slice; + var params = slice.call(arguments, 1); - var item = Utils.GetData(this, 'data'); + this.listeners = this.listeners || {}; - // id needs to be converted to a string when comparing - var id = '' + item.id; + // Params should always come in as an array + if (params == null) { + params = []; + } - if ((item.element != null && item.element.selected) || - (item.element == null && $.inArray(id, selectedIds) > -1)) { - $option.attr('aria-selected', 'true'); - } else { - $option.attr('aria-selected', 'false'); - } - }); + // If there are no arguments to the event, use a temporary object + if (params.length === 0) { + params.push({}); + } - }); - }; + // Set the `_type` of the first object to the event + params[0]._type = event; - Results.prototype.showLoading = function (params) { - this.hideLoading(); + if (event in this.listeners) { + this.invoke(this.listeners[event], slice.call(arguments, 1)); + } - var loadingMore = this.options.get('translations').get('searching'); + if ('*' in this.listeners) { + this.invoke(this.listeners['*'], arguments); + } + }; - var loading = { - disabled: true, - loading: true, - text: loadingMore(params) - }; - var $loading = this.option(loading); - $loading.className += ' loading-results'; + Observable.prototype.invoke = function (listeners, params) { + for (var i = 0, len = listeners.length; i < len; i++) { + listeners[i].apply(this, params); + } + }; - this.$results.prepend($loading); - }; + Utils.Observable = Observable; - Results.prototype.hideLoading = function () { - this.$results.find('.loading-results').remove(); - }; + Utils.generateChars = function (length) { + var chars = ''; - Results.prototype.option = function (data) { - var option = document.createElement('li'); - option.className = 'select2-results__option'; + for (var i = 0; i < length; i++) { + var randomChar = Math.floor(Math.random() * 36); + chars += randomChar.toString(36); + } - var attrs = { - 'role': 'option', - 'aria-selected': 'false' - }; + return chars; + }; - var matches = window.Element.prototype.matches || - window.Element.prototype.msMatchesSelector || - window.Element.prototype.webkitMatchesSelector; + Utils.bind = function (func, context) { + return function () { + func.apply(context, arguments); + }; + }; - if ((data.element != null && matches.call(data.element, ':disabled')) || - (data.element == null && data.disabled)) { - delete attrs['aria-selected']; - attrs['aria-disabled'] = 'true'; - } + Utils._convertData = function (data) { + for (var originalKey in data) { + var keys = originalKey.split('-'); + + var dataLevel = data; + + if (keys.length === 1) { + continue; + } + + for (var k = 0; k < keys.length; k++) { + var key = keys[k]; + + // Lowercase the first letter + // By default, dash-separated becomes camelCase + key = key.substring(0, 1).toLowerCase() + key.substring(1); + + if (!(key in dataLevel)) { + dataLevel[key] = {}; + } + + if (k == keys.length - 1) { + dataLevel[key] = data[originalKey]; + } + + dataLevel = dataLevel[key]; + } + + delete data[originalKey]; + } + + return data; + }; + + Utils.hasScroll = function (index, el) { + // Adapted from the function created by @ShadowScripter + // and adapted by @BillBarry on the Stack Exchange Code Review website. + // The original code can be found at + // http://codereview.stackexchange.com/q/13338 + // and was designed to be used with the Sizzle selector engine. + + var $el = $(el); + var overflowX = el.style.overflowX; + var overflowY = el.style.overflowY; + + //Check both x and y declarations + if (overflowX === overflowY && + (overflowY === 'hidden' || overflowY === 'visible')) { + return false; + } + + if (overflowX === 'scroll' || overflowY === 'scroll') { + return true; + } + + return ($el.innerHeight() < el.scrollHeight || + $el.innerWidth() < el.scrollWidth); + }; + + Utils.escapeMarkup = function (markup) { + var replaceMap = { + '\\': '\', + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''', + '/': '/' + }; + + // Do not try to escape the markup if it's not a string + if (typeof markup !== 'string') { + return markup; + } + + return String(markup).replace(/[&<>"'\/\\]/g, function (match) { + return replaceMap[match]; + }); + }; + + // Append an array of jQuery nodes to a given element. + Utils.appendMany = function ($element, $nodes) { + // jQuery 1.7.x does not support $.fn.append() with an array + // Fall back to a jQuery object collection using $.fn.add() + if ($.fn.jquery.substr(0, 3) === '1.7') { + var $jqNodes = $(); + + $.map($nodes, function (node) { + $jqNodes = $jqNodes.add(node); + }); + + $nodes = $jqNodes; + } + + $element.append($nodes); + }; + + // Cache objects in Utils.__cache instead of $.data (see #4346) + Utils.__cache = {}; + + var id = 0; + Utils.GetUniqueElementId = function (element) { + // Get a unique element Id. If element has no id, + // creates a new unique number, stores it in the id + // attribute and returns the new id. + // If an id already exists, it simply returns it. + + var select2Id = element.getAttribute('data-select2-id'); + if (select2Id == null) { + // If element has id, use it. + if (element.id) { + select2Id = element.id; + element.setAttribute('data-select2-id', select2Id); + } else { + element.setAttribute('data-select2-id', ++id); + select2Id = id.toString(); + } + } + return select2Id; + }; + + Utils.StoreData = function (element, name, value) { + // Stores an item in the cache for a specified element. + // name is the cache key. + var id = Utils.GetUniqueElementId(element); + if (!Utils.__cache[id]) { + Utils.__cache[id] = {}; + } + + Utils.__cache[id][name] = value; + }; + + Utils.GetData = function (element, name) { + // Retrieves a value from the cache by its key (name) + // name is optional. If no name specified, return + // all cache items for the specified element. + // and for a specified element. + var id = Utils.GetUniqueElementId(element); + if (name) { + if (Utils.__cache[id]) { + if (Utils.__cache[id][name] != null) { + return Utils.__cache[id][name]; + } + return $(element).data(name); // Fallback to HTML5 data attribs. + } + return $(element).data(name); // Fallback to HTML5 data attribs. + } else { + return Utils.__cache[id]; + } + }; + + Utils.RemoveData = function (element) { + // Removes all cached items for a specified element. + var id = Utils.GetUniqueElementId(element); + if (Utils.__cache[id] != null) { + delete Utils.__cache[id]; + } + + element.removeAttribute('data-select2-id'); + }; + + return Utils; + }); + + S2.define('select2/results', [ + 'jquery', + './utils' + ], function ($, Utils) { + function Results($element, options, dataAdapter) { + this.$element = $element; + this.data = dataAdapter; + this.options = options; + + Results.__super__.constructor.call(this); + } + + Utils.Extend(Results, Utils.Observable); + + Results.prototype.render = function () { + var $results = $( + '
      ' + ); + + if (this.options.get('multiple')) { + $results.attr('aria-multiselectable', 'true'); + } + + this.$results = $results; + + return $results; + }; + + Results.prototype.clear = function () { + this.$results.empty(); + }; + + Results.prototype.displayMessage = function (params) { + var escapeMarkup = this.options.get('escapeMarkup'); + + this.clear(); + this.hideLoading(); + + var $message = $( + '' + ); + + var message = this.options.get('translations').get(params.message); + + $message.append( + escapeMarkup( + message(params.args) + ) + ); + + $message[0].className += ' select2-results__message'; + + this.$results.append($message); + }; + + Results.prototype.hideMessages = function () { + this.$results.find('.select2-results__message').remove(); + }; + + Results.prototype.append = function (data) { + this.hideLoading(); + + var $options = []; - if (data.id == null) { - delete attrs['aria-selected']; - } + if (data.results == null || data.results.length === 0) { + if (this.$results.children().length === 0) { + this.trigger('results:message', { + message: 'noResults' + }); + } - if (data._resultId != null) { - option.id = data._resultId; - } + return; + } - if (data.title) { - option.title = data.title; - } + data.results = this.sort(data.results); - if (data.children) { - attrs.role = 'group'; - attrs['aria-label'] = data.text; - delete attrs['aria-selected']; - } + for (var d = 0; d < data.results.length; d++) { + var item = data.results[d]; - for (var attr in attrs) { - var val = attrs[attr]; + var $option = this.option(item); - option.setAttribute(attr, val); - } + $options.push($option); + } - if (data.children) { - var $option = $(option); + this.$results.append($options); + }; - var label = document.createElement('strong'); - label.className = 'select2-results__group'; + Results.prototype.position = function ($results, $dropdown) { + var $resultsContainer = $dropdown.find('.select2-results'); + $resultsContainer.append($results); + }; - var $label = $(label); - this.template(data, label); + Results.prototype.sort = function (data) { + var sorter = this.options.get('sorter'); - var $children = []; + return sorter(data); + }; - for (var c = 0; c < data.children.length; c++) { - var child = data.children[c]; + Results.prototype.highlightFirstItem = function () { + var $options = this.$results + .find('.select2-results__option[aria-selected]'); - var $child = this.option(child); + var $selected = $options.filter('[aria-selected=true]'); - $children.push($child); - } + // Check if there are any selected options + if ($selected.length > 0) { + // If there are selected options, highlight the first + $selected.first().trigger('mouseenter'); + } else { + // If there are no selected options, highlight the first option + // in the dropdown + $options.first().trigger('mouseenter'); + } - var $childrenContainer = $('
        ', { - 'class': 'select2-results__options select2-results__options--nested' - }); + this.ensureHighlightVisible(); + }; - $childrenContainer.append($children); + Results.prototype.setClasses = function () { + var self = this; - $option.append(label); - $option.append($childrenContainer); - } else { - this.template(data, option); - } + this.data.current(function (selected) { + var selectedIds = $.map(selected, function (s) { + return s.id.toString(); + }); - Utils.StoreData(option, 'data', data); + var $options = self.$results + .find('.select2-results__option[aria-selected]'); - return option; - }; + $options.each(function () { + var $option = $(this); - Results.prototype.bind = function (container, $container) { - var self = this; + var item = Utils.GetData(this, 'data'); - var id = container.id + '-results'; + // id needs to be converted to a string when comparing + var id = '' + item.id; - this.$results.attr('id', id); + if ((item.element != null && item.element.selected) || + (item.element == null && $.inArray(id, selectedIds) > -1)) { + $option.attr('aria-selected', 'true'); + } else { + $option.attr('aria-selected', 'false'); + } + }); - container.on('results:all', function (params) { - self.clear(); - self.append(params.data); + }); + }; - if (container.isOpen()) { - self.setClasses(); - self.highlightFirstItem(); - } - }); + Results.prototype.showLoading = function (params) { + this.hideLoading(); - container.on('results:append', function (params) { - self.append(params.data); + var loadingMore = this.options.get('translations').get('searching'); - if (container.isOpen()) { - self.setClasses(); - } - }); + var loading = { + disabled: true, + loading: true, + text: loadingMore(params) + }; + var $loading = this.option(loading); + $loading.className += ' loading-results'; - container.on('query', function (params) { - self.hideMessages(); - self.showLoading(params); - }); + this.$results.prepend($loading); + }; - container.on('select', function () { - if (!container.isOpen()) { - return; - } + Results.prototype.hideLoading = function () { + this.$results.find('.loading-results').remove(); + }; - self.setClasses(); + Results.prototype.option = function (data) { + var option = document.createElement('li'); + option.className = 'select2-results__option'; - if (self.options.get('scrollAfterSelect')) { - self.highlightFirstItem(); - } - }); + var attrs = { + 'role': 'option', + 'aria-selected': 'false' + }; - container.on('unselect', function () { - if (!container.isOpen()) { - return; - } + var matches = window.Element.prototype.matches || + window.Element.prototype.msMatchesSelector || + window.Element.prototype.webkitMatchesSelector; - self.setClasses(); + if ((data.element != null && matches.call(data.element, ':disabled')) || + (data.element == null && data.disabled)) { + delete attrs['aria-selected']; + attrs['aria-disabled'] = 'true'; + } - if (self.options.get('scrollAfterSelect')) { - self.highlightFirstItem(); - } - }); + if (data.id == null) { + delete attrs['aria-selected']; + } - container.on('open', function () { - // When the dropdown is open, aria-expended="true" - self.$results.attr('aria-expanded', 'true'); - self.$results.attr('aria-hidden', 'false'); + if (data._resultId != null) { + option.id = data._resultId; + } - self.setClasses(); - self.ensureHighlightVisible(); - }); + if (data.title) { + option.title = data.title; + } - container.on('close', function () { - // When the dropdown is closed, aria-expended="false" - self.$results.attr('aria-expanded', 'false'); - self.$results.attr('aria-hidden', 'true'); - self.$results.removeAttr('aria-activedescendant'); - }); + if (data.children) { + attrs.role = 'group'; + attrs['aria-label'] = data.text; + delete attrs['aria-selected']; + } - container.on('results:toggle', function () { - var $highlighted = self.getHighlightedResults(); + for (var attr in attrs) { + var val = attrs[attr]; - if ($highlighted.length === 0) { - return; - } + option.setAttribute(attr, val); + } - $highlighted.trigger('mouseup'); - }); + if (data.children) { + var $option = $(option); - container.on('results:select', function () { - var $highlighted = self.getHighlightedResults(); + var label = document.createElement('strong'); + label.className = 'select2-results__group'; - if ($highlighted.length === 0) { - return; - } + var $label = $(label); + this.template(data, label); - var data = Utils.GetData($highlighted[0], 'data'); + var $children = []; - if ($highlighted.attr('aria-selected') == 'true') { - self.trigger('close', {}); - } else { - self.trigger('select', { - data: data - }); - } - }); + for (var c = 0; c < data.children.length; c++) { + var child = data.children[c]; - container.on('results:previous', function () { - var $highlighted = self.getHighlightedResults(); + var $child = this.option(child); - var $options = self.$results.find('[aria-selected]'); + $children.push($child); + } - var currentIndex = $options.index($highlighted); + var $childrenContainer = $('
          ', { + 'class': 'select2-results__options select2-results__options--nested' + }); - // If we are already at the top, don't move further - // If no options, currentIndex will be -1 - if (currentIndex <= 0) { - return; - } + $childrenContainer.append($children); - var nextIndex = currentIndex - 1; + $option.append(label); + $option.append($childrenContainer); + } else { + this.template(data, option); + } - // If none are highlighted, highlight the first - if ($highlighted.length === 0) { - nextIndex = 0; - } + Utils.StoreData(option, 'data', data); - var $next = $options.eq(nextIndex); + return option; + }; - $next.trigger('mouseenter'); + Results.prototype.bind = function (container, $container) { + var self = this; - var currentOffset = self.$results.offset().top; - var nextTop = $next.offset().top; - var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset); + var id = container.id + '-results'; - if (nextIndex === 0) { - self.$results.scrollTop(0); - } else if (nextTop - currentOffset < 0) { - self.$results.scrollTop(nextOffset); - } - }); + this.$results.attr('id', id); - container.on('results:next', function () { - var $highlighted = self.getHighlightedResults(); + container.on('results:all', function (params) { + self.clear(); + self.append(params.data); - var $options = self.$results.find('[aria-selected]'); - - var currentIndex = $options.index($highlighted); + if (container.isOpen()) { + self.setClasses(); + self.highlightFirstItem(); + } + }); - var nextIndex = currentIndex + 1; + container.on('results:append', function (params) { + self.append(params.data); - // If we are at the last option, stay there - if (nextIndex >= $options.length) { - return; - } + if (container.isOpen()) { + self.setClasses(); + } + }); - var $next = $options.eq(nextIndex); + container.on('query', function (params) { + self.hideMessages(); + self.showLoading(params); + }); - $next.trigger('mouseenter'); + container.on('select', function () { + if (!container.isOpen()) { + return; + } - var currentOffset = self.$results.offset().top + - self.$results.outerHeight(false); - var nextBottom = $next.offset().top + $next.outerHeight(false); - var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset; + self.setClasses(); - if (nextIndex === 0) { - self.$results.scrollTop(0); - } else if (nextBottom > currentOffset) { - self.$results.scrollTop(nextOffset); - } - }); + if (self.options.get('scrollAfterSelect')) { + self.highlightFirstItem(); + } + }); - container.on('results:focus', function (params) { - params.element.addClass('select2-results__option--highlighted'); - }); + container.on('unselect', function () { + if (!container.isOpen()) { + return; + } - container.on('results:message', function (params) { - self.displayMessage(params); - }); + self.setClasses(); - if ($.fn.mousewheel) { - this.$results.on('mousewheel', function (e) { - var top = self.$results.scrollTop(); + if (self.options.get('scrollAfterSelect')) { + self.highlightFirstItem(); + } + }); - var bottom = self.$results.get(0).scrollHeight - top + e.deltaY; + container.on('open', function () { + // When the dropdown is open, aria-expended="true" + self.$results.attr('aria-expanded', 'true'); + self.$results.attr('aria-hidden', 'false'); - var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0; - var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height(); + self.setClasses(); + self.ensureHighlightVisible(); + }); - if (isAtTop) { - self.$results.scrollTop(0); + container.on('close', function () { + // When the dropdown is closed, aria-expended="false" + self.$results.attr('aria-expanded', 'false'); + self.$results.attr('aria-hidden', 'true'); + self.$results.removeAttr('aria-activedescendant'); + }); - e.preventDefault(); - e.stopPropagation(); - } else if (isAtBottom) { - self.$results.scrollTop( - self.$results.get(0).scrollHeight - self.$results.height() - ); + container.on('results:toggle', function () { + var $highlighted = self.getHighlightedResults(); - e.preventDefault(); - e.stopPropagation(); - } - }); - } + if ($highlighted.length === 0) { + return; + } - this.$results.on('mouseup', '.select2-results__option[aria-selected]', - function (evt) { - var $this = $(this); + $highlighted.trigger('mouseup'); + }); - var data = Utils.GetData(this, 'data'); - - if ($this.attr('aria-selected') === 'true') { - if (self.options.get('multiple')) { - self.trigger('unselect', { - originalEvent: evt, - data: data - }); - } else { - self.trigger('close', {}); - } - - return; - } - - self.trigger('select', { - originalEvent: evt, - data: data - }); - }); - - this.$results.on('mouseenter', '.select2-results__option[aria-selected]', - function (evt) { - var data = Utils.GetData(this, 'data'); - - self.getHighlightedResults() - .removeClass('select2-results__option--highlighted'); - - self.trigger('results:focus', { - data: data, - element: $(this) - }); - }); - }; - - Results.prototype.getHighlightedResults = function () { - var $highlighted = this.$results - .find('.select2-results__option--highlighted'); - - return $highlighted; - }; - - Results.prototype.destroy = function () { - this.$results.remove(); - }; - - Results.prototype.ensureHighlightVisible = function () { - var $highlighted = this.getHighlightedResults(); - - if ($highlighted.length === 0) { - return; - } - - var $options = this.$results.find('[aria-selected]'); - - var currentIndex = $options.index($highlighted); - - var currentOffset = this.$results.offset().top; - var nextTop = $highlighted.offset().top; - var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset); - - var offsetDelta = nextTop - currentOffset; - nextOffset -= $highlighted.outerHeight(false) * 2; - - if (currentIndex <= 2) { - this.$results.scrollTop(0); - } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) { - this.$results.scrollTop(nextOffset); - } - }; - - Results.prototype.template = function (result, container) { - var template = this.options.get('templateResult'); - var escapeMarkup = this.options.get('escapeMarkup'); - - var content = template(result, container); - - if (content == null) { - container.style.display = 'none'; - } else if (typeof content === 'string') { - container.innerHTML = escapeMarkup(content); - } else { - $(container).append(content); - } - }; - - return Results; -}); - -S2.define('select2/keys',[ - -], function () { - var KEYS = { - BACKSPACE: 8, - TAB: 9, - ENTER: 13, - SHIFT: 16, - CTRL: 17, - ALT: 18, - ESC: 27, - SPACE: 32, - PAGE_UP: 33, - PAGE_DOWN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - DELETE: 46 - }; - - return KEYS; -}); - -S2.define('select2/selection/base',[ - 'jquery', - '../utils', - '../keys' -], function ($, Utils, KEYS) { - function BaseSelection ($element, options) { - this.$element = $element; - this.options = options; - - BaseSelection.__super__.constructor.call(this); - } - - Utils.Extend(BaseSelection, Utils.Observable); - - BaseSelection.prototype.render = function () { - var $selection = $( - '' - ); - - this._tabindex = 0; - - if (Utils.GetData(this.$element[0], 'old-tabindex') != null) { - this._tabindex = Utils.GetData(this.$element[0], 'old-tabindex'); - } else if (this.$element.attr('tabindex') != null) { - this._tabindex = this.$element.attr('tabindex'); - } - - $selection.attr('title', this.$element.attr('title')); - $selection.attr('tabindex', this._tabindex); - $selection.attr('aria-disabled', 'false'); - - this.$selection = $selection; - - return $selection; - }; - - BaseSelection.prototype.bind = function (container, $container) { - var self = this; - - var resultsId = container.id + '-results'; - - this.container = container; - - this.$selection.on('focus', function (evt) { - self.trigger('focus', evt); - }); - - this.$selection.on('blur', function (evt) { - self._handleBlur(evt); - }); - - this.$selection.on('keydown', function (evt) { - self.trigger('keypress', evt); - - if (evt.which === KEYS.SPACE) { - evt.preventDefault(); - } - }); - - container.on('results:focus', function (params) { - self.$selection.attr('aria-activedescendant', params.data._resultId); - }); - - container.on('selection:update', function (params) { - self.update(params.data); - }); - - container.on('open', function () { - // When the dropdown is open, aria-expanded="true" - self.$selection.attr('aria-expanded', 'true'); - self.$selection.attr('aria-owns', resultsId); - - self._attachCloseHandler(container); - }); - - container.on('close', function () { - // When the dropdown is closed, aria-expanded="false" - self.$selection.attr('aria-expanded', 'false'); - self.$selection.removeAttr('aria-activedescendant'); - self.$selection.removeAttr('aria-owns'); - - self.$selection.trigger('focus'); - - self._detachCloseHandler(container); - }); - - container.on('enable', function () { - self.$selection.attr('tabindex', self._tabindex); - self.$selection.attr('aria-disabled', 'false'); - }); - - container.on('disable', function () { - self.$selection.attr('tabindex', '-1'); - self.$selection.attr('aria-disabled', 'true'); - }); - }; - - BaseSelection.prototype._handleBlur = function (evt) { - var self = this; - - // This needs to be delayed as the active element is the body when the tab - // key is pressed, possibly along with others. - window.setTimeout(function () { - // Don't trigger `blur` if the focus is still in the selection - if ( - (document.activeElement == self.$selection[0]) || - ($.contains(self.$selection[0], document.activeElement)) - ) { - return; - } - - self.trigger('blur', evt); - }, 1); - }; - - BaseSelection.prototype._attachCloseHandler = function (container) { - - $(document.body).on('mousedown.select2.' + container.id, function (e) { - var $target = $(e.target); - - var $select = $target.closest('.select2'); - - var $all = $('.select2.select2-container--open'); - - $all.each(function () { - if (this == $select[0]) { - return; - } - - var $element = Utils.GetData(this, 'element'); - - $element.select2('close'); - }); - }); - }; - - BaseSelection.prototype._detachCloseHandler = function (container) { - $(document.body).off('mousedown.select2.' + container.id); - }; - - BaseSelection.prototype.position = function ($selection, $container) { - var $selectionContainer = $container.find('.selection'); - $selectionContainer.append($selection); - }; - - BaseSelection.prototype.destroy = function () { - this._detachCloseHandler(this.container); - }; - - BaseSelection.prototype.update = function (data) { - throw new Error('The `update` method must be defined in child classes.'); - }; - - /** - * Helper method to abstract the "enabled" (not "disabled") state of this - * object. - * - * @return {true} if the instance is not disabled. - * @return {false} if the instance is disabled. - */ - BaseSelection.prototype.isEnabled = function () { - return !this.isDisabled(); - }; - - /** - * Helper method to abstract the "disabled" state of this object. - * - * @return {true} if the disabled option is true. - * @return {false} if the disabled option is false. - */ - BaseSelection.prototype.isDisabled = function () { - return this.options.get('disabled'); - }; - - return BaseSelection; -}); - -S2.define('select2/selection/single',[ - 'jquery', - './base', - '../utils', - '../keys' -], function ($, BaseSelection, Utils, KEYS) { - function SingleSelection () { - SingleSelection.__super__.constructor.apply(this, arguments); - } - - Utils.Extend(SingleSelection, BaseSelection); - - SingleSelection.prototype.render = function () { - var $selection = SingleSelection.__super__.render.call(this); - - $selection.addClass('select2-selection--single'); - - $selection.html( - '' + - '' + - '' + - '' - ); - - return $selection; - }; - - SingleSelection.prototype.bind = function (container, $container) { - var self = this; - - SingleSelection.__super__.bind.apply(this, arguments); - - var id = container.id + '-container'; - - this.$selection.find('.select2-selection__rendered') - .attr('id', id) - .attr('role', 'textbox') - .attr('aria-readonly', 'true'); - this.$selection.attr('aria-labelledby', id); - - this.$selection.on('mousedown', function (evt) { - // Only respond to left clicks - if (evt.which !== 1) { - return; - } - - self.trigger('toggle', { - originalEvent: evt - }); - }); - - this.$selection.on('focus', function (evt) { - // User focuses on the container - }); - - this.$selection.on('blur', function (evt) { - // User exits the container - }); - - container.on('focus', function (evt) { - if (!container.isOpen()) { - self.$selection.trigger('focus'); - } - }); - }; - - SingleSelection.prototype.clear = function () { - var $rendered = this.$selection.find('.select2-selection__rendered'); - $rendered.empty(); - $rendered.removeAttr('title'); // clear tooltip on empty - }; - - SingleSelection.prototype.display = function (data, container) { - var template = this.options.get('templateSelection'); - var escapeMarkup = this.options.get('escapeMarkup'); - - return escapeMarkup(template(data, container)); - }; - - SingleSelection.prototype.selectionContainer = function () { - return $(''); - }; - - SingleSelection.prototype.update = function (data) { - if (data.length === 0) { - this.clear(); - return; - } - - var selection = data[0]; - - var $rendered = this.$selection.find('.select2-selection__rendered'); - var formatted = this.display(selection, $rendered); - - $rendered.empty().append(formatted); - - var title = selection.title || selection.text; - - if (title) { - $rendered.attr('title', title); - } else { - $rendered.removeAttr('title'); - } - }; - - return SingleSelection; -}); + container.on('results:select', function () { + var $highlighted = self.getHighlightedResults(); -S2.define('select2/selection/multiple',[ - 'jquery', - './base', - '../utils' -], function ($, BaseSelection, Utils) { - function MultipleSelection ($element, options) { - MultipleSelection.__super__.constructor.apply(this, arguments); - } + if ($highlighted.length === 0) { + return; + } - Utils.Extend(MultipleSelection, BaseSelection); + var data = Utils.GetData($highlighted[0], 'data'); - MultipleSelection.prototype.render = function () { - var $selection = MultipleSelection.__super__.render.call(this); + if ($highlighted.attr('aria-selected') == 'true') { + self.trigger('close', {}); + } else { + self.trigger('select', { + data: data + }); + } + }); - $selection.addClass('select2-selection--multiple'); + container.on('results:previous', function () { + var $highlighted = self.getHighlightedResults(); - $selection.html( - '
            ' - ); + var $options = self.$results.find('[aria-selected]'); - return $selection; - }; + var currentIndex = $options.index($highlighted); - MultipleSelection.prototype.bind = function (container, $container) { - var self = this; + // If we are already at the top, don't move further + // If no options, currentIndex will be -1 + if (currentIndex <= 0) { + return; + } - MultipleSelection.__super__.bind.apply(this, arguments); + var nextIndex = currentIndex - 1; - this.$selection.on('click', function (evt) { - self.trigger('toggle', { - originalEvent: evt - }); - }); + // If none are highlighted, highlight the first + if ($highlighted.length === 0) { + nextIndex = 0; + } - this.$selection.on( - 'click', - '.select2-selection__choice__remove', - function (evt) { - // Ignore the event if it is disabled - if (self.isDisabled()) { - return; - } + var $next = $options.eq(nextIndex); - var $remove = $(this); - var $selection = $remove.parent(); + $next.trigger('mouseenter'); - var data = Utils.GetData($selection[0], 'data'); + var currentOffset = self.$results.offset().top; + var nextTop = $next.offset().top; + var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset); - self.trigger('unselect', { - originalEvent: evt, - data: data - }); - } - ); - }; + if (nextIndex === 0) { + self.$results.scrollTop(0); + } else if (nextTop - currentOffset < 0) { + self.$results.scrollTop(nextOffset); + } + }); - MultipleSelection.prototype.clear = function () { - var $rendered = this.$selection.find('.select2-selection__rendered'); - $rendered.empty(); - $rendered.removeAttr('title'); - }; + container.on('results:next', function () { + var $highlighted = self.getHighlightedResults(); - MultipleSelection.prototype.display = function (data, container) { - var template = this.options.get('templateSelection'); - var escapeMarkup = this.options.get('escapeMarkup'); + var $options = self.$results.find('[aria-selected]'); + + var currentIndex = $options.index($highlighted); - return escapeMarkup(template(data, container)); - }; + var nextIndex = currentIndex + 1; - MultipleSelection.prototype.selectionContainer = function () { - var $container = $( - '
          • ' + - '' + - '×' + - '' + - '
          • ' - ); + // If we are at the last option, stay there + if (nextIndex >= $options.length) { + return; + } - return $container; - }; + var $next = $options.eq(nextIndex); - MultipleSelection.prototype.update = function (data) { - this.clear(); + $next.trigger('mouseenter'); - if (data.length === 0) { - return; - } + var currentOffset = self.$results.offset().top + + self.$results.outerHeight(false); + var nextBottom = $next.offset().top + $next.outerHeight(false); + var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset; - var $selections = []; + if (nextIndex === 0) { + self.$results.scrollTop(0); + } else if (nextBottom > currentOffset) { + self.$results.scrollTop(nextOffset); + } + }); - for (var d = 0; d < data.length; d++) { - var selection = data[d]; + container.on('results:focus', function (params) { + params.element.addClass('select2-results__option--highlighted'); + }); - var $selection = this.selectionContainer(); - var formatted = this.display(selection, $selection); + container.on('results:message', function (params) { + self.displayMessage(params); + }); - $selection.append(formatted); + if ($.fn.mousewheel) { + this.$results.on('mousewheel', function (e) { + var top = self.$results.scrollTop(); - var title = selection.title || selection.text; + var bottom = self.$results.get(0).scrollHeight - top + e.deltaY; - if (title) { - $selection.attr('title', title); - } + var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0; + var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height(); - Utils.StoreData($selection[0], 'data', selection); + if (isAtTop) { + self.$results.scrollTop(0); - $selections.push($selection); - } + e.preventDefault(); + e.stopPropagation(); + } else if (isAtBottom) { + self.$results.scrollTop( + self.$results.get(0).scrollHeight - self.$results.height() + ); - var $rendered = this.$selection.find('.select2-selection__rendered'); + e.preventDefault(); + e.stopPropagation(); + } + }); + } - Utils.appendMany($rendered, $selections); - }; + this.$results.on('mouseup', '.select2-results__option[aria-selected]', + function (evt) { + var $this = $(this); + + var data = Utils.GetData(this, 'data'); + + if ($this.attr('aria-selected') === 'true') { + if (self.options.get('multiple')) { + self.trigger('unselect', { + originalEvent: evt, + data: data + }); + } else { + self.trigger('close', {}); + } + + return; + } + + self.trigger('select', { + originalEvent: evt, + data: data + }); + }); + + this.$results.on('mouseenter', '.select2-results__option[aria-selected]', + function (evt) { + var data = Utils.GetData(this, 'data'); + + self.getHighlightedResults() + .removeClass('select2-results__option--highlighted'); + + self.trigger('results:focus', { + data: data, + element: $(this) + }); + }); + }; + + Results.prototype.getHighlightedResults = function () { + var $highlighted = this.$results + .find('.select2-results__option--highlighted'); + + return $highlighted; + }; + + Results.prototype.destroy = function () { + this.$results.remove(); + }; + + Results.prototype.ensureHighlightVisible = function () { + var $highlighted = this.getHighlightedResults(); + + if ($highlighted.length === 0) { + return; + } + + var $options = this.$results.find('[aria-selected]'); + + var currentIndex = $options.index($highlighted); + + var currentOffset = this.$results.offset().top; + var nextTop = $highlighted.offset().top; + var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset); + + var offsetDelta = nextTop - currentOffset; + nextOffset -= $highlighted.outerHeight(false) * 2; + + if (currentIndex <= 2) { + this.$results.scrollTop(0); + } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) { + this.$results.scrollTop(nextOffset); + } + }; + + Results.prototype.template = function (result, container) { + var template = this.options.get('templateResult'); + var escapeMarkup = this.options.get('escapeMarkup'); + + var content = template(result, container); + + if (content == null) { + container.style.display = 'none'; + } else if (typeof content === 'string') { + container.innerHTML = escapeMarkup(content); + } else { + $(container).append(content); + } + }; + + return Results; + }); + + S2.define('select2/keys', [], function () { + var KEYS = { + BACKSPACE: 8, + TAB: 9, + ENTER: 13, + SHIFT: 16, + CTRL: 17, + ALT: 18, + ESC: 27, + SPACE: 32, + PAGE_UP: 33, + PAGE_DOWN: 34, + END: 35, + HOME: 36, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46 + }; + + return KEYS; + }); + + S2.define('select2/selection/base', [ + 'jquery', + '../utils', + '../keys' + ], function ($, Utils, KEYS) { + function BaseSelection($element, options) { + this.$element = $element; + this.options = options; + + BaseSelection.__super__.constructor.call(this); + } + + Utils.Extend(BaseSelection, Utils.Observable); + + BaseSelection.prototype.render = function () { + var $selection = $( + '' + ); + + this._tabindex = 0; + + if (Utils.GetData(this.$element[0], 'old-tabindex') != null) { + this._tabindex = Utils.GetData(this.$element[0], 'old-tabindex'); + } else if (this.$element.attr('tabindex') != null) { + this._tabindex = this.$element.attr('tabindex'); + } + + $selection.attr('title', this.$element.attr('title')); + $selection.attr('tabindex', this._tabindex); + $selection.attr('aria-disabled', 'false'); + + this.$selection = $selection; + + return $selection; + }; + + BaseSelection.prototype.bind = function (container, $container) { + var self = this; + + var resultsId = container.id + '-results'; + + this.container = container; + + this.$selection.on('focus', function (evt) { + self.trigger('focus', evt); + }); + + this.$selection.on('blur', function (evt) { + self._handleBlur(evt); + }); + + this.$selection.on('keydown', function (evt) { + self.trigger('keypress', evt); + + if (evt.which === KEYS.SPACE) { + evt.preventDefault(); + } + }); + + container.on('results:focus', function (params) { + self.$selection.attr('aria-activedescendant', params.data._resultId); + }); + + container.on('selection:update', function (params) { + self.update(params.data); + }); + + container.on('open', function () { + // When the dropdown is open, aria-expanded="true" + self.$selection.attr('aria-expanded', 'true'); + self.$selection.attr('aria-owns', resultsId); + + self._attachCloseHandler(container); + }); + + container.on('close', function () { + // When the dropdown is closed, aria-expanded="false" + self.$selection.attr('aria-expanded', 'false'); + self.$selection.removeAttr('aria-activedescendant'); + self.$selection.removeAttr('aria-owns'); + + self.$selection.trigger('focus'); + + self._detachCloseHandler(container); + }); + + container.on('enable', function () { + self.$selection.attr('tabindex', self._tabindex); + self.$selection.attr('aria-disabled', 'false'); + }); + + container.on('disable', function () { + self.$selection.attr('tabindex', '-1'); + self.$selection.attr('aria-disabled', 'true'); + }); + }; + + BaseSelection.prototype._handleBlur = function (evt) { + var self = this; + + // This needs to be delayed as the active element is the body when the tab + // key is pressed, possibly along with others. + window.setTimeout(function () { + // Don't trigger `blur` if the focus is still in the selection + if ( + (document.activeElement == self.$selection[0]) || + ($.contains(self.$selection[0], document.activeElement)) + ) { + return; + } + + self.trigger('blur', evt); + }, 1); + }; + + BaseSelection.prototype._attachCloseHandler = function (container) { + + $(document.body).on('mousedown.select2.' + container.id, function (e) { + var $target = $(e.target); + + var $select = $target.closest('.select2'); + + var $all = $('.select2.select2-container--open'); + + $all.each(function () { + if (this == $select[0]) { + return; + } + + var $element = Utils.GetData(this, 'element'); + + $element.select2('close'); + }); + }); + }; + + BaseSelection.prototype._detachCloseHandler = function (container) { + $(document.body).off('mousedown.select2.' + container.id); + }; + + BaseSelection.prototype.position = function ($selection, $container) { + var $selectionContainer = $container.find('.selection'); + $selectionContainer.append($selection); + }; + + BaseSelection.prototype.destroy = function () { + this._detachCloseHandler(this.container); + }; + + BaseSelection.prototype.update = function (data) { + throw new Error('The `update` method must be defined in child classes.'); + }; + + /** + * Helper method to abstract the "enabled" (not "disabled") state of this + * object. + * + * @return {true} if the instance is not disabled. + * @return {false} if the instance is disabled. + */ + BaseSelection.prototype.isEnabled = function () { + return !this.isDisabled(); + }; + + /** + * Helper method to abstract the "disabled" state of this object. + * + * @return {true} if the disabled option is true. + * @return {false} if the disabled option is false. + */ + BaseSelection.prototype.isDisabled = function () { + return this.options.get('disabled'); + }; + + return BaseSelection; + }); + + S2.define('select2/selection/single', [ + 'jquery', + './base', + '../utils', + '../keys' + ], function ($, BaseSelection, Utils, KEYS) { + function SingleSelection() { + SingleSelection.__super__.constructor.apply(this, arguments); + } + + Utils.Extend(SingleSelection, BaseSelection); + + SingleSelection.prototype.render = function () { + var $selection = SingleSelection.__super__.render.call(this); + + $selection.addClass('select2-selection--single'); + + $selection.html( + '' + + '' + + '' + + '' + ); + + return $selection; + }; + + SingleSelection.prototype.bind = function (container, $container) { + var self = this; + + SingleSelection.__super__.bind.apply(this, arguments); + + var id = container.id + '-container'; + + this.$selection.find('.select2-selection__rendered') + .attr('id', id) + .attr('role', 'textbox') + .attr('aria-readonly', 'true'); + this.$selection.attr('aria-labelledby', id); + + this.$selection.on('mousedown', function (evt) { + // Only respond to left clicks + if (evt.which !== 1) { + return; + } + + self.trigger('toggle', { + originalEvent: evt + }); + }); + + this.$selection.on('focus', function (evt) { + // User focuses on the container + }); + + this.$selection.on('blur', function (evt) { + // User exits the container + }); + + container.on('focus', function (evt) { + if (!container.isOpen()) { + self.$selection.trigger('focus'); + } + }); + }; + + SingleSelection.prototype.clear = function () { + var $rendered = this.$selection.find('.select2-selection__rendered'); + $rendered.empty(); + $rendered.removeAttr('title'); // clear tooltip on empty + }; + + SingleSelection.prototype.display = function (data, container) { + var template = this.options.get('templateSelection'); + var escapeMarkup = this.options.get('escapeMarkup'); + + return escapeMarkup(template(data, container)); + }; + + SingleSelection.prototype.selectionContainer = function () { + return $(''); + }; + + SingleSelection.prototype.update = function (data) { + if (data.length === 0) { + this.clear(); + return; + } + + var selection = data[0]; + + var $rendered = this.$selection.find('.select2-selection__rendered'); + var formatted = this.display(selection, $rendered); + + $rendered.empty().append(formatted); + + var title = selection.title || selection.text; + + if (title) { + $rendered.attr('title', title); + } else { + $rendered.removeAttr('title'); + } + }; + + return SingleSelection; + }); - return MultipleSelection; -}); + S2.define('select2/selection/multiple', [ + 'jquery', + './base', + '../utils' + ], function ($, BaseSelection, Utils) { + function MultipleSelection($element, options) { + MultipleSelection.__super__.constructor.apply(this, arguments); + } -S2.define('select2/selection/placeholder',[ - '../utils' -], function (Utils) { - function Placeholder (decorated, $element, options) { - this.placeholder = this.normalizePlaceholder(options.get('placeholder')); + Utils.Extend(MultipleSelection, BaseSelection); - decorated.call(this, $element, options); - } + MultipleSelection.prototype.render = function () { + var $selection = MultipleSelection.__super__.render.call(this); - Placeholder.prototype.normalizePlaceholder = function (_, placeholder) { - if (typeof placeholder === 'string') { - placeholder = { - id: '', - text: placeholder - }; - } + $selection.addClass('select2-selection--multiple'); - return placeholder; - }; + $selection.html( + '
              ' + ); - Placeholder.prototype.createPlaceholder = function (decorated, placeholder) { - var $placeholder = this.selectionContainer(); + return $selection; + }; - $placeholder.html(this.display(placeholder)); - $placeholder.addClass('select2-selection__placeholder') - .removeClass('select2-selection__choice'); + MultipleSelection.prototype.bind = function (container, $container) { + var self = this; - return $placeholder; - }; + MultipleSelection.__super__.bind.apply(this, arguments); - Placeholder.prototype.update = function (decorated, data) { - var singlePlaceholder = ( - data.length == 1 && data[0].id != this.placeholder.id - ); - var multipleSelections = data.length > 1; + this.$selection.on('click', function (evt) { + self.trigger('toggle', { + originalEvent: evt + }); + }); - if (multipleSelections || singlePlaceholder) { - return decorated.call(this, data); - } + this.$selection.on( + 'click', + '.select2-selection__choice__remove', + function (evt) { + // Ignore the event if it is disabled + if (self.isDisabled()) { + return; + } - this.clear(); + var $remove = $(this); + var $selection = $remove.parent(); - var $placeholder = this.createPlaceholder(this.placeholder); + var data = Utils.GetData($selection[0], 'data'); - this.$selection.find('.select2-selection__rendered').append($placeholder); - }; + self.trigger('unselect', { + originalEvent: evt, + data: data + }); + } + ); + }; - return Placeholder; -}); + MultipleSelection.prototype.clear = function () { + var $rendered = this.$selection.find('.select2-selection__rendered'); + $rendered.empty(); + $rendered.removeAttr('title'); + }; -S2.define('select2/selection/allowClear',[ - 'jquery', - '../keys', - '../utils' -], function ($, KEYS, Utils) { - function AllowClear () { } + MultipleSelection.prototype.display = function (data, container) { + var template = this.options.get('templateSelection'); + var escapeMarkup = this.options.get('escapeMarkup'); - AllowClear.prototype.bind = function (decorated, container, $container) { - var self = this; + return escapeMarkup(template(data, container)); + }; - decorated.call(this, container, $container); + MultipleSelection.prototype.selectionContainer = function () { + var $container = $( + '
            • ' + + '' + + '×' + + '' + + '
            • ' + ); - if (this.placeholder == null) { - if (this.options.get('debug') && window.console && console.error) { - console.error( - 'Select2: The `allowClear` option should be used in combination ' + - 'with the `placeholder` option.' - ); - } - } + return $container; + }; - this.$selection.on('mousedown', '.select2-selection__clear', - function (evt) { - self._handleClear(evt); - }); + MultipleSelection.prototype.update = function (data) { + this.clear(); - container.on('keypress', function (evt) { - self._handleKeyboardClear(evt, container); - }); - }; - - AllowClear.prototype._handleClear = function (_, evt) { - // Ignore the event if it is disabled - if (this.isDisabled()) { - return; - } - - var $clear = this.$selection.find('.select2-selection__clear'); - - // Ignore the event if nothing has been selected - if ($clear.length === 0) { - return; - } - - evt.stopPropagation(); - - var data = Utils.GetData($clear[0], 'data'); - - var previousVal = this.$element.val(); - this.$element.val(this.placeholder.id); - - var unselectData = { - data: data - }; - this.trigger('clear', unselectData); - if (unselectData.prevented) { - this.$element.val(previousVal); - return; - } - - for (var d = 0; d < data.length; d++) { - unselectData = { - data: data[d] - }; - - // Trigger the `unselect` event, so people can prevent it from being - // cleared. - this.trigger('unselect', unselectData); - - // If the event was prevented, don't clear it out. - if (unselectData.prevented) { - this.$element.val(previousVal); - return; - } - } - - this.$element.trigger('input').trigger('change'); - - this.trigger('toggle', {}); - }; - - AllowClear.prototype._handleKeyboardClear = function (_, evt, container) { - if (container.isOpen()) { - return; - } - - if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) { - this._handleClear(evt); - } - }; - - AllowClear.prototype.update = function (decorated, data) { - decorated.call(this, data); - - if (this.$selection.find('.select2-selection__placeholder').length > 0 || - data.length === 0) { - return; - } - - var removeAll = this.options.get('translations').get('removeAllItems'); - - var $remove = $( - '' + - '×' + - '' - ); - Utils.StoreData($remove[0], 'data', data); - - this.$selection.find('.select2-selection__rendered').prepend($remove); - }; - - return AllowClear; -}); - -S2.define('select2/selection/search',[ - 'jquery', - '../utils', - '../keys' -], function ($, Utils, KEYS) { - function Search (decorated, $element, options) { - decorated.call(this, $element, options); - } - - Search.prototype.render = function (decorated) { - var $search = $( - '' - ); - - this.$searchContainer = $search; - this.$search = $search.find('input'); - - var $rendered = decorated.call(this); - - this._transferTabIndex(); - - return $rendered; - }; - - Search.prototype.bind = function (decorated, container, $container) { - var self = this; - - var resultsId = container.id + '-results'; - - decorated.call(this, container, $container); - - container.on('open', function () { - self.$search.attr('aria-controls', resultsId); - self.$search.trigger('focus'); - }); - - container.on('close', function () { - self.$search.val(''); - self.$search.removeAttr('aria-controls'); - self.$search.removeAttr('aria-activedescendant'); - self.$search.trigger('focus'); - }); - - container.on('enable', function () { - self.$search.prop('disabled', false); - - self._transferTabIndex(); - }); - - container.on('disable', function () { - self.$search.prop('disabled', true); - }); - - container.on('focus', function (evt) { - self.$search.trigger('focus'); - }); - - container.on('results:focus', function (params) { - if (params.data._resultId) { - self.$search.attr('aria-activedescendant', params.data._resultId); - } else { - self.$search.removeAttr('aria-activedescendant'); - } - }); - - this.$selection.on('focusin', '.select2-search--inline', function (evt) { - self.trigger('focus', evt); - }); - - this.$selection.on('focusout', '.select2-search--inline', function (evt) { - self._handleBlur(evt); - }); - - this.$selection.on('keydown', '.select2-search--inline', function (evt) { - evt.stopPropagation(); - - self.trigger('keypress', evt); - - self._keyUpPrevented = evt.isDefaultPrevented(); - - var key = evt.which; - - if (key === KEYS.BACKSPACE && self.$search.val() === '') { - var $previousChoice = self.$searchContainer - .prev('.select2-selection__choice'); - - if ($previousChoice.length > 0) { - var item = Utils.GetData($previousChoice[0], 'data'); - - self.searchRemoveChoice(item); - - evt.preventDefault(); - } - } - }); - - this.$selection.on('click', '.select2-search--inline', function (evt) { - if (self.$search.val()) { - evt.stopPropagation(); - } - }); - - // Try to detect the IE version should the `documentMode` property that - // is stored on the document. This is only implemented in IE and is - // slightly cleaner than doing a user agent check. - // This property is not available in Edge, but Edge also doesn't have - // this bug. - var msie = document.documentMode; - var disableInputEvents = msie && msie <= 11; - - // Workaround for browsers which do not support the `input` event - // This will prevent double-triggering of events for browsers which support - // both the `keyup` and `input` events. - this.$selection.on( - 'input.searchcheck', - '.select2-search--inline', - function (evt) { - // IE will trigger the `input` event when a placeholder is used on a - // search box. To get around this issue, we are forced to ignore all - // `input` events in IE and keep using `keyup`. - if (disableInputEvents) { - self.$selection.off('input.search input.searchcheck'); - return; - } - - // Unbind the duplicated `keyup` event - self.$selection.off('keyup.search'); - } - ); - - this.$selection.on( - 'keyup.search input.search', - '.select2-search--inline', - function (evt) { - // IE will trigger the `input` event when a placeholder is used on a - // search box. To get around this issue, we are forced to ignore all - // `input` events in IE and keep using `keyup`. - if (disableInputEvents && evt.type === 'input') { - self.$selection.off('input.search input.searchcheck'); - return; - } - - var key = evt.which; - - // We can freely ignore events from modifier keys - if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) { - return; - } - - // Tabbing will be handled during the `keydown` phase - if (key == KEYS.TAB) { - return; - } - - self.handleSearch(evt); - } - ); - }; - - /** - * This method will transfer the tabindex attribute from the rendered - * selection to the search box. This allows for the search box to be used as - * the primary focus instead of the selection container. - * - * @private - */ - Search.prototype._transferTabIndex = function (decorated) { - this.$search.attr('tabindex', this.$selection.attr('tabindex')); - this.$selection.attr('tabindex', '-1'); - }; - - Search.prototype.createPlaceholder = function (decorated, placeholder) { - this.$search.attr('placeholder', placeholder.text); - }; - - Search.prototype.update = function (decorated, data) { - var searchHadFocus = this.$search[0] == document.activeElement; - - this.$search.attr('placeholder', ''); - - decorated.call(this, data); - - this.$selection.find('.select2-selection__rendered') - .append(this.$searchContainer); - - this.resizeSearch(); - if (searchHadFocus) { - this.$search.trigger('focus'); - } - }; - - Search.prototype.handleSearch = function () { - this.resizeSearch(); - - if (!this._keyUpPrevented) { - var input = this.$search.val(); - - this.trigger('query', { - term: input - }); - } - - this._keyUpPrevented = false; - }; - - Search.prototype.searchRemoveChoice = function (decorated, item) { - this.trigger('unselect', { - data: item - }); - - this.$search.val(item.text); - this.handleSearch(); - }; - - Search.prototype.resizeSearch = function () { - this.$search.css('width', '25px'); - - var width = ''; - - if (this.$search.attr('placeholder') !== '') { - width = this.$selection.find('.select2-selection__rendered').width(); - } else { - var minimumWidth = this.$search.val().length + 1; - - width = (minimumWidth * 0.75) + 'em'; - } - - this.$search.css('width', width); - }; - - return Search; -}); - -S2.define('select2/selection/eventRelay',[ - 'jquery' -], function ($) { - function EventRelay () { } - - EventRelay.prototype.bind = function (decorated, container, $container) { - var self = this; - var relayEvents = [ - 'open', 'opening', - 'close', 'closing', - 'select', 'selecting', - 'unselect', 'unselecting', - 'clear', 'clearing' - ]; - - var preventableEvents = [ - 'opening', 'closing', 'selecting', 'unselecting', 'clearing' - ]; - - decorated.call(this, container, $container); - - container.on('*', function (name, params) { - // Ignore events that should not be relayed - if ($.inArray(name, relayEvents) === -1) { - return; - } - - // The parameters should always be an object - params = params || {}; - - // Generate the jQuery event for the Select2 event - var evt = $.Event('select2:' + name, { - params: params - }); - - self.$element.trigger(evt); - - // Only handle preventable events if it was one - if ($.inArray(name, preventableEvents) === -1) { - return; - } - - params.prevented = evt.isDefaultPrevented(); - }); - }; - - return EventRelay; -}); - -S2.define('select2/translation',[ - 'jquery', - 'require' -], function ($, require) { - function Translation (dict) { - this.dict = dict || {}; - } - - Translation.prototype.all = function () { - return this.dict; - }; - - Translation.prototype.get = function (key) { - return this.dict[key]; - }; - - Translation.prototype.extend = function (translation) { - this.dict = $.extend({}, translation.all(), this.dict); - }; - - // Static functions - - Translation._cache = {}; - - Translation.loadPath = function (path) { - if (!(path in Translation._cache)) { - var translations = require(path); - - Translation._cache[path] = translations; - } - - return new Translation(Translation._cache[path]); - }; - - return Translation; -}); - -S2.define('select2/diacritics',[ - -], function () { - var diacritics = { - '\u24B6': 'A', - '\uFF21': 'A', - '\u00C0': 'A', - '\u00C1': 'A', - '\u00C2': 'A', - '\u1EA6': 'A', - '\u1EA4': 'A', - '\u1EAA': 'A', - '\u1EA8': 'A', - '\u00C3': 'A', - '\u0100': 'A', - '\u0102': 'A', - '\u1EB0': 'A', - '\u1EAE': 'A', - '\u1EB4': 'A', - '\u1EB2': 'A', - '\u0226': 'A', - '\u01E0': 'A', - '\u00C4': 'A', - '\u01DE': 'A', - '\u1EA2': 'A', - '\u00C5': 'A', - '\u01FA': 'A', - '\u01CD': 'A', - '\u0200': 'A', - '\u0202': 'A', - '\u1EA0': 'A', - '\u1EAC': 'A', - '\u1EB6': 'A', - '\u1E00': 'A', - '\u0104': 'A', - '\u023A': 'A', - '\u2C6F': 'A', - '\uA732': 'AA', - '\u00C6': 'AE', - '\u01FC': 'AE', - '\u01E2': 'AE', - '\uA734': 'AO', - '\uA736': 'AU', - '\uA738': 'AV', - '\uA73A': 'AV', - '\uA73C': 'AY', - '\u24B7': 'B', - '\uFF22': 'B', - '\u1E02': 'B', - '\u1E04': 'B', - '\u1E06': 'B', - '\u0243': 'B', - '\u0182': 'B', - '\u0181': 'B', - '\u24B8': 'C', - '\uFF23': 'C', - '\u0106': 'C', - '\u0108': 'C', - '\u010A': 'C', - '\u010C': 'C', - '\u00C7': 'C', - '\u1E08': 'C', - '\u0187': 'C', - '\u023B': 'C', - '\uA73E': 'C', - '\u24B9': 'D', - '\uFF24': 'D', - '\u1E0A': 'D', - '\u010E': 'D', - '\u1E0C': 'D', - '\u1E10': 'D', - '\u1E12': 'D', - '\u1E0E': 'D', - '\u0110': 'D', - '\u018B': 'D', - '\u018A': 'D', - '\u0189': 'D', - '\uA779': 'D', - '\u01F1': 'DZ', - '\u01C4': 'DZ', - '\u01F2': 'Dz', - '\u01C5': 'Dz', - '\u24BA': 'E', - '\uFF25': 'E', - '\u00C8': 'E', - '\u00C9': 'E', - '\u00CA': 'E', - '\u1EC0': 'E', - '\u1EBE': 'E', - '\u1EC4': 'E', - '\u1EC2': 'E', - '\u1EBC': 'E', - '\u0112': 'E', - '\u1E14': 'E', - '\u1E16': 'E', - '\u0114': 'E', - '\u0116': 'E', - '\u00CB': 'E', - '\u1EBA': 'E', - '\u011A': 'E', - '\u0204': 'E', - '\u0206': 'E', - '\u1EB8': 'E', - '\u1EC6': 'E', - '\u0228': 'E', - '\u1E1C': 'E', - '\u0118': 'E', - '\u1E18': 'E', - '\u1E1A': 'E', - '\u0190': 'E', - '\u018E': 'E', - '\u24BB': 'F', - '\uFF26': 'F', - '\u1E1E': 'F', - '\u0191': 'F', - '\uA77B': 'F', - '\u24BC': 'G', - '\uFF27': 'G', - '\u01F4': 'G', - '\u011C': 'G', - '\u1E20': 'G', - '\u011E': 'G', - '\u0120': 'G', - '\u01E6': 'G', - '\u0122': 'G', - '\u01E4': 'G', - '\u0193': 'G', - '\uA7A0': 'G', - '\uA77D': 'G', - '\uA77E': 'G', - '\u24BD': 'H', - '\uFF28': 'H', - '\u0124': 'H', - '\u1E22': 'H', - '\u1E26': 'H', - '\u021E': 'H', - '\u1E24': 'H', - '\u1E28': 'H', - '\u1E2A': 'H', - '\u0126': 'H', - '\u2C67': 'H', - '\u2C75': 'H', - '\uA78D': 'H', - '\u24BE': 'I', - '\uFF29': 'I', - '\u00CC': 'I', - '\u00CD': 'I', - '\u00CE': 'I', - '\u0128': 'I', - '\u012A': 'I', - '\u012C': 'I', - '\u0130': 'I', - '\u00CF': 'I', - '\u1E2E': 'I', - '\u1EC8': 'I', - '\u01CF': 'I', - '\u0208': 'I', - '\u020A': 'I', - '\u1ECA': 'I', - '\u012E': 'I', - '\u1E2C': 'I', - '\u0197': 'I', - '\u24BF': 'J', - '\uFF2A': 'J', - '\u0134': 'J', - '\u0248': 'J', - '\u24C0': 'K', - '\uFF2B': 'K', - '\u1E30': 'K', - '\u01E8': 'K', - '\u1E32': 'K', - '\u0136': 'K', - '\u1E34': 'K', - '\u0198': 'K', - '\u2C69': 'K', - '\uA740': 'K', - '\uA742': 'K', - '\uA744': 'K', - '\uA7A2': 'K', - '\u24C1': 'L', - '\uFF2C': 'L', - '\u013F': 'L', - '\u0139': 'L', - '\u013D': 'L', - '\u1E36': 'L', - '\u1E38': 'L', - '\u013B': 'L', - '\u1E3C': 'L', - '\u1E3A': 'L', - '\u0141': 'L', - '\u023D': 'L', - '\u2C62': 'L', - '\u2C60': 'L', - '\uA748': 'L', - '\uA746': 'L', - '\uA780': 'L', - '\u01C7': 'LJ', - '\u01C8': 'Lj', - '\u24C2': 'M', - '\uFF2D': 'M', - '\u1E3E': 'M', - '\u1E40': 'M', - '\u1E42': 'M', - '\u2C6E': 'M', - '\u019C': 'M', - '\u24C3': 'N', - '\uFF2E': 'N', - '\u01F8': 'N', - '\u0143': 'N', - '\u00D1': 'N', - '\u1E44': 'N', - '\u0147': 'N', - '\u1E46': 'N', - '\u0145': 'N', - '\u1E4A': 'N', - '\u1E48': 'N', - '\u0220': 'N', - '\u019D': 'N', - '\uA790': 'N', - '\uA7A4': 'N', - '\u01CA': 'NJ', - '\u01CB': 'Nj', - '\u24C4': 'O', - '\uFF2F': 'O', - '\u00D2': 'O', - '\u00D3': 'O', - '\u00D4': 'O', - '\u1ED2': 'O', - '\u1ED0': 'O', - '\u1ED6': 'O', - '\u1ED4': 'O', - '\u00D5': 'O', - '\u1E4C': 'O', - '\u022C': 'O', - '\u1E4E': 'O', - '\u014C': 'O', - '\u1E50': 'O', - '\u1E52': 'O', - '\u014E': 'O', - '\u022E': 'O', - '\u0230': 'O', - '\u00D6': 'O', - '\u022A': 'O', - '\u1ECE': 'O', - '\u0150': 'O', - '\u01D1': 'O', - '\u020C': 'O', - '\u020E': 'O', - '\u01A0': 'O', - '\u1EDC': 'O', - '\u1EDA': 'O', - '\u1EE0': 'O', - '\u1EDE': 'O', - '\u1EE2': 'O', - '\u1ECC': 'O', - '\u1ED8': 'O', - '\u01EA': 'O', - '\u01EC': 'O', - '\u00D8': 'O', - '\u01FE': 'O', - '\u0186': 'O', - '\u019F': 'O', - '\uA74A': 'O', - '\uA74C': 'O', - '\u0152': 'OE', - '\u01A2': 'OI', - '\uA74E': 'OO', - '\u0222': 'OU', - '\u24C5': 'P', - '\uFF30': 'P', - '\u1E54': 'P', - '\u1E56': 'P', - '\u01A4': 'P', - '\u2C63': 'P', - '\uA750': 'P', - '\uA752': 'P', - '\uA754': 'P', - '\u24C6': 'Q', - '\uFF31': 'Q', - '\uA756': 'Q', - '\uA758': 'Q', - '\u024A': 'Q', - '\u24C7': 'R', - '\uFF32': 'R', - '\u0154': 'R', - '\u1E58': 'R', - '\u0158': 'R', - '\u0210': 'R', - '\u0212': 'R', - '\u1E5A': 'R', - '\u1E5C': 'R', - '\u0156': 'R', - '\u1E5E': 'R', - '\u024C': 'R', - '\u2C64': 'R', - '\uA75A': 'R', - '\uA7A6': 'R', - '\uA782': 'R', - '\u24C8': 'S', - '\uFF33': 'S', - '\u1E9E': 'S', - '\u015A': 'S', - '\u1E64': 'S', - '\u015C': 'S', - '\u1E60': 'S', - '\u0160': 'S', - '\u1E66': 'S', - '\u1E62': 'S', - '\u1E68': 'S', - '\u0218': 'S', - '\u015E': 'S', - '\u2C7E': 'S', - '\uA7A8': 'S', - '\uA784': 'S', - '\u24C9': 'T', - '\uFF34': 'T', - '\u1E6A': 'T', - '\u0164': 'T', - '\u1E6C': 'T', - '\u021A': 'T', - '\u0162': 'T', - '\u1E70': 'T', - '\u1E6E': 'T', - '\u0166': 'T', - '\u01AC': 'T', - '\u01AE': 'T', - '\u023E': 'T', - '\uA786': 'T', - '\uA728': 'TZ', - '\u24CA': 'U', - '\uFF35': 'U', - '\u00D9': 'U', - '\u00DA': 'U', - '\u00DB': 'U', - '\u0168': 'U', - '\u1E78': 'U', - '\u016A': 'U', - '\u1E7A': 'U', - '\u016C': 'U', - '\u00DC': 'U', - '\u01DB': 'U', - '\u01D7': 'U', - '\u01D5': 'U', - '\u01D9': 'U', - '\u1EE6': 'U', - '\u016E': 'U', - '\u0170': 'U', - '\u01D3': 'U', - '\u0214': 'U', - '\u0216': 'U', - '\u01AF': 'U', - '\u1EEA': 'U', - '\u1EE8': 'U', - '\u1EEE': 'U', - '\u1EEC': 'U', - '\u1EF0': 'U', - '\u1EE4': 'U', - '\u1E72': 'U', - '\u0172': 'U', - '\u1E76': 'U', - '\u1E74': 'U', - '\u0244': 'U', - '\u24CB': 'V', - '\uFF36': 'V', - '\u1E7C': 'V', - '\u1E7E': 'V', - '\u01B2': 'V', - '\uA75E': 'V', - '\u0245': 'V', - '\uA760': 'VY', - '\u24CC': 'W', - '\uFF37': 'W', - '\u1E80': 'W', - '\u1E82': 'W', - '\u0174': 'W', - '\u1E86': 'W', - '\u1E84': 'W', - '\u1E88': 'W', - '\u2C72': 'W', - '\u24CD': 'X', - '\uFF38': 'X', - '\u1E8A': 'X', - '\u1E8C': 'X', - '\u24CE': 'Y', - '\uFF39': 'Y', - '\u1EF2': 'Y', - '\u00DD': 'Y', - '\u0176': 'Y', - '\u1EF8': 'Y', - '\u0232': 'Y', - '\u1E8E': 'Y', - '\u0178': 'Y', - '\u1EF6': 'Y', - '\u1EF4': 'Y', - '\u01B3': 'Y', - '\u024E': 'Y', - '\u1EFE': 'Y', - '\u24CF': 'Z', - '\uFF3A': 'Z', - '\u0179': 'Z', - '\u1E90': 'Z', - '\u017B': 'Z', - '\u017D': 'Z', - '\u1E92': 'Z', - '\u1E94': 'Z', - '\u01B5': 'Z', - '\u0224': 'Z', - '\u2C7F': 'Z', - '\u2C6B': 'Z', - '\uA762': 'Z', - '\u24D0': 'a', - '\uFF41': 'a', - '\u1E9A': 'a', - '\u00E0': 'a', - '\u00E1': 'a', - '\u00E2': 'a', - '\u1EA7': 'a', - '\u1EA5': 'a', - '\u1EAB': 'a', - '\u1EA9': 'a', - '\u00E3': 'a', - '\u0101': 'a', - '\u0103': 'a', - '\u1EB1': 'a', - '\u1EAF': 'a', - '\u1EB5': 'a', - '\u1EB3': 'a', - '\u0227': 'a', - '\u01E1': 'a', - '\u00E4': 'a', - '\u01DF': 'a', - '\u1EA3': 'a', - '\u00E5': 'a', - '\u01FB': 'a', - '\u01CE': 'a', - '\u0201': 'a', - '\u0203': 'a', - '\u1EA1': 'a', - '\u1EAD': 'a', - '\u1EB7': 'a', - '\u1E01': 'a', - '\u0105': 'a', - '\u2C65': 'a', - '\u0250': 'a', - '\uA733': 'aa', - '\u00E6': 'ae', - '\u01FD': 'ae', - '\u01E3': 'ae', - '\uA735': 'ao', - '\uA737': 'au', - '\uA739': 'av', - '\uA73B': 'av', - '\uA73D': 'ay', - '\u24D1': 'b', - '\uFF42': 'b', - '\u1E03': 'b', - '\u1E05': 'b', - '\u1E07': 'b', - '\u0180': 'b', - '\u0183': 'b', - '\u0253': 'b', - '\u24D2': 'c', - '\uFF43': 'c', - '\u0107': 'c', - '\u0109': 'c', - '\u010B': 'c', - '\u010D': 'c', - '\u00E7': 'c', - '\u1E09': 'c', - '\u0188': 'c', - '\u023C': 'c', - '\uA73F': 'c', - '\u2184': 'c', - '\u24D3': 'd', - '\uFF44': 'd', - '\u1E0B': 'd', - '\u010F': 'd', - '\u1E0D': 'd', - '\u1E11': 'd', - '\u1E13': 'd', - '\u1E0F': 'd', - '\u0111': 'd', - '\u018C': 'd', - '\u0256': 'd', - '\u0257': 'd', - '\uA77A': 'd', - '\u01F3': 'dz', - '\u01C6': 'dz', - '\u24D4': 'e', - '\uFF45': 'e', - '\u00E8': 'e', - '\u00E9': 'e', - '\u00EA': 'e', - '\u1EC1': 'e', - '\u1EBF': 'e', - '\u1EC5': 'e', - '\u1EC3': 'e', - '\u1EBD': 'e', - '\u0113': 'e', - '\u1E15': 'e', - '\u1E17': 'e', - '\u0115': 'e', - '\u0117': 'e', - '\u00EB': 'e', - '\u1EBB': 'e', - '\u011B': 'e', - '\u0205': 'e', - '\u0207': 'e', - '\u1EB9': 'e', - '\u1EC7': 'e', - '\u0229': 'e', - '\u1E1D': 'e', - '\u0119': 'e', - '\u1E19': 'e', - '\u1E1B': 'e', - '\u0247': 'e', - '\u025B': 'e', - '\u01DD': 'e', - '\u24D5': 'f', - '\uFF46': 'f', - '\u1E1F': 'f', - '\u0192': 'f', - '\uA77C': 'f', - '\u24D6': 'g', - '\uFF47': 'g', - '\u01F5': 'g', - '\u011D': 'g', - '\u1E21': 'g', - '\u011F': 'g', - '\u0121': 'g', - '\u01E7': 'g', - '\u0123': 'g', - '\u01E5': 'g', - '\u0260': 'g', - '\uA7A1': 'g', - '\u1D79': 'g', - '\uA77F': 'g', - '\u24D7': 'h', - '\uFF48': 'h', - '\u0125': 'h', - '\u1E23': 'h', - '\u1E27': 'h', - '\u021F': 'h', - '\u1E25': 'h', - '\u1E29': 'h', - '\u1E2B': 'h', - '\u1E96': 'h', - '\u0127': 'h', - '\u2C68': 'h', - '\u2C76': 'h', - '\u0265': 'h', - '\u0195': 'hv', - '\u24D8': 'i', - '\uFF49': 'i', - '\u00EC': 'i', - '\u00ED': 'i', - '\u00EE': 'i', - '\u0129': 'i', - '\u012B': 'i', - '\u012D': 'i', - '\u00EF': 'i', - '\u1E2F': 'i', - '\u1EC9': 'i', - '\u01D0': 'i', - '\u0209': 'i', - '\u020B': 'i', - '\u1ECB': 'i', - '\u012F': 'i', - '\u1E2D': 'i', - '\u0268': 'i', - '\u0131': 'i', - '\u24D9': 'j', - '\uFF4A': 'j', - '\u0135': 'j', - '\u01F0': 'j', - '\u0249': 'j', - '\u24DA': 'k', - '\uFF4B': 'k', - '\u1E31': 'k', - '\u01E9': 'k', - '\u1E33': 'k', - '\u0137': 'k', - '\u1E35': 'k', - '\u0199': 'k', - '\u2C6A': 'k', - '\uA741': 'k', - '\uA743': 'k', - '\uA745': 'k', - '\uA7A3': 'k', - '\u24DB': 'l', - '\uFF4C': 'l', - '\u0140': 'l', - '\u013A': 'l', - '\u013E': 'l', - '\u1E37': 'l', - '\u1E39': 'l', - '\u013C': 'l', - '\u1E3D': 'l', - '\u1E3B': 'l', - '\u017F': 'l', - '\u0142': 'l', - '\u019A': 'l', - '\u026B': 'l', - '\u2C61': 'l', - '\uA749': 'l', - '\uA781': 'l', - '\uA747': 'l', - '\u01C9': 'lj', - '\u24DC': 'm', - '\uFF4D': 'm', - '\u1E3F': 'm', - '\u1E41': 'm', - '\u1E43': 'm', - '\u0271': 'm', - '\u026F': 'm', - '\u24DD': 'n', - '\uFF4E': 'n', - '\u01F9': 'n', - '\u0144': 'n', - '\u00F1': 'n', - '\u1E45': 'n', - '\u0148': 'n', - '\u1E47': 'n', - '\u0146': 'n', - '\u1E4B': 'n', - '\u1E49': 'n', - '\u019E': 'n', - '\u0272': 'n', - '\u0149': 'n', - '\uA791': 'n', - '\uA7A5': 'n', - '\u01CC': 'nj', - '\u24DE': 'o', - '\uFF4F': 'o', - '\u00F2': 'o', - '\u00F3': 'o', - '\u00F4': 'o', - '\u1ED3': 'o', - '\u1ED1': 'o', - '\u1ED7': 'o', - '\u1ED5': 'o', - '\u00F5': 'o', - '\u1E4D': 'o', - '\u022D': 'o', - '\u1E4F': 'o', - '\u014D': 'o', - '\u1E51': 'o', - '\u1E53': 'o', - '\u014F': 'o', - '\u022F': 'o', - '\u0231': 'o', - '\u00F6': 'o', - '\u022B': 'o', - '\u1ECF': 'o', - '\u0151': 'o', - '\u01D2': 'o', - '\u020D': 'o', - '\u020F': 'o', - '\u01A1': 'o', - '\u1EDD': 'o', - '\u1EDB': 'o', - '\u1EE1': 'o', - '\u1EDF': 'o', - '\u1EE3': 'o', - '\u1ECD': 'o', - '\u1ED9': 'o', - '\u01EB': 'o', - '\u01ED': 'o', - '\u00F8': 'o', - '\u01FF': 'o', - '\u0254': 'o', - '\uA74B': 'o', - '\uA74D': 'o', - '\u0275': 'o', - '\u0153': 'oe', - '\u01A3': 'oi', - '\u0223': 'ou', - '\uA74F': 'oo', - '\u24DF': 'p', - '\uFF50': 'p', - '\u1E55': 'p', - '\u1E57': 'p', - '\u01A5': 'p', - '\u1D7D': 'p', - '\uA751': 'p', - '\uA753': 'p', - '\uA755': 'p', - '\u24E0': 'q', - '\uFF51': 'q', - '\u024B': 'q', - '\uA757': 'q', - '\uA759': 'q', - '\u24E1': 'r', - '\uFF52': 'r', - '\u0155': 'r', - '\u1E59': 'r', - '\u0159': 'r', - '\u0211': 'r', - '\u0213': 'r', - '\u1E5B': 'r', - '\u1E5D': 'r', - '\u0157': 'r', - '\u1E5F': 'r', - '\u024D': 'r', - '\u027D': 'r', - '\uA75B': 'r', - '\uA7A7': 'r', - '\uA783': 'r', - '\u24E2': 's', - '\uFF53': 's', - '\u00DF': 's', - '\u015B': 's', - '\u1E65': 's', - '\u015D': 's', - '\u1E61': 's', - '\u0161': 's', - '\u1E67': 's', - '\u1E63': 's', - '\u1E69': 's', - '\u0219': 's', - '\u015F': 's', - '\u023F': 's', - '\uA7A9': 's', - '\uA785': 's', - '\u1E9B': 's', - '\u24E3': 't', - '\uFF54': 't', - '\u1E6B': 't', - '\u1E97': 't', - '\u0165': 't', - '\u1E6D': 't', - '\u021B': 't', - '\u0163': 't', - '\u1E71': 't', - '\u1E6F': 't', - '\u0167': 't', - '\u01AD': 't', - '\u0288': 't', - '\u2C66': 't', - '\uA787': 't', - '\uA729': 'tz', - '\u24E4': 'u', - '\uFF55': 'u', - '\u00F9': 'u', - '\u00FA': 'u', - '\u00FB': 'u', - '\u0169': 'u', - '\u1E79': 'u', - '\u016B': 'u', - '\u1E7B': 'u', - '\u016D': 'u', - '\u00FC': 'u', - '\u01DC': 'u', - '\u01D8': 'u', - '\u01D6': 'u', - '\u01DA': 'u', - '\u1EE7': 'u', - '\u016F': 'u', - '\u0171': 'u', - '\u01D4': 'u', - '\u0215': 'u', - '\u0217': 'u', - '\u01B0': 'u', - '\u1EEB': 'u', - '\u1EE9': 'u', - '\u1EEF': 'u', - '\u1EED': 'u', - '\u1EF1': 'u', - '\u1EE5': 'u', - '\u1E73': 'u', - '\u0173': 'u', - '\u1E77': 'u', - '\u1E75': 'u', - '\u0289': 'u', - '\u24E5': 'v', - '\uFF56': 'v', - '\u1E7D': 'v', - '\u1E7F': 'v', - '\u028B': 'v', - '\uA75F': 'v', - '\u028C': 'v', - '\uA761': 'vy', - '\u24E6': 'w', - '\uFF57': 'w', - '\u1E81': 'w', - '\u1E83': 'w', - '\u0175': 'w', - '\u1E87': 'w', - '\u1E85': 'w', - '\u1E98': 'w', - '\u1E89': 'w', - '\u2C73': 'w', - '\u24E7': 'x', - '\uFF58': 'x', - '\u1E8B': 'x', - '\u1E8D': 'x', - '\u24E8': 'y', - '\uFF59': 'y', - '\u1EF3': 'y', - '\u00FD': 'y', - '\u0177': 'y', - '\u1EF9': 'y', - '\u0233': 'y', - '\u1E8F': 'y', - '\u00FF': 'y', - '\u1EF7': 'y', - '\u1E99': 'y', - '\u1EF5': 'y', - '\u01B4': 'y', - '\u024F': 'y', - '\u1EFF': 'y', - '\u24E9': 'z', - '\uFF5A': 'z', - '\u017A': 'z', - '\u1E91': 'z', - '\u017C': 'z', - '\u017E': 'z', - '\u1E93': 'z', - '\u1E95': 'z', - '\u01B6': 'z', - '\u0225': 'z', - '\u0240': 'z', - '\u2C6C': 'z', - '\uA763': 'z', - '\u0386': '\u0391', - '\u0388': '\u0395', - '\u0389': '\u0397', - '\u038A': '\u0399', - '\u03AA': '\u0399', - '\u038C': '\u039F', - '\u038E': '\u03A5', - '\u03AB': '\u03A5', - '\u038F': '\u03A9', - '\u03AC': '\u03B1', - '\u03AD': '\u03B5', - '\u03AE': '\u03B7', - '\u03AF': '\u03B9', - '\u03CA': '\u03B9', - '\u0390': '\u03B9', - '\u03CC': '\u03BF', - '\u03CD': '\u03C5', - '\u03CB': '\u03C5', - '\u03B0': '\u03C5', - '\u03CE': '\u03C9', - '\u03C2': '\u03C3', - '\u2019': '\'' - }; - - return diacritics; -}); - -S2.define('select2/data/base',[ - '../utils' -], function (Utils) { - function BaseAdapter ($element, options) { - BaseAdapter.__super__.constructor.call(this); - } - - Utils.Extend(BaseAdapter, Utils.Observable); - - BaseAdapter.prototype.current = function (callback) { - throw new Error('The `current` method must be defined in child classes.'); - }; - - BaseAdapter.prototype.query = function (params, callback) { - throw new Error('The `query` method must be defined in child classes.'); - }; - - BaseAdapter.prototype.bind = function (container, $container) { - // Can be implemented in subclasses - }; - - BaseAdapter.prototype.destroy = function () { - // Can be implemented in subclasses - }; - - BaseAdapter.prototype.generateResultId = function (container, data) { - var id = container.id + '-result-'; - - id += Utils.generateChars(4); - - if (data.id != null) { - id += '-' + data.id.toString(); - } else { - id += '-' + Utils.generateChars(4); - } - return id; - }; - - return BaseAdapter; -}); - -S2.define('select2/data/select',[ - './base', - '../utils', - 'jquery' -], function (BaseAdapter, Utils, $) { - function SelectAdapter ($element, options) { - this.$element = $element; - this.options = options; - - SelectAdapter.__super__.constructor.call(this); - } - - Utils.Extend(SelectAdapter, BaseAdapter); - - SelectAdapter.prototype.current = function (callback) { - var data = []; - var self = this; - - this.$element.find(':selected').each(function () { - var $option = $(this); - - var option = self.item($option); - - data.push(option); - }); - - callback(data); - }; - - SelectAdapter.prototype.select = function (data) { - var self = this; - - data.selected = true; + if (data.length === 0) { + return; + } - // If data.element is a DOM node, use it instead - if ($(data.element).is('option')) { - data.element.selected = true; + var $selections = []; - this.$element.trigger('input').trigger('change'); + for (var d = 0; d < data.length; d++) { + var selection = data[d]; - return; - } + var $selection = this.selectionContainer(); + var formatted = this.display(selection, $selection); - if (this.$element.prop('multiple')) { - this.current(function (currentData) { - var val = []; + $selection.append(formatted); - data = [data]; - data.push.apply(data, currentData); + var title = selection.title || selection.text; - for (var d = 0; d < data.length; d++) { - var id = data[d].id; + if (title) { + $selection.attr('title', title); + } - if ($.inArray(id, val) === -1) { - val.push(id); - } - } + Utils.StoreData($selection[0], 'data', selection); - self.$element.val(val); - self.$element.trigger('input').trigger('change'); - }); - } else { - var val = data.id; + $selections.push($selection); + } - this.$element.val(val); - this.$element.trigger('input').trigger('change'); - } - }; + var $rendered = this.$selection.find('.select2-selection__rendered'); - SelectAdapter.prototype.unselect = function (data) { - var self = this; + Utils.appendMany($rendered, $selections); + }; - if (!this.$element.prop('multiple')) { - return; - } + return MultipleSelection; + }); - data.selected = false; + S2.define('select2/selection/placeholder', [ + '../utils' + ], function (Utils) { + function Placeholder(decorated, $element, options) { + this.placeholder = this.normalizePlaceholder(options.get('placeholder')); - if ($(data.element).is('option')) { - data.element.selected = false; + decorated.call(this, $element, options); + } - this.$element.trigger('input').trigger('change'); + Placeholder.prototype.normalizePlaceholder = function (_, placeholder) { + if (typeof placeholder === 'string') { + placeholder = { + id: '', + text: placeholder + }; + } - return; - } + return placeholder; + }; - this.current(function (currentData) { - var val = []; + Placeholder.prototype.createPlaceholder = function (decorated, placeholder) { + var $placeholder = this.selectionContainer(); - for (var d = 0; d < currentData.length; d++) { - var id = currentData[d].id; + $placeholder.html(this.display(placeholder)); + $placeholder.addClass('select2-selection__placeholder') + .removeClass('select2-selection__choice'); - if (id !== data.id && $.inArray(id, val) === -1) { - val.push(id); - } - } + return $placeholder; + }; - self.$element.val(val); + Placeholder.prototype.update = function (decorated, data) { + var singlePlaceholder = ( + data.length == 1 && data[0].id != this.placeholder.id + ); + var multipleSelections = data.length > 1; - self.$element.trigger('input').trigger('change'); - }); - }; + if (multipleSelections || singlePlaceholder) { + return decorated.call(this, data); + } - SelectAdapter.prototype.bind = function (container, $container) { - var self = this; + this.clear(); - this.container = container; + var $placeholder = this.createPlaceholder(this.placeholder); - container.on('select', function (params) { - self.select(params.data); - }); + this.$selection.find('.select2-selection__rendered').append($placeholder); + }; - container.on('unselect', function (params) { - self.unselect(params.data); - }); - }; + return Placeholder; + }); - SelectAdapter.prototype.destroy = function () { - // Remove anything added to child elements - this.$element.find('*').each(function () { - // Remove any custom data set by Select2 - Utils.RemoveData(this); - }); - }; + S2.define('select2/selection/allowClear', [ + 'jquery', + '../keys', + '../utils' + ], function ($, KEYS, Utils) { + function AllowClear() { + } - SelectAdapter.prototype.query = function (params, callback) { - var data = []; - var self = this; + AllowClear.prototype.bind = function (decorated, container, $container) { + var self = this; - var $options = this.$element.children(); + decorated.call(this, container, $container); - $options.each(function () { - var $option = $(this); + if (this.placeholder == null) { + if (this.options.get('debug') && window.console && console.error) { + console.error( + 'Select2: The `allowClear` option should be used in combination ' + + 'with the `placeholder` option.' + ); + } + } - if (!$option.is('option') && !$option.is('optgroup')) { - return; - } + this.$selection.on('mousedown', '.select2-selection__clear', + function (evt) { + self._handleClear(evt); + }); + + container.on('keypress', function (evt) { + self._handleKeyboardClear(evt, container); + }); + }; + + AllowClear.prototype._handleClear = function (_, evt) { + // Ignore the event if it is disabled + if (this.isDisabled()) { + return; + } + + var $clear = this.$selection.find('.select2-selection__clear'); + + // Ignore the event if nothing has been selected + if ($clear.length === 0) { + return; + } + + evt.stopPropagation(); + + var data = Utils.GetData($clear[0], 'data'); + + var previousVal = this.$element.val(); + this.$element.val(this.placeholder.id); + + var unselectData = { + data: data + }; + this.trigger('clear', unselectData); + if (unselectData.prevented) { + this.$element.val(previousVal); + return; + } + + for (var d = 0; d < data.length; d++) { + unselectData = { + data: data[d] + }; + + // Trigger the `unselect` event, so people can prevent it from being + // cleared. + this.trigger('unselect', unselectData); + + // If the event was prevented, don't clear it out. + if (unselectData.prevented) { + this.$element.val(previousVal); + return; + } + } + + this.$element.trigger('input').trigger('change'); + + this.trigger('toggle', {}); + }; + + AllowClear.prototype._handleKeyboardClear = function (_, evt, container) { + if (container.isOpen()) { + return; + } + + if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) { + this._handleClear(evt); + } + }; + + AllowClear.prototype.update = function (decorated, data) { + decorated.call(this, data); + + if (this.$selection.find('.select2-selection__placeholder').length > 0 || + data.length === 0) { + return; + } + + var removeAll = this.options.get('translations').get('removeAllItems'); + + var $remove = $( + '' + + '×' + + '' + ); + Utils.StoreData($remove[0], 'data', data); + + this.$selection.find('.select2-selection__rendered').prepend($remove); + }; + + return AllowClear; + }); + + S2.define('select2/selection/search', [ + 'jquery', + '../utils', + '../keys' + ], function ($, Utils, KEYS) { + function Search(decorated, $element, options) { + decorated.call(this, $element, options); + } + + Search.prototype.render = function (decorated) { + var $search = $( + '' + ); + + this.$searchContainer = $search; + this.$search = $search.find('input'); + + var $rendered = decorated.call(this); + + this._transferTabIndex(); + + return $rendered; + }; + + Search.prototype.bind = function (decorated, container, $container) { + var self = this; + + var resultsId = container.id + '-results'; + + decorated.call(this, container, $container); + + container.on('open', function () { + self.$search.attr('aria-controls', resultsId); + self.$search.trigger('focus'); + }); + + container.on('close', function () { + self.$search.val(''); + self.$search.removeAttr('aria-controls'); + self.$search.removeAttr('aria-activedescendant'); + self.$search.trigger('focus'); + }); + + container.on('enable', function () { + self.$search.prop('disabled', false); + + self._transferTabIndex(); + }); + + container.on('disable', function () { + self.$search.prop('disabled', true); + }); + + container.on('focus', function (evt) { + self.$search.trigger('focus'); + }); + + container.on('results:focus', function (params) { + if (params.data._resultId) { + self.$search.attr('aria-activedescendant', params.data._resultId); + } else { + self.$search.removeAttr('aria-activedescendant'); + } + }); + + this.$selection.on('focusin', '.select2-search--inline', function (evt) { + self.trigger('focus', evt); + }); + + this.$selection.on('focusout', '.select2-search--inline', function (evt) { + self._handleBlur(evt); + }); + + this.$selection.on('keydown', '.select2-search--inline', function (evt) { + evt.stopPropagation(); + + self.trigger('keypress', evt); + + self._keyUpPrevented = evt.isDefaultPrevented(); + + var key = evt.which; + + if (key === KEYS.BACKSPACE && self.$search.val() === '') { + var $previousChoice = self.$searchContainer + .prev('.select2-selection__choice'); + + if ($previousChoice.length > 0) { + var item = Utils.GetData($previousChoice[0], 'data'); + + self.searchRemoveChoice(item); + + evt.preventDefault(); + } + } + }); + + this.$selection.on('click', '.select2-search--inline', function (evt) { + if (self.$search.val()) { + evt.stopPropagation(); + } + }); + + // Try to detect the IE version should the `documentMode` property that + // is stored on the document. This is only implemented in IE and is + // slightly cleaner than doing a user agent check. + // This property is not available in Edge, but Edge also doesn't have + // this bug. + var msie = document.documentMode; + var disableInputEvents = msie && msie <= 11; + + // Workaround for browsers which do not support the `input` event + // This will prevent double-triggering of events for browsers which support + // both the `keyup` and `input` events. + this.$selection.on( + 'input.searchcheck', + '.select2-search--inline', + function (evt) { + // IE will trigger the `input` event when a placeholder is used on a + // search box. To get around this issue, we are forced to ignore all + // `input` events in IE and keep using `keyup`. + if (disableInputEvents) { + self.$selection.off('input.search input.searchcheck'); + return; + } + + // Unbind the duplicated `keyup` event + self.$selection.off('keyup.search'); + } + ); + + this.$selection.on( + 'keyup.search input.search', + '.select2-search--inline', + function (evt) { + // IE will trigger the `input` event when a placeholder is used on a + // search box. To get around this issue, we are forced to ignore all + // `input` events in IE and keep using `keyup`. + if (disableInputEvents && evt.type === 'input') { + self.$selection.off('input.search input.searchcheck'); + return; + } + + var key = evt.which; + + // We can freely ignore events from modifier keys + if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) { + return; + } + + // Tabbing will be handled during the `keydown` phase + if (key == KEYS.TAB) { + return; + } + + self.handleSearch(evt); + } + ); + }; + + /** + * This method will transfer the tabindex attribute from the rendered + * selection to the search box. This allows for the search box to be used as + * the primary focus instead of the selection container. + * + * @private + */ + Search.prototype._transferTabIndex = function (decorated) { + this.$search.attr('tabindex', this.$selection.attr('tabindex')); + this.$selection.attr('tabindex', '-1'); + }; + + Search.prototype.createPlaceholder = function (decorated, placeholder) { + this.$search.attr('placeholder', placeholder.text); + }; + + Search.prototype.update = function (decorated, data) { + var searchHadFocus = this.$search[0] == document.activeElement; + + this.$search.attr('placeholder', ''); + + decorated.call(this, data); + + this.$selection.find('.select2-selection__rendered') + .append(this.$searchContainer); + + this.resizeSearch(); + if (searchHadFocus) { + this.$search.trigger('focus'); + } + }; + + Search.prototype.handleSearch = function () { + this.resizeSearch(); + + if (!this._keyUpPrevented) { + var input = this.$search.val(); + + this.trigger('query', { + term: input + }); + } + + this._keyUpPrevented = false; + }; + + Search.prototype.searchRemoveChoice = function (decorated, item) { + this.trigger('unselect', { + data: item + }); + + this.$search.val(item.text); + this.handleSearch(); + }; + + Search.prototype.resizeSearch = function () { + this.$search.css('width', '25px'); + + var width = ''; + + if (this.$search.attr('placeholder') !== '') { + width = this.$selection.find('.select2-selection__rendered').width(); + } else { + var minimumWidth = this.$search.val().length + 1; + + width = (minimumWidth * 0.75) + 'em'; + } + + this.$search.css('width', width); + }; + + return Search; + }); + + S2.define('select2/selection/eventRelay', [ + 'jquery' + ], function ($) { + function EventRelay() { + } + + EventRelay.prototype.bind = function (decorated, container, $container) { + var self = this; + var relayEvents = [ + 'open', 'opening', + 'close', 'closing', + 'select', 'selecting', + 'unselect', 'unselecting', + 'clear', 'clearing' + ]; + + var preventableEvents = [ + 'opening', 'closing', 'selecting', 'unselecting', 'clearing' + ]; + + decorated.call(this, container, $container); + + container.on('*', function (name, params) { + // Ignore events that should not be relayed + if ($.inArray(name, relayEvents) === -1) { + return; + } + + // The parameters should always be an object + params = params || {}; + + // Generate the jQuery event for the Select2 event + var evt = $.Event('select2:' + name, { + params: params + }); + + self.$element.trigger(evt); + + // Only handle preventable events if it was one + if ($.inArray(name, preventableEvents) === -1) { + return; + } + + params.prevented = evt.isDefaultPrevented(); + }); + }; + + return EventRelay; + }); + + S2.define('select2/translation', [ + 'jquery', + 'require' + ], function ($, require) { + function Translation(dict) { + this.dict = dict || {}; + } + + Translation.prototype.all = function () { + return this.dict; + }; + + Translation.prototype.get = function (key) { + return this.dict[key]; + }; + + Translation.prototype.extend = function (translation) { + this.dict = $.extend({}, translation.all(), this.dict); + }; + + // Static functions + + Translation._cache = {}; + + Translation.loadPath = function (path) { + if (!(path in Translation._cache)) { + var translations = require(path); + + Translation._cache[path] = translations; + } + + return new Translation(Translation._cache[path]); + }; + + return Translation; + }); + + S2.define('select2/diacritics', [], function () { + var diacritics = { + '\u24B6': 'A', + '\uFF21': 'A', + '\u00C0': 'A', + '\u00C1': 'A', + '\u00C2': 'A', + '\u1EA6': 'A', + '\u1EA4': 'A', + '\u1EAA': 'A', + '\u1EA8': 'A', + '\u00C3': 'A', + '\u0100': 'A', + '\u0102': 'A', + '\u1EB0': 'A', + '\u1EAE': 'A', + '\u1EB4': 'A', + '\u1EB2': 'A', + '\u0226': 'A', + '\u01E0': 'A', + '\u00C4': 'A', + '\u01DE': 'A', + '\u1EA2': 'A', + '\u00C5': 'A', + '\u01FA': 'A', + '\u01CD': 'A', + '\u0200': 'A', + '\u0202': 'A', + '\u1EA0': 'A', + '\u1EAC': 'A', + '\u1EB6': 'A', + '\u1E00': 'A', + '\u0104': 'A', + '\u023A': 'A', + '\u2C6F': 'A', + '\uA732': 'AA', + '\u00C6': 'AE', + '\u01FC': 'AE', + '\u01E2': 'AE', + '\uA734': 'AO', + '\uA736': 'AU', + '\uA738': 'AV', + '\uA73A': 'AV', + '\uA73C': 'AY', + '\u24B7': 'B', + '\uFF22': 'B', + '\u1E02': 'B', + '\u1E04': 'B', + '\u1E06': 'B', + '\u0243': 'B', + '\u0182': 'B', + '\u0181': 'B', + '\u24B8': 'C', + '\uFF23': 'C', + '\u0106': 'C', + '\u0108': 'C', + '\u010A': 'C', + '\u010C': 'C', + '\u00C7': 'C', + '\u1E08': 'C', + '\u0187': 'C', + '\u023B': 'C', + '\uA73E': 'C', + '\u24B9': 'D', + '\uFF24': 'D', + '\u1E0A': 'D', + '\u010E': 'D', + '\u1E0C': 'D', + '\u1E10': 'D', + '\u1E12': 'D', + '\u1E0E': 'D', + '\u0110': 'D', + '\u018B': 'D', + '\u018A': 'D', + '\u0189': 'D', + '\uA779': 'D', + '\u01F1': 'DZ', + '\u01C4': 'DZ', + '\u01F2': 'Dz', + '\u01C5': 'Dz', + '\u24BA': 'E', + '\uFF25': 'E', + '\u00C8': 'E', + '\u00C9': 'E', + '\u00CA': 'E', + '\u1EC0': 'E', + '\u1EBE': 'E', + '\u1EC4': 'E', + '\u1EC2': 'E', + '\u1EBC': 'E', + '\u0112': 'E', + '\u1E14': 'E', + '\u1E16': 'E', + '\u0114': 'E', + '\u0116': 'E', + '\u00CB': 'E', + '\u1EBA': 'E', + '\u011A': 'E', + '\u0204': 'E', + '\u0206': 'E', + '\u1EB8': 'E', + '\u1EC6': 'E', + '\u0228': 'E', + '\u1E1C': 'E', + '\u0118': 'E', + '\u1E18': 'E', + '\u1E1A': 'E', + '\u0190': 'E', + '\u018E': 'E', + '\u24BB': 'F', + '\uFF26': 'F', + '\u1E1E': 'F', + '\u0191': 'F', + '\uA77B': 'F', + '\u24BC': 'G', + '\uFF27': 'G', + '\u01F4': 'G', + '\u011C': 'G', + '\u1E20': 'G', + '\u011E': 'G', + '\u0120': 'G', + '\u01E6': 'G', + '\u0122': 'G', + '\u01E4': 'G', + '\u0193': 'G', + '\uA7A0': 'G', + '\uA77D': 'G', + '\uA77E': 'G', + '\u24BD': 'H', + '\uFF28': 'H', + '\u0124': 'H', + '\u1E22': 'H', + '\u1E26': 'H', + '\u021E': 'H', + '\u1E24': 'H', + '\u1E28': 'H', + '\u1E2A': 'H', + '\u0126': 'H', + '\u2C67': 'H', + '\u2C75': 'H', + '\uA78D': 'H', + '\u24BE': 'I', + '\uFF29': 'I', + '\u00CC': 'I', + '\u00CD': 'I', + '\u00CE': 'I', + '\u0128': 'I', + '\u012A': 'I', + '\u012C': 'I', + '\u0130': 'I', + '\u00CF': 'I', + '\u1E2E': 'I', + '\u1EC8': 'I', + '\u01CF': 'I', + '\u0208': 'I', + '\u020A': 'I', + '\u1ECA': 'I', + '\u012E': 'I', + '\u1E2C': 'I', + '\u0197': 'I', + '\u24BF': 'J', + '\uFF2A': 'J', + '\u0134': 'J', + '\u0248': 'J', + '\u24C0': 'K', + '\uFF2B': 'K', + '\u1E30': 'K', + '\u01E8': 'K', + '\u1E32': 'K', + '\u0136': 'K', + '\u1E34': 'K', + '\u0198': 'K', + '\u2C69': 'K', + '\uA740': 'K', + '\uA742': 'K', + '\uA744': 'K', + '\uA7A2': 'K', + '\u24C1': 'L', + '\uFF2C': 'L', + '\u013F': 'L', + '\u0139': 'L', + '\u013D': 'L', + '\u1E36': 'L', + '\u1E38': 'L', + '\u013B': 'L', + '\u1E3C': 'L', + '\u1E3A': 'L', + '\u0141': 'L', + '\u023D': 'L', + '\u2C62': 'L', + '\u2C60': 'L', + '\uA748': 'L', + '\uA746': 'L', + '\uA780': 'L', + '\u01C7': 'LJ', + '\u01C8': 'Lj', + '\u24C2': 'M', + '\uFF2D': 'M', + '\u1E3E': 'M', + '\u1E40': 'M', + '\u1E42': 'M', + '\u2C6E': 'M', + '\u019C': 'M', + '\u24C3': 'N', + '\uFF2E': 'N', + '\u01F8': 'N', + '\u0143': 'N', + '\u00D1': 'N', + '\u1E44': 'N', + '\u0147': 'N', + '\u1E46': 'N', + '\u0145': 'N', + '\u1E4A': 'N', + '\u1E48': 'N', + '\u0220': 'N', + '\u019D': 'N', + '\uA790': 'N', + '\uA7A4': 'N', + '\u01CA': 'NJ', + '\u01CB': 'Nj', + '\u24C4': 'O', + '\uFF2F': 'O', + '\u00D2': 'O', + '\u00D3': 'O', + '\u00D4': 'O', + '\u1ED2': 'O', + '\u1ED0': 'O', + '\u1ED6': 'O', + '\u1ED4': 'O', + '\u00D5': 'O', + '\u1E4C': 'O', + '\u022C': 'O', + '\u1E4E': 'O', + '\u014C': 'O', + '\u1E50': 'O', + '\u1E52': 'O', + '\u014E': 'O', + '\u022E': 'O', + '\u0230': 'O', + '\u00D6': 'O', + '\u022A': 'O', + '\u1ECE': 'O', + '\u0150': 'O', + '\u01D1': 'O', + '\u020C': 'O', + '\u020E': 'O', + '\u01A0': 'O', + '\u1EDC': 'O', + '\u1EDA': 'O', + '\u1EE0': 'O', + '\u1EDE': 'O', + '\u1EE2': 'O', + '\u1ECC': 'O', + '\u1ED8': 'O', + '\u01EA': 'O', + '\u01EC': 'O', + '\u00D8': 'O', + '\u01FE': 'O', + '\u0186': 'O', + '\u019F': 'O', + '\uA74A': 'O', + '\uA74C': 'O', + '\u0152': 'OE', + '\u01A2': 'OI', + '\uA74E': 'OO', + '\u0222': 'OU', + '\u24C5': 'P', + '\uFF30': 'P', + '\u1E54': 'P', + '\u1E56': 'P', + '\u01A4': 'P', + '\u2C63': 'P', + '\uA750': 'P', + '\uA752': 'P', + '\uA754': 'P', + '\u24C6': 'Q', + '\uFF31': 'Q', + '\uA756': 'Q', + '\uA758': 'Q', + '\u024A': 'Q', + '\u24C7': 'R', + '\uFF32': 'R', + '\u0154': 'R', + '\u1E58': 'R', + '\u0158': 'R', + '\u0210': 'R', + '\u0212': 'R', + '\u1E5A': 'R', + '\u1E5C': 'R', + '\u0156': 'R', + '\u1E5E': 'R', + '\u024C': 'R', + '\u2C64': 'R', + '\uA75A': 'R', + '\uA7A6': 'R', + '\uA782': 'R', + '\u24C8': 'S', + '\uFF33': 'S', + '\u1E9E': 'S', + '\u015A': 'S', + '\u1E64': 'S', + '\u015C': 'S', + '\u1E60': 'S', + '\u0160': 'S', + '\u1E66': 'S', + '\u1E62': 'S', + '\u1E68': 'S', + '\u0218': 'S', + '\u015E': 'S', + '\u2C7E': 'S', + '\uA7A8': 'S', + '\uA784': 'S', + '\u24C9': 'T', + '\uFF34': 'T', + '\u1E6A': 'T', + '\u0164': 'T', + '\u1E6C': 'T', + '\u021A': 'T', + '\u0162': 'T', + '\u1E70': 'T', + '\u1E6E': 'T', + '\u0166': 'T', + '\u01AC': 'T', + '\u01AE': 'T', + '\u023E': 'T', + '\uA786': 'T', + '\uA728': 'TZ', + '\u24CA': 'U', + '\uFF35': 'U', + '\u00D9': 'U', + '\u00DA': 'U', + '\u00DB': 'U', + '\u0168': 'U', + '\u1E78': 'U', + '\u016A': 'U', + '\u1E7A': 'U', + '\u016C': 'U', + '\u00DC': 'U', + '\u01DB': 'U', + '\u01D7': 'U', + '\u01D5': 'U', + '\u01D9': 'U', + '\u1EE6': 'U', + '\u016E': 'U', + '\u0170': 'U', + '\u01D3': 'U', + '\u0214': 'U', + '\u0216': 'U', + '\u01AF': 'U', + '\u1EEA': 'U', + '\u1EE8': 'U', + '\u1EEE': 'U', + '\u1EEC': 'U', + '\u1EF0': 'U', + '\u1EE4': 'U', + '\u1E72': 'U', + '\u0172': 'U', + '\u1E76': 'U', + '\u1E74': 'U', + '\u0244': 'U', + '\u24CB': 'V', + '\uFF36': 'V', + '\u1E7C': 'V', + '\u1E7E': 'V', + '\u01B2': 'V', + '\uA75E': 'V', + '\u0245': 'V', + '\uA760': 'VY', + '\u24CC': 'W', + '\uFF37': 'W', + '\u1E80': 'W', + '\u1E82': 'W', + '\u0174': 'W', + '\u1E86': 'W', + '\u1E84': 'W', + '\u1E88': 'W', + '\u2C72': 'W', + '\u24CD': 'X', + '\uFF38': 'X', + '\u1E8A': 'X', + '\u1E8C': 'X', + '\u24CE': 'Y', + '\uFF39': 'Y', + '\u1EF2': 'Y', + '\u00DD': 'Y', + '\u0176': 'Y', + '\u1EF8': 'Y', + '\u0232': 'Y', + '\u1E8E': 'Y', + '\u0178': 'Y', + '\u1EF6': 'Y', + '\u1EF4': 'Y', + '\u01B3': 'Y', + '\u024E': 'Y', + '\u1EFE': 'Y', + '\u24CF': 'Z', + '\uFF3A': 'Z', + '\u0179': 'Z', + '\u1E90': 'Z', + '\u017B': 'Z', + '\u017D': 'Z', + '\u1E92': 'Z', + '\u1E94': 'Z', + '\u01B5': 'Z', + '\u0224': 'Z', + '\u2C7F': 'Z', + '\u2C6B': 'Z', + '\uA762': 'Z', + '\u24D0': 'a', + '\uFF41': 'a', + '\u1E9A': 'a', + '\u00E0': 'a', + '\u00E1': 'a', + '\u00E2': 'a', + '\u1EA7': 'a', + '\u1EA5': 'a', + '\u1EAB': 'a', + '\u1EA9': 'a', + '\u00E3': 'a', + '\u0101': 'a', + '\u0103': 'a', + '\u1EB1': 'a', + '\u1EAF': 'a', + '\u1EB5': 'a', + '\u1EB3': 'a', + '\u0227': 'a', + '\u01E1': 'a', + '\u00E4': 'a', + '\u01DF': 'a', + '\u1EA3': 'a', + '\u00E5': 'a', + '\u01FB': 'a', + '\u01CE': 'a', + '\u0201': 'a', + '\u0203': 'a', + '\u1EA1': 'a', + '\u1EAD': 'a', + '\u1EB7': 'a', + '\u1E01': 'a', + '\u0105': 'a', + '\u2C65': 'a', + '\u0250': 'a', + '\uA733': 'aa', + '\u00E6': 'ae', + '\u01FD': 'ae', + '\u01E3': 'ae', + '\uA735': 'ao', + '\uA737': 'au', + '\uA739': 'av', + '\uA73B': 'av', + '\uA73D': 'ay', + '\u24D1': 'b', + '\uFF42': 'b', + '\u1E03': 'b', + '\u1E05': 'b', + '\u1E07': 'b', + '\u0180': 'b', + '\u0183': 'b', + '\u0253': 'b', + '\u24D2': 'c', + '\uFF43': 'c', + '\u0107': 'c', + '\u0109': 'c', + '\u010B': 'c', + '\u010D': 'c', + '\u00E7': 'c', + '\u1E09': 'c', + '\u0188': 'c', + '\u023C': 'c', + '\uA73F': 'c', + '\u2184': 'c', + '\u24D3': 'd', + '\uFF44': 'd', + '\u1E0B': 'd', + '\u010F': 'd', + '\u1E0D': 'd', + '\u1E11': 'd', + '\u1E13': 'd', + '\u1E0F': 'd', + '\u0111': 'd', + '\u018C': 'd', + '\u0256': 'd', + '\u0257': 'd', + '\uA77A': 'd', + '\u01F3': 'dz', + '\u01C6': 'dz', + '\u24D4': 'e', + '\uFF45': 'e', + '\u00E8': 'e', + '\u00E9': 'e', + '\u00EA': 'e', + '\u1EC1': 'e', + '\u1EBF': 'e', + '\u1EC5': 'e', + '\u1EC3': 'e', + '\u1EBD': 'e', + '\u0113': 'e', + '\u1E15': 'e', + '\u1E17': 'e', + '\u0115': 'e', + '\u0117': 'e', + '\u00EB': 'e', + '\u1EBB': 'e', + '\u011B': 'e', + '\u0205': 'e', + '\u0207': 'e', + '\u1EB9': 'e', + '\u1EC7': 'e', + '\u0229': 'e', + '\u1E1D': 'e', + '\u0119': 'e', + '\u1E19': 'e', + '\u1E1B': 'e', + '\u0247': 'e', + '\u025B': 'e', + '\u01DD': 'e', + '\u24D5': 'f', + '\uFF46': 'f', + '\u1E1F': 'f', + '\u0192': 'f', + '\uA77C': 'f', + '\u24D6': 'g', + '\uFF47': 'g', + '\u01F5': 'g', + '\u011D': 'g', + '\u1E21': 'g', + '\u011F': 'g', + '\u0121': 'g', + '\u01E7': 'g', + '\u0123': 'g', + '\u01E5': 'g', + '\u0260': 'g', + '\uA7A1': 'g', + '\u1D79': 'g', + '\uA77F': 'g', + '\u24D7': 'h', + '\uFF48': 'h', + '\u0125': 'h', + '\u1E23': 'h', + '\u1E27': 'h', + '\u021F': 'h', + '\u1E25': 'h', + '\u1E29': 'h', + '\u1E2B': 'h', + '\u1E96': 'h', + '\u0127': 'h', + '\u2C68': 'h', + '\u2C76': 'h', + '\u0265': 'h', + '\u0195': 'hv', + '\u24D8': 'i', + '\uFF49': 'i', + '\u00EC': 'i', + '\u00ED': 'i', + '\u00EE': 'i', + '\u0129': 'i', + '\u012B': 'i', + '\u012D': 'i', + '\u00EF': 'i', + '\u1E2F': 'i', + '\u1EC9': 'i', + '\u01D0': 'i', + '\u0209': 'i', + '\u020B': 'i', + '\u1ECB': 'i', + '\u012F': 'i', + '\u1E2D': 'i', + '\u0268': 'i', + '\u0131': 'i', + '\u24D9': 'j', + '\uFF4A': 'j', + '\u0135': 'j', + '\u01F0': 'j', + '\u0249': 'j', + '\u24DA': 'k', + '\uFF4B': 'k', + '\u1E31': 'k', + '\u01E9': 'k', + '\u1E33': 'k', + '\u0137': 'k', + '\u1E35': 'k', + '\u0199': 'k', + '\u2C6A': 'k', + '\uA741': 'k', + '\uA743': 'k', + '\uA745': 'k', + '\uA7A3': 'k', + '\u24DB': 'l', + '\uFF4C': 'l', + '\u0140': 'l', + '\u013A': 'l', + '\u013E': 'l', + '\u1E37': 'l', + '\u1E39': 'l', + '\u013C': 'l', + '\u1E3D': 'l', + '\u1E3B': 'l', + '\u017F': 'l', + '\u0142': 'l', + '\u019A': 'l', + '\u026B': 'l', + '\u2C61': 'l', + '\uA749': 'l', + '\uA781': 'l', + '\uA747': 'l', + '\u01C9': 'lj', + '\u24DC': 'm', + '\uFF4D': 'm', + '\u1E3F': 'm', + '\u1E41': 'm', + '\u1E43': 'm', + '\u0271': 'm', + '\u026F': 'm', + '\u24DD': 'n', + '\uFF4E': 'n', + '\u01F9': 'n', + '\u0144': 'n', + '\u00F1': 'n', + '\u1E45': 'n', + '\u0148': 'n', + '\u1E47': 'n', + '\u0146': 'n', + '\u1E4B': 'n', + '\u1E49': 'n', + '\u019E': 'n', + '\u0272': 'n', + '\u0149': 'n', + '\uA791': 'n', + '\uA7A5': 'n', + '\u01CC': 'nj', + '\u24DE': 'o', + '\uFF4F': 'o', + '\u00F2': 'o', + '\u00F3': 'o', + '\u00F4': 'o', + '\u1ED3': 'o', + '\u1ED1': 'o', + '\u1ED7': 'o', + '\u1ED5': 'o', + '\u00F5': 'o', + '\u1E4D': 'o', + '\u022D': 'o', + '\u1E4F': 'o', + '\u014D': 'o', + '\u1E51': 'o', + '\u1E53': 'o', + '\u014F': 'o', + '\u022F': 'o', + '\u0231': 'o', + '\u00F6': 'o', + '\u022B': 'o', + '\u1ECF': 'o', + '\u0151': 'o', + '\u01D2': 'o', + '\u020D': 'o', + '\u020F': 'o', + '\u01A1': 'o', + '\u1EDD': 'o', + '\u1EDB': 'o', + '\u1EE1': 'o', + '\u1EDF': 'o', + '\u1EE3': 'o', + '\u1ECD': 'o', + '\u1ED9': 'o', + '\u01EB': 'o', + '\u01ED': 'o', + '\u00F8': 'o', + '\u01FF': 'o', + '\u0254': 'o', + '\uA74B': 'o', + '\uA74D': 'o', + '\u0275': 'o', + '\u0153': 'oe', + '\u01A3': 'oi', + '\u0223': 'ou', + '\uA74F': 'oo', + '\u24DF': 'p', + '\uFF50': 'p', + '\u1E55': 'p', + '\u1E57': 'p', + '\u01A5': 'p', + '\u1D7D': 'p', + '\uA751': 'p', + '\uA753': 'p', + '\uA755': 'p', + '\u24E0': 'q', + '\uFF51': 'q', + '\u024B': 'q', + '\uA757': 'q', + '\uA759': 'q', + '\u24E1': 'r', + '\uFF52': 'r', + '\u0155': 'r', + '\u1E59': 'r', + '\u0159': 'r', + '\u0211': 'r', + '\u0213': 'r', + '\u1E5B': 'r', + '\u1E5D': 'r', + '\u0157': 'r', + '\u1E5F': 'r', + '\u024D': 'r', + '\u027D': 'r', + '\uA75B': 'r', + '\uA7A7': 'r', + '\uA783': 'r', + '\u24E2': 's', + '\uFF53': 's', + '\u00DF': 's', + '\u015B': 's', + '\u1E65': 's', + '\u015D': 's', + '\u1E61': 's', + '\u0161': 's', + '\u1E67': 's', + '\u1E63': 's', + '\u1E69': 's', + '\u0219': 's', + '\u015F': 's', + '\u023F': 's', + '\uA7A9': 's', + '\uA785': 's', + '\u1E9B': 's', + '\u24E3': 't', + '\uFF54': 't', + '\u1E6B': 't', + '\u1E97': 't', + '\u0165': 't', + '\u1E6D': 't', + '\u021B': 't', + '\u0163': 't', + '\u1E71': 't', + '\u1E6F': 't', + '\u0167': 't', + '\u01AD': 't', + '\u0288': 't', + '\u2C66': 't', + '\uA787': 't', + '\uA729': 'tz', + '\u24E4': 'u', + '\uFF55': 'u', + '\u00F9': 'u', + '\u00FA': 'u', + '\u00FB': 'u', + '\u0169': 'u', + '\u1E79': 'u', + '\u016B': 'u', + '\u1E7B': 'u', + '\u016D': 'u', + '\u00FC': 'u', + '\u01DC': 'u', + '\u01D8': 'u', + '\u01D6': 'u', + '\u01DA': 'u', + '\u1EE7': 'u', + '\u016F': 'u', + '\u0171': 'u', + '\u01D4': 'u', + '\u0215': 'u', + '\u0217': 'u', + '\u01B0': 'u', + '\u1EEB': 'u', + '\u1EE9': 'u', + '\u1EEF': 'u', + '\u1EED': 'u', + '\u1EF1': 'u', + '\u1EE5': 'u', + '\u1E73': 'u', + '\u0173': 'u', + '\u1E77': 'u', + '\u1E75': 'u', + '\u0289': 'u', + '\u24E5': 'v', + '\uFF56': 'v', + '\u1E7D': 'v', + '\u1E7F': 'v', + '\u028B': 'v', + '\uA75F': 'v', + '\u028C': 'v', + '\uA761': 'vy', + '\u24E6': 'w', + '\uFF57': 'w', + '\u1E81': 'w', + '\u1E83': 'w', + '\u0175': 'w', + '\u1E87': 'w', + '\u1E85': 'w', + '\u1E98': 'w', + '\u1E89': 'w', + '\u2C73': 'w', + '\u24E7': 'x', + '\uFF58': 'x', + '\u1E8B': 'x', + '\u1E8D': 'x', + '\u24E8': 'y', + '\uFF59': 'y', + '\u1EF3': 'y', + '\u00FD': 'y', + '\u0177': 'y', + '\u1EF9': 'y', + '\u0233': 'y', + '\u1E8F': 'y', + '\u00FF': 'y', + '\u1EF7': 'y', + '\u1E99': 'y', + '\u1EF5': 'y', + '\u01B4': 'y', + '\u024F': 'y', + '\u1EFF': 'y', + '\u24E9': 'z', + '\uFF5A': 'z', + '\u017A': 'z', + '\u1E91': 'z', + '\u017C': 'z', + '\u017E': 'z', + '\u1E93': 'z', + '\u1E95': 'z', + '\u01B6': 'z', + '\u0225': 'z', + '\u0240': 'z', + '\u2C6C': 'z', + '\uA763': 'z', + '\u0386': '\u0391', + '\u0388': '\u0395', + '\u0389': '\u0397', + '\u038A': '\u0399', + '\u03AA': '\u0399', + '\u038C': '\u039F', + '\u038E': '\u03A5', + '\u03AB': '\u03A5', + '\u038F': '\u03A9', + '\u03AC': '\u03B1', + '\u03AD': '\u03B5', + '\u03AE': '\u03B7', + '\u03AF': '\u03B9', + '\u03CA': '\u03B9', + '\u0390': '\u03B9', + '\u03CC': '\u03BF', + '\u03CD': '\u03C5', + '\u03CB': '\u03C5', + '\u03B0': '\u03C5', + '\u03CE': '\u03C9', + '\u03C2': '\u03C3', + '\u2019': '\'' + }; + + return diacritics; + }); + + S2.define('select2/data/base', [ + '../utils' + ], function (Utils) { + function BaseAdapter($element, options) { + BaseAdapter.__super__.constructor.call(this); + } + + Utils.Extend(BaseAdapter, Utils.Observable); + + BaseAdapter.prototype.current = function (callback) { + throw new Error('The `current` method must be defined in child classes.'); + }; + + BaseAdapter.prototype.query = function (params, callback) { + throw new Error('The `query` method must be defined in child classes.'); + }; + + BaseAdapter.prototype.bind = function (container, $container) { + // Can be implemented in subclasses + }; + + BaseAdapter.prototype.destroy = function () { + // Can be implemented in subclasses + }; + + BaseAdapter.prototype.generateResultId = function (container, data) { + var id = container.id + '-result-'; + + id += Utils.generateChars(4); + + if (data.id != null) { + id += '-' + data.id.toString(); + } else { + id += '-' + Utils.generateChars(4); + } + return id; + }; + + return BaseAdapter; + }); + + S2.define('select2/data/select', [ + './base', + '../utils', + 'jquery' + ], function (BaseAdapter, Utils, $) { + function SelectAdapter($element, options) { + this.$element = $element; + this.options = options; + + SelectAdapter.__super__.constructor.call(this); + } + + Utils.Extend(SelectAdapter, BaseAdapter); + + SelectAdapter.prototype.current = function (callback) { + var data = []; + var self = this; + + this.$element.find(':selected').each(function () { + var $option = $(this); + + var option = self.item($option); + + data.push(option); + }); + + callback(data); + }; + + SelectAdapter.prototype.select = function (data) { + var self = this; + + data.selected = true; - var option = self.item($option); + // If data.element is a DOM node, use it instead + if ($(data.element).is('option')) { + data.element.selected = true; - var matches = self.matches(params, option); + this.$element.trigger('input').trigger('change'); - if (matches !== null) { - data.push(matches); - } - }); + return; + } - callback({ - results: data - }); - }; + if (this.$element.prop('multiple')) { + this.current(function (currentData) { + var val = []; - SelectAdapter.prototype.addOptions = function ($options) { - Utils.appendMany(this.$element, $options); - }; + data = [data]; + data.push.apply(data, currentData); - SelectAdapter.prototype.option = function (data) { - var option; + for (var d = 0; d < data.length; d++) { + var id = data[d].id; - if (data.children) { - option = document.createElement('optgroup'); - option.label = data.text; - } else { - option = document.createElement('option'); + if ($.inArray(id, val) === -1) { + val.push(id); + } + } - if (option.textContent !== undefined) { - option.textContent = data.text; - } else { - option.innerText = data.text; - } - } + self.$element.val(val); + self.$element.trigger('input').trigger('change'); + }); + } else { + var val = data.id; - if (data.id !== undefined) { - option.value = data.id; - } + this.$element.val(val); + this.$element.trigger('input').trigger('change'); + } + }; - if (data.disabled) { - option.disabled = true; - } + SelectAdapter.prototype.unselect = function (data) { + var self = this; - if (data.selected) { - option.selected = true; - } + if (!this.$element.prop('multiple')) { + return; + } - if (data.title) { - option.title = data.title; - } + data.selected = false; - var $option = $(option); + if ($(data.element).is('option')) { + data.element.selected = false; - var normalizedData = this._normalizeItem(data); - normalizedData.element = option; + this.$element.trigger('input').trigger('change'); - // Override the option's data with the combined data - Utils.StoreData(option, 'data', normalizedData); + return; + } - return $option; - }; + this.current(function (currentData) { + var val = []; - SelectAdapter.prototype.item = function ($option) { - var data = {}; + for (var d = 0; d < currentData.length; d++) { + var id = currentData[d].id; - data = Utils.GetData($option[0], 'data'); + if (id !== data.id && $.inArray(id, val) === -1) { + val.push(id); + } + } - if (data != null) { - return data; - } + self.$element.val(val); - if ($option.is('option')) { - data = { - id: $option.val(), - text: $option.text(), - disabled: $option.prop('disabled'), - selected: $option.prop('selected'), - title: $option.prop('title') - }; - } else if ($option.is('optgroup')) { - data = { - text: $option.prop('label'), - children: [], - title: $option.prop('title') - }; + self.$element.trigger('input').trigger('change'); + }); + }; - var $children = $option.children('option'); - var children = []; + SelectAdapter.prototype.bind = function (container, $container) { + var self = this; - for (var c = 0; c < $children.length; c++) { - var $child = $($children[c]); + this.container = container; - var child = this.item($child); + container.on('select', function (params) { + self.select(params.data); + }); - children.push(child); - } + container.on('unselect', function (params) { + self.unselect(params.data); + }); + }; - data.children = children; - } + SelectAdapter.prototype.destroy = function () { + // Remove anything added to child elements + this.$element.find('*').each(function () { + // Remove any custom data set by Select2 + Utils.RemoveData(this); + }); + }; - data = this._normalizeItem(data); - data.element = $option[0]; + SelectAdapter.prototype.query = function (params, callback) { + var data = []; + var self = this; - Utils.StoreData($option[0], 'data', data); + var $options = this.$element.children(); - return data; - }; + $options.each(function () { + var $option = $(this); - SelectAdapter.prototype._normalizeItem = function (item) { - if (item !== Object(item)) { - item = { - id: item, - text: item - }; - } + if (!$option.is('option') && !$option.is('optgroup')) { + return; + } - item = $.extend({}, { - text: '' - }, item); + var option = self.item($option); - var defaults = { - selected: false, - disabled: false - }; + var matches = self.matches(params, option); - if (item.id != null) { - item.id = item.id.toString(); - } + if (matches !== null) { + data.push(matches); + } + }); - if (item.text != null) { - item.text = item.text.toString(); - } + callback({ + results: data + }); + }; - if (item._resultId == null && item.id && this.container != null) { - item._resultId = this.generateResultId(this.container, item); - } + SelectAdapter.prototype.addOptions = function ($options) { + Utils.appendMany(this.$element, $options); + }; - return $.extend({}, defaults, item); - }; + SelectAdapter.prototype.option = function (data) { + var option; - SelectAdapter.prototype.matches = function (params, data) { - var matcher = this.options.get('matcher'); + if (data.children) { + option = document.createElement('optgroup'); + option.label = data.text; + } else { + option = document.createElement('option'); - return matcher(params, data); - }; + if (option.textContent !== undefined) { + option.textContent = data.text; + } else { + option.innerText = data.text; + } + } - return SelectAdapter; -}); + if (data.id !== undefined) { + option.value = data.id; + } -S2.define('select2/data/array',[ - './select', - '../utils', - 'jquery' -], function (SelectAdapter, Utils, $) { - function ArrayAdapter ($element, options) { - this._dataToConvert = options.get('data') || []; + if (data.disabled) { + option.disabled = true; + } - ArrayAdapter.__super__.constructor.call(this, $element, options); - } + if (data.selected) { + option.selected = true; + } - Utils.Extend(ArrayAdapter, SelectAdapter); + if (data.title) { + option.title = data.title; + } - ArrayAdapter.prototype.bind = function (container, $container) { - ArrayAdapter.__super__.bind.call(this, container, $container); + var $option = $(option); - this.addOptions(this.convertToOptions(this._dataToConvert)); - }; + var normalizedData = this._normalizeItem(data); + normalizedData.element = option; - ArrayAdapter.prototype.select = function (data) { - var $option = this.$element.find('option').filter(function (i, elm) { - return elm.value == data.id.toString(); - }); + // Override the option's data with the combined data + Utils.StoreData(option, 'data', normalizedData); - if ($option.length === 0) { - $option = this.option(data); + return $option; + }; - this.addOptions($option); - } + SelectAdapter.prototype.item = function ($option) { + var data = {}; - ArrayAdapter.__super__.select.call(this, data); - }; + data = Utils.GetData($option[0], 'data'); - ArrayAdapter.prototype.convertToOptions = function (data) { - var self = this; + if (data != null) { + return data; + } - var $existing = this.$element.find('option'); - var existingIds = $existing.map(function () { - return self.item($(this)).id; - }).get(); + if ($option.is('option')) { + data = { + id: $option.val(), + text: $option.text(), + disabled: $option.prop('disabled'), + selected: $option.prop('selected'), + title: $option.prop('title') + }; + } else if ($option.is('optgroup')) { + data = { + text: $option.prop('label'), + children: [], + title: $option.prop('title') + }; - var $options = []; + var $children = $option.children('option'); + var children = []; - // Filter out all items except for the one passed in the argument - function onlyItem (item) { - return function () { - return $(this).val() == item.id; - }; - } + for (var c = 0; c < $children.length; c++) { + var $child = $($children[c]); - for (var d = 0; d < data.length; d++) { - var item = this._normalizeItem(data[d]); + var child = this.item($child); - // Skip items which were pre-loaded, only merge the data - if ($.inArray(item.id, existingIds) >= 0) { - var $existingOption = $existing.filter(onlyItem(item)); + children.push(child); + } - var existingData = this.item($existingOption); - var newData = $.extend(true, {}, item, existingData); + data.children = children; + } - var $newOption = this.option(newData); + data = this._normalizeItem(data); + data.element = $option[0]; - $existingOption.replaceWith($newOption); + Utils.StoreData($option[0], 'data', data); - continue; - } + return data; + }; - var $option = this.option(item); + SelectAdapter.prototype._normalizeItem = function (item) { + if (item !== Object(item)) { + item = { + id: item, + text: item + }; + } - if (item.children) { - var $children = this.convertToOptions(item.children); + item = $.extend({}, { + text: '' + }, item); - Utils.appendMany($option, $children); - } + var defaults = { + selected: false, + disabled: false + }; - $options.push($option); - } + if (item.id != null) { + item.id = item.id.toString(); + } - return $options; - }; + if (item.text != null) { + item.text = item.text.toString(); + } - return ArrayAdapter; -}); + if (item._resultId == null && item.id && this.container != null) { + item._resultId = this.generateResultId(this.container, item); + } -S2.define('select2/data/ajax',[ - './array', - '../utils', - 'jquery' -], function (ArrayAdapter, Utils, $) { - function AjaxAdapter ($element, options) { - this.ajaxOptions = this._applyDefaults(options.get('ajax')); + return $.extend({}, defaults, item); + }; - if (this.ajaxOptions.processResults != null) { - this.processResults = this.ajaxOptions.processResults; - } + SelectAdapter.prototype.matches = function (params, data) { + var matcher = this.options.get('matcher'); - AjaxAdapter.__super__.constructor.call(this, $element, options); - } - - Utils.Extend(AjaxAdapter, ArrayAdapter); - - AjaxAdapter.prototype._applyDefaults = function (options) { - var defaults = { - data: function (params) { - return $.extend({}, params, { - q: params.term - }); - }, - transport: function (params, success, failure) { - var $request = $.ajax(params); + return matcher(params, data); + }; - $request.then(success); - $request.fail(failure); + return SelectAdapter; + }); - return $request; - } - }; + S2.define('select2/data/array', [ + './select', + '../utils', + 'jquery' + ], function (SelectAdapter, Utils, $) { + function ArrayAdapter($element, options) { + this._dataToConvert = options.get('data') || []; - return $.extend({}, defaults, options, true); - }; + ArrayAdapter.__super__.constructor.call(this, $element, options); + } - AjaxAdapter.prototype.processResults = function (results) { - return results; - }; + Utils.Extend(ArrayAdapter, SelectAdapter); - AjaxAdapter.prototype.query = function (params, callback) { - var matches = []; - var self = this; + ArrayAdapter.prototype.bind = function (container, $container) { + ArrayAdapter.__super__.bind.call(this, container, $container); - if (this._request != null) { - // JSONP requests cannot always be aborted - if ($.isFunction(this._request.abort)) { - this._request.abort(); - } + this.addOptions(this.convertToOptions(this._dataToConvert)); + }; - this._request = null; - } + ArrayAdapter.prototype.select = function (data) { + var $option = this.$element.find('option').filter(function (i, elm) { + return elm.value == data.id.toString(); + }); - var options = $.extend({ - type: 'GET' - }, this.ajaxOptions); + if ($option.length === 0) { + $option = this.option(data); - if (typeof options.url === 'function') { - options.url = options.url.call(this.$element, params); - } + this.addOptions($option); + } - if (typeof options.data === 'function') { - options.data = options.data.call(this.$element, params); - } + ArrayAdapter.__super__.select.call(this, data); + }; - function request () { - var $request = options.transport(options, function (data) { - var results = self.processResults(data, params); + ArrayAdapter.prototype.convertToOptions = function (data) { + var self = this; - if (self.options.get('debug') && window.console && console.error) { - // Check to make sure that the response included a `results` key. - if (!results || !results.results || !$.isArray(results.results)) { - console.error( - 'Select2: The AJAX results did not return an array in the ' + - '`results` key of the response.' - ); - } - } + var $existing = this.$element.find('option'); + var existingIds = $existing.map(function () { + return self.item($(this)).id; + }).get(); - callback(results); - }, function () { - // Attempt to detect if a request was aborted - // Only works if the transport exposes a status property - if ('status' in $request && - ($request.status === 0 || $request.status === '0')) { - return; - } - - self.trigger('results:message', { - message: 'errorLoading' - }); - }); - - self._request = $request; - } - - if (this.ajaxOptions.delay && params.term != null) { - if (this._queryTimeout) { - window.clearTimeout(this._queryTimeout); - } - - this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay); - } else { - request(); - } - }; + var $options = []; - return AjaxAdapter; -}); + // Filter out all items except for the one passed in the argument + function onlyItem(item) { + return function () { + return $(this).val() == item.id; + }; + } -S2.define('select2/data/tags',[ - 'jquery' -], function ($) { - function Tags (decorated, $element, options) { - var tags = options.get('tags'); + for (var d = 0; d < data.length; d++) { + var item = this._normalizeItem(data[d]); - var createTag = options.get('createTag'); + // Skip items which were pre-loaded, only merge the data + if ($.inArray(item.id, existingIds) >= 0) { + var $existingOption = $existing.filter(onlyItem(item)); - if (createTag !== undefined) { - this.createTag = createTag; - } + var existingData = this.item($existingOption); + var newData = $.extend(true, {}, item, existingData); - var insertTag = options.get('insertTag'); + var $newOption = this.option(newData); - if (insertTag !== undefined) { - this.insertTag = insertTag; - } + $existingOption.replaceWith($newOption); - decorated.call(this, $element, options); + continue; + } - if ($.isArray(tags)) { - for (var t = 0; t < tags.length; t++) { - var tag = tags[t]; - var item = this._normalizeItem(tag); + var $option = this.option(item); - var $option = this.option(item); + if (item.children) { + var $children = this.convertToOptions(item.children); - this.$element.append($option); - } - } - } + Utils.appendMany($option, $children); + } - Tags.prototype.query = function (decorated, params, callback) { - var self = this; + $options.push($option); + } - this._removeOldTags(); + return $options; + }; - if (params.term == null || params.page != null) { - decorated.call(this, params, callback); - return; - } + return ArrayAdapter; + }); - function wrapper (obj, child) { - var data = obj.results; + S2.define('select2/data/ajax', [ + './array', + '../utils', + 'jquery' + ], function (ArrayAdapter, Utils, $) { + function AjaxAdapter($element, options) { + this.ajaxOptions = this._applyDefaults(options.get('ajax')); - for (var i = 0; i < data.length; i++) { - var option = data[i]; + if (this.ajaxOptions.processResults != null) { + this.processResults = this.ajaxOptions.processResults; + } - var checkChildren = ( - option.children != null && - !wrapper({ - results: option.children - }, true) - ); + AjaxAdapter.__super__.constructor.call(this, $element, options); + } + + Utils.Extend(AjaxAdapter, ArrayAdapter); + + AjaxAdapter.prototype._applyDefaults = function (options) { + var defaults = { + data: function (params) { + return $.extend({}, params, { + q: params.term + }); + }, + transport: function (params, success, failure) { + var $request = $.ajax(params); - var optionText = (option.text || '').toUpperCase(); - var paramsTerm = (params.term || '').toUpperCase(); + $request.then(success); + $request.fail(failure); - var checkText = optionText === paramsTerm; + return $request; + } + }; - if (checkText || checkChildren) { - if (child) { - return false; - } + return $.extend({}, defaults, options, true); + }; - obj.data = data; - callback(obj); + AjaxAdapter.prototype.processResults = function (results) { + return results; + }; - return; - } - } + AjaxAdapter.prototype.query = function (params, callback) { + var matches = []; + var self = this; - if (child) { - return true; - } + if (this._request != null) { + // JSONP requests cannot always be aborted + if ($.isFunction(this._request.abort)) { + this._request.abort(); + } - var tag = self.createTag(params); + this._request = null; + } - if (tag != null) { - var $option = self.option(tag); - $option.attr('data-select2-tag', true); + var options = $.extend({ + type: 'GET' + }, this.ajaxOptions); - self.addOptions([$option]); + if (typeof options.url === 'function') { + options.url = options.url.call(this.$element, params); + } - self.insertTag(data, tag); - } + if (typeof options.data === 'function') { + options.data = options.data.call(this.$element, params); + } - obj.results = data; + function request() { + var $request = options.transport(options, function (data) { + var results = self.processResults(data, params); - callback(obj); - } + if (self.options.get('debug') && window.console && console.error) { + // Check to make sure that the response included a `results` key. + if (!results || !results.results || !$.isArray(results.results)) { + console.error( + 'Select2: The AJAX results did not return an array in the ' + + '`results` key of the response.' + ); + } + } - decorated.call(this, params, wrapper); - }; + callback(results); + }, function () { + // Attempt to detect if a request was aborted + // Only works if the transport exposes a status property + if ('status' in $request && + ($request.status === 0 || $request.status === '0')) { + return; + } + + self.trigger('results:message', { + message: 'errorLoading' + }); + }); + + self._request = $request; + } + + if (this.ajaxOptions.delay && params.term != null) { + if (this._queryTimeout) { + window.clearTimeout(this._queryTimeout); + } + + this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay); + } else { + request(); + } + }; - Tags.prototype.createTag = function (decorated, params) { - var term = $.trim(params.term); + return AjaxAdapter; + }); - if (term === '') { - return null; - } + S2.define('select2/data/tags', [ + 'jquery' + ], function ($) { + function Tags(decorated, $element, options) { + var tags = options.get('tags'); - return { - id: term, - text: term - }; - }; + var createTag = options.get('createTag'); - Tags.prototype.insertTag = function (_, data, tag) { - data.unshift(tag); - }; + if (createTag !== undefined) { + this.createTag = createTag; + } - Tags.prototype._removeOldTags = function (_) { - var $options = this.$element.find('option[data-select2-tag]'); + var insertTag = options.get('insertTag'); - $options.each(function () { - if (this.selected) { - return; - } + if (insertTag !== undefined) { + this.insertTag = insertTag; + } - $(this).remove(); - }); - }; + decorated.call(this, $element, options); - return Tags; -}); + if ($.isArray(tags)) { + for (var t = 0; t < tags.length; t++) { + var tag = tags[t]; + var item = this._normalizeItem(tag); -S2.define('select2/data/tokenizer',[ - 'jquery' -], function ($) { - function Tokenizer (decorated, $element, options) { - var tokenizer = options.get('tokenizer'); + var $option = this.option(item); - if (tokenizer !== undefined) { - this.tokenizer = tokenizer; - } + this.$element.append($option); + } + } + } - decorated.call(this, $element, options); - } + Tags.prototype.query = function (decorated, params, callback) { + var self = this; - Tokenizer.prototype.bind = function (decorated, container, $container) { - decorated.call(this, container, $container); + this._removeOldTags(); - this.$search = container.dropdown.$search || container.selection.$search || - $container.find('.select2-search__field'); - }; + if (params.term == null || params.page != null) { + decorated.call(this, params, callback); + return; + } - Tokenizer.prototype.query = function (decorated, params, callback) { - var self = this; + function wrapper(obj, child) { + var data = obj.results; - function createAndSelect (data) { - // Normalize the data object so we can use it for checks - var item = self._normalizeItem(data); + for (var i = 0; i < data.length; i++) { + var option = data[i]; - // Check if the data object already exists as a tag - // Select it if it doesn't - var $existingOptions = self.$element.find('option').filter(function () { - return $(this).val() === item.id; - }); + var checkChildren = ( + option.children != null && + !wrapper({ + results: option.children + }, true) + ); - // If an existing option wasn't found for it, create the option - if (!$existingOptions.length) { - var $option = self.option(item); - $option.attr('data-select2-tag', true); + var optionText = (option.text || '').toUpperCase(); + var paramsTerm = (params.term || '').toUpperCase(); - self._removeOldTags(); - self.addOptions([$option]); - } + var checkText = optionText === paramsTerm; - // Select the item, now that we know there is an option for it - select(item); - } + if (checkText || checkChildren) { + if (child) { + return false; + } - function select (data) { - self.trigger('select', { - data: data - }); - } + obj.data = data; + callback(obj); - params.term = params.term || ''; + return; + } + } - var tokenData = this.tokenizer(params, this.options, createAndSelect); + if (child) { + return true; + } - if (tokenData.term !== params.term) { - // Replace the search term if we have the search box - if (this.$search.length) { - this.$search.val(tokenData.term); - this.$search.trigger('focus'); - } + var tag = self.createTag(params); - params.term = tokenData.term; - } + if (tag != null) { + var $option = self.option(tag); + $option.attr('data-select2-tag', true); - decorated.call(this, params, callback); - }; - - Tokenizer.prototype.tokenizer = function (_, params, options, callback) { - var separators = options.get('tokenSeparators') || []; - var term = params.term; - var i = 0; + self.addOptions([$option]); - var createTag = this.createTag || function (params) { - return { - id: params.term, - text: params.term - }; - }; + self.insertTag(data, tag); + } - while (i < term.length) { - var termChar = term[i]; + obj.results = data; - if ($.inArray(termChar, separators) === -1) { - i++; + callback(obj); + } - continue; - } + decorated.call(this, params, wrapper); + }; - var part = term.substr(0, i); - var partParams = $.extend({}, params, { - term: part - }); + Tags.prototype.createTag = function (decorated, params) { + var term = $.trim(params.term); - var data = createTag(partParams); + if (term === '') { + return null; + } - if (data == null) { - i++; - continue; - } + return { + id: term, + text: term + }; + }; - callback(data); + Tags.prototype.insertTag = function (_, data, tag) { + data.unshift(tag); + }; - // Reset the term to not include the tokenized portion - term = term.substr(i + 1) || ''; - i = 0; - } + Tags.prototype._removeOldTags = function (_) { + var $options = this.$element.find('option[data-select2-tag]'); - return { - term: term - }; - }; + $options.each(function () { + if (this.selected) { + return; + } - return Tokenizer; -}); + $(this).remove(); + }); + }; -S2.define('select2/data/minimumInputLength',[ + return Tags; + }); -], function () { - function MinimumInputLength (decorated, $e, options) { - this.minimumInputLength = options.get('minimumInputLength'); - - decorated.call(this, $e, options); - } - - MinimumInputLength.prototype.query = function (decorated, params, callback) { - params.term = params.term || ''; - - if (params.term.length < this.minimumInputLength) { - this.trigger('results:message', { - message: 'inputTooShort', - args: { - minimum: this.minimumInputLength, - input: params.term, - params: params - } - }); - - return; - } - - decorated.call(this, params, callback); - }; - - return MinimumInputLength; -}); - -S2.define('select2/data/maximumInputLength',[ - -], function () { - function MaximumInputLength (decorated, $e, options) { - this.maximumInputLength = options.get('maximumInputLength'); - - decorated.call(this, $e, options); - } - - MaximumInputLength.prototype.query = function (decorated, params, callback) { - params.term = params.term || ''; - - if (this.maximumInputLength > 0 && - params.term.length > this.maximumInputLength) { - this.trigger('results:message', { - message: 'inputTooLong', - args: { - maximum: this.maximumInputLength, - input: params.term, - params: params - } - }); - - return; - } - - decorated.call(this, params, callback); - }; - - return MaximumInputLength; -}); + S2.define('select2/data/tokenizer', [ + 'jquery' + ], function ($) { + function Tokenizer(decorated, $element, options) { + var tokenizer = options.get('tokenizer'); -S2.define('select2/data/maximumSelectionLength',[ - -], function (){ - function MaximumSelectionLength (decorated, $e, options) { - this.maximumSelectionLength = options.get('maximumSelectionLength'); - - decorated.call(this, $e, options); - } - - MaximumSelectionLength.prototype.bind = - function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - container.on('select', function () { - self._checkIfMaximumSelected(); - }); - }; - - MaximumSelectionLength.prototype.query = - function (decorated, params, callback) { - var self = this; - - this._checkIfMaximumSelected(function () { - decorated.call(self, params, callback); - }); - }; + if (tokenizer !== undefined) { + this.tokenizer = tokenizer; + } - MaximumSelectionLength.prototype._checkIfMaximumSelected = - function (_, successCallback) { - var self = this; + decorated.call(this, $element, options); + } - this.current(function (currentData) { - var count = currentData != null ? currentData.length : 0; - if (self.maximumSelectionLength > 0 && - count >= self.maximumSelectionLength) { - self.trigger('results:message', { - message: 'maximumSelected', - args: { - maximum: self.maximumSelectionLength - } - }); - return; - } - - if (successCallback) { - successCallback(); - } - }); - }; - - return MaximumSelectionLength; -}); + Tokenizer.prototype.bind = function (decorated, container, $container) { + decorated.call(this, container, $container); -S2.define('select2/dropdown',[ - 'jquery', - './utils' -], function ($, Utils) { - function Dropdown ($element, options) { - this.$element = $element; - this.options = options; - - Dropdown.__super__.constructor.call(this); - } - - Utils.Extend(Dropdown, Utils.Observable); + this.$search = container.dropdown.$search || container.selection.$search || + $container.find('.select2-search__field'); + }; - Dropdown.prototype.render = function () { - var $dropdown = $( - '' + - '' + - '' - ); - - $dropdown.attr('dir', this.options.get('dir')); - - this.$dropdown = $dropdown; - - return $dropdown; - }; - - Dropdown.prototype.bind = function () { - // Should be implemented in subclasses - }; - - Dropdown.prototype.position = function ($dropdown, $container) { - // Should be implemented in subclasses - }; - - Dropdown.prototype.destroy = function () { - // Remove the dropdown from the DOM - this.$dropdown.remove(); - }; - - return Dropdown; -}); - -S2.define('select2/dropdown/search',[ - 'jquery', - '../utils' -], function ($, Utils) { - function Search () { } - - Search.prototype.render = function (decorated) { - var $rendered = decorated.call(this); - - var $search = $( - '' + - '' + - '' - ); - - this.$searchContainer = $search; - this.$search = $search.find('input'); - - $rendered.prepend($search); - - return $rendered; - }; - - Search.prototype.bind = function (decorated, container, $container) { - var self = this; - - var resultsId = container.id + '-results'; - - decorated.call(this, container, $container); - - this.$search.on('keydown', function (evt) { - self.trigger('keypress', evt); - - self._keyUpPrevented = evt.isDefaultPrevented(); - }); - - // Workaround for browsers which do not support the `input` event - // This will prevent double-triggering of events for browsers which support - // both the `keyup` and `input` events. - this.$search.on('input', function (evt) { - // Unbind the duplicated `keyup` event - $(this).off('keyup'); - }); - - this.$search.on('keyup input', function (evt) { - self.handleSearch(evt); - }); - - container.on('open', function () { - self.$search.attr('tabindex', 0); - self.$search.attr('aria-controls', resultsId); + Tokenizer.prototype.query = function (decorated, params, callback) { + var self = this; - self.$search.trigger('focus'); + function createAndSelect(data) { + // Normalize the data object so we can use it for checks + var item = self._normalizeItem(data); - window.setTimeout(function () { - self.$search.trigger('focus'); - }, 0); - }); + // Check if the data object already exists as a tag + // Select it if it doesn't + var $existingOptions = self.$element.find('option').filter(function () { + return $(this).val() === item.id; + }); - container.on('close', function () { - self.$search.attr('tabindex', -1); - self.$search.removeAttr('aria-controls'); - self.$search.removeAttr('aria-activedescendant'); + // If an existing option wasn't found for it, create the option + if (!$existingOptions.length) { + var $option = self.option(item); + $option.attr('data-select2-tag', true); - self.$search.val(''); - self.$search.trigger('blur'); - }); + self._removeOldTags(); + self.addOptions([$option]); + } - container.on('focus', function () { - if (!container.isOpen()) { - self.$search.trigger('focus'); - } - }); + // Select the item, now that we know there is an option for it + select(item); + } - container.on('results:all', function (params) { - if (params.query.term == null || params.query.term === '') { - var showSearch = self.showSearch(params); + function select(data) { + self.trigger('select', { + data: data + }); + } - if (showSearch) { - self.$searchContainer.removeClass('select2-search--hide'); - } else { - self.$searchContainer.addClass('select2-search--hide'); - } - } - }); + params.term = params.term || ''; - container.on('results:focus', function (params) { - if (params.data._resultId) { - self.$search.attr('aria-activedescendant', params.data._resultId); - } else { - self.$search.removeAttr('aria-activedescendant'); - } - }); - }; + var tokenData = this.tokenizer(params, this.options, createAndSelect); - Search.prototype.handleSearch = function (evt) { - if (!this._keyUpPrevented) { - var input = this.$search.val(); + if (tokenData.term !== params.term) { + // Replace the search term if we have the search box + if (this.$search.length) { + this.$search.val(tokenData.term); + this.$search.trigger('focus'); + } + + params.term = tokenData.term; + } + + decorated.call(this, params, callback); + }; + + Tokenizer.prototype.tokenizer = function (_, params, options, callback) { + var separators = options.get('tokenSeparators') || []; + var term = params.term; + var i = 0; + + var createTag = this.createTag || function (params) { + return { + id: params.term, + text: params.term + }; + }; - this.trigger('query', { - term: input - }); - } + while (i < term.length) { + var termChar = term[i]; - this._keyUpPrevented = false; - }; + if ($.inArray(termChar, separators) === -1) { + i++; - Search.prototype.showSearch = function (_, params) { - return true; - }; + continue; + } - return Search; -}); + var part = term.substr(0, i); + var partParams = $.extend({}, params, { + term: part + }); -S2.define('select2/dropdown/hidePlaceholder',[ + var data = createTag(partParams); -], function () { - function HidePlaceholder (decorated, $element, options, dataAdapter) { - this.placeholder = this.normalizePlaceholder(options.get('placeholder')); + if (data == null) { + i++; + continue; + } + + callback(data); - decorated.call(this, $element, options, dataAdapter); - } + // Reset the term to not include the tokenized portion + term = term.substr(i + 1) || ''; + i = 0; + } - HidePlaceholder.prototype.append = function (decorated, data) { - data.results = this.removePlaceholder(data.results); + return { + term: term + }; + }; + + return Tokenizer; + }); + + S2.define('select2/data/minimumInputLength', [], function () { + function MinimumInputLength(decorated, $e, options) { + this.minimumInputLength = options.get('minimumInputLength'); + + decorated.call(this, $e, options); + } + + MinimumInputLength.prototype.query = function (decorated, params, callback) { + params.term = params.term || ''; + + if (params.term.length < this.minimumInputLength) { + this.trigger('results:message', { + message: 'inputTooShort', + args: { + minimum: this.minimumInputLength, + input: params.term, + params: params + } + }); + + return; + } + + decorated.call(this, params, callback); + }; + + return MinimumInputLength; + }); + + S2.define('select2/data/maximumInputLength', [], function () { + function MaximumInputLength(decorated, $e, options) { + this.maximumInputLength = options.get('maximumInputLength'); + + decorated.call(this, $e, options); + } + + MaximumInputLength.prototype.query = function (decorated, params, callback) { + params.term = params.term || ''; + + if (this.maximumInputLength > 0 && + params.term.length > this.maximumInputLength) { + this.trigger('results:message', { + message: 'inputTooLong', + args: { + maximum: this.maximumInputLength, + input: params.term, + params: params + } + }); + + return; + } + + decorated.call(this, params, callback); + }; + + return MaximumInputLength; + }); + + S2.define('select2/data/maximumSelectionLength', [], function () { + function MaximumSelectionLength(decorated, $e, options) { + this.maximumSelectionLength = options.get('maximumSelectionLength'); + + decorated.call(this, $e, options); + } + + MaximumSelectionLength.prototype.bind = + function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + container.on('select', function () { + self._checkIfMaximumSelected(); + }); + }; + + MaximumSelectionLength.prototype.query = + function (decorated, params, callback) { + var self = this; + + this._checkIfMaximumSelected(function () { + decorated.call(self, params, callback); + }); + }; + + MaximumSelectionLength.prototype._checkIfMaximumSelected = + function (_, successCallback) { + var self = this; + + this.current(function (currentData) { + var count = currentData != null ? currentData.length : 0; + if (self.maximumSelectionLength > 0 && + count >= self.maximumSelectionLength) { + self.trigger('results:message', { + message: 'maximumSelected', + args: { + maximum: self.maximumSelectionLength + } + }); + return; + } + + if (successCallback) { + successCallback(); + } + }); + }; + + return MaximumSelectionLength; + }); + + S2.define('select2/dropdown', [ + 'jquery', + './utils' + ], function ($, Utils) { + function Dropdown($element, options) { + this.$element = $element; + this.options = options; + + Dropdown.__super__.constructor.call(this); + } + + Utils.Extend(Dropdown, Utils.Observable); + + Dropdown.prototype.render = function () { + var $dropdown = $( + '' + + '' + + '' + ); + + $dropdown.attr('dir', this.options.get('dir')); + + this.$dropdown = $dropdown; + + return $dropdown; + }; + + Dropdown.prototype.bind = function () { + // Should be implemented in subclasses + }; + + Dropdown.prototype.position = function ($dropdown, $container) { + // Should be implemented in subclasses + }; + + Dropdown.prototype.destroy = function () { + // Remove the dropdown from the DOM + this.$dropdown.remove(); + }; + + return Dropdown; + }); + + S2.define('select2/dropdown/search', [ + 'jquery', + '../utils' + ], function ($, Utils) { + function Search() { + } + + Search.prototype.render = function (decorated) { + var $rendered = decorated.call(this); + + var $search = $( + '' + + '' + + '' + ); + + this.$searchContainer = $search; + this.$search = $search.find('input'); + + $rendered.prepend($search); + + return $rendered; + }; + + Search.prototype.bind = function (decorated, container, $container) { + var self = this; + + var resultsId = container.id + '-results'; + + decorated.call(this, container, $container); + + this.$search.on('keydown', function (evt) { + self.trigger('keypress', evt); + + self._keyUpPrevented = evt.isDefaultPrevented(); + }); + + // Workaround for browsers which do not support the `input` event + // This will prevent double-triggering of events for browsers which support + // both the `keyup` and `input` events. + this.$search.on('input', function (evt) { + // Unbind the duplicated `keyup` event + $(this).off('keyup'); + }); + + this.$search.on('keyup input', function (evt) { + self.handleSearch(evt); + }); + + container.on('open', function () { + self.$search.attr('tabindex', 0); + self.$search.attr('aria-controls', resultsId); + + self.$search.trigger('focus'); + + window.setTimeout(function () { + self.$search.trigger('focus'); + }, 0); + }); + + container.on('close', function () { + self.$search.attr('tabindex', -1); + self.$search.removeAttr('aria-controls'); + self.$search.removeAttr('aria-activedescendant'); - decorated.call(this, data); - }; + self.$search.val(''); + self.$search.trigger('blur'); + }); + + container.on('focus', function () { + if (!container.isOpen()) { + self.$search.trigger('focus'); + } + }); - HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) { - if (typeof placeholder === 'string') { - placeholder = { - id: '', - text: placeholder - }; - } - - return placeholder; - }; - - HidePlaceholder.prototype.removePlaceholder = function (_, data) { - var modifiedData = data.slice(0); + container.on('results:all', function (params) { + if (params.query.term == null || params.query.term === '') { + var showSearch = self.showSearch(params); + + if (showSearch) { + self.$searchContainer.removeClass('select2-search--hide'); + } else { + self.$searchContainer.addClass('select2-search--hide'); + } + } + }); + + container.on('results:focus', function (params) { + if (params.data._resultId) { + self.$search.attr('aria-activedescendant', params.data._resultId); + } else { + self.$search.removeAttr('aria-activedescendant'); + } + }); + }; + + Search.prototype.handleSearch = function (evt) { + if (!this._keyUpPrevented) { + var input = this.$search.val(); + + this.trigger('query', { + term: input + }); + } - for (var d = data.length - 1; d >= 0; d--) { - var item = data[d]; + this._keyUpPrevented = false; + }; - if (this.placeholder.id === item.id) { - modifiedData.splice(d, 1); - } - } + Search.prototype.showSearch = function (_, params) { + return true; + }; + + return Search; + }); - return modifiedData; - }; + S2.define('select2/dropdown/hidePlaceholder', [], function () { + function HidePlaceholder(decorated, $element, options, dataAdapter) { + this.placeholder = this.normalizePlaceholder(options.get('placeholder')); - return HidePlaceholder; -}); + decorated.call(this, $element, options, dataAdapter); + } + + HidePlaceholder.prototype.append = function (decorated, data) { + data.results = this.removePlaceholder(data.results); -S2.define('select2/dropdown/infiniteScroll',[ - 'jquery' -], function ($) { - function InfiniteScroll (decorated, $element, options, dataAdapter) { - this.lastParams = {}; + decorated.call(this, data); + }; - decorated.call(this, $element, options, dataAdapter); + HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) { + if (typeof placeholder === 'string') { + placeholder = { + id: '', + text: placeholder + }; + } + + return placeholder; + }; + + HidePlaceholder.prototype.removePlaceholder = function (_, data) { + var modifiedData = data.slice(0); + + for (var d = data.length - 1; d >= 0; d--) { + var item = data[d]; - this.$loadingMore = this.createLoadingMore(); - this.loading = false; - } + if (this.placeholder.id === item.id) { + modifiedData.splice(d, 1); + } + } - InfiniteScroll.prototype.append = function (decorated, data) { - this.$loadingMore.remove(); - this.loading = false; + return modifiedData; + }; - decorated.call(this, data); + return HidePlaceholder; + }); + + S2.define('select2/dropdown/infiniteScroll', [ + 'jquery' + ], function ($) { + function InfiniteScroll(decorated, $element, options, dataAdapter) { + this.lastParams = {}; - if (this.showLoadingMore(data)) { - this.$results.append(this.$loadingMore); - this.loadMoreIfNeeded(); - } - }; + decorated.call(this, $element, options, dataAdapter); - InfiniteScroll.prototype.bind = function (decorated, container, $container) { - var self = this; + this.$loadingMore = this.createLoadingMore(); + this.loading = false; + } - decorated.call(this, container, $container); + InfiniteScroll.prototype.append = function (decorated, data) { + this.$loadingMore.remove(); + this.loading = false; - container.on('query', function (params) { - self.lastParams = params; - self.loading = true; - }); + decorated.call(this, data); - container.on('query:append', function (params) { - self.lastParams = params; - self.loading = true; - }); + if (this.showLoadingMore(data)) { + this.$results.append(this.$loadingMore); + this.loadMoreIfNeeded(); + } + }; - this.$results.on('scroll', this.loadMoreIfNeeded.bind(this)); - }; + InfiniteScroll.prototype.bind = function (decorated, container, $container) { + var self = this; - InfiniteScroll.prototype.loadMoreIfNeeded = function () { - var isLoadMoreVisible = $.contains( - document.documentElement, - this.$loadingMore[0] - ); + decorated.call(this, container, $container); - if (this.loading || !isLoadMoreVisible) { - return; - } + container.on('query', function (params) { + self.lastParams = params; + self.loading = true; + }); - var currentOffset = this.$results.offset().top + - this.$results.outerHeight(false); - var loadingMoreOffset = this.$loadingMore.offset().top + - this.$loadingMore.outerHeight(false); + container.on('query:append', function (params) { + self.lastParams = params; + self.loading = true; + }); - if (currentOffset + 50 >= loadingMoreOffset) { - this.loadMore(); - } - }; + this.$results.on('scroll', this.loadMoreIfNeeded.bind(this)); + }; - InfiniteScroll.prototype.loadMore = function () { - this.loading = true; + InfiniteScroll.prototype.loadMoreIfNeeded = function () { + var isLoadMoreVisible = $.contains( + document.documentElement, + this.$loadingMore[0] + ); - var params = $.extend({}, {page: 1}, this.lastParams); + if (this.loading || !isLoadMoreVisible) { + return; + } - params.page++; + var currentOffset = this.$results.offset().top + + this.$results.outerHeight(false); + var loadingMoreOffset = this.$loadingMore.offset().top + + this.$loadingMore.outerHeight(false); - this.trigger('query:append', params); - }; + if (currentOffset + 50 >= loadingMoreOffset) { + this.loadMore(); + } + }; - InfiniteScroll.prototype.showLoadingMore = function (_, data) { - return data.pagination && data.pagination.more; - }; + InfiniteScroll.prototype.loadMore = function () { + this.loading = true; - InfiniteScroll.prototype.createLoadingMore = function () { - var $option = $( - '
            • ' - ); + var params = $.extend({}, {page: 1}, this.lastParams); - var message = this.options.get('translations').get('loadingMore'); + params.page++; - $option.html(message(this.lastParams)); + this.trigger('query:append', params); + }; - return $option; - }; + InfiniteScroll.prototype.showLoadingMore = function (_, data) { + return data.pagination && data.pagination.more; + }; - return InfiniteScroll; -}); + InfiniteScroll.prototype.createLoadingMore = function () { + var $option = $( + '
            • ' + ); -S2.define('select2/dropdown/attachBody',[ - 'jquery', - '../utils' -], function ($, Utils) { - function AttachBody (decorated, $element, options) { - this.$dropdownParent = $(options.get('dropdownParent') || document.body); + var message = this.options.get('translations').get('loadingMore'); - decorated.call(this, $element, options); - } + $option.html(message(this.lastParams)); - AttachBody.prototype.bind = function (decorated, container, $container) { - var self = this; + return $option; + }; - decorated.call(this, container, $container); + return InfiniteScroll; + }); - container.on('open', function () { - self._showDropdown(); - self._attachPositioningHandler(container); + S2.define('select2/dropdown/attachBody', [ + 'jquery', + '../utils' + ], function ($, Utils) { + function AttachBody(decorated, $element, options) { + this.$dropdownParent = $(options.get('dropdownParent') || document.body); - // Must bind after the results handlers to ensure correct sizing - self._bindContainerResultHandlers(container); - }); + decorated.call(this, $element, options); + } - container.on('close', function () { - self._hideDropdown(); - self._detachPositioningHandler(container); - }); + AttachBody.prototype.bind = function (decorated, container, $container) { + var self = this; - this.$dropdownContainer.on('mousedown', function (evt) { - evt.stopPropagation(); - }); - }; + decorated.call(this, container, $container); - AttachBody.prototype.destroy = function (decorated) { - decorated.call(this); + container.on('open', function () { + self._showDropdown(); + self._attachPositioningHandler(container); - this.$dropdownContainer.remove(); - }; + // Must bind after the results handlers to ensure correct sizing + self._bindContainerResultHandlers(container); + }); - AttachBody.prototype.position = function (decorated, $dropdown, $container) { - // Clone all of the container classes - $dropdown.attr('class', $container.attr('class')); + container.on('close', function () { + self._hideDropdown(); + self._detachPositioningHandler(container); + }); - $dropdown.removeClass('select2'); - $dropdown.addClass('select2-container--open'); + this.$dropdownContainer.on('mousedown', function (evt) { + evt.stopPropagation(); + }); + }; - $dropdown.css({ - position: 'absolute', - top: -999999 - }); + AttachBody.prototype.destroy = function (decorated) { + decorated.call(this); - this.$container = $container; - }; + this.$dropdownContainer.remove(); + }; - AttachBody.prototype.render = function (decorated) { - var $container = $(''); + AttachBody.prototype.position = function (decorated, $dropdown, $container) { + // Clone all of the container classes + $dropdown.attr('class', $container.attr('class')); - var $dropdown = decorated.call(this); - $container.append($dropdown); + $dropdown.removeClass('select2'); + $dropdown.addClass('select2-container--open'); - this.$dropdownContainer = $container; + $dropdown.css({ + position: 'absolute', + top: -999999 + }); - return $container; - }; + this.$container = $container; + }; - AttachBody.prototype._hideDropdown = function (decorated) { - this.$dropdownContainer.detach(); - }; + AttachBody.prototype.render = function (decorated) { + var $container = $(''); - AttachBody.prototype._bindContainerResultHandlers = - function (decorated, container) { + var $dropdown = decorated.call(this); + $container.append($dropdown); - // These should only be bound once - if (this._containerResultsHandlersBound) { - return; - } + this.$dropdownContainer = $container; - var self = this; + return $container; + }; - container.on('results:all', function () { - self._positionDropdown(); - self._resizeDropdown(); - }); + AttachBody.prototype._hideDropdown = function (decorated) { + this.$dropdownContainer.detach(); + }; - container.on('results:append', function () { - self._positionDropdown(); - self._resizeDropdown(); - }); + AttachBody.prototype._bindContainerResultHandlers = + function (decorated, container) { - container.on('results:message', function () { - self._positionDropdown(); - self._resizeDropdown(); - }); + // These should only be bound once + if (this._containerResultsHandlersBound) { + return; + } - container.on('select', function () { - self._positionDropdown(); - self._resizeDropdown(); - }); + var self = this; - container.on('unselect', function () { - self._positionDropdown(); - self._resizeDropdown(); - }); + container.on('results:all', function () { + self._positionDropdown(); + self._resizeDropdown(); + }); - this._containerResultsHandlersBound = true; - }; + container.on('results:append', function () { + self._positionDropdown(); + self._resizeDropdown(); + }); - AttachBody.prototype._attachPositioningHandler = - function (decorated, container) { - var self = this; + container.on('results:message', function () { + self._positionDropdown(); + self._resizeDropdown(); + }); - var scrollEvent = 'scroll.select2.' + container.id; - var resizeEvent = 'resize.select2.' + container.id; - var orientationEvent = 'orientationchange.select2.' + container.id; + container.on('select', function () { + self._positionDropdown(); + self._resizeDropdown(); + }); - var $watchers = this.$container.parents().filter(Utils.hasScroll); - $watchers.each(function () { - Utils.StoreData(this, 'select2-scroll-position', { - x: $(this).scrollLeft(), - y: $(this).scrollTop() - }); - }); + container.on('unselect', function () { + self._positionDropdown(); + self._resizeDropdown(); + }); - $watchers.on(scrollEvent, function (ev) { - var position = Utils.GetData(this, 'select2-scroll-position'); - $(this).scrollTop(position.y); - }); - - $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent, - function (e) { - self._positionDropdown(); - self._resizeDropdown(); - }); - }; - - AttachBody.prototype._detachPositioningHandler = - function (decorated, container) { - var scrollEvent = 'scroll.select2.' + container.id; - var resizeEvent = 'resize.select2.' + container.id; - var orientationEvent = 'orientationchange.select2.' + container.id; - - var $watchers = this.$container.parents().filter(Utils.hasScroll); - $watchers.off(scrollEvent); - - $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent); - }; - - AttachBody.prototype._positionDropdown = function () { - var $window = $(window); - - var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above'); - var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below'); - - var newDirection = null; - - var offset = this.$container.offset(); - - offset.bottom = offset.top + this.$container.outerHeight(false); - - var container = { - height: this.$container.outerHeight(false) - }; - - container.top = offset.top; - container.bottom = offset.top + container.height; - - var dropdown = { - height: this.$dropdown.outerHeight(false) - }; - - var viewport = { - top: $window.scrollTop(), - bottom: $window.scrollTop() + $window.height() - }; - - var enoughRoomAbove = viewport.top < (offset.top - dropdown.height); - var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height); - - var css = { - left: offset.left, - top: container.bottom - }; - - // Determine what the parent element is to use for calculating the offset - var $offsetParent = this.$dropdownParent; - - // For statically positioned elements, we need to get the element - // that is determining the offset - if ($offsetParent.css('position') === 'static') { - $offsetParent = $offsetParent.offsetParent(); - } - - var parentOffset = { - top: 0, - left: 0 - }; - - if ( - $.contains(document.body, $offsetParent[0]) || - $offsetParent[0].isConnected - ) { - parentOffset = $offsetParent.offset(); - } - - css.top -= parentOffset.top; - css.left -= parentOffset.left; - - if (!isCurrentlyAbove && !isCurrentlyBelow) { - newDirection = 'below'; - } - - if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) { - newDirection = 'above'; - } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) { - newDirection = 'below'; - } - - if (newDirection == 'above' || - (isCurrentlyAbove && newDirection !== 'below')) { - css.top = container.top - parentOffset.top - dropdown.height; - } - - if (newDirection != null) { - this.$dropdown - .removeClass('select2-dropdown--below select2-dropdown--above') - .addClass('select2-dropdown--' + newDirection); - this.$container - .removeClass('select2-container--below select2-container--above') - .addClass('select2-container--' + newDirection); - } + this._containerResultsHandlersBound = true; + }; - this.$dropdownContainer.css(css); - }; + AttachBody.prototype._attachPositioningHandler = + function (decorated, container) { + var self = this; - AttachBody.prototype._resizeDropdown = function () { - var css = { - width: this.$container.outerWidth(false) + 'px' - }; + var scrollEvent = 'scroll.select2.' + container.id; + var resizeEvent = 'resize.select2.' + container.id; + var orientationEvent = 'orientationchange.select2.' + container.id; - if (this.options.get('dropdownAutoWidth')) { - css.minWidth = css.width; - css.position = 'relative'; - css.width = 'auto'; - } - - this.$dropdown.css(css); - }; - - AttachBody.prototype._showDropdown = function (decorated) { - this.$dropdownContainer.appendTo(this.$dropdownParent); + var $watchers = this.$container.parents().filter(Utils.hasScroll); + $watchers.each(function () { + Utils.StoreData(this, 'select2-scroll-position', { + x: $(this).scrollLeft(), + y: $(this).scrollTop() + }); + }); - this._positionDropdown(); - this._resizeDropdown(); - }; + $watchers.on(scrollEvent, function (ev) { + var position = Utils.GetData(this, 'select2-scroll-position'); + $(this).scrollTop(position.y); + }); + + $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent, + function (e) { + self._positionDropdown(); + self._resizeDropdown(); + }); + }; + + AttachBody.prototype._detachPositioningHandler = + function (decorated, container) { + var scrollEvent = 'scroll.select2.' + container.id; + var resizeEvent = 'resize.select2.' + container.id; + var orientationEvent = 'orientationchange.select2.' + container.id; + + var $watchers = this.$container.parents().filter(Utils.hasScroll); + $watchers.off(scrollEvent); + + $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent); + }; + + AttachBody.prototype._positionDropdown = function () { + var $window = $(window); + + var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above'); + var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below'); + + var newDirection = null; + + var offset = this.$container.offset(); + + offset.bottom = offset.top + this.$container.outerHeight(false); + + var container = { + height: this.$container.outerHeight(false) + }; + + container.top = offset.top; + container.bottom = offset.top + container.height; + + var dropdown = { + height: this.$dropdown.outerHeight(false) + }; + + var viewport = { + top: $window.scrollTop(), + bottom: $window.scrollTop() + $window.height() + }; + + var enoughRoomAbove = viewport.top < (offset.top - dropdown.height); + var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height); + + var css = { + left: offset.left, + top: container.bottom + }; + + // Determine what the parent element is to use for calculating the offset + var $offsetParent = this.$dropdownParent; + + // For statically positioned elements, we need to get the element + // that is determining the offset + if ($offsetParent.css('position') === 'static') { + $offsetParent = $offsetParent.offsetParent(); + } + + var parentOffset = { + top: 0, + left: 0 + }; + + if ( + $.contains(document.body, $offsetParent[0]) || + $offsetParent[0].isConnected + ) { + parentOffset = $offsetParent.offset(); + } + + css.top -= parentOffset.top; + css.left -= parentOffset.left; + + if (!isCurrentlyAbove && !isCurrentlyBelow) { + newDirection = 'below'; + } + + if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) { + newDirection = 'above'; + } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) { + newDirection = 'below'; + } + + if (newDirection == 'above' || + (isCurrentlyAbove && newDirection !== 'below')) { + css.top = container.top - parentOffset.top - dropdown.height; + } + + if (newDirection != null) { + this.$dropdown + .removeClass('select2-dropdown--below select2-dropdown--above') + .addClass('select2-dropdown--' + newDirection); + this.$container + .removeClass('select2-container--below select2-container--above') + .addClass('select2-container--' + newDirection); + } + + this.$dropdownContainer.css(css); + }; - return AttachBody; -}); - -S2.define('select2/dropdown/minimumResultsForSearch',[ - -], function () { - function countResults (data) { - var count = 0; - - for (var d = 0; d < data.length; d++) { - var item = data[d]; - - if (item.children) { - count += countResults(item.children); - } else { - count++; - } - } - - return count; - } - - function MinimumResultsForSearch (decorated, $element, options, dataAdapter) { - this.minimumResultsForSearch = options.get('minimumResultsForSearch'); - - if (this.minimumResultsForSearch < 0) { - this.minimumResultsForSearch = Infinity; - } - - decorated.call(this, $element, options, dataAdapter); - } - - MinimumResultsForSearch.prototype.showSearch = function (decorated, params) { - if (countResults(params.data.results) < this.minimumResultsForSearch) { - return false; - } - - return decorated.call(this, params); - }; - - return MinimumResultsForSearch; -}); - -S2.define('select2/dropdown/selectOnClose',[ - '../utils' -], function (Utils) { - function SelectOnClose () { } - - SelectOnClose.prototype.bind = function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - container.on('close', function (params) { - self._handleSelectOnClose(params); - }); - }; - - SelectOnClose.prototype._handleSelectOnClose = function (_, params) { - if (params && params.originalSelect2Event != null) { - var event = params.originalSelect2Event; - - // Don't select an item if the close event was triggered from a select or - // unselect event - if (event._type === 'select' || event._type === 'unselect') { - return; - } - } - - var $highlightedResults = this.getHighlightedResults(); - - // Only select highlighted results - if ($highlightedResults.length < 1) { - return; - } - - var data = Utils.GetData($highlightedResults[0], 'data'); - - // Don't re-select already selected resulte - if ( - (data.element != null && data.element.selected) || - (data.element == null && data.selected) - ) { - return; - } - - this.trigger('select', { - data: data - }); - }; - - return SelectOnClose; -}); - -S2.define('select2/dropdown/closeOnSelect',[ - -], function () { - function CloseOnSelect () { } - - CloseOnSelect.prototype.bind = function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - container.on('select', function (evt) { - self._selectTriggered(evt); - }); - - container.on('unselect', function (evt) { - self._selectTriggered(evt); - }); - }; - - CloseOnSelect.prototype._selectTriggered = function (_, evt) { - var originalEvent = evt.originalEvent; - - // Don't close if the control key is being held - if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) { - return; - } - - this.trigger('close', { - originalEvent: originalEvent, - originalSelect2Event: evt - }); - }; - - return CloseOnSelect; -}); - -S2.define('select2/i18n/en',[],function () { - // English - return { - errorLoading: function () { - return 'The results could not be loaded.'; - }, - inputTooLong: function (args) { - var overChars = args.input.length - args.maximum; - - var message = 'Please delete ' + overChars + ' character'; - - if (overChars != 1) { - message += 's'; - } - - return message; - }, - inputTooShort: function (args) { - var remainingChars = args.minimum - args.input.length; - - var message = 'Please enter ' + remainingChars + ' or more characters'; - - return message; - }, - loadingMore: function () { - return 'Loading more results…'; - }, - maximumSelected: function (args) { - var message = 'You can only select ' + args.maximum + ' item'; - - if (args.maximum != 1) { - message += 's'; - } - - return message; - }, - noResults: function () { - return 'No results found'; - }, - searching: function () { - return 'Searching…'; - }, - removeAllItems: function () { - return 'Remove all items'; - } - }; -}); - -S2.define('select2/defaults',[ - 'jquery', - 'require', - - './results', - - './selection/single', - './selection/multiple', - './selection/placeholder', - './selection/allowClear', - './selection/search', - './selection/eventRelay', - - './utils', - './translation', - './diacritics', - - './data/select', - './data/array', - './data/ajax', - './data/tags', - './data/tokenizer', - './data/minimumInputLength', - './data/maximumInputLength', - './data/maximumSelectionLength', - - './dropdown', - './dropdown/search', - './dropdown/hidePlaceholder', - './dropdown/infiniteScroll', - './dropdown/attachBody', - './dropdown/minimumResultsForSearch', - './dropdown/selectOnClose', - './dropdown/closeOnSelect', - - './i18n/en' -], function ($, require, - - ResultsList, - - SingleSelection, MultipleSelection, Placeholder, AllowClear, - SelectionSearch, EventRelay, - - Utils, Translation, DIACRITICS, - - SelectData, ArrayData, AjaxData, Tags, Tokenizer, - MinimumInputLength, MaximumInputLength, MaximumSelectionLength, - - Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll, - AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect, - - EnglishTranslation) { - function Defaults () { - this.reset(); - } - - Defaults.prototype.apply = function (options) { - options = $.extend(true, {}, this.defaults, options); - - if (options.dataAdapter == null) { - if (options.ajax != null) { - options.dataAdapter = AjaxData; - } else if (options.data != null) { - options.dataAdapter = ArrayData; - } else { - options.dataAdapter = SelectData; - } - - if (options.minimumInputLength > 0) { - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - MinimumInputLength - ); - } - - if (options.maximumInputLength > 0) { - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - MaximumInputLength - ); - } - - if (options.maximumSelectionLength > 0) { - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - MaximumSelectionLength - ); - } - - if (options.tags) { - options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags); - } - - if (options.tokenSeparators != null || options.tokenizer != null) { - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - Tokenizer - ); - } - - if (options.query != null) { - var Query = require(options.amdBase + 'compat/query'); - - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - Query - ); - } - - if (options.initSelection != null) { - var InitSelection = require(options.amdBase + 'compat/initSelection'); - - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - InitSelection - ); - } - } - - if (options.resultsAdapter == null) { - options.resultsAdapter = ResultsList; - - if (options.ajax != null) { - options.resultsAdapter = Utils.Decorate( - options.resultsAdapter, - InfiniteScroll - ); - } - - if (options.placeholder != null) { - options.resultsAdapter = Utils.Decorate( - options.resultsAdapter, - HidePlaceholder - ); - } - - if (options.selectOnClose) { - options.resultsAdapter = Utils.Decorate( - options.resultsAdapter, - SelectOnClose - ); - } - } - - if (options.dropdownAdapter == null) { - if (options.multiple) { - options.dropdownAdapter = Dropdown; - } else { - var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch); - - options.dropdownAdapter = SearchableDropdown; - } - - if (options.minimumResultsForSearch !== 0) { - options.dropdownAdapter = Utils.Decorate( - options.dropdownAdapter, - MinimumResultsForSearch - ); - } - - if (options.closeOnSelect) { - options.dropdownAdapter = Utils.Decorate( - options.dropdownAdapter, - CloseOnSelect - ); - } - - if ( - options.dropdownCssClass != null || - options.dropdownCss != null || - options.adaptDropdownCssClass != null - ) { - var DropdownCSS = require(options.amdBase + 'compat/dropdownCss'); - - options.dropdownAdapter = Utils.Decorate( - options.dropdownAdapter, - DropdownCSS - ); - } - - options.dropdownAdapter = Utils.Decorate( - options.dropdownAdapter, - AttachBody - ); - } - - if (options.selectionAdapter == null) { - if (options.multiple) { - options.selectionAdapter = MultipleSelection; - } else { - options.selectionAdapter = SingleSelection; - } - - // Add the placeholder mixin if a placeholder was specified - if (options.placeholder != null) { - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - Placeholder - ); - } - - if (options.allowClear) { - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - AllowClear - ); - } - - if (options.multiple) { - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - SelectionSearch - ); - } - - if ( - options.containerCssClass != null || - options.containerCss != null || - options.adaptContainerCssClass != null - ) { - var ContainerCSS = require(options.amdBase + 'compat/containerCss'); - - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - ContainerCSS - ); - } - - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - EventRelay - ); - } - - // If the defaults were not previously applied from an element, it is - // possible for the language option to have not been resolved - options.language = this._resolveLanguage(options.language); - - // Always fall back to English since it will always be complete - options.language.push('en'); - - var uniqueLanguages = []; - - for (var l = 0; l < options.language.length; l++) { - var language = options.language[l]; - - if (uniqueLanguages.indexOf(language) === -1) { - uniqueLanguages.push(language); - } - } - - options.language = uniqueLanguages; - - options.translations = this._processTranslations( - options.language, - options.debug - ); - - return options; - }; - - Defaults.prototype.reset = function () { - function stripDiacritics (text) { - // Used 'uni range + named function' from http://jsperf.com/diacritics/18 - function match(a) { - return DIACRITICS[a] || a; - } - - return text.replace(/[^\u0000-\u007E]/g, match); - } - - function matcher (params, data) { - // Always return the object if there is nothing to compare - if ($.trim(params.term) === '') { - return data; - } - - // Do a recursive check for options with children - if (data.children && data.children.length > 0) { - // Clone the data object if there are children - // This is required as we modify the object to remove any non-matches - var match = $.extend(true, {}, data); - - // Check each child of the option - for (var c = data.children.length - 1; c >= 0; c--) { - var child = data.children[c]; - - var matches = matcher(params, child); - - // If there wasn't a match, remove the object in the array - if (matches == null) { - match.children.splice(c, 1); - } - } - - // If any children matched, return the new object - if (match.children.length > 0) { - return match; - } - - // If there were no matching children, check just the plain object - return matcher(params, match); - } - - var original = stripDiacritics(data.text).toUpperCase(); - var term = stripDiacritics(params.term).toUpperCase(); - - // Check if the text contains the term - if (original.indexOf(term) > -1) { - return data; - } - - // If it doesn't contain the term, don't return anything - return null; - } - - this.defaults = { - amdBase: './', - amdLanguageBase: './i18n/', - closeOnSelect: true, - debug: false, - dropdownAutoWidth: false, - escapeMarkup: Utils.escapeMarkup, - language: {}, - matcher: matcher, - minimumInputLength: 0, - maximumInputLength: 0, - maximumSelectionLength: 0, - minimumResultsForSearch: 0, - selectOnClose: false, - scrollAfterSelect: false, - sorter: function (data) { - return data; - }, - templateResult: function (result) { - return result.text; - }, - templateSelection: function (selection) { - return selection.text; - }, - theme: 'default', - width: 'resolve' - }; - }; - - Defaults.prototype.applyFromElement = function (options, $element) { - var optionLanguage = options.language; - var defaultLanguage = this.defaults.language; - var elementLanguage = $element.prop('lang'); - var parentLanguage = $element.closest('[lang]').prop('lang'); - - var languages = Array.prototype.concat.call( - this._resolveLanguage(elementLanguage), - this._resolveLanguage(optionLanguage), - this._resolveLanguage(defaultLanguage), - this._resolveLanguage(parentLanguage) - ); - - options.language = languages; - - return options; - }; - - Defaults.prototype._resolveLanguage = function (language) { - if (!language) { - return []; - } - - if ($.isEmptyObject(language)) { - return []; - } - - if ($.isPlainObject(language)) { - return [language]; - } - - var languages; - - if (!$.isArray(language)) { - languages = [language]; - } else { - languages = language; - } - - var resolvedLanguages = []; - - for (var l = 0; l < languages.length; l++) { - resolvedLanguages.push(languages[l]); - - if (typeof languages[l] === 'string' && languages[l].indexOf('-') > 0) { - // Extract the region information if it is included - var languageParts = languages[l].split('-'); - var baseLanguage = languageParts[0]; - - resolvedLanguages.push(baseLanguage); - } - } - - return resolvedLanguages; - }; - - Defaults.prototype._processTranslations = function (languages, debug) { - var translations = new Translation(); - - for (var l = 0; l < languages.length; l++) { - var languageData = new Translation(); - - var language = languages[l]; - - if (typeof language === 'string') { - try { - // Try to load it with the original name - languageData = Translation.loadPath(language); - } catch (e) { - try { - // If we couldn't load it, check if it wasn't the full path - language = this.defaults.amdLanguageBase + language; - languageData = Translation.loadPath(language); - } catch (ex) { - // The translation could not be loaded at all. Sometimes this is - // because of a configuration problem, other times this can be - // because of how Select2 helps load all possible translation files - if (debug && window.console && console.warn) { - console.warn( - 'Select2: The language file for "' + language + '" could ' + - 'not be automatically loaded. A fallback will be used instead.' - ); - } - } - } - } else if ($.isPlainObject(language)) { - languageData = new Translation(language); - } else { - languageData = language; - } - - translations.extend(languageData); - } - - return translations; - }; - - Defaults.prototype.set = function (key, value) { - var camelKey = $.camelCase(key); - - var data = {}; - data[camelKey] = value; - - var convertedData = Utils._convertData(data); - - $.extend(true, this.defaults, convertedData); - }; - - var defaults = new Defaults(); - - return defaults; -}); - -S2.define('select2/options',[ - 'require', - 'jquery', - './defaults', - './utils' -], function (require, $, Defaults, Utils) { - function Options (options, $element) { - this.options = options; - - if ($element != null) { - this.fromElement($element); - } - - if ($element != null) { - this.options = Defaults.applyFromElement(this.options, $element); - } - - this.options = Defaults.apply(this.options); - - if ($element && $element.is('input')) { - var InputCompat = require(this.get('amdBase') + 'compat/inputData'); - - this.options.dataAdapter = Utils.Decorate( - this.options.dataAdapter, - InputCompat - ); - } - } - - Options.prototype.fromElement = function ($e) { - var excludedData = ['select2']; - - if (this.options.multiple == null) { - this.options.multiple = $e.prop('multiple'); - } - - if (this.options.disabled == null) { - this.options.disabled = $e.prop('disabled'); - } - - if (this.options.dir == null) { - if ($e.prop('dir')) { - this.options.dir = $e.prop('dir'); - } else if ($e.closest('[dir]').prop('dir')) { - this.options.dir = $e.closest('[dir]').prop('dir'); - } else { - this.options.dir = 'ltr'; - } - } - - $e.prop('disabled', this.options.disabled); - $e.prop('multiple', this.options.multiple); - - if (Utils.GetData($e[0], 'select2Tags')) { - if (this.options.debug && window.console && console.warn) { - console.warn( - 'Select2: The `data-select2-tags` attribute has been changed to ' + - 'use the `data-data` and `data-tags="true"` attributes and will be ' + - 'removed in future versions of Select2.' - ); - } - - Utils.StoreData($e[0], 'data', Utils.GetData($e[0], 'select2Tags')); - Utils.StoreData($e[0], 'tags', true); - } - - if (Utils.GetData($e[0], 'ajaxUrl')) { - if (this.options.debug && window.console && console.warn) { - console.warn( - 'Select2: The `data-ajax-url` attribute has been changed to ' + - '`data-ajax--url` and support for the old attribute will be removed' + - ' in future versions of Select2.' - ); - } + AttachBody.prototype._resizeDropdown = function () { + var css = { + width: this.$container.outerWidth(false) + 'px' + }; + + if (this.options.get('dropdownAutoWidth')) { + css.minWidth = css.width; + css.position = 'relative'; + css.width = 'auto'; + } + + this.$dropdown.css(css); + }; + + AttachBody.prototype._showDropdown = function (decorated) { + this.$dropdownContainer.appendTo(this.$dropdownParent); + + this._positionDropdown(); + this._resizeDropdown(); + }; + + return AttachBody; + }); + + S2.define('select2/dropdown/minimumResultsForSearch', [], function () { + function countResults(data) { + var count = 0; + + for (var d = 0; d < data.length; d++) { + var item = data[d]; + + if (item.children) { + count += countResults(item.children); + } else { + count++; + } + } + + return count; + } + + function MinimumResultsForSearch(decorated, $element, options, dataAdapter) { + this.minimumResultsForSearch = options.get('minimumResultsForSearch'); + + if (this.minimumResultsForSearch < 0) { + this.minimumResultsForSearch = Infinity; + } + + decorated.call(this, $element, options, dataAdapter); + } + + MinimumResultsForSearch.prototype.showSearch = function (decorated, params) { + if (countResults(params.data.results) < this.minimumResultsForSearch) { + return false; + } + + return decorated.call(this, params); + }; + + return MinimumResultsForSearch; + }); + + S2.define('select2/dropdown/selectOnClose', [ + '../utils' + ], function (Utils) { + function SelectOnClose() { + } + + SelectOnClose.prototype.bind = function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + container.on('close', function (params) { + self._handleSelectOnClose(params); + }); + }; + + SelectOnClose.prototype._handleSelectOnClose = function (_, params) { + if (params && params.originalSelect2Event != null) { + var event = params.originalSelect2Event; + + // Don't select an item if the close event was triggered from a select or + // unselect event + if (event._type === 'select' || event._type === 'unselect') { + return; + } + } + + var $highlightedResults = this.getHighlightedResults(); + + // Only select highlighted results + if ($highlightedResults.length < 1) { + return; + } + + var data = Utils.GetData($highlightedResults[0], 'data'); + + // Don't re-select already selected resulte + if ( + (data.element != null && data.element.selected) || + (data.element == null && data.selected) + ) { + return; + } + + this.trigger('select', { + data: data + }); + }; + + return SelectOnClose; + }); + + S2.define('select2/dropdown/closeOnSelect', [], function () { + function CloseOnSelect() { + } + + CloseOnSelect.prototype.bind = function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + container.on('select', function (evt) { + self._selectTriggered(evt); + }); + + container.on('unselect', function (evt) { + self._selectTriggered(evt); + }); + }; + + CloseOnSelect.prototype._selectTriggered = function (_, evt) { + var originalEvent = evt.originalEvent; + + // Don't close if the control key is being held + if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) { + return; + } + + this.trigger('close', { + originalEvent: originalEvent, + originalSelect2Event: evt + }); + }; + + return CloseOnSelect; + }); + + S2.define('select2/i18n/en', [], function () { + // English + return { + errorLoading: function () { + return 'The results could not be loaded.'; + }, + inputTooLong: function (args) { + var overChars = args.input.length - args.maximum; + + var message = 'Please delete ' + overChars + ' character'; + + if (overChars != 1) { + message += 's'; + } + + return message; + }, + inputTooShort: function (args) { + var remainingChars = args.minimum - args.input.length; + + var message = 'Please enter ' + remainingChars + ' or more characters'; + + return message; + }, + loadingMore: function () { + return 'Loading more results…'; + }, + maximumSelected: function (args) { + var message = 'You can only select ' + args.maximum + ' item'; + + if (args.maximum != 1) { + message += 's'; + } + + return message; + }, + noResults: function () { + return 'No results found'; + }, + searching: function () { + return 'Searching…'; + }, + removeAllItems: function () { + return 'Remove all items'; + } + }; + }); + + S2.define('select2/defaults', [ + 'jquery', + 'require', + + './results', + + './selection/single', + './selection/multiple', + './selection/placeholder', + './selection/allowClear', + './selection/search', + './selection/eventRelay', + + './utils', + './translation', + './diacritics', + + './data/select', + './data/array', + './data/ajax', + './data/tags', + './data/tokenizer', + './data/minimumInputLength', + './data/maximumInputLength', + './data/maximumSelectionLength', + + './dropdown', + './dropdown/search', + './dropdown/hidePlaceholder', + './dropdown/infiniteScroll', + './dropdown/attachBody', + './dropdown/minimumResultsForSearch', + './dropdown/selectOnClose', + './dropdown/closeOnSelect', + + './i18n/en' + ], function ($, require, + ResultsList, + SingleSelection, MultipleSelection, Placeholder, AllowClear, + SelectionSearch, EventRelay, + Utils, Translation, DIACRITICS, + SelectData, ArrayData, AjaxData, Tags, Tokenizer, + MinimumInputLength, MaximumInputLength, MaximumSelectionLength, + Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll, + AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect, + EnglishTranslation) { + function Defaults() { + this.reset(); + } + + Defaults.prototype.apply = function (options) { + options = $.extend(true, {}, this.defaults, options); + + if (options.dataAdapter == null) { + if (options.ajax != null) { + options.dataAdapter = AjaxData; + } else if (options.data != null) { + options.dataAdapter = ArrayData; + } else { + options.dataAdapter = SelectData; + } + + if (options.minimumInputLength > 0) { + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + MinimumInputLength + ); + } + + if (options.maximumInputLength > 0) { + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + MaximumInputLength + ); + } + + if (options.maximumSelectionLength > 0) { + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + MaximumSelectionLength + ); + } + + if (options.tags) { + options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags); + } + + if (options.tokenSeparators != null || options.tokenizer != null) { + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + Tokenizer + ); + } + + if (options.query != null) { + var Query = require(options.amdBase + 'compat/query'); + + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + Query + ); + } + + if (options.initSelection != null) { + var InitSelection = require(options.amdBase + 'compat/initSelection'); + + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + InitSelection + ); + } + } + + if (options.resultsAdapter == null) { + options.resultsAdapter = ResultsList; + + if (options.ajax != null) { + options.resultsAdapter = Utils.Decorate( + options.resultsAdapter, + InfiniteScroll + ); + } + + if (options.placeholder != null) { + options.resultsAdapter = Utils.Decorate( + options.resultsAdapter, + HidePlaceholder + ); + } + + if (options.selectOnClose) { + options.resultsAdapter = Utils.Decorate( + options.resultsAdapter, + SelectOnClose + ); + } + } + + if (options.dropdownAdapter == null) { + if (options.multiple) { + options.dropdownAdapter = Dropdown; + } else { + var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch); + + options.dropdownAdapter = SearchableDropdown; + } + + if (options.minimumResultsForSearch !== 0) { + options.dropdownAdapter = Utils.Decorate( + options.dropdownAdapter, + MinimumResultsForSearch + ); + } + + if (options.closeOnSelect) { + options.dropdownAdapter = Utils.Decorate( + options.dropdownAdapter, + CloseOnSelect + ); + } + + if ( + options.dropdownCssClass != null || + options.dropdownCss != null || + options.adaptDropdownCssClass != null + ) { + var DropdownCSS = require(options.amdBase + 'compat/dropdownCss'); + + options.dropdownAdapter = Utils.Decorate( + options.dropdownAdapter, + DropdownCSS + ); + } + + options.dropdownAdapter = Utils.Decorate( + options.dropdownAdapter, + AttachBody + ); + } + + if (options.selectionAdapter == null) { + if (options.multiple) { + options.selectionAdapter = MultipleSelection; + } else { + options.selectionAdapter = SingleSelection; + } + + // Add the placeholder mixin if a placeholder was specified + if (options.placeholder != null) { + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + Placeholder + ); + } + + if (options.allowClear) { + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + AllowClear + ); + } + + if (options.multiple) { + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + SelectionSearch + ); + } + + if ( + options.containerCssClass != null || + options.containerCss != null || + options.adaptContainerCssClass != null + ) { + var ContainerCSS = require(options.amdBase + 'compat/containerCss'); + + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + ContainerCSS + ); + } + + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + EventRelay + ); + } + + // If the defaults were not previously applied from an element, it is + // possible for the language option to have not been resolved + options.language = this._resolveLanguage(options.language); + + // Always fall back to English since it will always be complete + options.language.push('en'); + + var uniqueLanguages = []; + + for (var l = 0; l < options.language.length; l++) { + var language = options.language[l]; + + if (uniqueLanguages.indexOf(language) === -1) { + uniqueLanguages.push(language); + } + } + + options.language = uniqueLanguages; + + options.translations = this._processTranslations( + options.language, + options.debug + ); + + return options; + }; + + Defaults.prototype.reset = function () { + function stripDiacritics(text) { + // Used 'uni range + named function' from http://jsperf.com/diacritics/18 + function match(a) { + return DIACRITICS[a] || a; + } + + return text.replace(/[^\u0000-\u007E]/g, match); + } + + function matcher(params, data) { + // Always return the object if there is nothing to compare + if ($.trim(params.term) === '') { + return data; + } + + // Do a recursive check for options with children + if (data.children && data.children.length > 0) { + // Clone the data object if there are children + // This is required as we modify the object to remove any non-matches + var match = $.extend(true, {}, data); + + // Check each child of the option + for (var c = data.children.length - 1; c >= 0; c--) { + var child = data.children[c]; + + var matches = matcher(params, child); + + // If there wasn't a match, remove the object in the array + if (matches == null) { + match.children.splice(c, 1); + } + } + + // If any children matched, return the new object + if (match.children.length > 0) { + return match; + } + + // If there were no matching children, check just the plain object + return matcher(params, match); + } + + var original = stripDiacritics(data.text).toUpperCase(); + var term = stripDiacritics(params.term).toUpperCase(); + + // Check if the text contains the term + if (original.indexOf(term) > -1) { + return data; + } + + // If it doesn't contain the term, don't return anything + return null; + } + + this.defaults = { + amdBase: './', + amdLanguageBase: './i18n/', + closeOnSelect: true, + debug: false, + dropdownAutoWidth: false, + escapeMarkup: Utils.escapeMarkup, + language: {}, + matcher: matcher, + minimumInputLength: 0, + maximumInputLength: 0, + maximumSelectionLength: 0, + minimumResultsForSearch: 0, + selectOnClose: false, + scrollAfterSelect: false, + sorter: function (data) { + return data; + }, + templateResult: function (result) { + return result.text; + }, + templateSelection: function (selection) { + return selection.text; + }, + theme: 'default', + width: 'resolve' + }; + }; + + Defaults.prototype.applyFromElement = function (options, $element) { + var optionLanguage = options.language; + var defaultLanguage = this.defaults.language; + var elementLanguage = $element.prop('lang'); + var parentLanguage = $element.closest('[lang]').prop('lang'); + + var languages = Array.prototype.concat.call( + this._resolveLanguage(elementLanguage), + this._resolveLanguage(optionLanguage), + this._resolveLanguage(defaultLanguage), + this._resolveLanguage(parentLanguage) + ); + + options.language = languages; + + return options; + }; + + Defaults.prototype._resolveLanguage = function (language) { + if (!language) { + return []; + } + + if ($.isEmptyObject(language)) { + return []; + } + + if ($.isPlainObject(language)) { + return [language]; + } + + var languages; + + if (!$.isArray(language)) { + languages = [language]; + } else { + languages = language; + } + + var resolvedLanguages = []; + + for (var l = 0; l < languages.length; l++) { + resolvedLanguages.push(languages[l]); + + if (typeof languages[l] === 'string' && languages[l].indexOf('-') > 0) { + // Extract the region information if it is included + var languageParts = languages[l].split('-'); + var baseLanguage = languageParts[0]; + + resolvedLanguages.push(baseLanguage); + } + } + + return resolvedLanguages; + }; + + Defaults.prototype._processTranslations = function (languages, debug) { + var translations = new Translation(); + + for (var l = 0; l < languages.length; l++) { + var languageData = new Translation(); + + var language = languages[l]; + + if (typeof language === 'string') { + try { + // Try to load it with the original name + languageData = Translation.loadPath(language); + } catch (e) { + try { + // If we couldn't load it, check if it wasn't the full path + language = this.defaults.amdLanguageBase + language; + languageData = Translation.loadPath(language); + } catch (ex) { + // The translation could not be loaded at all. Sometimes this is + // because of a configuration problem, other times this can be + // because of how Select2 helps load all possible translation files + if (debug && window.console && console.warn) { + console.warn( + 'Select2: The language file for "' + language + '" could ' + + 'not be automatically loaded. A fallback will be used instead.' + ); + } + } + } + } else if ($.isPlainObject(language)) { + languageData = new Translation(language); + } else { + languageData = language; + } + + translations.extend(languageData); + } + + return translations; + }; + + Defaults.prototype.set = function (key, value) { + var camelKey = $.camelCase(key); + + var data = {}; + data[camelKey] = value; + + var convertedData = Utils._convertData(data); + + $.extend(true, this.defaults, convertedData); + }; + + var defaults = new Defaults(); + + return defaults; + }); + + S2.define('select2/options', [ + 'require', + 'jquery', + './defaults', + './utils' + ], function (require, $, Defaults, Utils) { + function Options(options, $element) { + this.options = options; + + if ($element != null) { + this.fromElement($element); + } + + if ($element != null) { + this.options = Defaults.applyFromElement(this.options, $element); + } + + this.options = Defaults.apply(this.options); + + if ($element && $element.is('input')) { + var InputCompat = require(this.get('amdBase') + 'compat/inputData'); + + this.options.dataAdapter = Utils.Decorate( + this.options.dataAdapter, + InputCompat + ); + } + } + + Options.prototype.fromElement = function ($e) { + var excludedData = ['select2']; + + if (this.options.multiple == null) { + this.options.multiple = $e.prop('multiple'); + } + + if (this.options.disabled == null) { + this.options.disabled = $e.prop('disabled'); + } + + if (this.options.dir == null) { + if ($e.prop('dir')) { + this.options.dir = $e.prop('dir'); + } else if ($e.closest('[dir]').prop('dir')) { + this.options.dir = $e.closest('[dir]').prop('dir'); + } else { + this.options.dir = 'ltr'; + } + } + + $e.prop('disabled', this.options.disabled); + $e.prop('multiple', this.options.multiple); + + if (Utils.GetData($e[0], 'select2Tags')) { + if (this.options.debug && window.console && console.warn) { + console.warn( + 'Select2: The `data-select2-tags` attribute has been changed to ' + + 'use the `data-data` and `data-tags="true"` attributes and will be ' + + 'removed in future versions of Select2.' + ); + } + + Utils.StoreData($e[0], 'data', Utils.GetData($e[0], 'select2Tags')); + Utils.StoreData($e[0], 'tags', true); + } + + if (Utils.GetData($e[0], 'ajaxUrl')) { + if (this.options.debug && window.console && console.warn) { + console.warn( + 'Select2: The `data-ajax-url` attribute has been changed to ' + + '`data-ajax--url` and support for the old attribute will be removed' + + ' in future versions of Select2.' + ); + } - $e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl')); - Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl')); - } + $e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl')); + Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl')); + } - var dataset = {}; + var dataset = {}; - function upperCaseLetter(_, letter) { - return letter.toUpperCase(); - } + function upperCaseLetter(_, letter) { + return letter.toUpperCase(); + } - // Pre-load all of the attributes which are prefixed with `data-` - for (var attr = 0; attr < $e[0].attributes.length; attr++) { - var attributeName = $e[0].attributes[attr].name; - var prefix = 'data-'; + // Pre-load all of the attributes which are prefixed with `data-` + for (var attr = 0; attr < $e[0].attributes.length; attr++) { + var attributeName = $e[0].attributes[attr].name; + var prefix = 'data-'; - if (attributeName.substr(0, prefix.length) == prefix) { - // Get the contents of the attribute after `data-` - var dataName = attributeName.substring(prefix.length); + if (attributeName.substr(0, prefix.length) == prefix) { + // Get the contents of the attribute after `data-` + var dataName = attributeName.substring(prefix.length); - // Get the data contents from the consistent source - // This is more than likely the jQuery data helper - var dataValue = Utils.GetData($e[0], dataName); + // Get the data contents from the consistent source + // This is more than likely the jQuery data helper + var dataValue = Utils.GetData($e[0], dataName); - // camelCase the attribute name to match the spec - var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter); + // camelCase the attribute name to match the spec + var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter); - // Store the data attribute contents into the dataset since - dataset[camelDataName] = dataValue; - } - } + // Store the data attribute contents into the dataset since + dataset[camelDataName] = dataValue; + } + } - // Prefer the element's `dataset` attribute if it exists - // jQuery 1.x does not correctly handle data attributes with multiple dashes - if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) { - dataset = $.extend(true, {}, $e[0].dataset, dataset); - } + // Prefer the element's `dataset` attribute if it exists + // jQuery 1.x does not correctly handle data attributes with multiple dashes + if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) { + dataset = $.extend(true, {}, $e[0].dataset, dataset); + } - // Prefer our internal data cache if it exists - var data = $.extend(true, {}, Utils.GetData($e[0]), dataset); + // Prefer our internal data cache if it exists + var data = $.extend(true, {}, Utils.GetData($e[0]), dataset); - data = Utils._convertData(data); + data = Utils._convertData(data); - for (var key in data) { - if ($.inArray(key, excludedData) > -1) { - continue; - } + for (var key in data) { + if ($.inArray(key, excludedData) > -1) { + continue; + } - if ($.isPlainObject(this.options[key])) { - $.extend(this.options[key], data[key]); - } else { - this.options[key] = data[key]; - } - } + if ($.isPlainObject(this.options[key])) { + $.extend(this.options[key], data[key]); + } else { + this.options[key] = data[key]; + } + } - return this; - }; + return this; + }; - Options.prototype.get = function (key) { - return this.options[key]; - }; + Options.prototype.get = function (key) { + return this.options[key]; + }; - Options.prototype.set = function (key, val) { - this.options[key] = val; - }; + Options.prototype.set = function (key, val) { + this.options[key] = val; + }; - return Options; -}); + return Options; + }); -S2.define('select2/core',[ - 'jquery', - './options', - './utils', - './keys' -], function ($, Options, Utils, KEYS) { - var Select2 = function ($element, options) { - if (Utils.GetData($element[0], 'select2') != null) { - Utils.GetData($element[0], 'select2').destroy(); - } + S2.define('select2/core', [ + 'jquery', + './options', + './utils', + './keys' + ], function ($, Options, Utils, KEYS) { + var Select2 = function ($element, options) { + if (Utils.GetData($element[0], 'select2') != null) { + Utils.GetData($element[0], 'select2').destroy(); + } - this.$element = $element; + this.$element = $element; - this.id = this._generateId($element); + this.id = this._generateId($element); - options = options || {}; + options = options || {}; - this.options = new Options(options, $element); + this.options = new Options(options, $element); - Select2.__super__.constructor.call(this); + Select2.__super__.constructor.call(this); - // Set up the tabindex + // Set up the tabindex - var tabindex = $element.attr('tabindex') || 0; - Utils.StoreData($element[0], 'old-tabindex', tabindex); - $element.attr('tabindex', '-1'); + var tabindex = $element.attr('tabindex') || 0; + Utils.StoreData($element[0], 'old-tabindex', tabindex); + $element.attr('tabindex', '-1'); - // Set up containers and adapters + // Set up containers and adapters - var DataAdapter = this.options.get('dataAdapter'); - this.dataAdapter = new DataAdapter($element, this.options); + var DataAdapter = this.options.get('dataAdapter'); + this.dataAdapter = new DataAdapter($element, this.options); - var $container = this.render(); + var $container = this.render(); - this._placeContainer($container); + this._placeContainer($container); - var SelectionAdapter = this.options.get('selectionAdapter'); - this.selection = new SelectionAdapter($element, this.options); - this.$selection = this.selection.render(); + var SelectionAdapter = this.options.get('selectionAdapter'); + this.selection = new SelectionAdapter($element, this.options); + this.$selection = this.selection.render(); - this.selection.position(this.$selection, $container); + this.selection.position(this.$selection, $container); - var DropdownAdapter = this.options.get('dropdownAdapter'); - this.dropdown = new DropdownAdapter($element, this.options); - this.$dropdown = this.dropdown.render(); + var DropdownAdapter = this.options.get('dropdownAdapter'); + this.dropdown = new DropdownAdapter($element, this.options); + this.$dropdown = this.dropdown.render(); - this.dropdown.position(this.$dropdown, $container); + this.dropdown.position(this.$dropdown, $container); - var ResultsAdapter = this.options.get('resultsAdapter'); - this.results = new ResultsAdapter($element, this.options, this.dataAdapter); - this.$results = this.results.render(); + var ResultsAdapter = this.options.get('resultsAdapter'); + this.results = new ResultsAdapter($element, this.options, this.dataAdapter); + this.$results = this.results.render(); - this.results.position(this.$results, this.$dropdown); + this.results.position(this.$results, this.$dropdown); - // Bind events + // Bind events - var self = this; + var self = this; - // Bind the container to all of the adapters - this._bindAdapters(); + // Bind the container to all of the adapters + this._bindAdapters(); - // Register any DOM event handlers - this._registerDomEvents(); + // Register any DOM event handlers + this._registerDomEvents(); - // Register any internal event handlers - this._registerDataEvents(); - this._registerSelectionEvents(); - this._registerDropdownEvents(); - this._registerResultsEvents(); - this._registerEvents(); + // Register any internal event handlers + this._registerDataEvents(); + this._registerSelectionEvents(); + this._registerDropdownEvents(); + this._registerResultsEvents(); + this._registerEvents(); - // Set the initial state - this.dataAdapter.current(function (initialData) { - self.trigger('selection:update', { - data: initialData - }); - }); + // Set the initial state + this.dataAdapter.current(function (initialData) { + self.trigger('selection:update', { + data: initialData + }); + }); - // Hide the original select - $element.addClass('select2-hidden-accessible'); - $element.attr('aria-hidden', 'true'); + // Hide the original select + $element.addClass('select2-hidden-accessible'); + $element.attr('aria-hidden', 'true'); - // Synchronize any monitored attributes - this._syncAttributes(); + // Synchronize any monitored attributes + this._syncAttributes(); - Utils.StoreData($element[0], 'select2', this); + Utils.StoreData($element[0], 'select2', this); - // Ensure backwards compatibility with $element.data('select2'). - $element.data('select2', this); - }; + // Ensure backwards compatibility with $element.data('select2'). + $element.data('select2', this); + }; - Utils.Extend(Select2, Utils.Observable); + Utils.Extend(Select2, Utils.Observable); - Select2.prototype._generateId = function ($element) { - var id = ''; + Select2.prototype._generateId = function ($element) { + var id = ''; - if ($element.attr('id') != null) { - id = $element.attr('id'); - } else if ($element.attr('name') != null) { - id = $element.attr('name') + '-' + Utils.generateChars(2); - } else { - id = Utils.generateChars(4); - } + if ($element.attr('id') != null) { + id = $element.attr('id'); + } else if ($element.attr('name') != null) { + id = $element.attr('name') + '-' + Utils.generateChars(2); + } else { + id = Utils.generateChars(4); + } - id = id.replace(/(:|\.|\[|\]|,)/g, ''); - id = 'select2-' + id; + id = id.replace(/(:|\.|\[|\]|,)/g, ''); + id = 'select2-' + id; - return id; - }; + return id; + }; - Select2.prototype._placeContainer = function ($container) { - $container.insertAfter(this.$element); + Select2.prototype._placeContainer = function ($container) { + $container.insertAfter(this.$element); - var width = this._resolveWidth(this.$element, this.options.get('width')); + var width = this._resolveWidth(this.$element, this.options.get('width')); - if (width != null) { - $container.css('width', width); - } - }; + if (width != null) { + $container.css('width', width); + } + }; - Select2.prototype._resolveWidth = function ($element, method) { - var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i; + Select2.prototype._resolveWidth = function ($element, method) { + var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i; - if (method == 'resolve') { - var styleWidth = this._resolveWidth($element, 'style'); + if (method == 'resolve') { + var styleWidth = this._resolveWidth($element, 'style'); - if (styleWidth != null) { - return styleWidth; - } + if (styleWidth != null) { + return styleWidth; + } - return this._resolveWidth($element, 'element'); - } + return this._resolveWidth($element, 'element'); + } - if (method == 'element') { - var elementWidth = $element.outerWidth(false); - - if (elementWidth <= 0) { - return 'auto'; - } + if (method == 'element') { + var elementWidth = $element.outerWidth(false); + + if (elementWidth <= 0) { + return 'auto'; + } - return elementWidth + 'px'; - } - - if (method == 'style') { - var style = $element.attr('style'); - - if (typeof(style) !== 'string') { - return null; - } - - var attrs = style.split(';'); - - for (var i = 0, l = attrs.length; i < l; i = i + 1) { - var attr = attrs[i].replace(/\s/g, ''); - var matches = attr.match(WIDTH); - - if (matches !== null && matches.length >= 1) { - return matches[1]; - } - } - - return null; - } - - if (method == 'computedstyle') { - var computedStyle = window.getComputedStyle($element[0]); - - return computedStyle.width; - } - - return method; - }; - - Select2.prototype._bindAdapters = function () { - this.dataAdapter.bind(this, this.$container); - this.selection.bind(this, this.$container); - - this.dropdown.bind(this, this.$container); - this.results.bind(this, this.$container); - }; - - Select2.prototype._registerDomEvents = function () { - var self = this; - - this.$element.on('change.select2', function () { - self.dataAdapter.current(function (data) { - self.trigger('selection:update', { - data: data - }); - }); - }); - - this.$element.on('focus.select2', function (evt) { - self.trigger('focus', evt); - }); - - this._syncA = Utils.bind(this._syncAttributes, this); - this._syncS = Utils.bind(this._syncSubtree, this); - - if (this.$element[0].attachEvent) { - this.$element[0].attachEvent('onpropertychange', this._syncA); - } - - var observer = window.MutationObserver || - window.WebKitMutationObserver || - window.MozMutationObserver - ; - - if (observer != null) { - this._observer = new observer(function (mutations) { - self._syncA(); - self._syncS(null, mutations); - }); - this._observer.observe(this.$element[0], { - attributes: true, - childList: true, - subtree: false - }); - } else if (this.$element[0].addEventListener) { - this.$element[0].addEventListener( - 'DOMAttrModified', - self._syncA, - false - ); - this.$element[0].addEventListener( - 'DOMNodeInserted', - self._syncS, - false - ); - this.$element[0].addEventListener( - 'DOMNodeRemoved', - self._syncS, - false - ); - } - }; - - Select2.prototype._registerDataEvents = function () { - var self = this; - - this.dataAdapter.on('*', function (name, params) { - self.trigger(name, params); - }); - }; - - Select2.prototype._registerSelectionEvents = function () { - var self = this; - var nonRelayEvents = ['toggle', 'focus']; - - this.selection.on('toggle', function () { - self.toggleDropdown(); - }); - - this.selection.on('focus', function (params) { - self.focus(params); - }); - - this.selection.on('*', function (name, params) { - if ($.inArray(name, nonRelayEvents) !== -1) { - return; - } - - self.trigger(name, params); - }); - }; - - Select2.prototype._registerDropdownEvents = function () { - var self = this; - - this.dropdown.on('*', function (name, params) { - self.trigger(name, params); - }); - }; - - Select2.prototype._registerResultsEvents = function () { - var self = this; - - this.results.on('*', function (name, params) { - self.trigger(name, params); - }); - }; - - Select2.prototype._registerEvents = function () { - var self = this; - - this.on('open', function () { - self.$container.addClass('select2-container--open'); - }); - - this.on('close', function () { - self.$container.removeClass('select2-container--open'); - }); - - this.on('enable', function () { - self.$container.removeClass('select2-container--disabled'); - }); - - this.on('disable', function () { - self.$container.addClass('select2-container--disabled'); - }); - - this.on('blur', function () { - self.$container.removeClass('select2-container--focus'); - }); - - this.on('query', function (params) { - if (!self.isOpen()) { - self.trigger('open', {}); - } - - this.dataAdapter.query(params, function (data) { - self.trigger('results:all', { - data: data, - query: params - }); - }); - }); - - this.on('query:append', function (params) { - this.dataAdapter.query(params, function (data) { - self.trigger('results:append', { - data: data, - query: params - }); - }); - }); - - this.on('keypress', function (evt) { - var key = evt.which; - - if (self.isOpen()) { - if (key === KEYS.ESC || key === KEYS.TAB || - (key === KEYS.UP && evt.altKey)) { - self.close(evt); - - evt.preventDefault(); - } else if (key === KEYS.ENTER) { - self.trigger('results:select', {}); - - evt.preventDefault(); - } else if ((key === KEYS.SPACE && evt.ctrlKey)) { - self.trigger('results:toggle', {}); - - evt.preventDefault(); - } else if (key === KEYS.UP) { - self.trigger('results:previous', {}); - - evt.preventDefault(); - } else if (key === KEYS.DOWN) { - self.trigger('results:next', {}); - - evt.preventDefault(); - } - } else { - if (key === KEYS.ENTER || key === KEYS.SPACE || - (key === KEYS.DOWN && evt.altKey)) { - self.open(); - - evt.preventDefault(); - } - } - }); - }; - - Select2.prototype._syncAttributes = function () { - this.options.set('disabled', this.$element.prop('disabled')); - - if (this.isDisabled()) { - if (this.isOpen()) { - this.close(); - } - - this.trigger('disable', {}); - } else { - this.trigger('enable', {}); - } - }; - - Select2.prototype._isChangeMutation = function (evt, mutations) { - var changed = false; - var self = this; - - // Ignore any mutation events raised for elements that aren't options or - // optgroups. This handles the case when the select element is destroyed - if ( - evt && evt.target && ( - evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP' - ) - ) { - return; - } - - if (!mutations) { - // If mutation events aren't supported, then we can only assume that the - // change affected the selections - changed = true; - } else if (mutations.addedNodes && mutations.addedNodes.length > 0) { - for (var n = 0; n < mutations.addedNodes.length; n++) { - var node = mutations.addedNodes[n]; - - if (node.selected) { - changed = true; - } - } - } else if (mutations.removedNodes && mutations.removedNodes.length > 0) { - changed = true; - } else if ($.isArray(mutations)) { - $.each(mutations, function(evt, mutation) { - if (self._isChangeMutation(evt, mutation)) { - // We've found a change mutation. - // Let's escape from the loop and continue - changed = true; - return false; - } - }); - } - return changed; - }; - - Select2.prototype._syncSubtree = function (evt, mutations) { - var changed = this._isChangeMutation(evt, mutations); - var self = this; - - // Only re-pull the data if we think there is a change - if (changed) { - this.dataAdapter.current(function (currentData) { - self.trigger('selection:update', { - data: currentData - }); - }); - } - }; - - /** - * Override the trigger method to automatically trigger pre-events when - * there are events that can be prevented. - */ - Select2.prototype.trigger = function (name, args) { - var actualTrigger = Select2.__super__.trigger; - var preTriggerMap = { - 'open': 'opening', - 'close': 'closing', - 'select': 'selecting', - 'unselect': 'unselecting', - 'clear': 'clearing' - }; - - if (args === undefined) { - args = {}; - } - - if (name in preTriggerMap) { - var preTriggerName = preTriggerMap[name]; - var preTriggerArgs = { - prevented: false, - name: name, - args: args - }; - - actualTrigger.call(this, preTriggerName, preTriggerArgs); - - if (preTriggerArgs.prevented) { - args.prevented = true; - - return; - } - } - - actualTrigger.call(this, name, args); - }; - - Select2.prototype.toggleDropdown = function () { - if (this.isDisabled()) { - return; - } - - if (this.isOpen()) { - this.close(); - } else { - this.open(); - } - }; - - Select2.prototype.open = function () { - if (this.isOpen()) { - return; - } - - if (this.isDisabled()) { - return; - } - - this.trigger('query', {}); - }; - - Select2.prototype.close = function (evt) { - if (!this.isOpen()) { - return; - } - - this.trigger('close', { originalEvent : evt }); - }; - - /** - * Helper method to abstract the "enabled" (not "disabled") state of this - * object. - * - * @return {true} if the instance is not disabled. - * @return {false} if the instance is disabled. - */ - Select2.prototype.isEnabled = function () { - return !this.isDisabled(); - }; - - /** - * Helper method to abstract the "disabled" state of this object. - * - * @return {true} if the disabled option is true. - * @return {false} if the disabled option is false. - */ - Select2.prototype.isDisabled = function () { - return this.options.get('disabled'); - }; - - Select2.prototype.isOpen = function () { - return this.$container.hasClass('select2-container--open'); - }; - - Select2.prototype.hasFocus = function () { - return this.$container.hasClass('select2-container--focus'); - }; - - Select2.prototype.focus = function (data) { - // No need to re-trigger focus events if we are already focused - if (this.hasFocus()) { - return; - } - - this.$container.addClass('select2-container--focus'); - this.trigger('focus', {}); - }; - - Select2.prototype.enable = function (args) { - if (this.options.get('debug') && window.console && console.warn) { - console.warn( - 'Select2: The `select2("enable")` method has been deprecated and will' + - ' be removed in later Select2 versions. Use $element.prop("disabled")' + - ' instead.' - ); - } - - if (args == null || args.length === 0) { - args = [true]; - } - - var disabled = !args[0]; - - this.$element.prop('disabled', disabled); - }; - - Select2.prototype.data = function () { - if (this.options.get('debug') && - arguments.length > 0 && window.console && console.warn) { - console.warn( - 'Select2: Data can no longer be set using `select2("data")`. You ' + - 'should consider setting the value instead using `$element.val()`.' - ); - } - - var data = []; - - this.dataAdapter.current(function (currentData) { - data = currentData; - }); - - return data; - }; - - Select2.prototype.val = function (args) { - if (this.options.get('debug') && window.console && console.warn) { - console.warn( - 'Select2: The `select2("val")` method has been deprecated and will be' + - ' removed in later Select2 versions. Use $element.val() instead.' - ); - } - - if (args == null || args.length === 0) { - return this.$element.val(); - } - - var newVal = args[0]; - - if ($.isArray(newVal)) { - newVal = $.map(newVal, function (obj) { - return obj.toString(); - }); - } - - this.$element.val(newVal).trigger('input').trigger('change'); - }; - - Select2.prototype.destroy = function () { - this.$container.remove(); - - if (this.$element[0].detachEvent) { - this.$element[0].detachEvent('onpropertychange', this._syncA); - } - - if (this._observer != null) { - this._observer.disconnect(); - this._observer = null; - } else if (this.$element[0].removeEventListener) { - this.$element[0] - .removeEventListener('DOMAttrModified', this._syncA, false); - this.$element[0] - .removeEventListener('DOMNodeInserted', this._syncS, false); - this.$element[0] - .removeEventListener('DOMNodeRemoved', this._syncS, false); - } - - this._syncA = null; - this._syncS = null; - - this.$element.off('.select2'); - this.$element.attr('tabindex', - Utils.GetData(this.$element[0], 'old-tabindex')); - - this.$element.removeClass('select2-hidden-accessible'); - this.$element.attr('aria-hidden', 'false'); - Utils.RemoveData(this.$element[0]); - this.$element.removeData('select2'); - - this.dataAdapter.destroy(); - this.selection.destroy(); - this.dropdown.destroy(); - this.results.destroy(); - - this.dataAdapter = null; - this.selection = null; - this.dropdown = null; - this.results = null; - }; - - Select2.prototype.render = function () { - var $container = $( - '' + - '' + - '' + - '' - ); - - $container.attr('dir', this.options.get('dir')); - - this.$container = $container; - - this.$container.addClass('select2-container--' + this.options.get('theme')); - - Utils.StoreData($container[0], 'element', this.$element); - - return $container; - }; - - return Select2; -}); - -S2.define('jquery-mousewheel',[ - 'jquery' -], function ($) { - // Used to shim jQuery.mousewheel for non-full builds. - return $; -}); - -S2.define('jquery.select2',[ - 'jquery', - 'jquery-mousewheel', - - './select2/core', - './select2/defaults', - './select2/utils' -], function ($, _, Select2, Defaults, Utils) { - if ($.fn.select2 == null) { - // All methods that should return the element - var thisMethods = ['open', 'close', 'destroy']; - - $.fn.select2 = function (options) { - options = options || {}; - - if (typeof options === 'object') { - this.each(function () { - var instanceOptions = $.extend(true, {}, options); - - var instance = new Select2($(this), instanceOptions); - }); - - return this; - } else if (typeof options === 'string') { - var ret; - var args = Array.prototype.slice.call(arguments, 1); - - this.each(function () { - var instance = Utils.GetData(this, 'select2'); - - if (instance == null && window.console && console.error) { - console.error( - 'The select2(\'' + options + '\') method was called on an ' + - 'element that is not using Select2.' - ); - } - - ret = instance[options].apply(instance, args); - }); - - // Check if we should be returning `this` - if ($.inArray(options, thisMethods) > -1) { - return this; - } - - return ret; - } else { - throw new Error('Invalid arguments for Select2: ' + options); - } - }; - } - - if ($.fn.select2.defaults == null) { - $.fn.select2.defaults = Defaults; - } - - return Select2; -}); - - // Return the AMD loader configuration so it can be used outside of this file - return { - define: S2.define, - require: S2.require - }; -}()); - - // Autoload the jQuery bindings - // We know that all of the modules exist above this, so we're safe - var select2 = S2.require('jquery.select2'); - - // Hold the AMD module references on the jQuery function that was just loaded - // This allows Select2 to use the internal loader outside of this file, such - // as in the language files. - jQuery.fn.select2.amd = S2; - - // Return the Select2 instance for anyone who is importing it. - return select2; + return elementWidth + 'px'; + } + + if (method == 'style') { + var style = $element.attr('style'); + + if (typeof (style) !== 'string') { + return null; + } + + var attrs = style.split(';'); + + for (var i = 0, l = attrs.length; i < l; i = i + 1) { + var attr = attrs[i].replace(/\s/g, ''); + var matches = attr.match(WIDTH); + + if (matches !== null && matches.length >= 1) { + return matches[1]; + } + } + + return null; + } + + if (method == 'computedstyle') { + var computedStyle = window.getComputedStyle($element[0]); + + return computedStyle.width; + } + + return method; + }; + + Select2.prototype._bindAdapters = function () { + this.dataAdapter.bind(this, this.$container); + this.selection.bind(this, this.$container); + + this.dropdown.bind(this, this.$container); + this.results.bind(this, this.$container); + }; + + Select2.prototype._registerDomEvents = function () { + var self = this; + + this.$element.on('change.select2', function () { + self.dataAdapter.current(function (data) { + self.trigger('selection:update', { + data: data + }); + }); + }); + + this.$element.on('focus.select2', function (evt) { + self.trigger('focus', evt); + }); + + this._syncA = Utils.bind(this._syncAttributes, this); + this._syncS = Utils.bind(this._syncSubtree, this); + + if (this.$element[0].attachEvent) { + this.$element[0].attachEvent('onpropertychange', this._syncA); + } + + var observer = window.MutationObserver || + window.WebKitMutationObserver || + window.MozMutationObserver + ; + + if (observer != null) { + this._observer = new observer(function (mutations) { + self._syncA(); + self._syncS(null, mutations); + }); + this._observer.observe(this.$element[0], { + attributes: true, + childList: true, + subtree: false + }); + } else if (this.$element[0].addEventListener) { + this.$element[0].addEventListener( + 'DOMAttrModified', + self._syncA, + false + ); + this.$element[0].addEventListener( + 'DOMNodeInserted', + self._syncS, + false + ); + this.$element[0].addEventListener( + 'DOMNodeRemoved', + self._syncS, + false + ); + } + }; + + Select2.prototype._registerDataEvents = function () { + var self = this; + + this.dataAdapter.on('*', function (name, params) { + self.trigger(name, params); + }); + }; + + Select2.prototype._registerSelectionEvents = function () { + var self = this; + var nonRelayEvents = ['toggle', 'focus']; + + this.selection.on('toggle', function () { + self.toggleDropdown(); + }); + + this.selection.on('focus', function (params) { + self.focus(params); + }); + + this.selection.on('*', function (name, params) { + if ($.inArray(name, nonRelayEvents) !== -1) { + return; + } + + self.trigger(name, params); + }); + }; + + Select2.prototype._registerDropdownEvents = function () { + var self = this; + + this.dropdown.on('*', function (name, params) { + self.trigger(name, params); + }); + }; + + Select2.prototype._registerResultsEvents = function () { + var self = this; + + this.results.on('*', function (name, params) { + self.trigger(name, params); + }); + }; + + Select2.prototype._registerEvents = function () { + var self = this; + + this.on('open', function () { + self.$container.addClass('select2-container--open'); + }); + + this.on('close', function () { + self.$container.removeClass('select2-container--open'); + }); + + this.on('enable', function () { + self.$container.removeClass('select2-container--disabled'); + }); + + this.on('disable', function () { + self.$container.addClass('select2-container--disabled'); + }); + + this.on('blur', function () { + self.$container.removeClass('select2-container--focus'); + }); + + this.on('query', function (params) { + if (!self.isOpen()) { + self.trigger('open', {}); + } + + this.dataAdapter.query(params, function (data) { + self.trigger('results:all', { + data: data, + query: params + }); + }); + }); + + this.on('query:append', function (params) { + this.dataAdapter.query(params, function (data) { + self.trigger('results:append', { + data: data, + query: params + }); + }); + }); + + this.on('keypress', function (evt) { + var key = evt.which; + + if (self.isOpen()) { + if (key === KEYS.ESC || key === KEYS.TAB || + (key === KEYS.UP && evt.altKey)) { + self.close(evt); + + evt.preventDefault(); + } else if (key === KEYS.ENTER) { + self.trigger('results:select', {}); + + evt.preventDefault(); + } else if ((key === KEYS.SPACE && evt.ctrlKey)) { + self.trigger('results:toggle', {}); + + evt.preventDefault(); + } else if (key === KEYS.UP) { + self.trigger('results:previous', {}); + + evt.preventDefault(); + } else if (key === KEYS.DOWN) { + self.trigger('results:next', {}); + + evt.preventDefault(); + } + } else { + if (key === KEYS.ENTER || key === KEYS.SPACE || + (key === KEYS.DOWN && evt.altKey)) { + self.open(); + + evt.preventDefault(); + } + } + }); + }; + + Select2.prototype._syncAttributes = function () { + this.options.set('disabled', this.$element.prop('disabled')); + + if (this.isDisabled()) { + if (this.isOpen()) { + this.close(); + } + + this.trigger('disable', {}); + } else { + this.trigger('enable', {}); + } + }; + + Select2.prototype._isChangeMutation = function (evt, mutations) { + var changed = false; + var self = this; + + // Ignore any mutation events raised for elements that aren't options or + // optgroups. This handles the case when the select element is destroyed + if ( + evt && evt.target && ( + evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP' + ) + ) { + return; + } + + if (!mutations) { + // If mutation events aren't supported, then we can only assume that the + // change affected the selections + changed = true; + } else if (mutations.addedNodes && mutations.addedNodes.length > 0) { + for (var n = 0; n < mutations.addedNodes.length; n++) { + var node = mutations.addedNodes[n]; + + if (node.selected) { + changed = true; + } + } + } else if (mutations.removedNodes && mutations.removedNodes.length > 0) { + changed = true; + } else if ($.isArray(mutations)) { + $.each(mutations, function (evt, mutation) { + if (self._isChangeMutation(evt, mutation)) { + // We've found a change mutation. + // Let's escape from the loop and continue + changed = true; + return false; + } + }); + } + return changed; + }; + + Select2.prototype._syncSubtree = function (evt, mutations) { + var changed = this._isChangeMutation(evt, mutations); + var self = this; + + // Only re-pull the data if we think there is a change + if (changed) { + this.dataAdapter.current(function (currentData) { + self.trigger('selection:update', { + data: currentData + }); + }); + } + }; + + /** + * Override the trigger method to automatically trigger pre-events when + * there are events that can be prevented. + */ + Select2.prototype.trigger = function (name, args) { + var actualTrigger = Select2.__super__.trigger; + var preTriggerMap = { + 'open': 'opening', + 'close': 'closing', + 'select': 'selecting', + 'unselect': 'unselecting', + 'clear': 'clearing' + }; + + if (args === undefined) { + args = {}; + } + + if (name in preTriggerMap) { + var preTriggerName = preTriggerMap[name]; + var preTriggerArgs = { + prevented: false, + name: name, + args: args + }; + + actualTrigger.call(this, preTriggerName, preTriggerArgs); + + if (preTriggerArgs.prevented) { + args.prevented = true; + + return; + } + } + + actualTrigger.call(this, name, args); + }; + + Select2.prototype.toggleDropdown = function () { + if (this.isDisabled()) { + return; + } + + if (this.isOpen()) { + this.close(); + } else { + this.open(); + } + }; + + Select2.prototype.open = function () { + if (this.isOpen()) { + return; + } + + if (this.isDisabled()) { + return; + } + + this.trigger('query', {}); + }; + + Select2.prototype.close = function (evt) { + if (!this.isOpen()) { + return; + } + + this.trigger('close', {originalEvent: evt}); + }; + + /** + * Helper method to abstract the "enabled" (not "disabled") state of this + * object. + * + * @return {true} if the instance is not disabled. + * @return {false} if the instance is disabled. + */ + Select2.prototype.isEnabled = function () { + return !this.isDisabled(); + }; + + /** + * Helper method to abstract the "disabled" state of this object. + * + * @return {true} if the disabled option is true. + * @return {false} if the disabled option is false. + */ + Select2.prototype.isDisabled = function () { + return this.options.get('disabled'); + }; + + Select2.prototype.isOpen = function () { + return this.$container.hasClass('select2-container--open'); + }; + + Select2.prototype.hasFocus = function () { + return this.$container.hasClass('select2-container--focus'); + }; + + Select2.prototype.focus = function (data) { + // No need to re-trigger focus events if we are already focused + if (this.hasFocus()) { + return; + } + + this.$container.addClass('select2-container--focus'); + this.trigger('focus', {}); + }; + + Select2.prototype.enable = function (args) { + if (this.options.get('debug') && window.console && console.warn) { + console.warn( + 'Select2: The `select2("enable")` method has been deprecated and will' + + ' be removed in later Select2 versions. Use $element.prop("disabled")' + + ' instead.' + ); + } + + if (args == null || args.length === 0) { + args = [true]; + } + + var disabled = !args[0]; + + this.$element.prop('disabled', disabled); + }; + + Select2.prototype.data = function () { + if (this.options.get('debug') && + arguments.length > 0 && window.console && console.warn) { + console.warn( + 'Select2: Data can no longer be set using `select2("data")`. You ' + + 'should consider setting the value instead using `$element.val()`.' + ); + } + + var data = []; + + this.dataAdapter.current(function (currentData) { + data = currentData; + }); + + return data; + }; + + Select2.prototype.val = function (args) { + if (this.options.get('debug') && window.console && console.warn) { + console.warn( + 'Select2: The `select2("val")` method has been deprecated and will be' + + ' removed in later Select2 versions. Use $element.val() instead.' + ); + } + + if (args == null || args.length === 0) { + return this.$element.val(); + } + + var newVal = args[0]; + + if ($.isArray(newVal)) { + newVal = $.map(newVal, function (obj) { + return obj.toString(); + }); + } + + this.$element.val(newVal).trigger('input').trigger('change'); + }; + + Select2.prototype.destroy = function () { + this.$container.remove(); + + if (this.$element[0].detachEvent) { + this.$element[0].detachEvent('onpropertychange', this._syncA); + } + + if (this._observer != null) { + this._observer.disconnect(); + this._observer = null; + } else if (this.$element[0].removeEventListener) { + this.$element[0] + .removeEventListener('DOMAttrModified', this._syncA, false); + this.$element[0] + .removeEventListener('DOMNodeInserted', this._syncS, false); + this.$element[0] + .removeEventListener('DOMNodeRemoved', this._syncS, false); + } + + this._syncA = null; + this._syncS = null; + + this.$element.off('.select2'); + this.$element.attr('tabindex', + Utils.GetData(this.$element[0], 'old-tabindex')); + + this.$element.removeClass('select2-hidden-accessible'); + this.$element.attr('aria-hidden', 'false'); + Utils.RemoveData(this.$element[0]); + this.$element.removeData('select2'); + + this.dataAdapter.destroy(); + this.selection.destroy(); + this.dropdown.destroy(); + this.results.destroy(); + + this.dataAdapter = null; + this.selection = null; + this.dropdown = null; + this.results = null; + }; + + Select2.prototype.render = function () { + var $container = $( + '' + + '' + + '' + + '' + ); + + $container.attr('dir', this.options.get('dir')); + + this.$container = $container; + + this.$container.addClass('select2-container--' + this.options.get('theme')); + + Utils.StoreData($container[0], 'element', this.$element); + + return $container; + }; + + return Select2; + }); + + S2.define('jquery-mousewheel', [ + 'jquery' + ], function ($) { + // Used to shim jQuery.mousewheel for non-full builds. + return $; + }); + + S2.define('jquery.select2', [ + 'jquery', + 'jquery-mousewheel', + + './select2/core', + './select2/defaults', + './select2/utils' + ], function ($, _, Select2, Defaults, Utils) { + if ($.fn.select2 == null) { + // All methods that should return the element + var thisMethods = ['open', 'close', 'destroy']; + + $.fn.select2 = function (options) { + options = options || {}; + + if (typeof options === 'object') { + this.each(function () { + var instanceOptions = $.extend(true, {}, options); + + var instance = new Select2($(this), instanceOptions); + }); + + return this; + } else if (typeof options === 'string') { + var ret; + var args = Array.prototype.slice.call(arguments, 1); + + this.each(function () { + var instance = Utils.GetData(this, 'select2'); + + if (instance == null && window.console && console.error) { + console.error( + 'The select2(\'' + options + '\') method was called on an ' + + 'element that is not using Select2.' + ); + } + + ret = instance[options].apply(instance, args); + }); + + // Check if we should be returning `this` + if ($.inArray(options, thisMethods) > -1) { + return this; + } + + return ret; + } else { + throw new Error('Invalid arguments for Select2: ' + options); + } + }; + } + + if ($.fn.select2.defaults == null) { + $.fn.select2.defaults = Defaults; + } + + return Select2; + }); + + // Return the AMD loader configuration so it can be used outside of this file + return { + define: S2.define, + require: S2.require + }; + }()); + + // Autoload the jQuery bindings + // We know that all of the modules exist above this, so we're safe + var select2 = S2.require('jquery.select2'); + + // Hold the AMD module references on the jQuery function that was just loaded + // This allows Select2 to use the internal loader outside of this file, such + // as in the language files. + jQuery.fn.select2.amd = S2; + + // Return the Select2 instance for anyone who is importing it. + return select2; })); diff --git a/composer.lock b/composer.lock index b01e8265..9d5e7af3 100644 --- a/composer.lock +++ b/composer.lock @@ -1,3650 +1,3650 @@ { - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "95d782211f665f2ce585ab3c9f916b58", - "packages": [ - { - "name": "ralouphie/mimey", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/mimey.git", - "reference": "2a0e997c733b7c2f9f8b61cafb006fd5fb9fa15a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/mimey/zipball/2a0e997c733b7c2f9f8b61cafb006fd5fb9fa15a", - "reference": "2a0e997c733b7c2f9f8b61cafb006fd5fb9fa15a", - "shasum": "" - }, - "require": { - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "~3.7.0", - "satooshi/php-coveralls": ">=1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Mimey\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "PHP package for converting file extensions to MIME types and vice versa.", - "support": { - "issues": "https://github.com/ralouphie/mimey/issues", - "source": "https://github.com/ralouphie/mimey/tree/master" - }, - "time": "2016-09-28T03:36:23+00:00" - }, - { - "name": "techcrunch/wp-async-task", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/techcrunch/wp-async-task.git", - "reference": "9bdbbf9df4ff5179711bb58b9a2451296f6753dc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/techcrunch/wp-async-task/zipball/9bdbbf9df4ff5179711bb58b9a2451296f6753dc", - "reference": "9bdbbf9df4ff5179711bb58b9a2451296f6753dc", - "shasum": "" - }, - "require-dev": { - "10up/wp_mock": "dev-master", - "phpunit/phpunit": "*@stable" - }, - "default-branch": true, - "type": "wordpress-plugin", - "autoload": { - "classmap": [ - "wp-async-task.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alex Khadiwala", - "role": "developer" - }, - { - "name": "Nicolas Vincent", - "role": "developer" - }, - { - "name": "Eric Mann", - "email": "eric.mann@10up.com", - "role": "developer" - }, - { - "name": "John P. Bloch", - "email": "john.bloch@10up.com", - "role": "developer" - } - ], - "description": "Run asynchronous tasks for long-running operations in WordPress", - "support": { - "issues": "https://github.com/techcrunch/wp-async-task/issues", - "source": "https://github.com/techcrunch/wp-async-task/tree/master" - }, - "time": "2016-03-10T17:37:13+00:00" - } - ], - "packages-dev": [ - { - "name": "10up/wp_mock", - "version": "0.4.2", - "source": { - "type": "git", - "url": "https://github.com/10up/wp_mock.git", - "reference": "9019226eb50df275aa86bb15bfc98a619601ee49" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/10up/wp_mock/zipball/9019226eb50df275aa86bb15bfc98a619601ee49", - "reference": "9019226eb50df275aa86bb15bfc98a619601ee49", - "shasum": "" - }, - "require": { - "antecedent/patchwork": "^2.1", - "mockery/mockery": "^1.0", - "php": ">=7.1", - "phpunit/phpunit": ">=7.0" - }, - "require-dev": { - "behat/behat": "^3.0", - "php-coveralls/php-coveralls": "^2.1", - "sebastian/comparator": ">=1.2.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "WP_Mock\\": "./php/WP_Mock" - }, - "classmap": [ - "php/WP_Mock.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-or-later" - ], - "description": "A mocking library to take the pain out of unit testing for WordPress", - "support": { - "issues": "https://github.com/10up/wp_mock/issues", - "source": "https://github.com/10up/wp_mock/tree/master" - }, - "time": "2019-03-16T03:44:39+00:00" - }, - { - "name": "antecedent/patchwork", - "version": "2.1.17", - "source": { - "type": "git", - "url": "https://github.com/antecedent/patchwork.git", - "reference": "df5aba175a44c2996ced4edf8ec9f9081b5348c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/antecedent/patchwork/zipball/df5aba175a44c2996ced4edf8ec9f9081b5348c0", - "reference": "df5aba175a44c2996ced4edf8ec9f9081b5348c0", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": ">=4" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignas Rudaitis", - "email": "ignas.rudaitis@gmail.com" - } - ], - "description": "Method redefinition (monkey-patching) functionality for PHP.", - "homepage": "http://patchwork2.org/", - "keywords": [ - "aop", - "aspect", - "interception", - "monkeypatching", - "redefinition", - "runkit", - "testing" - ], - "support": { - "issues": "https://github.com/antecedent/patchwork/issues", - "source": "https://github.com/antecedent/patchwork/tree/2.1.17" - }, - "time": "2021-10-21T14:22:43+00:00" - }, - { - "name": "brianium/paratest", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/paratestphp/paratest.git", - "reference": "a448f456921719fdf8a2c0f6d1e2e8f63c085ffa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/a448f456921719fdf8a2c0f6d1e2e8f63c085ffa", - "reference": "a448f456921719fdf8a2c0f6d1e2e8f63c085ffa", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-simplexml": "*", - "php": "^7.3 || ^8.0", - "phpunit/php-code-coverage": "^9.2.7", - "phpunit/php-file-iterator": "^3.0.5", - "phpunit/php-timer": "^5.0.3", - "phpunit/phpunit": "^9.5.10", - "sebastian/environment": "^5.1.3", - "symfony/console": "^4.4.30 || ^5.3.7", - "symfony/process": "^4.4.30 || ^5.3.7" - }, - "require-dev": { - "doctrine/coding-standard": "^9.0.0", - "ekino/phpstan-banned-code": "^0.5.0", - "ergebnis/phpstan-rules": "^0.15.3", - "ext-posix": "*", - "infection/infection": "^0.25.3", - "phpstan/phpstan": "^0.12.99", - "phpstan/phpstan-deprecation-rules": "^0.12.6", - "phpstan/phpstan-phpunit": "^0.12.22", - "phpstan/phpstan-strict-rules": "^0.12.11", - "squizlabs/php_codesniffer": "^3.6.0", - "symfony/filesystem": "^5.3.4", - "thecodingmachine/phpstan-strict-rules": "^0.12.1", - "vimeo/psalm": "^4.10.0" - }, - "default-branch": true, - "bin": [ - "bin/paratest" - ], - "type": "library", - "autoload": { - "psr-4": { - "ParaTest\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Brian Scaturro", - "email": "scaturrob@gmail.com", - "role": "Developer" - }, - { - "name": "Filippo Tessarotto", - "email": "zoeslam@gmail.com", - "role": "Developer" - } - ], - "description": "Parallel testing for PHP", - "homepage": "https://github.com/paratestphp/paratest", - "keywords": [ - "concurrent", - "parallel", - "phpunit", - "testing" - ], - "support": { - "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v6.3.3" - }, - "funding": [ - { - "url": "https://github.com/sponsors/Slamdunk", - "type": "github" - }, - { - "url": "https://paypal.me/filippotessarotto", - "type": "paypal" - } - ], - "time": "2021-11-19T07:41:55+00:00" - }, - { - "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "7d5cb8826ed72d4ca4c07acf005bba2282e5a7c7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/7d5cb8826ed72d4ca4c07acf005bba2282e5a7c7", - "reference": "7d5cb8826ed72d4ca4c07acf005bba2282e5a7c7", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0" - }, - "require-dev": { - "composer/composer": "*", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpcompatibility/php-compatibility": "^9.0" - }, - "default-branch": true, - "type": "composer-plugin", - "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" - }, - "autoload": { - "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" - } - ], - "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", - "keywords": [ - "PHPCodeSniffer", - "PHP_CodeSniffer", - "code quality", - "codesniffer", - "composer", - "installer", - "phpcs", - "plugin", - "qa", - "quality", - "standard", - "standards", - "style guide", - "stylecheck", - "tests" - ], - "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" - }, - "time": "2021-08-16T14:43:41+00:00" - }, - { - "name": "doctrine/instantiator", - "version": "1.5.x-dev", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "6410c4b8352cb64218641457cef64997e6b784fb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/6410c4b8352cb64218641457cef64997e6b784fb", - "reference": "6410c4b8352cb64218641457cef64997e6b784fb", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^8.0", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.x" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2020-11-10T19:05:51+00:00" - }, - { - "name": "hamcrest/hamcrest-php", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "9891fca284ef0dfcb19c94453c29932c9bb9a3c2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/9891fca284ef0dfcb19c94453c29932c9bb9a3c2", - "reference": "9891fca284ef0dfcb19c94453c29932c9bb9a3c2", - "shasum": "" - }, - "require": { - "php": "^5.3|^7.0|^8.0" - }, - "replace": { - "cordoval/hamcrest-php": "*", - "davedevelopment/hamcrest-php": "*", - "kodova/hamcrest-php": "*" - }, - "require-dev": { - "phpunit/php-file-iterator": "^1.4 || ^2.0", - "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "classmap": [ - "hamcrest" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "This is the PHP port of Hamcrest Matchers", - "keywords": [ - "test" - ], - "support": { - "issues": "https://github.com/hamcrest/hamcrest-php/issues", - "source": "https://github.com/hamcrest/hamcrest-php/tree/master" - }, - "time": "2021-08-12T08:29:30+00:00" - }, - { - "name": "mockery/mockery", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/mockery/mockery.git", - "reference": "816475d89d82ea968796523de8e56237ac5921a6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/816475d89d82ea968796523de8e56237ac5921a6", - "reference": "816475d89d82ea968796523de8e56237ac5921a6", - "shasum": "" - }, - "require": { - "hamcrest/hamcrest-php": "^2.0.1", - "lib-pcre": ">=7.0", - "php": "^7.3 || ^8.0" - }, - "conflict": { - "phpunit/phpunit": "<8.0" - }, - "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.3" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "psr-0": { - "Mockery": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - }, - { - "name": "Dave Marshall", - "email": "dave.marshall@atstsolutions.co.uk", - "homepage": "http://davedevelopment.co.uk" - } - ], - "description": "Mockery is a simple yet flexible PHP mock object framework", - "homepage": "https://github.com/mockery/mockery", - "keywords": [ - "BDD", - "TDD", - "library", - "mock", - "mock objects", - "mockery", - "stub", - "test", - "test double", - "testing" - ], - "support": { - "issues": "https://github.com/mockery/mockery/issues", - "source": "https://github.com/mockery/mockery/tree/master" - }, - "time": "2021-10-19T08:50:45+00:00" - }, - { - "name": "myclabs/deep-copy", - "version": "1.x-dev", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "replace": { - "myclabs/deep-copy": "self.version" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" - }, - "default-branch": true, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" - }, - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", - "type": "tidelift" - } - ], - "time": "2020-11-13T09:40:50+00:00" - }, - { - "name": "nikic/php-parser", - "version": "v4.13.1", - "source": { - "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=7.0" - }, - "require-dev": { - "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" - }, - "bin": [ - "bin/php-parse" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.9-dev" - } - }, - "autoload": { - "psr-4": { - "PhpParser\\": "lib/PhpParser" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nikita Popov" - } - ], - "description": "A PHP parser written in PHP", - "keywords": [ - "parser", - "php" - ], - "support": { - "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1" - }, - "time": "2021-11-03T20:52:16+00:00" - }, - { - "name": "phar-io/manifest", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-phar": "*", - "ext-xmlwriter": "*", - "phar-io/version": "^3.0.1", - "php": "^7.2 || ^8.0" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "support": { - "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" - }, - "time": "2021-07-20T11:28:43+00:00" - }, - { - "name": "phar-io/version", - "version": "3.1.0", - "source": { - "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "bae7c545bef187884426f042434e561ab1ddb182" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", - "reference": "bae7c545bef187884426f042434e561ab1ddb182", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Library for handling version information and constraints", - "support": { - "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.1.0" - }, - "time": "2021-02-23T14:00:09+00:00" - }, - { - "name": "phpcompatibility/php-compatibility", - "version": "9.3.5", - "source": { - "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." - }, - "type": "phpcodesniffer-standard", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-or-later" - ], - "authors": [ - { - "name": "Wim Godden", - "homepage": "https://github.com/wimg", - "role": "lead" - }, - { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", - "role": "lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" - } - ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", - "keywords": [ - "compatibility", - "phpcs", - "standards" - ], - "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibility" - }, - "time": "2019-12-27T09:44:58+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "a0eeab580cbdf4414fef6978732510a36ed0a9d6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/a0eeab580cbdf4414fef6978732510a36ed0a9d6", - "reference": "a0eeab580cbdf4414fef6978732510a36ed0a9d6", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master" - }, - "time": "2021-06-25T13:47:51+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" - }, - "time": "2021-10-19T17:43:47+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.x-dev", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "2a7ec2a310e8dff274c8af3bf3005288f0b1b7f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2a7ec2a310e8dff274c8af3bf3005288f0b1b7f6", - "reference": "2a7ec2a310e8dff274c8af3bf3005288f0b1b7f6", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "psalm/phar": "^4.8" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" - }, - "time": "2021-11-09T20:01:14+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", - "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.14.0" - }, - "time": "2021-09-10T09:02:12+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "9.2.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", - "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-libxml": "*", - "ext-xmlwriter": "*", - "nikic/php-parser": "^4.13.0", - "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "9.2-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.9" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-11-19T15:21:02+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "3.0.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "d7e633e95043246c5370e96d4cd17aa2cc79ab78" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/d7e633e95043246c5370e96d4cd17aa2cc79ab78", - "reference": "d7e633e95043246c5370e96d4cd17aa2cc79ab78", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-07-30T13:35:46+00:00" - }, - { - "name": "phpunit/php-invoker", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "ext-pcntl": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-pcntl": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Invoke callables with a timeout", - "homepage": "https://github.com/sebastianbergmann/php-invoker/", - "keywords": [ - "process" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T05:58:55+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T05:33:50+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "5.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:16:10+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "9.5.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6bcc8e610a24b9d382da960199447f8c40ae08f3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6bcc8e610a24b9d382da960199447f8c40ae08f3", - "reference": "6bcc8e610a24b9d382da960199447f8c40ae08f3", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.3.1", - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", - "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.7", - "phpunit/php-file-iterator": "^3.0.5", - "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^2.3.4", - "sebastian/version": "^3.0.2" - }, - "require-dev": { - "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0.1" - }, - "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "9.5-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ], - "files": [ - "src/Framework/Assert/Functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5" - }, - "funding": [ - { - "url": "https://phpunit.de/sponsors.html", - "type": "custom" - }, - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-11-11T09:11:03+00:00" - }, - { - "name": "psr/container", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "shasum": "" - }, - "require": { - "php": ">=7.4.0" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/2.0.2" - }, - "time": "2021-11-05T16:47:00+00:00" - }, - { - "name": "sebastian/cli-parser", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for parsing CLI options", - "homepage": "https://github.com/sebastianbergmann/cli-parser", - "support": { - "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T06:08:49+00:00" - }, - { - "name": "sebastian/code-unit", - "version": "1.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Collection of value objects that represent the PHP code units", - "homepage": "https://github.com/sebastianbergmann/code-unit", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:08:54+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "2.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T05:30:19+00:00" - }, - { - "name": "sebastian/comparator", - "version": "4.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "sebastian/diff": "^4.0", - "sebastian/exporter": "^4.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T15:49:45+00:00" - }, - { - "name": "sebastian/complexity", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^4.7", - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for calculating the complexity of PHP code units", - "homepage": "https://github.com/sebastianbergmann/complexity", - "support": { - "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T15:52:27+00:00" - }, - { - "name": "sebastian/diff", - "version": "4.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3", - "symfony/process": "^4.2 || ^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:10:38+00:00" - }, - { - "name": "sebastian/environment", - "version": "5.1.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-posix": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T05:52:38+00:00" - }, - { - "name": "sebastian/exporter", - "version": "4.0.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "sebastian/recursion-context": "^4.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "https://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-11-11T14:18:36+00:00" - }, - { - "name": "sebastian/global-state", - "version": "5.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" - }, - "require-dev": { - "ext-dom": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-06-11T13:31:12+00:00" - }, - { - "name": "sebastian/lines-of-code", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^4.6", - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for counting the lines of code in PHP source code", - "homepage": "https://github.com/sebastianbergmann/lines-of-code", - "support": { - "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-28T06:42:11+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "4.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:12:34+00:00" - }, - { - "name": "sebastian/object-reflector", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Allows reflection of object attributes, including inherited and non-public ones", - "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:14:26+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "4.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:17:30+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "abandoned": true, - "time": "2020-09-28T06:45:17+00:00" - }, - { - "name": "sebastian/type", - "version": "2.3.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/type.git", - "reference": "f24cbc541026c3bb7d27c647f0f9ea337135b22a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/f24cbc541026c3bb7d27c647f0f9ea337135b22a", - "reference": "f24cbc541026c3bb7d27c647f0f9ea337135b22a", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Collection of value objects that represent the types of the PHP type system", - "homepage": "https://github.com/sebastianbergmann/type", - "support": { - "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/2.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-06-18T06:28:45+00:00" - }, - { - "name": "sebastian/version", - "version": "3.0.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c6c1022351a901512170118436c764e473f6de8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", - "reference": "c6c1022351a901512170118436c764e473f6de8c", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "support": { - "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T06:39:44+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "0ed1d8c5ac325d6222396f7034d9c8e9d68a0cc9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/0ed1d8c5ac325d6222396f7034d9c8e9d68a0cc9", - "reference": "0ed1d8c5ac325d6222396f7034d9c8e9d68a0cc9", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "default-branch": true, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards" - ], - "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" - }, - "time": "2021-11-22T22:20:58+00:00" - }, - { - "name": "symfony/console", - "version": "5.4.x-dev", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "f797eedbbede8a2e6cdb8d5f16da0d6fb9bbfd12" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/f797eedbbede8a2e6cdb8d5f16da0d6fb9bbfd12", - "reference": "f797eedbbede8a2e6cdb8d5f16da0d6fb9bbfd12", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", - "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" - }, - "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" - }, - "provide": { - "psr/log-implementation": "1.0|2.0" - }, - "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Eases the creation of beautiful and testable command line interfaces", - "homepage": "https://symfony.com", - "keywords": [ - "cli", - "command line", - "console", - "terminal" - ], - "support": { - "source": "https://github.com/symfony/console/tree/5.4" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-11-23T18:53:11+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "dev-main", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", - "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", - "shasum": "" - }, - "require": { - "php": ">=8.0.2" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.0-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-11-01T23:48:49+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "dev-main", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "30885182c981ab175d4d034db0f6f469898070ab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", - "reference": "30885182c981ab175d4d034db0f6f469898070ab", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/main" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-10-20T20:35:02+00:00" - }, - { - "name": "symfony/polyfill-intl-grapheme", - "version": "dev-main", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", - "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's grapheme_* functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "grapheme", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/main" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-11-23T21:10:46+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "dev-main", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "intl", - "normalizer", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-02-19T12:13:01+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "dev-main", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "11b9acb5e8619aef6455735debf77dde8825795c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/11b9acb5e8619aef6455735debf77dde8825795c", - "reference": "11b9acb5e8619aef6455735debf77dde8825795c", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/main" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-10-20T20:35:02+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "dev-main", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/main" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-06-05T21:20:04+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "dev-main", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/main" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-09-13T13:58:33+00:00" - }, - { - "name": "symfony/process", - "version": "5.4.x-dev", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "e8f02d0795d3852e2e0169dc7660786e9de30859" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/e8f02d0795d3852e2e0169dc7660786e9de30859", - "reference": "e8f02d0795d3852e2e0169dc7660786e9de30859", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Executes commands in sub-processes", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/process/tree/5.4" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-11-23T14:18:55+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "dev-main", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/36715ebf9fb9db73db0cb24263c79077c6fe8603", - "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603", - "shasum": "" - }, - "require": { - "php": ">=8.0.2", - "psr/container": "^2.0" - }, - "conflict": { - "ext-psr": "<1.1|>=2" - }, - "suggest": { - "symfony/service-implementation": "" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.0-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.0.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-11-04T17:53:12+00:00" - }, - { - "name": "symfony/string", - "version": "6.0.x-dev", - "source": { - "type": "git", - "url": "https://github.com/symfony/string.git", - "reference": "ba727797426af0f587f4800566300bdc0cda0777" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/ba727797426af0f587f4800566300bdc0cda0777", - "reference": "ba727797426af0f587f4800566300bdc0cda0777", - "shasum": "" - }, - "require": { - "php": ">=8.0.2", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-intl-grapheme": "~1.0", - "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "conflict": { - "symfony/translation-contracts": "<2.0" - }, - "require-dev": { - "symfony/error-handler": "^5.4|^6.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/translation-contracts": "^2.0|^3.0", - "symfony/var-exporter": "^5.4|^6.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\String\\": "" - }, - "files": [ - "Resources/functions.php" - ], - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", - "homepage": "https://symfony.com", - "keywords": [ - "grapheme", - "i18n", - "string", - "unicode", - "utf-8", - "utf8" - ], - "support": { - "source": "https://github.com/symfony/string/tree/6.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-10-29T07:35:21+00:00" - }, - { - "name": "theseer/tokenizer", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": "^7.2 || ^8.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - } - ], - "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "support": { - "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" - }, - "funding": [ - { - "url": "https://github.com/theseer", - "type": "github" - } - ], - "time": "2021-07-28T10:34:58+00:00" - }, - { - "name": "webmozart/assert", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "b419d648592b0b8911cbbe10d450fe314f4fd262" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/b419d648592b0b8911cbbe10d450fe314f4fd262", - "reference": "b419d648592b0b8911cbbe10d450fe314f4fd262", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "default-branch": true, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/master" - }, - "time": "2021-06-19T13:45:26+00:00" - }, - { - "name": "wp-coding-standards/wpcs", - "version": "2.3.0", - "source": { - "type": "git", - "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "7da1894633f168fe244afc6de00d141f27517b62" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", - "reference": "7da1894633f168fe244afc6de00d141f27517b62", - "shasum": "" - }, - "require": { - "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.3.1" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", - "phpcompatibility/php-compatibility": "^9.0", - "phpcsstandards/phpcsdevtools": "^1.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." - }, - "type": "phpcodesniffer-standard", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Contributors", - "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" - } - ], - "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", - "keywords": [ - "phpcs", - "standards", - "wordpress" - ], - "support": { - "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", - "source": "https://github.com/WordPress/WordPress-Coding-Standards", - "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" - }, - "time": "2020-05-13T23:57:56+00:00" - } - ], - "aliases": [], - "minimum-stability": "dev", - "stability-flags": { - "techcrunch/wp-async-task": 20, - "brianium/paratest": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=7.0" - }, - "platform-dev": [], - "plugin-api-version": "2.2.0" + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "95d782211f665f2ce585ab3c9f916b58", + "packages": [ + { + "name": "ralouphie/mimey", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/mimey.git", + "reference": "2a0e997c733b7c2f9f8b61cafb006fd5fb9fa15a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/mimey/zipball/2a0e997c733b7c2f9f8b61cafb006fd5fb9fa15a", + "reference": "2a0e997c733b7c2f9f8b61cafb006fd5fb9fa15a", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7.0", + "satooshi/php-coveralls": ">=1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mimey\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "PHP package for converting file extensions to MIME types and vice versa.", + "support": { + "issues": "https://github.com/ralouphie/mimey/issues", + "source": "https://github.com/ralouphie/mimey/tree/master" + }, + "time": "2016-09-28T03:36:23+00:00" + }, + { + "name": "techcrunch/wp-async-task", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/techcrunch/wp-async-task.git", + "reference": "9bdbbf9df4ff5179711bb58b9a2451296f6753dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/techcrunch/wp-async-task/zipball/9bdbbf9df4ff5179711bb58b9a2451296f6753dc", + "reference": "9bdbbf9df4ff5179711bb58b9a2451296f6753dc", + "shasum": "" + }, + "require-dev": { + "10up/wp_mock": "dev-master", + "phpunit/phpunit": "*@stable" + }, + "default-branch": true, + "type": "wordpress-plugin", + "autoload": { + "classmap": [ + "wp-async-task.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Khadiwala", + "role": "developer" + }, + { + "name": "Nicolas Vincent", + "role": "developer" + }, + { + "name": "Eric Mann", + "email": "eric.mann@10up.com", + "role": "developer" + }, + { + "name": "John P. Bloch", + "email": "john.bloch@10up.com", + "role": "developer" + } + ], + "description": "Run asynchronous tasks for long-running operations in WordPress", + "support": { + "issues": "https://github.com/techcrunch/wp-async-task/issues", + "source": "https://github.com/techcrunch/wp-async-task/tree/master" + }, + "time": "2016-03-10T17:37:13+00:00" + } + ], + "packages-dev": [ + { + "name": "10up/wp_mock", + "version": "0.4.2", + "source": { + "type": "git", + "url": "https://github.com/10up/wp_mock.git", + "reference": "9019226eb50df275aa86bb15bfc98a619601ee49" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/10up/wp_mock/zipball/9019226eb50df275aa86bb15bfc98a619601ee49", + "reference": "9019226eb50df275aa86bb15bfc98a619601ee49", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.1", + "mockery/mockery": "^1.0", + "php": ">=7.1", + "phpunit/phpunit": ">=7.0" + }, + "require-dev": { + "behat/behat": "^3.0", + "php-coveralls/php-coveralls": "^2.1", + "sebastian/comparator": ">=1.2.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "WP_Mock\\": "./php/WP_Mock" + }, + "classmap": [ + "php/WP_Mock.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "description": "A mocking library to take the pain out of unit testing for WordPress", + "support": { + "issues": "https://github.com/10up/wp_mock/issues", + "source": "https://github.com/10up/wp_mock/tree/master" + }, + "time": "2019-03-16T03:44:39+00:00" + }, + { + "name": "antecedent/patchwork", + "version": "2.1.17", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "df5aba175a44c2996ced4edf8ec9f9081b5348c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/df5aba175a44c2996ced4edf8ec9f9081b5348c0", + "reference": "df5aba175a44c2996ced4edf8ec9f9081b5348c0", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "http://patchwork2.org/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "support": { + "issues": "https://github.com/antecedent/patchwork/issues", + "source": "https://github.com/antecedent/patchwork/tree/2.1.17" + }, + "time": "2021-10-21T14:22:43+00:00" + }, + { + "name": "brianium/paratest", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/paratestphp/paratest.git", + "reference": "a448f456921719fdf8a2c0f6d1e2e8f63c085ffa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/a448f456921719fdf8a2c0f6d1e2e8f63c085ffa", + "reference": "a448f456921719fdf8a2c0f6d1e2e8f63c085ffa", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-simplexml": "*", + "php": "^7.3 || ^8.0", + "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-timer": "^5.0.3", + "phpunit/phpunit": "^9.5.10", + "sebastian/environment": "^5.1.3", + "symfony/console": "^4.4.30 || ^5.3.7", + "symfony/process": "^4.4.30 || ^5.3.7" + }, + "require-dev": { + "doctrine/coding-standard": "^9.0.0", + "ekino/phpstan-banned-code": "^0.5.0", + "ergebnis/phpstan-rules": "^0.15.3", + "ext-posix": "*", + "infection/infection": "^0.25.3", + "phpstan/phpstan": "^0.12.99", + "phpstan/phpstan-deprecation-rules": "^0.12.6", + "phpstan/phpstan-phpunit": "^0.12.22", + "phpstan/phpstan-strict-rules": "^0.12.11", + "squizlabs/php_codesniffer": "^3.6.0", + "symfony/filesystem": "^5.3.4", + "thecodingmachine/phpstan-strict-rules": "^0.12.1", + "vimeo/psalm": "^4.10.0" + }, + "default-branch": true, + "bin": [ + "bin/paratest" + ], + "type": "library", + "autoload": { + "psr-4": { + "ParaTest\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Scaturro", + "email": "scaturrob@gmail.com", + "role": "Developer" + }, + { + "name": "Filippo Tessarotto", + "email": "zoeslam@gmail.com", + "role": "Developer" + } + ], + "description": "Parallel testing for PHP", + "homepage": "https://github.com/paratestphp/paratest", + "keywords": [ + "concurrent", + "parallel", + "phpunit", + "testing" + ], + "support": { + "issues": "https://github.com/paratestphp/paratest/issues", + "source": "https://github.com/paratestphp/paratest/tree/v6.3.3" + }, + "funding": [ + { + "url": "https://github.com/sponsors/Slamdunk", + "type": "github" + }, + { + "url": "https://paypal.me/filippotessarotto", + "type": "paypal" + } + ], + "time": "2021-11-19T07:41:55+00:00" + }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "7d5cb8826ed72d4ca4c07acf005bba2282e5a7c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/7d5cb8826ed72d4ca4c07acf005bba2282e5a7c7", + "reference": "7d5cb8826ed72d4ca4c07acf005bba2282e5a7c7", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpcompatibility/php-compatibility": "^9.0" + }, + "default-branch": true, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2021-08-16T14:43:41+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.5.x-dev", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "6410c4b8352cb64218641457cef64997e6b784fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/6410c4b8352cb64218641457cef64997e6b784fb", + "reference": "6410c4b8352cb64218641457cef64997e6b784fb", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^8.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.x" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-11-10T19:05:51+00:00" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "9891fca284ef0dfcb19c94453c29932c9bb9a3c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/9891fca284ef0dfcb19c94453c29932c9bb9a3c2", + "reference": "9891fca284ef0dfcb19c94453c29932c9bb9a3c2", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/master" + }, + "time": "2021-08-12T08:29:30+00:00" + }, + { + "name": "mockery/mockery", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "816475d89d82ea968796523de8e56237ac5921a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/816475d89d82ea968796523de8e56237ac5921a6", + "reference": "816475d89d82ea968796523de8e56237ac5921a6", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": "^7.3 || ^8.0" + }, + "conflict": { + "phpunit/phpunit": "<8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.3" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "support": { + "issues": "https://github.com/mockery/mockery/issues", + "source": "https://github.com/mockery/mockery/tree/master" + }, + "time": "2021-10-19T08:50:45+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.x-dev", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "default-branch": true, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.13.1", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", + "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1" + }, + "time": "2021-11-03T20:52:16+00:00" + }, + { + "name": "phar-io/manifest", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" + }, + { + "name": "phar-io/version", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "bae7c545bef187884426f042434e561ab1ddb182" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", + "reference": "bae7c545bef187884426f042434e561ab1ddb182", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.1.0" + }, + "time": "2021-02-23T14:00:09+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "a0eeab580cbdf4414fef6978732510a36ed0a9d6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/a0eeab580cbdf4414fef6978732510a36ed0a9d6", + "reference": "a0eeab580cbdf4414fef6978732510a36ed0a9d6", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master" + }, + "time": "2021-06-25T13:47:51+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" + }, + "require-dev": { + "mockery/mockery": "~1.3.2", + "psalm/phar": "^4.8" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + }, + "time": "2021-10-19T17:43:47+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.x-dev", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "2a7ec2a310e8dff274c8af3bf3005288f0b1b7f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2a7ec2a310e8dff274c8af3bf3005288f0b1b7f6", + "reference": "2a7ec2a310e8dff274c8af3bf3005288f0b1b7f6", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*", + "psalm/phar": "^4.8" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" + }, + "time": "2021-11-09T20:01:14+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.2", + "php": "^7.2 || ~8.0, <8.2", + "phpdocumentor/reflection-docblock": "^5.2", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" + }, + "require-dev": { + "phpspec/phpspec": "^6.0 || ^7.0", + "phpunit/phpunit": "^8.0 || ^9.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Prophecy\\": "src/Prophecy" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/1.14.0" + }, + "time": "2021-09-10T09:02:12+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.x-dev", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", + "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.13.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.9" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-11-19T15:21:02+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.x-dev", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "d7e633e95043246c5370e96d4cd17aa2cc79ab78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/d7e633e95043246c5370e96d4cd17aa2cc79ab78", + "reference": "d7e633e95043246c5370e96d4cd17aa2cc79ab78", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-07-30T13:35:46+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.5.x-dev", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "6bcc8e610a24b9d382da960199447f8c40ae08f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6bcc8e610a24b9d382da960199447f8c40ae08f3", + "reference": "6bcc8e610a24b9d382da960199447f8c40ae08f3", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.3.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=7.3", + "phpspec/prophecy": "^1.12.1", + "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.5", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.3", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^2.3.4", + "sebastian/version": "^3.0.2" + }, + "require-dev": { + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0.1" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.5-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-11-11T09:11:03+00:00" + }, + { + "name": "psr/container", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:49:45+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.7", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:52:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:10:38+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:52:38+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.x-dev", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-11-11T14:18:36+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-06-11T13:31:12+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.6", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-28T06:42:11+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:17:30+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "abandoned": true, + "time": "2020-09-28T06:45:17+00:00" + }, + { + "name": "sebastian/type", + "version": "2.3.x-dev", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "f24cbc541026c3bb7d27c647f0f9ea337135b22a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/f24cbc541026c3bb7d27c647f0f9ea337135b22a", + "reference": "f24cbc541026c3bb7d27c647f0f9ea337135b22a", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/2.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-06-18T06:28:45+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.x-dev", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "0ed1d8c5ac325d6222396f7034d9c8e9d68a0cc9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/0ed1d8c5ac325d6222396f7034d9c8e9d68a0cc9", + "reference": "0ed1d8c5ac325d6222396f7034d9c8e9d68a0cc9", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "default-branch": true, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-11-22T22:20:58+00:00" + }, + { + "name": "symfony/console", + "version": "5.4.x-dev", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "f797eedbbede8a2e6cdb8d5f16da0d6fb9bbfd12" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/f797eedbbede8a2e6cdb8d5f16da0d6fb9bbfd12", + "reference": "f797eedbbede8a2e6cdb8d5f16da0d6fb9bbfd12", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.1|^6.0" + }, + "conflict": { + "psr/log": ">=3", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0" + }, + "require-dev": { + "psr/log": "^1|^2", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-23T18:53:11+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", + "shasum": "" + }, + "require": { + "php": ">=8.0.2" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-01T23:48:49+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "30885182c981ab175d4d034db0f6f469898070ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/main" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-20T20:35:02+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/main" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-23T21:10:46+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "11b9acb5e8619aef6455735debf77dde8825795c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/11b9acb5e8619aef6455735debf77dde8825795c", + "reference": "11b9acb5e8619aef6455735debf77dde8825795c", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/main" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-20T20:35:02+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/main" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-06-05T21:20:04+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/main" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-09-13T13:58:33+00:00" + }, + { + "name": "symfony/process", + "version": "5.4.x-dev", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "e8f02d0795d3852e2e0169dc7660786e9de30859" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/e8f02d0795d3852e2e0169dc7660786e9de30859", + "reference": "e8f02d0795d3852e2e0169dc7660786e9de30859", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-23T14:18:55+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/36715ebf9fb9db73db0cb24263c79077c6fe8603", + "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "psr/container": "^2.0" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-04T17:53:12+00:00" + }, + { + "name": "symfony/string", + "version": "6.0.x-dev", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "ba727797426af0f587f4800566300bdc0cda0777" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/ba727797426af0f587f4800566300bdc0cda0777", + "reference": "ba727797426af0f587f4800566300bdc0cda0777", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.0" + }, + "require-dev": { + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/translation-contracts": "^2.0|^3.0", + "symfony/var-exporter": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "files": [ + "Resources/functions.php" + ], + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-29T07:35:21+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2021-07-28T10:34:58+00:00" + }, + { + "name": "webmozart/assert", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "b419d648592b0b8911cbbe10d450fe314f4fd262" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/b419d648592b0b8911cbbe10d450fe314f4fd262", + "reference": "b419d648592b0b8911cbbe10d450fe314f4fd262", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/master" + }, + "time": "2021-06-19T13:45:26+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "7da1894633f168fe244afc6de00d141f27517b62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", + "reference": "7da1894633f168fe244afc6de00d141f27517b62", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.3.1" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", + "phpcompatibility/php-compatibility": "^9.0", + "phpcsstandards/phpcsdevtools": "^1.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "wordpress" + ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, + "time": "2020-05-13T23:57:56+00:00" + } + ], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": { + "techcrunch/wp-async-task": 20, + "brianium/paratest": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.0" + }, + "platform-dev": [], + "plugin-api-version": "2.2.0" } diff --git a/gathercontent-importer.php b/gathercontent-importer.php index 155122bb..28fddd57 100644 --- a/gathercontent-importer.php +++ b/gathercontent-importer.php @@ -58,9 +58,9 @@ * If the server does not have the minimum supported version of PHP, * this notice will be shown in the dashboard. * + * @return void * @since 3.0.0 * - * @return void */ function gathercontent_importer_php_version_too_low_notice() { printf( @@ -72,9 +72,9 @@ function gathercontent_importer_php_version_too_low_notice() { /** * If the version of WordPress is not supported, this notice will be shown in the dashboard. * + * @return void * @since 3.0.0 * - * @return void */ function gathercontent_importer_wp_version_too_low_notice() { printf( @@ -86,20 +86,21 @@ function gathercontent_importer_wp_version_too_low_notice() { /** * Registers the default textdomain. * - * @since 3.0.0 - * + * @return void * @uses apply_filters() * @uses get_locale() * @uses load_textdomain() * @uses load_plugin_textdomain() * @uses plugin_basename() * - * @return void + * @since 3.0.0 + * */ function gathercontent_importer_i18n() { $text_domain = GATHERCONTENT_SLUG; - $locale = apply_filters( 'plugin_locale', get_locale(), $text_domain ); + $locale = apply_filters( 'plugin_locale', get_locale(), $text_domain ); load_textdomain( $text_domain, WP_LANG_DIR . "/{$text_domain}/{$text_domain}-{$locale}.mo" ); load_plugin_textdomain( $text_domain, false, plugin_basename( GATHERCONTENT_PATH ) . '/languages/' ); } + add_action( 'init', 'gathercontent_importer_i18n' ); diff --git a/includes/classes/admin/admin.php b/includes/classes/admin/admin.php index da2f3b7a..3e1a17c2 100644 --- a/includes/classes/admin/admin.php +++ b/includes/classes/admin/admin.php @@ -1,4 +1,5 @@ step > 0 ) { @@ -420,9 +425,9 @@ public function api_setup_complete_cb() { /** * Determine if settings need to be migrated from previous version. * + * @return mixed Settings key prefix, if old settings are found. * @since 3.0.0 * - * @return mixed Settings key prefix, if old settings are found. */ public function should_migrate() { if ( $this->get_setting( 'migrated' ) ) { @@ -438,9 +443,9 @@ public function should_migrate() { * Since previous version used `plugin_basename( __FILE__ )` to determine * the option prefix, we have to check a couple possible variations. * + * @return mixed Settings key prefix, if old settings are found. * @since 3.0.0.9 * - * @return mixed Settings key prefix, if old settings are found. */ public function prev_option_key() { $prefixes = array( diff --git a/includes/classes/admin/ajax/handlers.php b/includes/classes/admin/ajax/handlers.php index c2c48c9c..5de62787 100644 --- a/includes/classes/admin/ajax/handlers.php +++ b/includes/classes/admin/ajax/handlers.php @@ -45,9 +45,10 @@ class Handlers extends Plugin_Base { /** * Creates an instance of this class. * + * @param API $api API object. + * * @since 3.0.0 * - * @param API $api API object. */ public function __construct( API $api ) { @@ -59,9 +60,9 @@ public function __construct( API $api ) { /** * Initiates the ajax hook callbacks. * + * @return void * @since 3.0.0 * - * @return void */ public function init_hooks() { add_action( 'wp_ajax_gc_get_option_data', array( $this, 'gc_get_option_data_cb' ) ); @@ -82,9 +83,9 @@ public function init_hooks() { /** * Fetches select2 options. * + * @return void * @since 3.0.0 * - * @return void */ public function gc_get_option_data_cb() { if ( ! $this->_get_val( 'q' ) || ! $this->_get_val( 'column' ) ) { @@ -113,9 +114,9 @@ public function gc_get_option_data_cb() { /** * Fetches post item updates for the post-listing page. * + * @return void * @since 3.0.0 * - * @return void */ public function gc_get_posts_cb() { @@ -166,9 +167,9 @@ public function gc_get_posts_cb() { /** * Fetches post mapping project's available statuses. * + * @return void * @since 3.0.0 * - * @return void */ public function gc_get_post_statuses_cb() { $post_id = $this->_post_val( 'postId' ); @@ -200,9 +201,9 @@ public function gc_get_post_statuses_cb() { /** * Sets the GatherContent status for an item. * + * @return void * @since 3.0.0 * - * @return void */ public function set_gc_status_cb() { $post_data = $this->_post_val( 'post' ); @@ -229,9 +230,9 @@ public function set_gc_status_cb() { /** * Fetches fresh post-data for post model. * + * @return void * @since 3.0.0 * - * @return void */ public function gc_fetch_js_post_cb() { @@ -267,9 +268,9 @@ public function gc_disconnect_post_cb() { /** * Sets mapping id for a post or posts. * + * @return void * @since 3.0.0 * - * @return void */ public function gc_save_mapping_id_cb() { $post_data = $this->_post_val( 'post' ); @@ -312,9 +313,9 @@ public function gc_save_mapping_id_cb() { * Gets listing of accounts, projects, or template-mappings, only if template-mapping * exists for that account/project. * + * @return void * @since 3.0.0 * - * @return void */ public function gc_wp_filter_mappings_cb() { $post_data = $this->_post_val( 'post' ); @@ -381,9 +382,9 @@ public function gc_wp_filter_mappings_cb() { /** * Ajax callback when dismissing import errors.. will delete those errors to not show again. * + * @return void * @since 3.0.0 * - * @return void */ public function gc_dismiss_notice_cb() { if ( ! $this->_post_val( 'mapping' ) ) { @@ -408,9 +409,9 @@ public function gc_dismiss_notice_cb() { /** * Ajax callback when getting Component subfields for the mapping UI * + * @return void * @since 3.2.20 * - * @return void */ public function gc_component_subfields_cb() { // If data not provided from FE, stop and return error @@ -421,25 +422,24 @@ public function gc_component_subfields_cb() { $data = $this->_post_val( 'subfields_data' ); // If ACF Field group - if ( $data['name'] && str_contains($data['name'],"group") ){ - $field_group = acf_get_fields($data['name']); + if ( $data['name'] && str_contains( $data['name'], "group" ) ) { + $field_group = acf_get_fields( $data['name'] ); // If Repeater with sub fields - if($field_group){ + if ( $field_group ) { $success_data = array( 'field_data' => $field_group, ); - wp_send_json_success($success_data); + wp_send_json_success( $success_data ); } - } - // If field, get sub fields - elseif ( $data['name'] && str_contains($data['name'],"field") ){ - $field_parent = get_field_object($data['name']); + } // If field, get sub fields + elseif ( $data['name'] && str_contains( $data['name'], "field" ) ) { + $field_parent = get_field_object( $data['name'] ); // If Repeater with sub fields - if($field_parent['sub_fields']){ + if ( $field_parent['sub_fields'] ) { $success_data = array( 'field_data' => $field_parent['sub_fields'], ); - wp_send_json_success($success_data); + wp_send_json_success( $success_data ); } } @@ -454,11 +454,11 @@ public function gc_component_subfields_cb() { /** * Ajax-search for a WP user. * - * @since 3.0.0 - * - * @param string $search_term Search term. + * @param string $search_term Search term. * * @return array Array of results for select2. + * @since 3.0.0 + * */ protected function post_author( $search_term ) { if ( ! \GatherContent\Importer\user_allowed() ) { @@ -473,7 +473,7 @@ protected function post_author( $search_term ) { ); $users = array_map( - function( $user ) { + function ( $user ) { return array( 'text' => $user->user_login, 'id' => $user->ID, @@ -488,11 +488,11 @@ function( $user ) { /** * Nonce-verifier helper. * - * @since 3.0.0 - * - * @param string $nonce Nonce value. + * @param string $nonce Nonce value. * * @return bool Whether nonce was verified. + * @since 3.0.0 + * */ public function verify_nonce( $nonce ) { return wp_verify_nonce( $nonce, GATHERCONTENT_SLUG ); diff --git a/includes/classes/admin/ajax/sync-bulk.php b/includes/classes/admin/ajax/sync-bulk.php index 486506b5..e3a6fd73 100644 --- a/includes/classes/admin/ajax/sync-bulk.php +++ b/includes/classes/admin/ajax/sync-bulk.php @@ -1,4 +1,5 @@ url = admin_url( 'admin.php?page=' . static::SLUG ); @@ -59,9 +61,9 @@ public function __construct() { /** * Initiate admin hooks * + * @return void * @since 3.0.0 * - * @return void */ public function init_hooks() { $callbacks = array( @@ -81,9 +83,9 @@ public function init_hooks() { /** * Registers our menu item and admin page. * + * @return void * @since 3.0.0 * - * @return void */ abstract public function admin_menu(); @@ -92,9 +94,9 @@ abstract public function admin_page(); /** * Initializes the plugin's setting, and settings sections/Fields. * + * @return void * @since 3.0.0 * - * @return void */ protected function initialize_settings_sections() { register_setting( @@ -106,22 +108,24 @@ protected function initialize_settings_sections() { public function sanitize_settings( $options ) { self::$api->flush_cache(); + return $this->settings()->sanitize_settings( $options ); } /** * `add_settings_error` wrapper which is useable before `add_settings_error` is. * - * @since NEXT - * - * @global array $wp_settings_errors Storage array of errors registered during this pageload - * * @param string $setting Slug title of the setting to which this error applies - * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output. + * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output. * @param string $message The formatted message text to display to the user (will be shown inside styled * `
              ` and `

              ` tags). - * @param string $type Optional. Message type, controls HTML class. Accepts 'error' or 'updated'. + * @param string $type Optional. Message type, controls HTML class. Accepts 'error' or 'updated'. * Default 'error'. + * + * @since NEXT + * + * @global array $wp_settings_errors Storage array of errors registered during this pageload + * */ protected function add_settings_error( $setting, $code, $message, $type = 'error' ) { if ( function_exists( 'add_settings_error' ) ) { @@ -143,11 +147,11 @@ protected function add_settings_error( $setting, $code, $message, $type = 'error /** * Determine which step user is on. * - * @todo This should be determined which options they have filled out, and redirect user to step. - * + * @return int Step number. * @since 3.0.0 * - * @return int Step number. + * @todo This should be determined which options they have filled out, and redirect user to step. + * */ public function which_step() { return $this->step; @@ -156,11 +160,11 @@ public function which_step() { /** * Get option value. * - * @since 3.0.0 - * - * @param string $key Key from options array to retrieve. + * @param string $key Key from options array to retrieve. * * @return mixed Value for option. + * @since 3.0.0 + * */ public function get_setting( $key ) { return $this->settings()->get( $key ); @@ -169,9 +173,9 @@ public function get_setting( $key ) { /** * Gets the Settings object * + * @return Settings * @since 3.0.0 * - * @return Settings */ public function settings() { if ( null === $this->settings ) { @@ -197,9 +201,9 @@ protected function set_api( API $api ) { * Uses the platform URL to determine which account in the accounts object * (from the API) to set as the account. * + * @return bool Whether account was successfully set. * @since 3.0.0 * - * @return bool Whether account was successfully set. */ public function set_my_account() { $accounts = $this->api()->get_accounts(); @@ -212,6 +216,7 @@ public function set_my_account() { foreach ( $accounts as $index => $account ) { if ( $account_slug === $account->slug ) { $this->account = $account; + return true; } } @@ -222,11 +227,11 @@ public function set_my_account() { /** * Get the platform URL using the saved account slug. * - * @since 3.0.0 - * * @param string $path Optionally append a path to the platform URL. * * @return string The account platform url. + * @since 3.0.0 + * */ public function platform_url( $path = '' ) { return 'https://' . $this->_get_account_slug() . '.gathercontent.com/' . $path; diff --git a/includes/classes/admin/bulk.php b/includes/classes/admin/bulk.php index 349e1e9a..45bcc47d 100644 --- a/includes/classes/admin/bulk.php +++ b/includes/classes/admin/bulk.php @@ -29,9 +29,9 @@ class Bulk extends Post_Base { /** * The page-specific script ID to enqueue. * + * @return string * @since 3.0.0 * - * @return string */ protected function script_id() { return 'gathercontent-general'; @@ -40,9 +40,9 @@ protected function script_id() { /** * Initiate admin hooks * + * @return void * @since 3.0.0 * - * @return void */ public function init_hooks() { if ( ! is_admin() ) { @@ -56,7 +56,7 @@ public function init_hooks() { $pagenow && ! empty( $this->post_types ) && 'edit.php' === $pagenow - ) { + ) { add_action( 'admin_enqueue_scripts', array( $this, 'ui' ) ); } @@ -74,9 +74,9 @@ public function init_hooks() { /** * The Bulk Edit page UI callback. * + * @return void|bool * @since 3.0.0 * - * @return void|bool */ public function ui_page() { $screen = get_current_screen(); @@ -103,11 +103,11 @@ public function ui_page() { /** * Hooks the column callbacks for the current screen's post-type. * - * @since 3.0.0 - * - * @param string $post_type Current screen's post-type. + * @param string $post_type Current screen's post-type. * * @return void + * @since 3.0.0 + * */ public function hook_columns( $post_type ) { add_filter( "manage_{$post_type}_posts_columns", array( $this, 'register_column_headers' ), 8 ); @@ -121,11 +121,11 @@ public function hook_columns( $post_type ) { /** * Register the GC column header. * - * @since 3.0.0 - * - * @param array $columns Array of column header names. + * @param array $columns Array of column header names. * * @return array + * @since 3.0.0 + * */ public function register_column_headers( $columns ) { $columns['gathercontent'] = '

              GatherContent' . _x( 'Status', 'Content Workflow Item Status', 'content-workflow-by-bynder' ) . '
              '; @@ -136,12 +136,12 @@ public function register_column_headers( $columns ) { /** * The GC field column display output. * - * @since 3.0.0 - * - * @param string $column_name Column name. - * @param int $post_id Post ID. + * @param string $column_name Column name. + * @param int $post_id Post ID. * * @return void + * @since 3.0.0 + * */ public function column_display( $column_name, $post_id ) { @@ -170,13 +170,13 @@ public function column_display( $column_name, $post_id ) { /** * Handles the column view if it's being ajax-loaded. * - * @since 3.0.0 - * - * @param int $post_id Post ID. - * @param int $item_id Item id. - * @param int $mapping_id Mapping id. + * @param int $post_id Post ID. + * @param int $item_id Item id. + * @param int $mapping_id Mapping id. * * @return void + * @since 3.0.0 + * */ protected function ajax_view( $post_id, $item_id, $mapping_id ) { $status_name = $status_color = $status_id = ''; @@ -208,12 +208,12 @@ protected function ajax_view( $post_id, $item_id, $mapping_id ) { /** * The GC field quick-edit display output. * - * @since 3.0.0 - * - * @param string $column_name Column name. - * @param string $post_type Post type. + * @param string $column_name Column name. + * @param string $post_type Post type. * * @return void + * @since 3.0.0 + * */ public function quick_edit_box( $column_name, $post_type ) { if ( 'gathercontent' !== $column_name ) { @@ -226,12 +226,12 @@ public function quick_edit_box( $column_name, $post_type ) { /** * The GC field bulk-edit display output. * - * @since 3.0.0 - * - * @param string $column_name Column name. - * @param string $post_type Post type. + * @param string $column_name Column name. + * @param string $post_type Post type. * * @return void + * @since 3.0.0 + * */ public function bulk_edit_box( $column_name, $post_type ) { if ( 'gathercontent' !== $column_name ) { @@ -249,10 +249,11 @@ public function bulk_edit_box( $column_name, $post_type ) { /** * Sets the GatherContent status if being requested via quick-edit box. * + * @param int $post_id Post ID. + * @param object $post Post object. + * * @since 3.0.0 * - * @param int $post_id Post ID. - * @param object $post Post object. */ public function set_gc_status( $post_id, $post ) { if ( @@ -275,9 +276,9 @@ public function set_gc_status( $post_id, $post ) { /** * Gets the underscore templates array. * + * @return array * @since 3.0.0 * - * @return array */ protected function get_underscore_templates() { if ( empty( $this->posts ) ) { @@ -316,9 +317,9 @@ protected function get_underscore_templates() { /** * Get the localizable data array. * + * @return array Array of localizable data * @since 3.0.0 * - * @return array Array of localizable data */ protected function get_localize_data() { if ( empty( $this->posts ) ) { diff --git a/includes/classes/admin/enqueue.php b/includes/classes/admin/enqueue.php index ee80b823..829dd58a 100644 --- a/includes/classes/admin/enqueue.php +++ b/includes/classes/admin/enqueue.php @@ -6,6 +6,7 @@ */ namespace GatherContent\Importer\Admin; + use GatherContent\Importer\Base as Plugin_Base; use GatherContent\Importer\Utils; @@ -19,9 +20,9 @@ abstract class Enqueue extends Plugin_Base { /** * Enqueues the GC stylesheets. * + * @return void * @since 3.0.0 * - * @return void */ public function admin_enqueue_style() { \GatherContent\Importer\enqueue_style( 'cwby-select2', 'vendor/select2-4.0.13/select2', array(), '4.0.13' ); @@ -33,9 +34,9 @@ public function admin_enqueue_style() { /** * Enqueues the GC scripts, and hooks the localization to the footer. * + * @return void * @since 3.0.0 * - * @return void */ public function admin_enqueue_script() { @@ -63,7 +64,10 @@ public function admin_enqueue_script() { wp_scripts()->print_scripts( 'underscore' ); } - \GatherContent\Importer\enqueue_script( 'gathercontent', 'gathercontent', array( 'gc-select2', 'wp-backbone' ) ); + \GatherContent\Importer\enqueue_script( 'gathercontent', 'gathercontent', array( + 'gc-select2', + 'wp-backbone' + ) ); do_action( 'gc_admin_enqueue_script' ); @@ -75,9 +79,9 @@ public function admin_enqueue_script() { * Localizes the data for the GC scripts. Hooked to admin_footer in order to be run late, * and for the gathercontent_localized_data filter to be easily hooked to. * + * @return void * @since 3.0.0 * - * @return void */ public function script_localize() { /** @@ -85,7 +89,7 @@ public function script_localize() { * the queryargs used on the front-end. These are the only queryargs * referenced on the front-end. */ - $queryArgs = $this->_get_vals(['flush_cache', 'mapping']); + $queryArgs = $this->_get_vals( [ 'flush_cache', 'mapping' ] ); wp_localize_script( 'gathercontent', 'GatherContent', apply_filters( 'gathercontent_localized_data', array( 'debug' => Utils::script_debug(), diff --git a/includes/classes/admin/mapping-wizard.php b/includes/classes/admin/mapping-wizard.php index 7e86c835..0815ba60 100644 --- a/includes/classes/admin/mapping-wizard.php +++ b/includes/classes/admin/mapping-wizard.php @@ -1,4 +1,5 @@ 'gc-account', @@ -94,9 +95,9 @@ public function __construct( Admin $parent ) { /** * Registers our menu item and admin page. * + * @return void * @since 3.0.0 * - * @return void */ public function admin_menu() { $page = add_submenu_page( @@ -113,7 +114,7 @@ public function admin_menu() { add_action( 'load-' . $page, array( $this, 'add_help_tabs' ) ); } - public function admin_enqueue_assets($hook_suffix) { + public function admin_enqueue_assets( $hook_suffix ) { $this->admin_enqueue_style(); $this->admin_enqueue_script(); } @@ -151,10 +152,10 @@ public function add_help_tabs() { 'id' => 'gc-help-me', 'title' => __( 'Content Workflow', 'content-workflow-by-bynder' ), 'content' => __( - '

              Thank you for using the Content Workflow WordPress plugin!

              ' . - '

              To make the plugin more speedy, we cache the requests to GatherContent for 1 day, but if you find that you need to update the data from Content Workflow, just hit the "Refresh" button.

              ', - 'content-workflow-by-bynder' - ) . '

              ' . $this->refresh_connection_link() . '

              ', + '

              Thank you for using the Content Workflow WordPress plugin!

              ' . + '

              To make the plugin more speedy, we cache the requests to GatherContent for 1 day, but if you find that you need to update the data from Content Workflow, just hit the "Refresh" button.

              ', + 'content-workflow-by-bynder' + ) . '

              ' . $this->refresh_connection_link() . '

              ', ) ); @@ -285,9 +286,9 @@ public function body_class( $classes ) { /** * Initializes the plugin's setting, and settings sections/Fields. * + * @return void * @since 3.0.0 * - * @return void */ public function initialize_settings_sections() { @@ -314,9 +315,9 @@ public function initialize_settings_sections() { /** * Step one of the mapping wizard, pick a project from list of accounts. * + * @return void * @since 3.0.0 * - * @return void */ public function select_project() { $section = new Form_Section( @@ -408,9 +409,9 @@ public function select_project_fields_ui( $field ) { /** * Step two of the mapping wizard, pick a template in the chosen project. * + * @return void * @since 3.0.0 * - * @return void */ public function select_template() { $project = $this->api()->get_project( absint( $this->_get_val( 'project' ) ) ); @@ -491,9 +492,9 @@ public function select_template_fields_ui( $field ) { /** * Step three, the final step of the mapping wizard. Create a template-mapping. * + * @return void * @since 3.0.0 * - * @return void */ public function map_template() { @@ -524,13 +525,13 @@ public function map_template() { $sync_items = $mapping_id && $this->_get_val( 'sync-items' ); $notes = ''; - $is_acf_pro_installed = class_exists('acf_pro'); + $is_acf_pro_installed = class_exists( 'acf_pro' ); $template_has_repeatable_fields = false; - if (isset($template->related->structure->groups)) { - foreach ($template->related->structure->groups as $group) { - if (isset($group->fields)) { - foreach ($group->fields as $field) { - if (isset($field->metadata->repeatable) && $field->metadata->repeatable->isRepeatable) { + if ( isset( $template->related->structure->groups ) ) { + foreach ( $template->related->structure->groups as $group ) { + if ( isset( $group->fields ) ) { + foreach ( $group->fields as $field ) { + if ( isset( $field->metadata->repeatable ) && $field->metadata->repeatable->isRepeatable ) { $template_has_repeatable_fields = true; break 2; } @@ -539,10 +540,10 @@ public function map_template() { } } - if ($template_has_repeatable_fields && !$is_acf_pro_installed ){ + if ( $template_has_repeatable_fields && ! $is_acf_pro_installed ) { $notes .= $this->view( 'graceful-degradation', - array('additionalClass' => 'gc-component-disabled'), + array( 'additionalClass' => 'gc-component-disabled' ), false ); } @@ -637,11 +638,11 @@ public function map_template() { * Does not actually save fields, but simply uses the field values to determine where * we are in the process (wizard). * - * @since 3.0.0 - * - * @param array $options Array of options + * @param array $options Array of options * * @return void + * @since 3.0.0 + * */ public function sanitize_settings( $options ) { if ( ! isset( $options['project'] ) ) { @@ -672,11 +673,11 @@ public function sanitize_settings( $options ) { /** * Redirects to the template-picker page of the wizard. * - * @since 3.0.0 - * - * @param int $project GC Project ID. + * @param int $project GC Project ID. * * @return void + * @since 3.0.0 + * */ protected function redirect_to_template_picker( $project ) { wp_safe_redirect( esc_url_raw( add_query_arg( 'project', $project, $this->url ) ) ); @@ -686,12 +687,12 @@ protected function redirect_to_template_picker( $project ) { /** * Redirects to the (final) mapping-creator page of the wizard. * - * @since 3.0.0 - * - * @param int $project GC Project ID. - * @param int $template GC Template ID. + * @param int $project GC Project ID. + * @param int $template GC Template ID. * * @return void + * @since 3.0.0 + * */ protected function redirect_to_mapping_creation( $project, $template ) { @@ -714,13 +715,13 @@ protected function redirect_to_mapping_creation( $project, $template ) { * Creates/Saves a mapping post after submission and redirects back * to mapping-creator page to edit new mapping. * - * @since 3.0.0 - * - * @param int $project GC Project ID. - * @param int $template GC Template ID. - * @param array $options Array of options/values submitted. + * @param int $project GC Project ID. + * @param int $template GC Template ID. + * @param array $options Array of options/values submitted. * * @return void + * @since 3.0.0 + * */ protected function save_mapping_post_and_redirect( $project, $template, $options ) { if ( ! wp_verify_nonce( $options['create_mapping'], md5( $project . $template ) ) ) { @@ -746,9 +747,9 @@ protected function save_mapping_post_and_redirect( $project, $template, $options /** * A URL for flushing the cached connection to GC's API * + * @return string URL for flushing cache. * @since 3.0.0 * - * @return string URL for flushing cache. */ public function refresh_connection_link() { return \GatherContent\Importer\refresh_connection_link(); @@ -768,12 +769,12 @@ public function project_name_and_edit_link( $project ) { /** * Filter all the items in a project by template_id. * - * @since 3.0.0 - * - * @param int $project_id - * @param int $template_id + * @param int $project_id + * @param int $template_id * * @return mixed result of request + * @since 3.0.0 + * */ public function get_project_items_by_template( $project_id, $template_id ) { @@ -782,17 +783,18 @@ public function get_project_items_by_template( $project_id, $template_id ) { } $this->project_items[ $project_id ] = $this->api()->get_project_items( $project_id, $template_id, true ); + return $this->project_items[ $project_id ]; } /** * Create or update a template mapping post using the saved options/values. * - * @since 3.0.0 - * - * @param array $options Array of options from mapping UI. + * @param array $options Array of options from mapping UI. * * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure. + * @since 3.0.0 + * */ protected function create_or_update_mapping_post( $options ) { $post_args = $mapping_args = array(); @@ -819,9 +821,9 @@ protected function create_or_update_mapping_post( $options ) { /** * Determine if any conditions are met to cause us to redirect. * + * @return void * @since 3.0.0 * - * @return void */ protected function handle_redirects() { $this->maybe_redirect_to_create_new_mapping(); @@ -832,9 +834,9 @@ protected function handle_redirects() { * Determine if we should redirect to new-mapping settings page * when trying to create a new Template Mapping. * + * @return void * @since 3.0.0 * - * @return void */ protected function maybe_redirect_to_create_new_mapping() { global $pagenow; @@ -849,9 +851,9 @@ protected function maybe_redirect_to_create_new_mapping() { * Determine if we should redirect to a defined mapping template to edit. * (based on template/project id) * + * @return void * @since 3.0.0 * - * @return void */ protected function maybe_redirect_to_edit_mapping_template() { if ( diff --git a/includes/classes/admin/mapping/base.php b/includes/classes/admin/mapping/base.php index 85f6924f..3e82defe 100644 --- a/includes/classes/admin/mapping/base.php +++ b/includes/classes/admin/mapping/base.php @@ -61,9 +61,10 @@ abstract class Base extends Plugin_Base { /** * Constructor * + * @param array $args Arguments. + * * @since 3.0.0 * - * @param array $args Arguments. */ public function __construct( array $args ) { $this->mapping_id = $args['mapping_id']; @@ -77,45 +78,45 @@ public function __construct( array $args ) { /** * The page-specific script ID to enqueue. * + * @return string * @since 3.0.0 * - * @return string */ abstract protected function script_id(); /** * The page-specific Form_Section section UI callback. * + * @return void * @since 3.0.0 * - * @return void */ abstract protected function ui_page(); /** * Get the localizable data array. * + * @return array Array of localizable data * @since 3.0.0 * - * @return array Array of localizable data */ abstract protected function get_localize_data(); /** * Gets the underscore templates array. * + * @return array * @since 3.0.0 * - * @return array */ abstract protected function get_underscore_templates(); /** * The Form_Section section UI callback. * + * @return void * @since 3.0.0 * - * @return void */ public function ui() { if ( false === $this->ui_page() ) { @@ -136,9 +137,9 @@ public function ui() { /** * Output the underscore templates in the footer. * + * @return void * @since 3.0.0 * - * @return void */ public function footer_mapping_js_templates() { foreach ( $this->get_underscore_templates() as $template_id => $view_args ) { @@ -151,11 +152,11 @@ public function footer_mapping_js_templates() { /** * Add to the localized data array. * - * @since 3.0.0 - * - * @param array $data Array of localizable data. + * @param array $data Array of localizable data. * * @return array Modified array of data. + * @since 3.0.0 + * */ public function localize_data( $data ) { return array_merge( $data, $this->get_localize_data() ); @@ -164,11 +165,11 @@ public function localize_data( $data ) { /** * Get's the default options. + * @since 3.0.0 + * */ protected function get_default_field_options( $col ) { $select_options = array(); @@ -203,9 +204,9 @@ protected function get_default_field_options( $col ) { /** * Gets the columns from the posts table for the options. * @since 3.0.0 * - * @return array Array of - - underscore_options( $options_acf_groups ); ?> - underscore_empty_option( __( 'Do Not Import', 'content-workflow-by-bynder' ) ); ?> - - - - - <# } #> - + }, $groupIds ) ); + + // Prepare and execute query to get all fields for all groups + $fields_query = "SELECT * FROM {$wpdb->posts} WHERE post_type = 'acf-field' AND post_content LIKE '%repeater%' AND post_parent IN ($groupIdPlaceholders)"; + $fields_results = $wpdb->get_results( $wpdb->prepare( $fields_query, $groupIds ) ); + + // Group the field results by parent group + $grouped_field_results = []; + foreach ( $fields_results as $field ) { + $grouped_field_results[ $field->post_parent ][] = $field; + } + + foreach ( $group_results as $group ) { + // Set the top level field group array of options + $options_acf_groups[ $group->post_name ] = $group->post_title; + // Create a blank array based on the group id to define the groups fields + $options_acf_groups_fields[ $group->post_name ] = array(); + + // Get the fields for the current group from grouped results + $fields_for_group = $grouped_field_results[ $group->ID ] ?? []; + + // Loop fields within each ACF Field Group + foreach ( $fields_for_group as $field ) { + // Build array of fields based on parent group + $options_acf_groups_fields[ $group->post_name ][ $field->post_name ] = $field->post_title; + } + } + } + // print_r($options_acf_groups); + // print_r($options_acf_groups_fields); + ?> + + <# if ( 'e_type_id(); ?>' === data.field_type ) { #> + + + + + + <# } #> + diff --git a/includes/classes/admin/mapping/field-types/base.php b/includes/classes/admin/mapping/field-types/base.php index ffdda3e0..39043718 100644 --- a/includes/classes/admin/mapping/field-types/base.php +++ b/includes/classes/admin/mapping/field-types/base.php @@ -52,9 +52,9 @@ abstract class Base extends Plugin_Base implements Type { /** * Returns type_id property * + * @return [type] [description] * @since [since] * - * @return [type] [description] */ public function type_id() { return $this->type_id; diff --git a/includes/classes/admin/mapping/field-types/database.php b/includes/classes/admin/mapping/field-types/database.php index 5f778520..f33800d7 100644 --- a/includes/classes/admin/mapping/field-types/database.php +++ b/includes/classes/admin/mapping/field-types/database.php @@ -1,4 +1,5 @@ tableColumnData = $this->getTableColumns(); - $tableNames = array_keys($this->tableColumnData); - $this->post_options = array_combine($tableNames, $tableNames); + $tableNames = array_keys( $this->tableColumnData ); + $this->post_options = array_combine( $tableNames, $tableNames ); $this->option_label = __( 'Database', 'gathercontent-import' ); } - private function getAllTableColOptions() - { + private function getAllTableColOptions() { $allOpts = []; - foreach ($this->tableColumnData as $tableName => $columns) { - $allOpts = array_merge($allOpts, $this->getTableColOptions($tableName)); + foreach ( $this->tableColumnData as $tableName => $columns ) { + $allOpts = array_merge( $allOpts, $this->getTableColOptions( $tableName ) ); } return $allOpts; } - private function getTableColOptions(string $tableName) - { + private function getTableColOptions( string $tableName ) { $optionStrings = []; - foreach ($this->tableColumnData[$tableName] as $column) { + foreach ( $this->tableColumnData[ $tableName ] as $column ) { /** * Returns the required underscore template string to be true when * this column and table are selected. We need to check for both as @@ -91,7 +90,7 @@ public function underscore_option( $value, $label ) { <# if ( '" . $value . "' === (data.field_value ? data.field_value : '').split('.')[0] ) { #>selected='selected'<# } #> "; - echo ''; + echo ''; } /** @@ -100,30 +99,30 @@ public function underscore_option( $value, $label ) { * * @return Array - [tableName => colNames, ...] */ - private function getTableColumns(){ + private function getTableColumns() { global $wpdb; - $wpTables = $wpdb->get_col("SHOW TABLES LIKE '{$wpdb->prefix}%'"); + $wpTables = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}%'" ); $allColumns = []; - foreach($wpTables as $tableName){ - $tableCols = $wpdb->get_results("SHOW COLUMNS FROM $tableName"); + foreach ( $wpTables as $tableName ) { + $tableCols = $wpdb->get_results( "SHOW COLUMNS FROM $tableName" ); $columnNames = []; - foreach ($tableCols as $col) { + foreach ( $tableCols as $col ) { $columnNames[] = $col->Field; } /** * We are only interested in tables that contain a 'post_id' column */ - if(!in_array('post_id', $columnNames)){ + if ( ! in_array( 'post_id', $columnNames ) ) { continue; } - unset($columnNames[array_search('post_id', $columnNames)]); + unset( $columnNames[ array_search( 'post_id', $columnNames ) ] ); - $allColumns[$tableName] = $columnNames; + $allColumns[ $tableName ] = $columnNames; } return $allColumns; @@ -133,33 +132,34 @@ public function underscore_template( View $view ) { ?> <# if ( 'e_type_id(); ?>' === data.field_type ) { #> -
              - - - - - value="{{ data.field_value }}"<# } #> - /> -
              -

              - You can only select tables that contain a post_id column, as this is necessary to locate the corresponding row within the chosen table. -

              +
              + + + + + value="{{ data.field_value }}"<# } #> + /> +
              +

              + You can only select tables that contain a post_id column, as this is + necessary to locate the corresponding row within the chosen table. +

              <# } #> <# if ( 'e_type_id(); ?>' === data.field_type ) { #> - + <# } #> <# if ( 'e_type_id(); ?>' === data.field_type ) { #> - + <# } #> <# if ( 'e_type_id(); ?>' === data.field_type ) { #> - + <# } #> post_types as $type ) : ?> - <# if ( 'e_type_id(); ?>' === data.field_type && 'name; ?>' === data.post_type ) { #> - taxonomies ) ) : ?> @@ -46,8 +49,8 @@ public function underscore_template( View $view ) { underscore_empty_option( __( 'Do Not Import', 'content-workflow-by-bynder' ) ); ?> - <# } #> - + field_types[ $type->type_id() ] = $type; - add_action( 'gathercontent_field_type_option_underscore_template', array( $type, 'option_underscore_template' ) ); + add_action( 'gathercontent_field_type_option_underscore_template', array( + $type, + 'option_underscore_template' + ) ); add_action( 'gathercontent_field_type_underscore_template', array( $type, 'underscore_template' ) ); } diff --git a/includes/classes/admin/mapping/field-types/wpseo.php b/includes/classes/admin/mapping/field-types/wpseo.php index d4b8dd24..f2a32652 100644 --- a/includes/classes/admin/mapping/field-types/wpseo.php +++ b/includes/classes/admin/mapping/field-types/wpseo.php @@ -1,4 +1,5 @@ initialize_wpseo(); - $options = array('all_types' => []); + $options = array( 'all_types' => [] ); global $post; @@ -139,15 +140,16 @@ public function underscore_template( View $view ) { unset( $seo_options['all_types'] ); ?> <# if ( 'e_type_id(); ?>' === data.field_type ) { #> - + <# } #> error_parts( $last_error ); - $msg .= array_shift( $parts ); + $msg .= array_shift( $parts ); foreach ( $parts as $part ) { $msg .= '

              '; $msg .= $part; @@ -68,7 +69,7 @@ public function register_import_errors( $notices ) { if ( is_array( $item_errors ) ) { $msg = ''; $main = __( 'There were some errors with the item import:', 'content-workflow-by-bynder' ); - $msg .= '
                '; + $msg .= '
                  '; foreach ( $item_errors as $error ) { $parts = $this->error_parts( $error ); // $main = array_shift( $parts ); @@ -116,9 +117,9 @@ public function prepare_for_js( $item ) { /** * The page-specific script ID to enqueue. * + * @return string * @since 3.0.0 * - * @return string */ protected function script_id() { return 'gathercontent-sync'; @@ -127,9 +128,9 @@ protected function script_id() { /** * The sync page UI callback. * + * @return void * @since 3.0.0 * - * @return void */ public function ui_page() { // Output the markup for the JS to build on. @@ -138,16 +139,23 @@ public function ui_page() { * Previously the foreach below was iterating over the entire $_GET * super global. Now we use the specific keys only. */ - $hiddenInputs = $this->_get_vals([ - 'page', 'project', 'template', 'sync-items' - ]); + $hiddenInputs = $this->_get_vals( [ + 'page', + 'project', + 'template', + 'sync-items' + ] ); ?> $value ) : ?> - + -

                  +

                  +

                  @@ -159,9 +167,9 @@ public function ui_page() { /** * Get the localizable data array. * + * @return array Array of localizable data * @since 3.0.0 * - * @return array Array of localizable data */ protected function get_localize_data() { return array( @@ -176,9 +184,9 @@ protected function get_localize_data() { /** * Gets the underscore templates array. * + * @return array * @since 3.0.0 * - * @return array */ protected function get_underscore_templates() { return array( diff --git a/includes/classes/admin/mapping/template-mapper.php b/includes/classes/admin/mapping/template-mapper.php index e365ba55..fc1b4f54 100644 --- a/includes/classes/admin/mapping/template-mapper.php +++ b/includes/classes/admin/mapping/template-mapper.php @@ -1,4 +1,5 @@ mapping_id; @@ -191,45 +192,45 @@ protected function get_localize_data() { /** * Gets the underscore templates array. * + * @return array * @since 3.0.0 * - * @return array */ protected function get_underscore_templates() { $post_status_options = $this->get_default_field_options( 'post_status' ); - return array( - 'tmpl-gc-tabs-wrapper' => array(), - 'tmpl-gc-tab-wrapper' => array(), - 'tmpl-gc-mapping-tab-row' => array( - 'option_base' => $this->option_name, - 'post_types' => $this->post_types(), - ), - 'tmpl-gc-mapping-defaults-tab' => array( - 'post_author_label' => $this->post_column_label( 'post_author' ), - 'post_status_options' => $post_status_options, - 'post_status_label' => __( 'Default Status', 'content-workflow-by-bynder' ), - 'post_type_label' => $this->post_column_label( 'post_type' ), - 'post_type_options' => $this->get_default_field_options( 'post_type' ), - 'gc_status_options' => $this->statuses, - 'option_base' => $this->option_name, - ), - 'tmpl-gc-mapping-defaults-tab-status-mappings' => array( - 'option_base' => $this->option_name, - 'gc_status_options' => $this->statuses, - 'post_status_options' => $post_status_options, - ), - 'tmpl-gc-select2-item' => array(), - ); + return array( + 'tmpl-gc-tabs-wrapper' => array(), + 'tmpl-gc-tab-wrapper' => array(), + 'tmpl-gc-mapping-tab-row' => array( + 'option_base' => $this->option_name, + 'post_types' => $this->post_types(), + ), + 'tmpl-gc-mapping-defaults-tab' => array( + 'post_author_label' => $this->post_column_label( 'post_author' ), + 'post_status_options' => $post_status_options, + 'post_status_label' => __( 'Default Status', 'content-workflow-by-bynder' ), + 'post_type_label' => $this->post_column_label( 'post_type' ), + 'post_type_options' => $this->get_default_field_options( 'post_type' ), + 'gc_status_options' => $this->statuses, + 'option_base' => $this->option_name, + ), + 'tmpl-gc-mapping-defaults-tab-status-mappings' => array( + 'option_base' => $this->option_name, + 'gc_status_options' => $this->statuses, + 'post_status_options' => $post_status_options, + ), + 'tmpl-gc-select2-item' => array(), + ); } /** * Initiates the mapped field types. By default, post fields, taxonomies, and meta fields. * If WP-SEO is installed, that field type will be iniitated as well. * + * @return Field_Types\Types object * @since 3.0.0 * - * @return Field_Types\Types object */ protected function initiate_mapped_field_types() { $core_field_types = array( @@ -240,8 +241,8 @@ protected function initiate_mapped_field_types() { new Field_Types\Database(), ); - $is_acf_installed = class_exists('acf_pro'); - if ($is_acf_installed) { + $is_acf_installed = class_exists( 'acf_pro' ); + if ( $is_acf_installed ) { $core_field_types[] = new Field_Types\ACF(); } @@ -257,11 +258,11 @@ protected function initiate_mapped_field_types() { /** * Gets the Help Pointers array. * - * @since 3.0.0 - * - * @param bool $initial Whether we have a mapping ID. + * @param bool $initial Whether we have a mapping ID. * * @return array Array of Pointers. + * @since 3.0.0 + * */ protected function get_pointers( $initial ) { $enqueue = false; @@ -280,7 +281,7 @@ protected function get_pointers( $initial ) { if ( $initial ) { if ( ! in_array( 'gc_select_tab_how_to', $dismissed, 1 ) ) { - $content = '

                  ' . __( 'Template Tabs and Fields', 'content-workflow-by-bynder' ) . '

                  '; + $content = '

                  ' . __( 'Template Tabs and Fields', 'content-workflow-by-bynder' ) . '

                  '; $content .= '

                  ' . __( 'You\'ll find the tabs from the Content Workflow Template here. Select a tab to start mapping the Template fields.', 'content-workflow-by-bynder' ) . '

                  '; $pointers['select_tab_how_to'] = $content; @@ -288,7 +289,7 @@ protected function get_pointers( $initial ) { } if ( ! in_array( 'gc_map_status_how_to', $dismissed, 1 ) ) { - $content = '

                  ' . __( 'Content Workflow Status ↠ WordPress Status', 'content-workflow-by-bynder' ) . '

                  '; + $content = '

                  ' . __( 'Content Workflow Status ↠ WordPress Status', 'content-workflow-by-bynder' ) . '

                  '; $content .= '

                  ' . __( 'Here you\'ll be able to map each individual Content Workflow status to a WordPress status, and optionally, change the Content Workflow status when your items are imported to WordPress.', 'content-workflow-by-bynder' ) . '

                  '; $pointers['map_status_how_to'] = $content; @@ -297,7 +298,7 @@ protected function get_pointers( $initial ) { } else { if ( ! in_array( 'gc_refresh_connection', $dismissed, 1 ) ) { - $content = '

                  ' . __( 'Refresh data from Content Workflow', 'content-workflow-by-bynder' ) . '

                  '; + $content = '

                  ' . __( 'Refresh data from Content Workflow', 'content-workflow-by-bynder' ) . '

                  '; $content .= '

                  ' . __( 'To make the plugin more speedy, we cache the requests to Content Workflow for 1 day, but if you find that you need to update the data from Content Workflow, just hit the "Refresh" button.', 'content-workflow-by-bynder' ) . '

                  '; $content .= '

                  ' . __( 'For more help, click the "Help" tab in the upper-right-hand corner.', 'content-workflow-by-bynder' ) . '

                  '; @@ -317,12 +318,12 @@ protected function get_pointers( $initial ) { /** * Get's the GC tabs and adds a default tab for universal settings. * + * @return array Array of tabs. * @since 3.0.0 * - * @return array Array of tabs. */ - /** + /** * Retrieves and structures tabs with associated fields or components. * Handles tab groups, checks for ACF Pro presence, and constructs tab arrays. * Utilizes switch cases based on ACF Pro installation status. @@ -331,37 +332,37 @@ protected function get_pointers( $initial ) { */ protected function get_tabs() { - $tabs = []; - $post_type = $this->get_value('post_type', 'esc_attr'); - $tab_groups = $this->template->related->structure->groups ?? []; - $is_acf_pro_installed = class_exists('acf_pro'); + $tabs = []; + $post_type = $this->get_value( 'post_type', 'esc_attr' ); + $tab_groups = $this->template->related->structure->groups ?? []; + $is_acf_pro_installed = class_exists( 'acf_pro' ); - foreach ($tab_groups as $tab) { - $rows = []; + foreach ( $tab_groups as $tab ) { + $rows = []; $fields = $tab->fields ?? []; - foreach ($fields as $field) { - $metadata = $field->metadata; - $is_repeatable = (is_object($metadata) && isset($metadata->repeatable)) ? $metadata->repeatable->isRepeatable : false; + foreach ( $fields as $field ) { + $metadata = $field->metadata; + $is_repeatable = ( is_object( $metadata ) && isset( $metadata->repeatable ) ) ? $metadata->repeatable->isRepeatable : false; //We use components as rows and fields in the components as subrows if ACF PRo is installed - if ($is_acf_pro_installed) { + if ( $is_acf_pro_installed ) { - if (self::COMPONENT_FIELD !== $field->field_type) { - $this->formatAndAddField($field, $post_type, '', $is_repeatable, $rows); + if ( self::COMPONENT_FIELD !== $field->field_type ) { + $this->formatAndAddField( $field, $post_type, '', $is_repeatable, $rows ); } - if (self::COMPONENT_FIELD === $field->field_type) { - $component_id = $field->uuid; + if ( self::COMPONENT_FIELD === $field->field_type ) { + $component_id = $field->uuid; $component_name = $field->label; - $this->formatAndAddField($field, $post_type, $component_name, $is_repeatable, $rows, $component_id); + $this->formatAndAddField( $field, $post_type, $component_name, $is_repeatable, $rows, $component_id ); } } else { // When ACF Pro is not installed, use the original logic: // each row is just as it comes in. (each component field is an individual row) - $fields_data = ($field->component->fields ?? [$field]); + $fields_data = ( $field->component->fields ?? [ $field ] ); - foreach ($fields_data as $field_data) { + foreach ( $fields_data as $field_data ) { $formatted_field = $this->format_fields( $field_data, $post_type, @@ -370,7 +371,7 @@ protected function get_tabs() { self::COMPONENT_FIELD === $field->field_type ? $field->uuid : '' ); - if ($formatted_field) { + if ( $formatted_field ) { $rows[] = $formatted_field; } } @@ -378,26 +379,26 @@ protected function get_tabs() { } $tabs[] = [ - 'id' => $tab->uuid, - 'label' => $tab->name, - 'hidden' => !empty($tabs), - 'rows' => $rows, + 'id' => $tab->uuid, + 'label' => $tab->name, + 'hidden' => ! empty( $tabs ), + 'rows' => $rows, ]; } $default_tab = [ - 'id' => 'mapping-defaults', - 'label' => __('Mapping Defaults', 'content-workflow-by-bynder'), - 'hidden' => true, - 'navClasses' => 'alignright', - 'rows' => $this->post_options(), - 'post_author' => $this->get_value('post_author', 'absint', 1), - 'post_status' => $this->get_value('post_status', 'esc_attr', 'draft'), - 'post_type' => $post_type, - 'gc_status' => $this->get_gc_statuses(), + 'id' => 'mapping-defaults', + 'label' => __( 'Mapping Defaults', 'content-workflow-by-bynder' ), + 'hidden' => true, + 'navClasses' => 'alignright', + 'rows' => $this->post_options(), + 'post_author' => $this->get_value( 'post_author', 'absint', 1 ), + 'post_status' => $this->get_value( 'post_status', 'esc_attr', 'draft' ), + 'post_type' => $post_type, + 'gc_status' => $this->get_gc_statuses(), ]; - $default_tab['select2:post_author:' . $default_tab['post_author']] = $this->get_default_field_options('post_author'); + $default_tab[ 'select2:post_author:' . $default_tab['post_author'] ] = $this->get_default_field_options( 'post_author' ); $tabs[] = $default_tab; @@ -405,11 +406,10 @@ protected function get_tabs() { } + private function formatAndAddField( $field, $post_type, $component_name, $is_repeatable, &$rows, $component_id = '' ) { + $formatted_field = $this->format_fields( $field, $post_type, $component_name, $is_repeatable, $component_id ); - private function formatAndAddField($field, $post_type, $component_name, $is_repeatable, &$rows, $component_id = '') { - $formatted_field = $this->format_fields($field, $post_type, $component_name, $is_repeatable, $component_id); - - if ($formatted_field) { + if ( $formatted_field ) { $rows[] = $formatted_field; } } @@ -417,15 +417,15 @@ private function formatAndAddField($field, $post_type, $component_name, $is_repe /** * Format field object based on the field type * - * @since 4.0.0 - * - * @param mixed $field + * @param mixed $field * @param string|null $post_type - * @param string $component_name - * @param bool $is_repeatable - * @param string|int $component_id optional + * @param string $component_name + * @param bool $is_repeatable + * @param string|int $component_id optional * * @return null|mixed formatted field object. + * @since 4.0.0 + * */ private function format_fields( $field, $post_type, string $component_name = '', bool $is_repeatable = false, string $component_id = '' ) { @@ -453,10 +453,10 @@ private function format_fields( $field, $post_type, string $component_name = '', $field->typeName = Utils::gc_field_type_name( $field_type ); if ( $val = $this->get_value( $field->uuid ) ) { - $field->field_type = isset( $val['type'] ) ? $val['type'] : ''; - $field->field_value = isset( $val['value'] ) ? $val['value'] : ''; - $field->field_field = isset( $val['field'] ) ? $val['field'] : ''; - $field->field_subfields = isset( $val['sub_fields'] ) ? (array)$val['sub_fields'] : ''; + $field->field_type = isset( $val['type'] ) ? $val['type'] : ''; + $field->field_value = isset( $val['value'] ) ? $val['value'] : ''; + $field->field_field = isset( $val['field'] ) ? $val['field'] : ''; + $field->field_subfields = isset( $val['sub_fields'] ) ? (array) $val['sub_fields'] : ''; } $field->is_repeatable = $is_repeatable; diff --git a/includes/classes/admin/post-base.php b/includes/classes/admin/post-base.php index 25108802..29170eeb 100644 --- a/includes/classes/admin/post-base.php +++ b/includes/classes/admin/post-base.php @@ -17,7 +17,8 @@ * * @since 3.0.0 */ -class Post_Enqueue extends Enqueue {} +class Post_Enqueue extends Enqueue { +} /** * Class for managing syncing template items. @@ -60,10 +61,11 @@ abstract class Post_Base extends UI_Base { /** * Creates an instance of this class. * + * @param API $api API object. + * @param Mapping_Wizard $wizard Mapping_Wizard object. + * * @since 3.0.0 * - * @param API $api API object. - * @param Mapping_Wizard $wizard Mapping_Wizard object. */ public function __construct( API $api, Mapping_Wizard $wizard ) { $this->api = $api; @@ -75,9 +77,9 @@ public function __construct( API $api, Mapping_Wizard $wizard ) { /** * Get the localizable data array. * + * @return array Array of localizable data * @since 3.0.0 * - * @return array Array of localizable data */ protected function get_localize_data() { return array( diff --git a/includes/classes/admin/single.php b/includes/classes/admin/single.php index 90f82d26..8c335ab4 100644 --- a/includes/classes/admin/single.php +++ b/includes/classes/admin/single.php @@ -37,9 +37,9 @@ class Single extends Post_Base { /** * The page-specific script ID to enqueue. * + * @return string * @since 3.0.0 * - * @return string */ protected function script_id() { return 'gathercontent-single'; @@ -48,9 +48,9 @@ protected function script_id() { /** * Initiate admin hooks * + * @return void * @since 3.0.0 * - * @return void */ public function init_hooks() { if ( ! is_admin() ) { @@ -64,7 +64,7 @@ public function init_hooks() { $pagenow && ! empty( $this->post_types ) && 'post.php' === $pagenow - ) { + ) { add_action( 'admin_enqueue_scripts', array( $this, 'ui' ) ); } } @@ -72,9 +72,9 @@ public function init_hooks() { /** * The Bulk Edit page UI callback. * + * @return void|bool * @since 3.0.0 * - * @return void|bool */ public function ui_page() { $screen = get_current_screen(); @@ -90,17 +90,20 @@ public function ui_page() { $this->enqueue->admin_enqueue_style(); $this->enqueue->admin_enqueue_script(); - add_meta_box( 'gc-manage', 'Content Workflow ', array( $this, 'meta_box' ), $screen, 'side', 'high' ); + add_meta_box( 'gc-manage', 'Content Workflow ', array( + $this, + 'meta_box' + ), $screen, 'side', 'high' ); } /** * Metabox callback for outputting the metabox contents. * - * @since 3.0.0 - * - * @param object $post Post object. + * @param object $post Post object. * * @return void + * @since 3.0.0 + * */ public function meta_box( $post ) { $object = get_post_type_object( $post->post_type ); @@ -122,9 +125,9 @@ public function meta_box( $post ) { /** * Gets the underscore templates array. * + * @return array * @since 3.0.0 * - * @return array */ protected function get_underscore_templates() { return array( @@ -144,9 +147,9 @@ protected function get_underscore_templates() { /** * Get the localizable data array. * + * @return array Array of localizable data * @since 3.0.0 * - * @return array Array of localizable data */ protected function get_localize_data() { $data = parent::get_localize_data(); diff --git a/includes/classes/admin/support.php b/includes/classes/admin/support.php index e0854a6f..87e00d65 100644 --- a/includes/classes/admin/support.php +++ b/includes/classes/admin/support.php @@ -34,9 +34,9 @@ public function __construct() { /** * Downloads the current system info in a text file. * + * @return void * @since 3.0.1 * - * @return void */ public function download_sys_info() { if ( \GatherContent\Importer\user_allowed() ) { @@ -53,18 +53,19 @@ public function download_sys_info() { /** * Method needs to be empty. * + * @return void * @since 3.0.1 * - * @return void */ - public function initialize_settings_sections() {} + public function initialize_settings_sections() { + } /** * Registers our menu item and admin page. * + * @return void * @since 3.0.1 * - * @return void */ public function admin_menu() { add_submenu_page( @@ -80,12 +81,12 @@ public function admin_menu() { /** * Outputs the system info page. * - * @todo Include ajax tests and GC connectivity tests. + * @return void * @todo Output versions/locations of the JS libs we are using. * * @since 3.0.1 * - * @return void + * @todo Include ajax tests and GC connectivity tests. */ public function admin_page() { if ( ! class_exists( 'Browser' ) ) { @@ -97,66 +98,66 @@ public function admin_page() { // $sys_info = get_transient( 'gc_sys_info' ); // if ( ! $sys_info || $this->_get_val( 'flush_cache' ) ) { - $sys_info = $this->view( - 'system-info', - array( - 'multisite' => is_multisite() ? 'Yes' : 'No', - - 'site_url' => site_url(), - 'home_url' => home_url(), - - 'gc_version' => GATHERCONTENT_VERSION, - 'wp_version' => get_bloginfo( 'version' ), - 'permalink_structure' => get_option( 'permalink_structure' ), - 'theme' => $this->theme(), - 'host' => $this->host(), - 'browser' => $browser, - - 'php_version' => PHP_VERSION, - 'mysql_version' => @$wpdb->db_version(), - 'web_server_info' => $_SERVER['SERVER_SOFTWARE'], - - 'wordpress_memory_limit' => WP_MEMORY_LIMIT, - 'php_safe_mode' => ini_get( 'safe_mode' ) ? 'Yes' : 'No', - 'php_memory_limit' => ini_get( 'memory_limit' ), - 'php_upload_max_size' => ini_get( 'upload_max_filesize' ), - 'php_post_max_size' => ini_get( 'post_max_size' ), - 'php_upload_max_filesize' => ini_get( 'upload_max_filesize' ), - 'php_time_limit' => ini_get( 'max_execution_time' ), - 'php_max_input_vars' => ini_get( 'max_input_vars' ), - 'php_arg_separator' => ini_get( 'arg_separator.output' ), - 'php_allow_url_file_open' => ini_get( 'allow_url_fopen' ) ? 'Yes' : 'No', - - 'debug' => defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set', - 'script_debug' => defined( 'SCRIPT_DEBUG' ) ? SCRIPT_DEBUG ? 'Enabled' : 'Disabled' : 'Not set', - - 'pre_length' => $this->pre_length(), - - 'show_on_front' => get_option( 'show_on_front' ), - 'page_on_front' => $this->get_page( 'page_on_front' ), - 'page_for_posts' => $this->get_page( 'page_for_posts' ), - - 'session' => isset( $_SESSION ) ? 'Enabled' : 'Disabled', - 'session' => esc_html( ini_get( 'session.name' ) ), - 'session_name' => esc_html( ini_get( 'session.name' ) ), - 'cookie_path' => esc_html( ini_get( 'session.cookie_path' ) ), - 'save_path' => esc_html( ini_get( 'session.save_path' ) ), - 'use_cookies' => ini_get( 'session.use_cookies' ) ? 'On' : 'Off', - 'use_only_cookies' => ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off', - 'display_errors' => ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A', - 'fsockopen' => function_exists( 'fsockopen' ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.', - 'curl' => function_exists( 'curl_init' ) ? 'Your server supports cURL.' : 'Your server does not support cURL.', - 'soap_client' => class_exists( 'SoapClient' ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.', - 'suhosin' => extension_loaded( 'suhosin' ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.', - - 'active_plugins' => $this->active_plugins(), - 'network_active_plugins' => $this->network_active_plugins(), - 'gc_options' => print_r( get_option( 'gathercontent_importer' ), 1 ), - ), - false - ); - - // Store for a bit. + $sys_info = $this->view( + 'system-info', + array( + 'multisite' => is_multisite() ? 'Yes' : 'No', + + 'site_url' => site_url(), + 'home_url' => home_url(), + + 'gc_version' => GATHERCONTENT_VERSION, + 'wp_version' => get_bloginfo( 'version' ), + 'permalink_structure' => get_option( 'permalink_structure' ), + 'theme' => $this->theme(), + 'host' => $this->host(), + 'browser' => $browser, + + 'php_version' => PHP_VERSION, + 'mysql_version' => @$wpdb->db_version(), + 'web_server_info' => $_SERVER['SERVER_SOFTWARE'], + + 'wordpress_memory_limit' => WP_MEMORY_LIMIT, + 'php_safe_mode' => ini_get( 'safe_mode' ) ? 'Yes' : 'No', + 'php_memory_limit' => ini_get( 'memory_limit' ), + 'php_upload_max_size' => ini_get( 'upload_max_filesize' ), + 'php_post_max_size' => ini_get( 'post_max_size' ), + 'php_upload_max_filesize' => ini_get( 'upload_max_filesize' ), + 'php_time_limit' => ini_get( 'max_execution_time' ), + 'php_max_input_vars' => ini_get( 'max_input_vars' ), + 'php_arg_separator' => ini_get( 'arg_separator.output' ), + 'php_allow_url_file_open' => ini_get( 'allow_url_fopen' ) ? 'Yes' : 'No', + + 'debug' => defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set', + 'script_debug' => defined( 'SCRIPT_DEBUG' ) ? SCRIPT_DEBUG ? 'Enabled' : 'Disabled' : 'Not set', + + 'pre_length' => $this->pre_length(), + + 'show_on_front' => get_option( 'show_on_front' ), + 'page_on_front' => $this->get_page( 'page_on_front' ), + 'page_for_posts' => $this->get_page( 'page_for_posts' ), + + 'session' => isset( $_SESSION ) ? 'Enabled' : 'Disabled', + 'session' => esc_html( ini_get( 'session.name' ) ), + 'session_name' => esc_html( ini_get( 'session.name' ) ), + 'cookie_path' => esc_html( ini_get( 'session.cookie_path' ) ), + 'save_path' => esc_html( ini_get( 'session.save_path' ) ), + 'use_cookies' => ini_get( 'session.use_cookies' ) ? 'On' : 'Off', + 'use_only_cookies' => ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off', + 'display_errors' => ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A', + 'fsockopen' => function_exists( 'fsockopen' ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.', + 'curl' => function_exists( 'curl_init' ) ? 'Your server supports cURL.' : 'Your server does not support cURL.', + 'soap_client' => class_exists( 'SoapClient' ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.', + 'suhosin' => extension_loaded( 'suhosin' ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.', + + 'active_plugins' => $this->active_plugins(), + 'network_active_plugins' => $this->network_active_plugins(), + 'gc_options' => print_r( get_option( 'gathercontent_importer' ), 1 ), + ), + false + ); + + // Store for a bit. // set_transient( 'gc_sys_info', $sys_info, 20 * MINUTE_IN_SECONDS ); // } @@ -189,6 +190,7 @@ public function host() { public function pre_length() { $length = strlen( $GLOBALS['wpdb']->prefix ); + return 'Length: ' . $length . ', Status: ' . ( $length > 16 ? 'ERROR: Too Long' : 'Acceptable' ); } @@ -238,6 +240,7 @@ public function network_active_plugins() { public function get_page( $option_key ) { $id = get_option( $option_key ); $title = get_the_title( $id ); + return ( $title ? $title : 'N/A' ) . ' (#' . $id . ')'; } diff --git a/includes/classes/api.php b/includes/classes/api.php index d91bf97d..76fdd9c3 100644 --- a/includes/classes/api.php +++ b/includes/classes/api.php @@ -1,4 +1,5 @@ get( 'accounts' ); @@ -79,11 +81,11 @@ public function get_accounts() { /** * GC API request to get the results from the "/account/" endpoint. * - * @since 3.0.0 - * + * @return mixed Results of request. * @link https://gathercontent.com/developers/accounts/get-account/ * - * @return mixed Results of request. + * @since 3.0.0 + * */ public function get_account( $account_id ) { return $this->get( @@ -99,12 +101,13 @@ public function get_account( $account_id ) { /** * GC API request to get the results from the "/projects?account_id=" endpoint. * + * @param int $account_id Account ID. + * + * @return mixed Results of request. * @since 3.0.0 * * @link https://gathercontent.com/developers/projects/get-projects/ * - * @param int $account_id Account ID. - * @return mixed Results of request. */ public function get_account_projects( $account_id ) { return $this->get( 'projects?account_id=' . $account_id ); @@ -113,12 +116,13 @@ public function get_account_projects( $account_id ) { /** * GC API request to get the results from the "/projects/" endpoint. * + * @param int $project_id Project ID. + * + * @return mixed Results of request. * @since 3.0.0 * * @link https://gathercontent.com/developers/projects/get-projects-by-id/ * - * @param int $project_id Project ID. - * @return mixed Results of request. */ public function get_project( $project_id ) { return $this->get( 'projects/' . $project_id ); @@ -127,14 +131,14 @@ public function get_project( $project_id ) { /** * GC API request to get the results from the "/projects//statuses" endpoint. * - * @since 3.0.0 + * @param int $project_id Project ID. + * @param string $response Response result type. * + * @return mixed Results of request. * @link https://gathercontent.com/developers/projects/get-projects-statuses/ * - * @param int $project_id Project ID. - * @param string $response Response result type. + * @since 3.0.0 * - * @return mixed Results of request. */ public function get_project_statuses( $project_id, $response = '' ) { return $this->get( 'projects/' . $project_id . '/statuses', array(), $response ); @@ -145,15 +149,15 @@ public function get_project_statuses( $project_id, $response = '' ) { * * Pass template_id to filter it with template_id as well * + * @param int $project_id Project ID. + * @param int $template_id Template ID. + * @param bool $include_status bool defaults to false. + * + * @return mixed Results of request. * @since 3.2.0 * * @link https://docs.gathercontent.com/reference/listitems * - * @param int $project_id Project ID. - * @param int $template_id Template ID. - * @param bool $include_status bool defaults to false. - * - * @return mixed Results of request. */ public function get_project_items( $project_id, $template_id, $include_status = false ) { @@ -175,7 +179,7 @@ public function get_project_items( $project_id, $template_id, $include_status = ); if ( $include_status ) { - foreach ($response as $i => $item) { + foreach ( $response as $i => $item ) { $response[ $i ]->status = (object) $this->add_status_to_item( $item ); } } @@ -186,14 +190,14 @@ public function get_project_items( $project_id, $template_id, $include_status = /** * GC API request to get the results from the "/items/{item_id}" endpoint. * - * @since 3.2.0 + * @param int $item_id Item ID. + * @param bool $exclude_status set this to true to avoid appending status data * + * @return mixed Results of request. * @link https://docs.gathercontent.com/reference/getitem * - * @param int $item_id Item ID. - * @param bool $exclude_status set this to true to avoid appending status data + * @since 3.2.0 * - * @return mixed Results of request. */ public function get_item( $item_id, $exclude_status = false ) { @@ -218,10 +222,11 @@ public function get_item( $item_id, $exclude_status = false ) { /** * Add project status to single item. * - * @since 3.2.0 + * @param mixed $item item result object. * - * @param mixed $item item result object. * @return mixed $status_data. + * @since 3.2.0 + * */ public function add_status_to_item( $item ) { @@ -245,12 +250,13 @@ public function add_status_to_item( $item ) { /** * GC V2 API request to get the results from the "/projects/{project_id}/statuses/:status_id" endpoint. * + * @param int $project_id Project ID, int $status_id Status ID. + * + * @return mixed Results of request. * @since 3.2.0 * * @link https://docs.gathercontent.com/v0.5/reference/get-project-statuses-by-id * - * @param int $project_id Project ID, int $status_id Status ID. - * @return mixed Results of request. */ public function get_project_status_information( $project_id, $status_id ) { return $this->get( 'projects/' . $project_id . '/statuses/' . $status_id ); @@ -259,14 +265,14 @@ public function get_project_status_information( $project_id, $status_id ) { /** * GC V2 API request to get the files from the "/projects/{project_id}/files" endpoint. * - * @since 3.2.0 + * @param string $project_id required project_id to fetch the files. + * @param array $file_ids optional array to filter files with the project id. * + * @return mixed Results of request. * @link https://docs.gathercontent.com/reference/listfiles * - * @param string $project_id required project_id to fetch the files. - * @param array $file_ids optional array to filter files with the project id. + * @since 3.2.0 * - * @return mixed Results of request. */ public function get_item_files( $project_id, $file_ids = array() ) { @@ -287,15 +293,15 @@ public function get_item_files( $project_id, $file_ids = array() ) { /** * GC V2 API request to get the files from the "/projects/{project_id}/files" endpoint. * + * @param string $project_id required project_id to fetch the files. + * @param string $file_id to update meta data. + * @param array $meta_data to update + * + * @return int|false status code * @since 3.2.0 * * @link https://docs.gathercontent.com/reference/listfiles * - * @param string $project_id required project_id to fetch the files. - * @param string $file_id to update meta data. - * @param array $meta_data to update - * - * @return int|false status code */ public function update_file_meta( $project_id, $file_id, $meta_data ) { @@ -322,12 +328,13 @@ public function update_file_meta( $project_id, $file_id, $meta_data ) { /** * GC V2 API request to get the results from the "/projects/{project_id}/templates" endpoint. * + * @param int $project_id Project ID. + * + * @return mixed Results of request. * @since 3.0.0 * * @link https://docs.gathercontent.com/reference/listtemplates * - * @param int $project_id Project ID. - * @return mixed Results of request. */ public function get_project_templates( $project_id ) { @@ -344,12 +351,13 @@ public function get_project_templates( $project_id ) { /** * GC API request to get the results from the "/templates/{template_id}" endpoint. * + * @param int $template_id Template ID. + * + * @return mixed Results of request. * @since 3.0.0 * * @link https://docs.gathercontent.com/reference/gettemplate * - * @param int $template_id Template ID. - * @return mixed Results of request. */ public function get_template( $template_id ) { $response = $this->get( @@ -361,6 +369,7 @@ public function get_template( $template_id ) { ), 'full_data' ); + return $response; } @@ -369,13 +378,14 @@ public function get_template( $template_id ) { * * /items//choose_status * - * @since 3.0.0 + * @param int $item_id GatherContent Item Id. + * @param int $status_id Id of status to set. * + * @return bool If request was successful. * @link https://gathercontent.com/developers/items/post-items-choose_status/ * - * @param int $item_id GatherContent Item Id. - * @param int $status_id Id of status to set. - * @return bool If request was successful. + * @since 3.0.0 + * */ public function set_item_status( $item_id, $status_id ) { $response = $this->post( @@ -405,13 +415,14 @@ public function set_item_status( $item_id, $status_id ) { * * /items//content * - * @since 3.0.0 + * @param int $item_id GatherContent Item Id. + * @param array $content Data to save. * + * @return bool If request was successful. * @link https://docs.gathercontent.com/reference/updateitemcontent * - * @param int $item_id GatherContent Item Id. - * @param array $content Data to save. - * @return bool If request was successful. + * @since 3.0.0 + * */ public function update_item( $item_id, $content ) { @@ -438,10 +449,10 @@ public function update_item( $item_id, $content ) { * * @link https://docs.gathercontent.com/reference/createitem * - * @param int $project_id Project ID. - * @param int $template_id Template ID. - * @param string $name Item name. - * @param array $content + * @param int $project_id Project ID. + * @param int $template_id Template ID. + * @param string $name Item name. + * @param array $content * * @return bool If request was successful. */ @@ -465,6 +476,7 @@ public function create_item( $project_id, $template_id, $name, $content = array( if ( 201 === $response['response']['code'] ) { $item_id = json_decode( wp_remote_retrieve_body( $response ) )->data->id; } + return $item_id; } @@ -476,10 +488,10 @@ public function create_item( $project_id, $template_id, $name, $content = array( * * @link https://docs.gathercontent.com/reference/createitem * - * @param int $project_id Project ID. - * @param int $template_id Template ID. - * @param string $name Item name. - * @param array $content + * @param int $project_id Project ID. + * @param int $template_id Template ID. + * @param string $name Item name. + * @param array $content * * @return bool If request was successful. */ @@ -503,6 +515,7 @@ public function create_structured_item( $project_id, $template_id, $name, $conte if ( 201 === $response['response']['code'] ) { $item_id = json_decode( wp_remote_retrieve_body( $response ) )->data->id; } + return $item_id; } @@ -511,12 +524,13 @@ public function create_structured_item( $project_id, $template_id, $name, $conte /** * GC V2 API request to get the results from the "/projects/{project_id}/components" endpoint. * + * @param int $project_id Project Id. + * + * @return mixed Results of request. * @since 3.0.0 * * @link https://docs.gathercontent.com/reference/listcomponents * - * @param int $project_id Project Id. - * @return mixed Results of request. */ public function get_components( $project_id ) { return $this->get( @@ -528,15 +542,17 @@ public function get_components( $project_id ) { ) ); } + /** * GC V2 API request to get the results from the "/components/{component_uuid}" endpoint. * + * @param int $component_uuid Component UUid. + * + * @return mixed Results of request. * @since 3.0.0 * * @link https://docs.gathercontent.com/reference/getcomponent * - * @param int $component_uuid Component UUid. - * @return mixed Results of request. */ public function get_component( $component_uuid ) { return $this->get( @@ -552,13 +568,14 @@ public function get_component( $component_uuid ) { /** * POST request helper, which assumes a data parameter in response. * - * @since 3.0.0 + * @param string $endpoint GatherContent API endpoint to retrieve. + * @param array $args Optional. Request arguments. Default empty array. * + * @return mixed The response. * @see API::cache_get() For additional information * - * @param string $endpoint GatherContent API endpoint to retrieve. - * @param array $args Optional. Request arguments. Default empty array. - * @return mixed The response. + * @since 3.0.0 + * */ public function post( $endpoint, $args = array() ) { return $this->request( $endpoint, $args, 'POST' ); @@ -567,32 +584,34 @@ public function post( $endpoint, $args = array() ) { /** * PUT request helper, which assumes a data parameter in response. * - * @since 3.2.0 + * @param string $endpoint GatherContent API endpoint to retrieve. + * @param array $args Optional. Request arguments. Default empty array. * + * @return mixed The response. * @see API::cache_get() For additional information * - * @param string $endpoint GatherContent API endpoint to retrieve. - * @param array $args Optional. Request arguments. Default empty array. - * @return mixed The response. + * @since 3.2.0 + * */ public function put( $endpoint, $args = array() ) { $final_args = array_merge( array( 'method' => 'PUT' ), $args ); + return $this->request( $endpoint, $final_args, 'PUT' ); } /** * GET request helper which assumes caching, and assumes a data parameter in response. * - * @since 3.0.0 + * @param string $endpoint GatherContent API endpoint to retrieve. + * @param array $args Optional. Request arguments. Default empty array. + * @param string $response_type Optional. expected response. Default empty + * @param array $query_params Optional. Request query parameters to append to the URL. Default empty array. * + * @return mixed The response. * @see API::cache_get() For additional information * - * @param string $endpoint GatherContent API endpoint to retrieve. - * @param array $args Optional. Request arguments. Default empty array. - * @param string $response_type Optional. expected response. Default empty - * @param array $query_params Optional. Request query parameters to append to the URL. Default empty array. + * @since 3.0.0 * - * @return mixed The response. */ public function get( $endpoint, $args = array(), $response_type = '', $query_params = array() ) { @@ -610,16 +629,16 @@ public function get( $endpoint, $args = array(), $response_type = '', $query_par /** * Retrieve and cache the HTTP request. * - * @since 3.0.0 + * @param string $endpoint GatherContent API endpoint to retrieve. + * @param string $expiration The expiration time. Defaults to an hour. + * @param array $args Optional. Request arguments. Default empty array. + * @param array $query_params Optional. Request query parameters to append to the URL. Default empty array. * + * @return array The response. * @see API::request() For additional information * - * @param string $endpoint GatherContent API endpoint to retrieve. - * @param string $expiration The expiration time. Defaults to an hour. - * @param array $args Optional. Request arguments. Default empty array. - * @param array $query_params Optional. Request query parameters to append to the URL. Default empty array. + * @since 3.0.0 * - * @return array The response. */ public function cache_get( $endpoint, $expiration = HOUR_IN_SECONDS, $args = array(), $method = 'get', $query_params = array() ) { @@ -628,6 +647,7 @@ public function cache_get( $endpoint, $expiration = HOUR_IN_SECONDS, $args = arr if ( $this->only_cached ) { $this->only_cached = false; + return $response; } @@ -660,15 +680,16 @@ public function cache_get( $endpoint, $expiration = HOUR_IN_SECONDS, $args = arr * - Default 'POST' for wp_remote_post() * - Default 'HEAD' for wp_remote_head() * - * @since 3.0.0 + * @param string $endpoint GatherContent API endpoint to retrieve. + * @param array $args Optional. Request arguments. Default empty array. + * @param array $method Optional. Request method, defaults to 'GET'. + * @param array $query_params Optional. Request query parameters to append to the URL. Default empty array. * + * @return array The response. * @see WP_Http::request() For additional information on default arguments. * - * @param string $endpoint GatherContent API endpoint to retrieve. - * @param array $args Optional. Request arguments. Default empty array. - * @param array $method Optional. Request method, defaults to 'GET'. - * @param array $query_params Optional. Request query parameters to append to the URL. Default empty array. - * @return array The response. + * @since 3.0.0 + * */ public function request( $endpoint, $args = array(), $method = 'GET', $query_params = array() ) { @@ -752,11 +773,11 @@ public function request( $endpoint, $args = array(), $method = 'GET', $query_par /** * Prepares headers for GC requests. * - * @since 3.0.0 - * - * @param array $args Array of request args. + * @param array $args Array of request args. * * @return array Modified array of request args. + * @since 3.0.0 + * */ public function request_args( $args ) { if ( ! $this->user || ! $this->api_key ) { @@ -795,12 +816,13 @@ public function request_args( $args ) { * * e.g. `$this->only_cached()->get( 'me' )` * + * @return $this * @since 3.0.0 * - * @return $this */ public function only_cached() { $this->reset_request_cache = true; + return $this; } @@ -810,21 +832,22 @@ public function only_cached() { * * E.g. `$this->uncached()->get( 'me' )` * + * @return $this * @since 3.0.0 * - * @return $this */ public function uncached() { $this->reset_request_cache = true; + return $this; } /** * Some methods return false if response is not found. This allows retrieving the last response. * + * @return mixed The last request response. * @since 3.0.0 * - * @return mixed The last request response. */ public function get_last_response() { return $this->last_response; @@ -833,11 +856,11 @@ public function get_last_response() { /** * Flush all cached responses, or only for a given endpoint. * - * @since 3.0.0 - * - * @param string $endpoint Optional endpoint to clear cached response. + * @param string $endpoint Optional endpoint to clear cached response. * * @return bool Status of cache flush/deletion. + * @since 3.0.0 + * */ public function flush_cache( $endpoint = '' ) { $deleted = false; diff --git a/includes/classes/base.php b/includes/classes/base.php index b947854b..a54bf6bf 100644 --- a/includes/classes/base.php +++ b/includes/classes/base.php @@ -33,12 +33,12 @@ abstract class Base { * Creates an instance of this class. * Superglobals are passed as class arguments to keep the object clean of globals. * - * @since 3.0.0 - * - * @param array $_get Array of $_GET variables. + * @param array $_get Array of $_GET variables. * @param array $_post Array of $_POST variables. * * @throws Exception If the $_GET and $_Post variables are not set on the first initation. + * @since 3.0.0 + * */ protected function __construct( array $_get = null, array $_post = null ) { /** @@ -62,11 +62,11 @@ protected function __construct( array $_get = null, array $_post = null ) { /** * Get the value from the query array. * - * @since 3.0.0 - * - * @param string $key Key to check/retrieve. + * @param string $key Key to check/retrieve. * * @return mixed Query value if it exists. + * @since 3.0.0 + * */ public function _get_val( $key ) { return isset( self::$_get[ $key ] ) ? self::$_get[ $key ] : null; @@ -74,27 +74,28 @@ public function _get_val( $key ) { /** * Returns an array of the key=>value | null in $_GET if the given keys exist. + * * @param $keys + * * @return array|null */ - public function _get_vals($keys) - { - return array_reduce($keys, function($carry, $key){ - $carry[$key] = $this->_get_val($key); + public function _get_vals( $keys ) { + return array_reduce( $keys, function ( $carry, $key ) { + $carry[ $key ] = $this->_get_val( $key ); return $carry; - }, []); + }, [] ); } /** * See if the query array has a value and if its value matches the $value. * - * @since 3.0.0 - * - * @param string $key Key to check. - * @param string $value Value to check. + * @param string $key Key to check. + * @param string $value Value to check. * * @return bool Whether Query key/value exists. + * @since 3.0.0 + * */ public function get_val_equals( $key, $value ) { return isset( self::$_get[ $key ] ) && $value === self::$_get[ $key ]; @@ -103,11 +104,11 @@ public function get_val_equals( $key, $value ) { /** * Get the value from the $_POST array. * - * @since 3.0.0 - * - * @param string $key Key to check/retrieve. + * @param string $key Key to check/retrieve. * * @return mixed Query value if it exists. + * @since 3.0.0 + * */ public function _post_val( $key ) { return isset( self::$_post[ $key ] ) ? self::$_post[ $key ] : null; @@ -116,12 +117,12 @@ public function _post_val( $key ) { /** * See if the $_POST array has a value and if its value matches the $value. * - * @since 3.0.0 - * - * @param string $key Key to check. - * @param string $value Value to check. + * @param string $key Key to check. + * @param string $value Value to check. * * @return bool Whether Query key/value exists. + * @since 3.0.0 + * */ public function post_val_equals( $key, $value ) { return isset( self::$_post[ $key ] ) && $value === self::$_post[ $key ]; @@ -130,13 +131,13 @@ public function post_val_equals( $key, $value ) { /** * Outputs a view. * - * @since 3.0.0 - * - * @param string $template The template name. - * @param array $args Array of args for the template. - * @param boolean $echo Whether to output result or return it. + * @param string $template The template name. + * @param array $args Array of args for the template. + * @param boolean $echo Whether to output result or return it. * * @return mixed Result of view rendering if requesting to return it. + * @since 3.0.0 + * */ public function view( $template, array $args = array(), $echo = true ) { switch ( $template ) { diff --git a/includes/classes/compatibility/acf.php b/includes/classes/compatibility/acf.php index 412284e7..b8fcac95 100644 --- a/includes/classes/compatibility/acf.php +++ b/includes/classes/compatibility/acf.php @@ -27,25 +27,28 @@ class ACF extends Base { /** * Initiate admin hooks * + * @return void * @since 3.1.5 * - * @return void */ public function init_hooks() { add_filter( 'gc_new_wp_post_data', array( $this, 'maybe_transform_meta_for_acf' ), 10, 2 ); add_filter( 'gc_update_wp_post_data', array( $this, 'maybe_transform_meta_for_acf' ), 10, 2 ); - add_filter( 'gc_config_pre_meta_field_value_updated', array( $this, 'maybe_transform_config_meta_from_acf' ), 10, 4 ); + add_filter( 'gc_config_pre_meta_field_value_updated', array( + $this, + 'maybe_transform_config_meta_from_acf' + ), 10, 4 ); } /** * Handles transforming certain meta values from GC to ACF. * - * @since 3.1.5 - * - * @param array $post_data The post data to import/update. - * @param Pull $pull The Pull object. + * @param array $post_data The post data to import/update. + * @param Pull $pull The Pull object. * * @return array The possibly modified post data array. + * @since 3.1.5 + * */ public function maybe_transform_meta_for_acf( $post_data, Pull $pull ) { if ( empty( $post_data['meta_input'] ) ) { @@ -94,14 +97,14 @@ public function maybe_transform_meta_for_acf( $post_data, Pull $pull ) { /** * Handles transforming certain meta values from ACF to GC. * - * @since 3.1.5 - * - * @param bool $updated Whether config element was updated. - * @param mixed $meta_value The meta value to transform. - * @param string $meta_key The meta key to transform. - * @param Push $push The Push object. + * @param bool $updated Whether config element was updated. + * @param mixed $meta_value The meta value to transform. + * @param string $meta_key The meta key to transform. + * @param Push $push The Push object. * * @return bool Whether the config element is updated. + * @since 3.1.5 + * */ public function maybe_transform_config_meta_from_acf( $updated, $meta_value, $meta_key, Push $push ) { if ( ! isset( $push->element->type, $this->gc_acf_type_map[ $push->element->type ] ) || empty( $meta_value ) ) { @@ -141,7 +144,7 @@ public function maybe_transform_config_meta_from_acf( $updated, $meta_value, $me $updated = $cb( $meta_value, $push, $field ); break 2; - // $updated = $this->maybe_transform_checkbox_push_value( func_get_args() ); + // $updated = $this->maybe_transform_checkbox_push_value( func_get_args() ); } } @@ -151,12 +154,12 @@ public function maybe_transform_config_meta_from_acf( $updated, $meta_value, $me /** * Maybe transform checkbox value to ACF compatible version. * - * @since 3.1.5 - * - * @param mixed $meta_value GC Checkbox Field value - * @param array $field ACF Field array + * @param mixed $meta_value GC Checkbox Field value + * @param array $field ACF Field array * * @return mixed Possibly modified meta value. + * @since 3.1.5 + * */ public function maybe_transform_pull_value_checkbox( $meta_value, $field ) { if ( @@ -165,12 +168,12 @@ public function maybe_transform_pull_value_checkbox( $meta_value, $field ) { && ! empty( $field['choices'] ) ) { $meta_value = array_map( - function( $meta_arr_value ) use ( $field ) { + function ( $meta_arr_value ) use ( $field ) { // Replace choice with the choice key from ACF. $key = array_search( $meta_arr_value, $field['choices'] ); if ( false !== $key ) { - $meta_arr_value = $key; + $meta_arr_value = $key; } return $meta_arr_value; @@ -186,13 +189,13 @@ function( $meta_arr_value ) use ( $field ) { /** * Maybe transform checkbox value to GC compatible version. * - * @since 3.1.5 - * - * @param mixed $meta_value GC Checkbox Field value - * @param Push $push The Push object. - * @param array $field ACF Field array + * @param mixed $meta_value GC Checkbox Field value + * @param Push $push The Push object. + * @param array $field ACF Field array * * @return mixed Possibly modified meta value. + * @since 3.1.5 + * */ public function maybe_transform_push_value_checkbox( $meta_value, $push, $field ) { $updated = false; @@ -211,7 +214,7 @@ public function maybe_transform_push_value_checkbox( $meta_value, $push, $field } $updated = $push->update_element_selected_options( - function( $label ) use ( $meta_value ) { + function ( $label ) use ( $meta_value ) { return in_array( $label, $meta_value, true ); } ); @@ -222,12 +225,12 @@ function( $label ) use ( $meta_value ) { /** * Get the ACF objects for a post-type and post-id. * - * @since 3.1.5 - * - * @param string $post_type The post-type to filter by. - * @param integer $post_id The (optional) post-id to filter by. + * @param string $post_type The post-type to filter by. + * @param integer $post_id The (optional) post-id to filter by. * * @return bool|array Array of ACF objects if found, or false. + * @since 3.1.5 + * */ public function get_acfs( $post_type, $post_id = 0 ) { $filter = array( @@ -251,7 +254,7 @@ public function get_acfs( $post_type, $post_id = 0 ) { $acfs = array_filter( $field_groups, - function( $acf ) use ( $metabox_ids ) { + function ( $acf ) use ( $metabox_ids ) { return isset( $acf['id'] ) && in_array( $acf['id'], $metabox_ids ); } ); @@ -262,11 +265,11 @@ function( $acf ) use ( $metabox_ids ) { /** * Get the ACF fields for a given ACF object array. * - * @since 3.1.5 - * - * @param array $acf The ACF config array. + * @param array $acf The ACF config array. * * @return bool|array Array of fields for this config, or false. + * @since 3.1.5 + * */ public function get_acf_fields( $acf ) { if ( ! isset( $acf['id'] ) ) { diff --git a/includes/classes/compatibility/wpml.php b/includes/classes/compatibility/wpml.php index db25b24d..539836ed 100644 --- a/includes/classes/compatibility/wpml.php +++ b/includes/classes/compatibility/wpml.php @@ -21,14 +21,17 @@ class WPML extends Base { /** * Initiate admin hooks * + * @return void * @since 3.1.7 * - * @return void */ public function init_hooks() { add_filter( 'gc_new_wp_post_data', array( $this, 'maybe_transform_meta_for_wpml' ), 10, 2 ); add_filter( 'gc_update_wp_post_data', array( $this, 'maybe_transform_meta_for_wpml' ), 10, 2 ); - add_filter( 'gc_config_taxonomy_field_value_updated', array( $this, 'maybe_update_taxonomy_item_value_from_wpml' ), 10, 4 ); + add_filter( 'gc_config_taxonomy_field_value_updated', array( + $this, + 'maybe_update_taxonomy_item_value_from_wpml' + ), 10, 4 ); } /** @@ -36,12 +39,12 @@ public function init_hooks() { * * If the GC item uses the foreign language term name, then this will need to be unhooked. * - * @since 3.1.7 - * - * @param array $post_data The post data to import/update. - * @param Pull $pull The Pull object. + * @param array $post_data The post data to import/update. + * @param Pull $pull The Pull object. * * @return array The possibly modified post data array. + * @since 3.1.7 + * */ public function maybe_transform_meta_for_wpml( $post_data, Pull $pull ) { if ( @@ -84,14 +87,14 @@ public function maybe_transform_meta_for_wpml( $post_data, Pull $pull ) { * * If the GC item uses the foreign language term name, then this will need to be unhooked. * - * @since 3.1.7 - * - * @param bool $updated Whether this value was updated. - * @param string $taxonomy The taxonomy - * @param array $terms The array of taxonomy terms for this post. - * @param Push $push The Push object + * @param bool $updated Whether this value was updated. + * @param string $taxonomy The taxonomy + * @param array $terms The array of taxonomy terms for this post. + * @param Push $push The Push object * * @return bool Whether this value was updated. + * @since 3.1.7 + * */ public function maybe_update_taxonomy_item_value_from_wpml( $updated, $taxonomy, $terms, Push $push ) { if ( diff --git a/includes/classes/debug.php b/includes/classes/debug.php index b3425978..3c1c2ceb 100644 --- a/includes/classes/debug.php +++ b/includes/classes/debug.php @@ -81,15 +81,18 @@ public function __construct( Admin $admin ) { /** * Initiate admin hooks * + * @return void * @since 3.0.1 * - * @return void */ public function init_hooks() { if ( is_admin() && isset( $_GET[ self::$query_string ] ) ) { $enabled = self::toggle_debug_mode( $_GET[ self::$query_string ] ); unset( $_GET[ self::$query_string ] ); - add_action( 'all_admin_notices', array( $this, $enabled ? 'debug_enabled_notice' : 'debug_disabled_notice' ) ); + add_action( 'all_admin_notices', array( + $this, + $enabled ? 'debug_enabled_notice' : 'debug_disabled_notice' + ) ); } if ( ! self::$debug_mode ) { @@ -105,12 +108,12 @@ public function init_hooks() { /** * Hooked to `gc_sync_items_result`, logs results to the debug mode log. * - * @since 3.0.1 - * - * @param mixed $maybe_error Result of sync. - * @param object $sync The GatherContent\Importer\Sync\Pull or GatherContent\Importer\Sync\Push object. + * @param mixed $maybe_error Result of sync. + * @param object $sync The GatherContent\Importer\Sync\Pull or GatherContent\Importer\Sync\Push object. * * @return void + * @since 3.0.1 + * */ public function log_sync_results( $maybe_error, $sync ) { self::debug_log( $maybe_error, $sync->direction . ' items result' ); @@ -119,9 +122,9 @@ public function log_sync_results( $maybe_error, $sync ) { /** * Outputs admin notice that the debug mode has been disabled. * + * @return void * @since 3.0.1 * - * @return void */ public function debug_disabled_notice() { $msg = esc_html__( 'Content Workflow Debug Mode: Disabled', 'content-workflow-by-bynder' ); @@ -131,9 +134,9 @@ public function debug_disabled_notice() { /** * Outputs admin notice that the debug mode has been enabled. * + * @return void * @since 3.0.1 * - * @return void */ public function debug_enabled_notice() { $msg = esc_html__( 'Content Workflow Debug Mode: Enabled', 'content-workflow-by-bynder' ); @@ -194,11 +197,11 @@ public function add_debug_fields() { /** * The Debug mode checkbox toggle field callback. * - * @since 3.0.1 - * - * @param GatherContent\Importer\Settings\Form_Section $field Form_Section object. + * @param GatherContent\Importer\Settings\Form_Section $field Form_Section object. * * @return void + * @since 3.0.1 + * */ public function debug_checkbox_field_cb( $field ) { $id = $field->param( 'id' ); @@ -221,16 +224,17 @@ public function debug_checkbox_field_cb( $field ) { /** * Handles the actions associated with the debug checkbox toggle fields. * - * @since 3.0.1 - * - * @param array $settings Array of settings. + * @param array $settings Array of settings. * * @return void + * @since 3.0.1 + * */ public function do_debug_options_actions( $settings ) { if ( empty( $settings['debug']['log_importer_requests'] ) ) { $settings['log_importer_requests'] = false; unset( $settings['debug'] ); + return $settings; } @@ -274,6 +278,7 @@ public function do_debug_options_actions( $settings ) { } elseif ( $settings['log_importer_requests'] ) { $orig_settings['log_importer_requests'] = true; unset( $orig_settings['debug'] ); + return $orig_settings; } @@ -283,12 +288,12 @@ public function do_debug_options_actions( $settings ) { /** * Handles the actions associated with the stuck statuses checkboxes. * - * @since 3.0.1 - * - * @param array $settings Array of settings - * @param string $back_button The back button markup. + * @param array $settings Array of settings + * @param string $back_button The back button markup. * * @return void + * @since 3.0.1 + * */ public function handle_stuck_statuses( $settings, $back_button ) { global $wpdb; @@ -319,11 +324,11 @@ public function handle_stuck_statuses( $settings, $back_button ) { /** * Handles the deleting the debug mode log. * - * @since 3.0.1 - * - * @param string $back_button The back button markup. + * @param string $back_button The back button markup. * * @return void + * @since 3.0.1 + * */ public function delete_gc_log_file( $back_button ) { if ( unlink( self::$log_path ) ) { @@ -336,11 +341,11 @@ public function delete_gc_log_file( $back_button ) { /** * Handles the view for the debug mode log. * - * @since 3.0.1 - * - * @param string $back_button The back button markup. + * @param string $back_button The back button markup. * * @return void + * @since 3.0.1 + * */ public function view_gc_log_file( $back_button ) { $log_contents = file_exists( self::$log_path ) ? file_get_contents( self::$log_path ) : ''; @@ -355,9 +360,9 @@ public function view_gc_log_file( $back_button ) { /** * Check if GATHERCONTENT_DEBUG_MODE constant is set. * + * @return string * @since 3.0.2 * - * @return string */ public static function has_debug_constant() { return defined( 'GATHERCONTENT_DEBUG_MODE' ) && GATHERCONTENT_DEBUG_MODE; @@ -366,9 +371,9 @@ public static function has_debug_constant() { /** * Check if SCRIPT_DEBUG is enabled. * + * @return string * @since 3.0.1 * - * @return string */ public static function debug_mode() { return self::$debug_mode; @@ -377,11 +382,11 @@ public static function debug_mode() { /** * Enable/disable the Debug Mode. * - * @since 3.0.1 - * - * @param bool $debug_enabled Enable/Disable + * @param bool $debug_enabled Enable/Disable * * @return bool Whether it has been enabled. + * @since 3.0.1 + * */ public static function toggle_debug_mode( $debug_enabled ) { $changed = false; @@ -411,12 +416,12 @@ public static function toggle_debug_mode( $debug_enabled ) { /** * Write a message to the log if debug enabled. * - * @since 3.0.1 - * - * @param string $message Message to write to log file. - * @param string $title Describes what is being logged. + * @param string $message Message to write to log file. + * @param string $title Describes what is being logged. * * @return void + * @since 3.0.1 + * */ public static function debug_log( $message = '', $title = '' ) { if ( self::$debug_mode ) { @@ -427,11 +432,11 @@ public static function debug_log( $message = '', $title = '' ) { /** * Write a message to the log. * - * @since 3.0.1 - * - * @param string $message Message to write to log file. + * @param string $message Message to write to log file. * * @return void + * @since 3.0.1 + * */ protected static function _debug_log( $message = '', $title = '' ) { $message = print_r( $message, 1 ); diff --git a/includes/classes/dom.php b/includes/classes/dom.php index 040ffa3b..f618d23b 100644 --- a/includes/classes/dom.php +++ b/includes/classes/dom.php @@ -1,4 +1,5 @@ saveHTML( $this->getElementsByTagName( 'body' )->item( 0 ) ); + return str_replace( array( '', '' ), '', $body ); } diff --git a/includes/classes/exception.php b/includes/classes/exception.php index 6f4f2b20..1d8035df 100644 --- a/includes/classes/exception.php +++ b/includes/classes/exception.php @@ -24,11 +24,12 @@ class Exception extends \Exception { /** * Constructor. Handles assigning the data property. * + * @param string $message Exception message. + * @param int $code Exception code. + * @param mixed $data Additional data. + * * @since 3.0.0 * - * @param string $message Exception message. - * @param int $code Exception code. - * @param mixed $data Additional data. */ public function __construct( $message, $code, $data = null ) { parent::__construct( $message, $code ); @@ -40,9 +41,9 @@ public function __construct( $message, $code, $data = null ) { /** * Fetch the Exception data. * + * @return mixed Exception data * @since 3.0.0 * - * @return mixed Exception data */ public function get_data() { return $this->data; diff --git a/includes/classes/general.php b/includes/classes/general.php index 370b0e56..da4b51f6 100644 --- a/includes/classes/general.php +++ b/includes/classes/general.php @@ -1,4 +1,5 @@ admin->init_hooks(); @@ -173,6 +174,7 @@ public function init_hooks() { * Magic getter for our object, to make protected properties accessible. * * @param string $field + * * @return mixed */ public function __get( $field ) { diff --git a/includes/classes/mapping-post.php b/includes/classes/mapping-post.php index 0f4f703a..513cf341 100644 --- a/includes/classes/mapping-post.php +++ b/includes/classes/mapping-post.php @@ -15,7 +15,8 @@ * * @since 3.0.0 */ -class Mapping_Post_Exception extends Exception {} +class Mapping_Post_Exception extends Exception { +} /** * A wrapper for get_post which bundles a lot of mapping-specific functionality. @@ -48,14 +49,14 @@ class Mapping_Post extends Base { /** * Get a Mapping_Post object instance by Post ID/object * - * @since 3.0.0 - * - * @param WP_Post|int $post WP_Post object or ID. - * @param bool $throw_error Request to throw an error on failure. + * @param WP_Post|int $post WP_Post object or ID. + * @param bool $throw_error Request to throw an error on failure. * + * @return Mapping_Post|false Will return false if $post is not found or not a template-mapping post. * @throws Exception If requesting to throw an error. * - * @return Mapping_Post|false Will return false if $post is not found or not a template-mapping post. + * @since 3.0.0 + * */ public static function get( $post, $throw_error = false ) { if ( $post instanceof Mapping_Post ) { @@ -76,6 +77,7 @@ public static function get( $post, $throw_error = false ) { if ( $throw_error ) { throw $e; } + return false; } } @@ -83,13 +85,13 @@ public static function get( $post, $throw_error = false ) { /** * Get the full post object. * - * @since 3.0.0 - * - * @param mixed $post Post id or object. + * @param mixed $post Post id or object. * + * @return WP_Post Post object. * @throws Mapping_Post_Exception If post could not be retrieved. * - * @return WP_Post Post object. + * @since 3.0.0 + * */ protected static function get_post( $post ) { @@ -109,9 +111,10 @@ protected static function get_post( $post ) { /** * Creates an instance of this class. * + * @param WP_Post $post Post object. + * * @since 3.0.0 * - * @param WP_Post $post Post object. */ protected function __construct( WP_Post $post ) { @@ -122,11 +125,11 @@ protected function __construct( WP_Post $post ) { /** * Initiate the data property from the post content. * - * @since 3.0.0 - * - * @param WP_Post $post Post object. + * @param WP_Post $post Post object. * * @return void + * @since 3.0.0 + * */ protected function init_data( $post ) { @@ -150,12 +153,12 @@ protected function init_data( $post ) { /** * Get value from mapping data. * - * @since 3.0.0 - * - * @param string $arg The arg key. - * @param string $sub_arg Optional sub-arg key. + * @param string $arg The arg key. + * @param string $sub_arg Optional sub-arg key. * * @return mixed Result of lookup. + * @since 3.0.0 + * */ public function data( $arg = null, $sub_arg = null ) { if ( null === $arg ) { @@ -184,11 +187,11 @@ public function data( $arg = null, $sub_arg = null ) { /** * Get the corresponding WP post status based on the item status id. * - * @since 3.0.0 - * - * @param object $item Item object. + * @param object $item Item object. * * @return mixed WP post status or false. + * @since 3.0.0 + * */ public function get_wp_status_for_item( $item ) { $status_id = isset( $item->status_id ) ? $item->status_id : $item; @@ -204,11 +207,11 @@ public function get_wp_status_for_item( $item ) { /** * Get the status which the item should transition to. * - * @since 3.0.0 - * - * @param object $item Item object. + * @param object $item Item object. * * @return mixed New item status or false. + * @since 3.0.0 + * */ public function get_item_new_status( $item ) { $status_id = isset( $item->status_id ) ? $item->status_id : $item; @@ -217,15 +220,16 @@ public function get_item_new_status( $item ) { return absint( $gc_status['after'] ); } } + return false; } /** * Get the mapping edit link. * + * @return string * @since 3.0.0 * - * @return string */ public function get_edit_post_link() { return get_edit_post_link( $this->post->ID ); @@ -234,13 +238,13 @@ public function get_edit_post_link() { /** * Wrapper for update_post_meta. * - * @since 3.0.0 - * - * @param string $meta_key Metadata key. - * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. + * @param string $meta_key Metadata key. + * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. * * @return int|bool Meta ID if the key didn't exist, true on successful update, * false on failure. + * @since 3.0.0 + * */ public function update_meta( $meta_key, $meta_value ) { @@ -252,6 +256,7 @@ public function update_meta( $meta_key, $meta_value ) { * * @param string $meta_key The meta key to retrieve. By default, returns * data for all keys. Default empty. + * * @return mixed Will be an array if $single is false. Will be value of meta data * field if $single is true. */ @@ -273,9 +278,9 @@ public function delete_meta( $meta_key ) { /** * Gets the _gc_template meta value. * + * @return mixed * @since 3.0.0 * - * @return mixed */ public function get_template() { return $this->get_meta( '_gc_template' ); @@ -284,9 +289,9 @@ public function get_template() { /** * Gets the _gc_project meta value. * + * @return mixed * @since 3.0.0 * - * @return mixed */ public function get_project() { return $this->get_meta( '_gc_project' ); @@ -295,9 +300,9 @@ public function get_project() { /** * Gets the _gc_account_id meta value. * + * @return mixed * @since 3.0.0 * - * @return mixed */ public function get_account_id() { return $this->get_meta( '_gc_account_id' ); @@ -306,9 +311,9 @@ public function get_account_id() { /** * Gets the _gc_account meta value. * + * @return mixed * @since 3.0.0 * - * @return mixed */ public function get_account_slug() { return $this->get_meta( '_gc_account' ); @@ -317,9 +322,9 @@ public function get_account_slug() { /** * Gets the items to pull. * + * @return array * @since 3.0.0 * - * @return array */ public function get_items_to_pull() { @@ -329,12 +334,12 @@ public function get_items_to_pull() { /** * Updates the items to pull. * - * @since 3.0.0 - * - * @param array $items Array of items to store to meta. + * @param array $items Array of items to store to meta. * * @return int|bool Meta ID if the key didn't exist, true on successful update, * false on failure. + * @since 3.0.0 + * */ public function update_items_to_pull( $items ) { @@ -344,9 +349,9 @@ public function update_items_to_pull( $items ) { /** * Gets the percent of items pulled. * + * @return int * @since 3.0.0 * - * @return int */ public function get_pull_percent() { return $this->get_sync_percent(); @@ -355,9 +360,9 @@ public function get_pull_percent() { /** * Gets the items to push. * + * @return array * @since 3.0.0 * - * @return array */ public function get_items_to_push() { return $this->get_items_to_sync( 'push' ); @@ -366,12 +371,12 @@ public function get_items_to_push() { /** * Updates the items to pull. * - * @since 3.0.0 - * - * @param array $items Array of items to store to meta. + * @param array $items Array of items to store to meta. * * @return int|bool Meta ID if the key didn't exist, true on successful update, * false on failure. + * @since 3.0.0 + * */ public function update_items_to_push( $items ) { return $this->update_items_to_sync( $items, 'push' ); @@ -380,9 +385,9 @@ public function update_items_to_push( $items ) { /** * Gets the percent of items pushed. * + * @return int * @since 3.0.0 * - * @return int */ public function get_push_percent() { return $this->get_sync_percent( 'push' ); @@ -391,27 +396,28 @@ public function get_push_percent() { /** * Gets the items to sync, based on $direction * - * @since 3.0.0 - * - * @param string $direction Push or pull. + * @param string $direction Push or pull. * * @return array + * @since 3.0.0 + * */ public function get_items_to_sync( $direction = 'pull' ) { $items = $this->get_meta( "_gc_{$direction}_items" ); + return is_array( $items ) ? $items : array(); } /** * Updates the items to sync, based on $direction. * - * @since 3.0.0 - * - * @param array $items Array of items to store to meta. - * @param string $direction Push or pull. + * @param array $items Array of items to store to meta. + * @param string $direction Push or pull. * * @return int|bool Meta ID if the key didn't exist, true on successful update, * false on failure. + * @since 3.0.0 + * */ public function update_items_to_sync( $items, $direction = 'pull' ) { @@ -426,11 +432,11 @@ public function update_items_to_sync( $items, $direction = 'pull' ) { /** * Gets the percent of items synced. * - * @since 3.0.0 - * - * @param string $direction Push or pull. + * @param string $direction Push or pull. * * @return int + * @since 3.0.0 + * */ public function get_sync_percent( $direction = 'pull' ) { $percent = 1; @@ -456,9 +462,10 @@ public function get_sync_percent( $direction = 'pull' ) { /** * Magic getter for our object. * - * @param string $property The class property to get. - * @throws Mapping_Post_Exception Throws an exception if the field is invalid. + * @param string $property The class property to get. + * * @return mixed + * @throws Mapping_Post_Exception Throws an exception if the field is invalid. */ public function __get( $property ) { @@ -482,6 +489,7 @@ public function __get( $property ) { * Magic isset checker for our object. * * @param string $property The class property to check if isset. + * * @return bool */ public function __isset( $property ) { diff --git a/includes/classes/post-types/async-save-hook.php b/includes/classes/post-types/async-save-hook.php index 27b7e999..b0af5928 100644 --- a/includes/classes/post-types/async-save-hook.php +++ b/includes/classes/post-types/async-save-hook.php @@ -1,8 +1,9 @@ post_type !== $post->post_type ) { throw new \Exception( 'We only want async tasks for: ' . $this->post_type ); } + return array( 'post_id' => $post_id ); } diff --git a/includes/classes/post-types/base.php b/includes/classes/post-types/base.php index fcb989be..ee347fb4 100644 --- a/includes/classes/post-types/base.php +++ b/includes/classes/post-types/base.php @@ -1,19 +1,21 @@ args = $args; @@ -37,15 +39,17 @@ public function register_post_type() { /** * Filter CPT title entry placeholder text * - * @since 0.1.0 - * @param string $title Original placeholder text + * @param string $title Original placeholder text + * * @return string Modifed placeholder text + * @since 0.1.0 */ public function modify_title( $title ) { $screen = get_current_screen(); if ( isset( $screen->post_type ) && $screen->post_type == static::SLUG ) { $name = $this->args->labels->singular_name; + return sprintf( __( '%s Title', 'content-workflow-by-bynder' ), $name ); } diff --git a/includes/classes/post-types/template-mappings.php b/includes/classes/post-types/template-mappings.php index 576a7a81..c0e3880a 100644 --- a/includes/classes/post-types/template-mappings.php +++ b/includes/classes/post-types/template-mappings.php @@ -1,4 +1,5 @@ '; - print_r( $value ); + print_r( $value ); echo ''; } else { print_r( $value ); @@ -238,11 +244,11 @@ public function column_display( $column, $post_id ) { /** * Collect meta data for mapping. * - * @since 3.0.0 - * - * @param int $post_id Mapping post id + * @param int $post_id Mapping post id * * @return array Array of meta dat. + * @since 3.0.0 + * */ protected function column_post_data( $post_id ) { static $posts_data = array(); @@ -326,14 +332,14 @@ public function modify_mapping_post_edit_link( $link, $post ) { /** * removes quick edit from custom post type list * - * @since 3.0.0 - * - * @param array $actions An array of row action links. Defaults are + * @param array $actions An array of row action links. Defaults are * 'Edit', 'Quick Edit', 'Restore, 'Trash', * 'Delete Permanently', 'Preview', and 'View'. - * @param WP_Post $post The post object. + * @param WP_Post $post The post object. * * @return array Modified $actions. + * @since 3.0.0 + * */ function remove_quick_edit( $actions, $post ) { if ( self::SLUG === $post->post_type ) { @@ -399,7 +405,7 @@ public static function create_mapping( $mapping_args, $post_data = array(), $wp_ if ( ! empty( $mapping_args['content']['mapping'] ) ) { $mapping_args['content']['mapping'] = array_filter( $mapping_args['content']['mapping'], - function( $opt ) { + function ( $opt ) { return ! empty( $opt['value'] ) ? $opt : false; } ); @@ -661,11 +667,13 @@ protected function get_objects( $gotten, $meta_key, $all ) { $objects[ $object_id ]['mappings'][] = $post_id; } } + return $objects; } public static function get_mapping_post_types() { $all_types = get_option( 'gc_post_types', array() ); + return is_array( $all_types ) ? $all_types : array(); } @@ -679,11 +687,13 @@ public static function update_mapping_post_types( $all_types = false ) { public function get_mapping_template( $post_id ) { $mapping = Mapping_Post::get( $post_id ); + return $mapping ? $mapping->get_template() : false; } public function get_mapping_project( $post_id ) { $mapping = Mapping_Post::get( $post_id ); + return $mapping ? $mapping->get_project() : false; } @@ -719,21 +729,25 @@ public function get_mapping_account_id( $post_id ) { public function get_mapping_account_slug( $post_id ) { $mapping = Mapping_Post::get( $post_id ); + return $mapping ? $mapping->get_account_slug() : false; } public function get_items_to_pull( $post_id ) { $mapping = Mapping_Post::get( $post_id ); + return $mapping ? $mapping->get_items_to_pull() : false; } public function update_items_to_pull( $post_id, $items = array() ) { $mapping = Mapping_Post::get( $post_id ); + return $mapping ? $mapping->update_items_to_pull( $items ) : false; } public function get_pull_percent( $post_id ) { $mapping = Mapping_Post::get( $post_id ); + return $mapping ? $mapping->get_pull_percent() : 0; } diff --git a/includes/classes/settings/form-section.php b/includes/classes/settings/form-section.php index f94320f6..28743044 100644 --- a/includes/classes/settings/form-section.php +++ b/includes/classes/settings/form-section.php @@ -1,4 +1,5 @@ do_desc_callback(); } - $html .= ''; - $html .= $this->do_fields(); - $html .= '
                  '; + $html .= ''; + $html .= $this->do_fields(); + $html .= '
                  '; $html .= '
              '; @@ -51,6 +52,7 @@ public function do_desc_callback() { if ( is_callable( $this->callback ) ) { ob_start(); call_user_func( $this->callback, $this ); + return ob_get_clean(); } diff --git a/includes/classes/settings/setting.php b/includes/classes/settings/setting.php index ddb51613..14345755 100644 --- a/includes/classes/settings/setting.php +++ b/includes/classes/settings/setting.php @@ -1,4 +1,5 @@ options ) ) { diff --git a/includes/classes/sync/async-base.php b/includes/classes/sync/async-base.php index c1d34462..293a73be 100644 --- a/includes/classes/sync/async-base.php +++ b/includes/classes/sync/async-base.php @@ -1,4 +1,5 @@ _body_data ) || ! isset($this->_body_data['mapping_id'])) { + if ( empty( $this->_body_data ) || ! isset( $this->_body_data['mapping_id'] ) ) { return; } $mapping_post = get_post( $this->_body_data['mapping_id'] ); - do_action($this->_body_data['action'], $mapping_post); + do_action( $this->_body_data['action'], $mapping_post ); } /** * Prepare data for the asynchronous request * - * @throws Exception If for any reason the request should not happen - * * @param array $data An array of data sent to the hook * * @return array + * @throws Exception If for any reason the request should not happen + * */ protected function prepare_data( $data ) { return array( 'mapping_id' => isset( $data[0]->ID ) ? $data[0]->ID : 0 ); @@ -79,15 +80,16 @@ protected function run_action() { /** * Run the given async task action * + * @return bool Whether the do_action was called. * @since 3.1.4 * - * @return bool Whether the do_action was called. */ protected function run_given_action( $action_name ) { $mapping_id = absint( $_POST['mapping_id'] ); if ( $mapping_id && ( $mapping_post = get_post( $mapping_id ) ) ) { do_action( "wp_async_$action_name", $mapping_post ); + return true; } diff --git a/includes/classes/sync/async-pull-action.php b/includes/classes/sync/async-pull-action.php index ccff7358..cc58b3bb 100644 --- a/includes/classes/sync/async-pull-action.php +++ b/includes/classes/sync/async-pull-action.php @@ -1,4 +1,5 @@ api = $api; @@ -111,9 +113,9 @@ public function __construct( API $api, Async_Base $async ) { /** * Initiate admin hooks * + * @return void * @since 3.0.0 * - * @return void */ public function init_hooks() { $this->logger->init_hooks(); @@ -122,43 +124,44 @@ public function init_hooks() { /** * Handles pushing/pulling item. * - * @since 3.0.0 - * - * @param int $id id of thing to sync. + * @param int $id id of thing to sync. * + * @return mixed Result of push. * @throws Exception On failure. * - * @return mixed Result of push. + * @since 3.0.0 + * */ abstract protected function do_item( $id ); /** * Handles syncing items for a mapping. * + * @param int $mapping_post Mapping post object. + * + * @return mixed Result of sync. WP_Error on failure. * @todo Store errors. * * @since 3.0.0 * - * @param int $mapping_post Mapping post object. - * - * @return mixed Result of sync. WP_Error on failure. */ public function sync_items( $mapping_post ) { $result = $this->_sync_items( $mapping_post ); do_action( 'gc_sync_items_result', $result, $this ); + return $result; } /** * Handles syncing items for a mapping. * - * @since 3.0.0 - * - * @param int $mapping_post Mapping post object. + * @param int $mapping_post Mapping post object. * + * @return mixed Result of sync. * @throws Exception On failure. * - * @return mixed Result of sync. + * @since 3.0.0 + * */ protected function _sync_items( $mapping_post ) { try { @@ -220,13 +223,13 @@ protected function _sync_items( $mapping_post ) { /** * Wrapper for `get_post` that throws an exception if not found. * - * @since 3.0.0 - * - * @param int|object $post_id Post id or post object. + * @param int|object $post_id Post id or post object. * + * @return object Post object. * @throws Exception On failure. * - * @return object Post object. + * @since 3.0.0 + * */ protected function get_post( $post_id ) { $post = $post_id instanceof WP_Post ? $post_id : get_post( $post_id ); @@ -240,14 +243,14 @@ protected function get_post( $post_id ) { /** * Gets an item from the API, then sets it as the class item property. * - * @since 3.0.0 - * - * @param int $item_id Item id. - * @param bool $exclude_status set this to true to avoid appending status data + * @param int $item_id Item id. + * @param bool $exclude_status set this to true to avoid appending status data * + * @return object Item object. * @throws Exception On failure. * - * @return object Item object. + * @since 3.0.0 + * */ protected function set_item( $item_id, $exclude_status = false ) { $this->item = $this->api->uncached()->get_item( $item_id, $exclude_status ); @@ -263,11 +266,11 @@ protected function set_item( $item_id, $exclude_status = false ) { /** * Gets the pending sync items. * - * @since 3.0.0 - * + * @return array Array of pending sync items. * @throws Exception On failure. * - * @return array Array of pending sync items. + * @since 3.0.0 + * */ protected function get_items_to_sync() { $items = $this->mapping->get_items_to_sync( $this->direction ); @@ -282,11 +285,11 @@ protected function get_items_to_sync() { /** * Ensures the mapping has mapping data set. * - * @since 3.0.0 - * + * @return void * @throws Exception On failure. * - * @return void + * @since 3.0.0 + * */ protected function check_mapping_data() { $mapping_data = $this->mapping->data(); @@ -299,23 +302,24 @@ protected function check_mapping_data() { /** * Gets the current element's value, and passes through a filter. * + * @return mixed The current element's value. * @since 3.0.0 * - * @return mixed The current element's value. */ protected function get_element_value() { $val = $this->get_value_for_element( $this->element ); + return apply_filters( 'gc_get_element_value', $val, $this->element, $this->item ); } /** * Gets the element's value, based on the element type. * - * @since 3.0.0 - * * @param object $element The element to get the value for. * * @return mixed The current element's value. + * @since 3.0.0 + * */ protected function get_value_for_element( $element ) { $val = false; @@ -333,17 +337,17 @@ protected function get_value_for_element( $element ) { '#\(.+?)\<\/p\>#s', function ( $matches ) { return '

              ' . str_replace( - array( - "\n ", - "\r\n ", - "\r ", - "\n", - "\r\n", - "\r", - ), - '', - $matches[1] - ) . '

              '; + array( + "\n ", + "\r\n ", + "\r ", + "\n", + "\r\n", + "\r", + ), + '', + $matches[1] + ) . '

              '; }, $val ); @@ -372,7 +376,7 @@ function ( $matches ) { // http://regexr.com/3dpcf -- example. $val = preg_replace_callback( '~(&)(?:[a-z,A-Z,0-9]+|#\d+|#x[0-9a-f]+);~', - function( $matches ) { + function ( $matches ) { return str_replace( '&', '&', $matches[0] ); }, $val @@ -384,7 +388,7 @@ function( $matches ) { case 'choice_radio': $val = ''; - error_log('RADIO: ' . json_encode($element)); + error_log( 'RADIO: ' . json_encode( $element ) ); foreach ( $element->options as $idx => $option ) { if ( $option->selected ) { if ( isset( $option->value ) ) { @@ -408,18 +412,18 @@ function( $matches ) { case 'attachment': $element_value = is_array( $element->value ) ? $element->value : array(); - $val = $element_value ? array_map( + $val = $element_value ? array_map( function ( $v ) { return (object) array( - 'id' => $v->file_id, - 'project_id' => $this->item->project_id, - 'url' => $v->url, + 'id' => $v->file_id, + 'project_id' => $this->item->project_id, + 'url' => $v->url, 'optimised_image_url' => $v->optimised_image_url, - 'download_url' => $v->download_url, - 'filename' => $v->filename, - 'size' => $v->size, - 'mime_type' => $v->mime_type, - 'alt_text' => $v->alt_text, + 'download_url' => $v->download_url, + 'filename' => $v->filename, + 'size' => $v->size, + 'mime_type' => $v->mime_type, + 'alt_text' => $v->alt_text, ); }, $element_value @@ -433,15 +437,15 @@ function ( $v ) { break; } - return $val; + return $val; } /** * Sets the current element's value. * + * @return void * @since 3.0.0 * - * @return void */ protected function set_element_value() { $this->element->value = $this->get_element_value(); @@ -450,14 +454,14 @@ protected function set_element_value() { /** * Format the element's values to the required data format. * - * @since 3.2.0 - * - * @param mixed $field object. + * @param mixed $field object. * @param string|null $component_uuid optional component uuid only if the field is component. - * @param bool $append_component_id optional to append the component's id in the field, default is true - * @param bool $is_component_repeatable optional to tell that the field is a part of repeatable component + * @param bool $append_component_id optional to append the component's id in the field, default is true + * @param bool $is_component_repeatable optional to tell that the field is a part of repeatable component * * @return array + * @since 3.2.0 + * */ protected function format_element_data( $field, $component_uuid = '', $append_component_id = true, $is_component_repeatable = false ): array { @@ -469,11 +473,11 @@ protected function format_element_data( $field, $component_uuid = '', $append_co $content = isset( $this->item->content ) ? ( $component_uuid ? ( $this->item->content->$component_uuid ?? null ) : $this->item->content ) : null; $field_value = $content ? ( $content->$field_name ?? null ) : null; - if( ! $field_value && $component_uuid && $is_component_repeatable ){ + if ( ! $field_value && $component_uuid && $is_component_repeatable ) { $content_to_push = []; - foreach($content as $data) { - if( isset ( $data->$field_name ) ){ - array_push($content_to_push, $data->$field_name ); + foreach ( $content as $data ) { + if ( isset ( $data->$field_name ) ) { + array_push( $content_to_push, $data->$field_name ); } } $field_value = $content_to_push; @@ -484,7 +488,7 @@ protected function format_element_data( $field, $component_uuid = '', $append_co 'type' => $field->field_type, 'label' => $field->label, 'plain_text' => (bool) $is_plain, - 'value' => $this->format_field_value($field, $field_value, $is_component_repeatable, $is_repeatable), + 'value' => $this->format_field_value( $field, $field_value, $is_component_repeatable, $is_repeatable ), 'repeatable' => (bool) $is_repeatable, 'options' => $this->format_selected_options_data( $metadata, $field_value ), ); @@ -493,34 +497,35 @@ protected function format_element_data( $field, $component_uuid = '', $append_co /** * Format the field's value. * - * @since 3.2.0 - * * @param mixed $field object. * @param mixed $field_value object. - * @param bool $is_component_repeatable to tell that the field is a part of repeatable component - * @param bool $is_repeatable to tell that the field itself is a repeatable + * @param bool $is_component_repeatable to tell that the field is a part of repeatable component + * @param bool $is_repeatable to tell that the field itself is a repeatable * * @return mixed + * @since 3.2.0 + * */ - protected function format_field_value( $field, $field_value, $is_component_repeatable, $is_repeatable) { - error_log('value: ' . json_encode($field_value)); + protected function format_field_value( $field, $field_value, $is_component_repeatable, $is_repeatable ) { + error_log( 'value: ' . json_encode( $field_value ) ); - if( empty( $field_value ) ) { + if ( empty( $field_value ) ) { return ''; } // handle repeatables - if($is_component_repeatable || $is_repeatable) { + if ( $is_component_repeatable || $is_repeatable ) { // handle attachment repeatables - if( 'attachment' === $field->field_type && $is_component_repeatable ){ + if ( 'attachment' === $field->field_type && $is_component_repeatable ) { $attachments = []; - foreach($field_value as $value){ - foreach($value as $val){ - array_push($attachments, $val); + foreach ( $field_value as $value ) { + foreach ( $value as $val ) { + array_push( $attachments, $val ); } } + return $attachments; } @@ -528,15 +533,15 @@ protected function format_field_value( $field, $field_value, $is_component_repea ( is_array( $field_value ) ? array_values( array_filter( $field_value, - function( $val ) { - if(is_string($val)){ + function ( $val ) { + if ( is_string( $val ) ) { return trim( $val ) !== ''; } else { return $val; } } ) - ) : $field_value )); + ) : $field_value ) ); } return $field_value; @@ -547,12 +552,12 @@ function( $val ) { * Format the element's options. * This method only returns the selected options * - * @since 3.2.0 - * * @param mixed $metadata object. * @param mixed $field_value object. * * @return array + * @since 3.2.0 + * */ protected function format_selected_options_data( $metadata, $field_value ): array { @@ -569,18 +574,18 @@ protected function format_selected_options_data( $metadata, $field_value ): arra $options[] = (object) array( 'name' => $option->optionId, 'label' => $option->label, - 'selected' => ! empty($matched_option), + 'selected' => ! empty( $matched_option ), ); } - if (isset($metadata->choice_fields->otherOption)) { - $option = $metadata->choice_fields->otherOption; + if ( isset( $metadata->choice_fields->otherOption ) ) { + $option = $metadata->choice_fields->otherOption; $matched_option = wp_list_filter( $field_value, array( 'id' => $option->optionId ) ); $options[] = (object) [ 'name' => $option->optionId, 'label' => $field_value[0]->label, - 'selected' => ! empty($matched_option), + 'selected' => ! empty( $matched_option ), ]; } @@ -590,11 +595,11 @@ protected function format_selected_options_data( $metadata, $field_value ): arra /** * Determines if the field can be appended to. * - * @since 3.0.0 - * - * @param string $field Field to check. + * @param string $field Field to check. * * @return bool Whether field can append. + * @since 3.0.0 + * */ protected function type_can_append( $field ) { $can_append = in_array( $field, $this->append_types, true ); @@ -606,13 +611,13 @@ protected function type_can_append( $field ) { * Check for existence of image/media shortcodes in the GC content, and parse the attributes. * `[media-$number align=left|right|center|none linkto=file|attachment-page size=thumbnail|medium|large|etc]` * - * @since 3.0.0 - * @uses get_shortcode_regex - * - * @param string $content The GC content. - * @param int $args Args for field/image positional argument. + * @param string $content The GC content. + * @param int $args Args for field/image positional argument. * * @return false|array Array of attributes on success. + * @uses get_shortcode_regex + * + * @since 3.0.0 */ public function get_media_shortcode_attributes( $content, $args ) { $args = wp_parse_args( @@ -661,13 +666,13 @@ public function get_media_shortcode_attributes( $content, $args ) { /** * If a GC "shortcode" is found, we'll parse the attributes and retun an image for insertion. * - * @since 3.0.0 - * - * @param array $atts Array of attributes. - * @param int $media_id The GC media object id. - * @param int $attach_id The WP media id. + * @param array $atts Array of attributes. + * @param int $media_id The GC media object id. + * @param int $attach_id The WP media id. * * @return string Image markup, if successful. + * @since 3.0.0 + * */ public function get_requested_media( $atts, $media_id, $attach_id ) { $image = ''; @@ -756,11 +761,11 @@ public function get_requested_media( $atts, $media_id, $attach_id ) { * and converts them to GC shortcodes. This is intended for PUSHING * content to GatherContent. * - * @since 3.0.0 - * - * @param string $content HTML content. + * @param string $content HTML content. * * @return string Updated content. + * @since 3.0.0 + * */ public function convert_media_to_shortcodes( $content ) { $dom = new Dom( $content ); @@ -779,7 +784,7 @@ public function convert_media_to_shortcodes( $content ) { // It's possible GC media shortcodes could be used more than once // Only increase the index if the gcid (gc media id) is unique. if ( ! isset( $ids[ $gcid ] ) ) { - $index++; + $index ++; } // Mark this gc media id. @@ -796,7 +801,10 @@ public function convert_media_to_shortcodes( $content ) { } // If wrapped in a link, need to get that too. - if ( isset( $data['linkto'] ) && in_array( $data['linkto'], array( 'attachment-page', 'file' ), true ) ) { + if ( isset( $data['linkto'] ) && in_array( $data['linkto'], array( + 'attachment-page', + 'file' + ), true ) ) { // @codingStandardsIgnoreStart if ( 'a' === $img->parentNode->tagName ) { $node_to_replace = $dom->saveHTML( $img->parentNode ); @@ -822,7 +830,8 @@ public function convert_media_to_shortcodes( $content ) { * U+200D zero width joiner Unicode code point * U+FEFF zero width no-break space Unicode code point * - * @param string $string The string to clean. + * @param string $string The string to clean. + * * @return string The cleaned up string. */ public static function remove_zero_width( $string ) { @@ -832,7 +841,8 @@ public static function remove_zero_width( $string ) { /** * Magic getter for our object, to make protected properties accessible. * - * @param string $property Protected class property. + * @param string $property Protected class property. + * * @return mixed */ public function __get( $property ) { diff --git a/includes/classes/sync/log.php b/includes/classes/sync/log.php index c10342fb..2232be48 100644 --- a/includes/classes/sync/log.php +++ b/includes/classes/sync/log.php @@ -38,9 +38,9 @@ class Log extends Plugin_Base { /** * Initiate admin hooks * + * @return void * @since 3.0.0 * - * @return void */ public function init_hooks() { add_action( 'gc_sync_items_result', array( $this, 'handle_logging' ), 10, 2 ); @@ -49,12 +49,12 @@ public function init_hooks() { /** * Handles logging sync errors to mapping post-meta. * - * @since 3.0.0 - * - * @param mixed $maybe_error Result of sync. WP_Error on failure. - * @param Base $sync GatherContent\Importer\Sync\Base object. + * @param mixed $maybe_error Result of sync. WP_Error on failure. + * @param Base $sync GatherContent\Importer\Sync\Base object. * * @return void + * @since 3.0.0 + * */ public function handle_logging( $maybe_error, $sync ) { if ( @@ -74,9 +74,9 @@ public function handle_logging( $maybe_error, $sync ) { /** * Log the error to the mapping post meta. * + * @return void * @since 3.0.0 * - * @return void */ public function log_errors() { if ( 0 === strpos( $this->error->get_error_code(), "gc_{$this->sync->direction}_item_fail_" ) ) { @@ -110,11 +110,11 @@ public function log_errors() { /** * Checks if the given WP_Error object matches our existing error object. * - * @since 3.0.0 - * - * @param WP_Error $to_compare WP_Error object. + * @param WP_Error $to_compare WP_Error object. * * @return bool Whether given WP_Error object matches existing error object. + * @since 3.0.0 + * */ public function error_same( $to_compare ) { return ( diff --git a/includes/classes/sync/pull.php b/includes/classes/sync/pull.php index 2f84199b..49c31a95 100644 --- a/includes/classes/sync/pull.php +++ b/includes/classes/sync/pull.php @@ -31,9 +31,10 @@ class Pull extends Base { /** * Creates an instance of this class. * + * @param API $api API object. + * * @since 3.0.0 * - * @param API $api API object. */ public function __construct( API $api ) { parent::__construct( $api, new Async_Pull_Action() ); @@ -42,9 +43,9 @@ public function __construct( API $api ) { /** * Initiate plugins_loaded hooks. * + * @return void * @since 3.0.2 * - * @return void */ public static function init_plugins_loaded_hooks() { add_action( 'gc_associate_hierarchy', array( __CLASS__, 'associate_hierarchy' ) ); @@ -53,9 +54,9 @@ public static function init_plugins_loaded_hooks() { /** * Initiate admin hooks * + * @return void * @since 3.0.0 * - * @return void */ public function init_hooks() { parent::init_hooks(); @@ -67,12 +68,12 @@ public function init_hooks() { /** * A method for trying to pull directly (without async hooks). * - * @since 3.0.0 - * - * @param int $mapping_post Mapping post ID or object. - * @param int $item_id GC item id. + * @param int $mapping_post Mapping post ID or object. + * @param int $item_id GC item id. * * @return mixed Result of pull. WP_Error on failure. + * @since 3.0.0 + * */ public function maybe_pull_item( $mapping_post, $item_id ) { @@ -82,6 +83,7 @@ public function maybe_pull_item( $mapping_post, $item_id ) { } catch ( \Exception $e ) { $result = new WP_Error( 'gc_pull_item_fail_' . $e->getCode(), $e->getMessage(), $e->get_data() ); } + return $result; } @@ -91,6 +93,7 @@ public function maybe_pull_item( $mapping_post, $item_id ) { * @param string $postIdColumn 'post_id' * @param int $post_id 123 * @param string $content 'Some great and cool content' + * * @return bool true on success */ public function saveContentToTable( @@ -99,13 +102,12 @@ public function saveContentToTable( string $postIdColumn, int $post_id, string $content - ) - { + ) { global $wpdb; - $data = [$column => $content]; - $where = [$postIdColumn => $post_id]; - $wpdb->update($table,$data,$where); // false | int + $data = [ $column => $content ]; + $where = [ $postIdColumn => $post_id ]; + $wpdb->update( $table, $data, $where ); // false | int return true; } @@ -114,52 +116,53 @@ public function saveContentToTable( * @TODO restrict what tables / columns can be used. * * @param string $tableColumnString "tableName.columnName" + * * @return false|string[] */ - private function isTableColumnStringValid(string $tableColumnString) - { + private function isTableColumnStringValid( string $tableColumnString ) { global $wpdb; - $parts = explode('.', $tableColumnString); - if(count($parts) !== 2){ + $parts = explode( '.', $tableColumnString ); + if ( count( $parts ) !== 2 ) { return false; } - $table = $parts[0]; + $table = $parts[0]; $column = $parts[1]; - $results = $wpdb->get_results($wpdb->prepare("SHOW COLUMNS FROM %1s;", $table)); + $results = $wpdb->get_results( $wpdb->prepare( "SHOW COLUMNS FROM %1s;", $table ) ); - foreach ($results as $row){ - if($row->Field === $column){ - return [$table, $column]; + foreach ( $results as $row ) { + if ( $row->Field === $column ) { + return [ $table, $column ]; } } return false; } - private function handleDatabaseMappings(array $databaseMappings, int $post_id) - { - foreach ($databaseMappings as $tableAndColumn => $content){ + private function handleDatabaseMappings( array $databaseMappings, int $post_id ) { + foreach ( $databaseMappings as $tableAndColumn => $content ) { - $parts = $this->isTableColumnStringValid($tableAndColumn); - if(!$parts) continue; + $parts = $this->isTableColumnStringValid( $tableAndColumn ); + if ( ! $parts ) { + continue; + } - $table = $parts[0]; + $table = $parts[0]; $column = $parts[1]; $success = $this->saveContentToTable( $table, $column, 'post_id', $post_id, $content ); - if(!$success){ - throw new Exception('Failed to save content to table',500, [ - 'table' => $table, - 'column' => $column, + if ( ! $success ) { + throw new Exception( 'Failed to save content to table', 500, [ + 'table' => $table, + 'column' => $column, 'post_id' => $post_id, 'content' => $content - ]); + ] ); } } } @@ -167,13 +170,13 @@ private function handleDatabaseMappings(array $databaseMappings, int $post_id) /** * Pulls GC item to update a post after some sanitiy checks. * - * @since 3.0.0 - * - * @param int $id GC Item ID. + * @param int $id GC Item ID. * + * @return mixed Result of pull. * @throws Exception On failure. * - * @return mixed Result of pull. + * @since 3.0.0 + * */ protected function do_item( $id ) { $roundTwo = false; @@ -212,7 +215,7 @@ protected function do_item( $id ) { $post_data = (array) $existing; } else { $post_data['ID'] = 0; - $roundTwo = true; + $roundTwo = true; } $post_data = $this->map_gc_data_to_wp_data( $post_data ); @@ -232,7 +235,7 @@ protected function do_item( $id ) { * these are saved into the main wp_posts table */ $databaseMappings = $post_data['database'] ?? []; - unset($post_data['database']); + unset( $post_data['database'] ); $post_id = wp_insert_post( $post_data, 1 ); @@ -253,8 +256,8 @@ protected function do_item( $id ) { ) ); - if(!empty($databaseMappings)){ - $this->handleDatabaseMappings($databaseMappings, $post_id); + if ( ! empty( $databaseMappings ) ) { + $this->handleDatabaseMappings( $databaseMappings, $post_id ); } if ( ! empty( $tax_terms ) ) { @@ -296,7 +299,7 @@ protected function do_item( $id ) { $updated_post_data['meta_input'] = array_map( function ( $meta ) { return is_array( $meta ) && count( $meta ) > 1 - ? wp_json_encode($meta) + ? wp_json_encode( $meta ) : array_shift( $meta ); }, $replacements['meta_input'] @@ -322,7 +325,7 @@ function ( $meta ) { // Hence the need to run it the second time when we have the correct ID. // If we do not do it this way, it is going to look for the post with ID = 0 always to attach the component to and that will be wrong. // We can later look for a beter approach to handle this but this works just fine. - if ($roundTwo == true){ + if ( $roundTwo == true ) { $post_data = $this->set_acf_field_value( $post_data ); } @@ -332,11 +335,11 @@ function ( $meta ) { /** * Maps the GC item config data to WP data. * - * @since 3.0.0 - * - * @param array $post_data The WP Post data array. + * @param array $post_data The WP Post data array. * * @return array Item config array on success. + * @since 3.0.0 + * */ protected function map_gc_data_to_wp_data( $post_data = array() ) { @@ -388,9 +391,9 @@ protected function map_gc_data_to_wp_data( $post_data = array() ) { * * Only if the post title is empty, or there is no post_title field mapped. * + * @return boolean * @since 3.1.8 * - * @return boolean */ public function should_update_title_with_item_name( $post_data ) { $should = ! empty( $this->item->name ); @@ -405,9 +408,9 @@ public function should_update_title_with_item_name( $post_data ) { /** * Check if mapping has a mapping for the post_title. (To fallback to item title) * + * @return boolean * @since 3.1.8 * - * @return boolean */ public function has_post_title_mapping() { try { @@ -426,6 +429,7 @@ function ( $mapped ) { } catch ( \Exception $e ) { return true; } + return false; } @@ -433,11 +437,11 @@ function ( $mapped ) { /** * Loops the GC item content elements and maps the WP post data. * - * @since 3.0.0 - * - * @param array $post_data The WP Post data array. + * @param array $post_data The WP Post data array. * * @return array Modified post data array on success. + * @since 3.0.0 + * */ protected function loop_item_elements_and_map( $post_data ) { @@ -463,24 +467,24 @@ protected function loop_item_elements_and_map( $post_data ) { $component_uuid = 'component' === $field->field_type ? $field->uuid : ''; $is_component_repeatable = false; - if($component_uuid) { - $metadata = $field->metadata; + if ( $component_uuid ) { + $metadata = $field->metadata; $is_component_repeatable = ( is_object( $metadata ) && isset( $metadata->repeatable ) ) ? $metadata->repeatable->isRepeatable : false; } $componentProcessed = false; // Initialize flag outside the loop - foreach ($fields_data as $field_data) { - $this->element = (object) $this->format_element_data($field_data, $component_uuid, true, $is_component_repeatable); - $uuid = $this->element->name; + foreach ( $fields_data as $field_data ) { + $this->element = (object) $this->format_element_data( $field_data, $component_uuid, true, $is_component_repeatable ); + $uuid = $this->element->name; // Check if "_component_" exists in the string and if it has not been processed yet - if (strpos($uuid, "_component_") !== false && !$componentProcessed) { + if ( strpos( $uuid, "_component_" ) !== false && ! $componentProcessed ) { // Split the string by "_component_" - $parts = explode("_component_", $uuid); + $parts = explode( "_component_", $uuid ); // Get the last part - $uuid = end($parts); + $uuid = end( $parts ); // Concatenate the last part with the prefix "_component_" $uuid = $uuid . "_component_" . $uuid; @@ -490,10 +494,10 @@ protected function loop_item_elements_and_map( $post_data ) { } // Further processing with the UUID - $destination = $this->mapping->data($uuid); - if ($destination && isset($destination['type'], $destination['value'])) { - $columns[$destination['value']] = true; - $post_data = $this->set_post_values($destination, $post_data); + $destination = $this->mapping->data( $uuid ); + if ( $destination && isset( $destination['type'], $destination['value'] ) ) { + $columns[ $destination['value'] ] = true; + $post_data = $this->set_post_values( $destination, $post_data ); } } @@ -514,12 +518,12 @@ protected function loop_item_elements_and_map( $post_data ) { /** * Sets the post data value, for each data type. * - * @since 3.0.0 - * - * @param array $destination Destination array, includes type and value. - * @param array $post_data The WP Post data array. + * @param array $destination Destination array, includes type and value. + * @param array $post_data The WP Post data array. * * @return array $post_data The modified WP Post data array. + * @since 3.0.0 + * */ protected function set_post_values( $destination, $post_data ) { @@ -552,9 +556,10 @@ protected function set_post_values( $destination, $post_data ) { break; } // @codingStandardsIgnoreStart - } catch (\Exception $e) { + } catch ( \Exception $e ) { // @todo logging? } + // @codingStandardsIgnoreEnd return $post_data; @@ -563,12 +568,12 @@ protected function set_post_values( $destination, $post_data ) { /** * Sets the WP post fields based on the item config. * - * @since 3.0.0 - * - * @param string $post_column The post data column. - * @param array $post_data The WP Post data array. + * @param string $post_column The post data column. + * @param array $post_data The WP Post data array. * * @return array $post_data The modified WP Post data array. + * @since 3.0.0 + * */ protected function set_post_field_value( $post_column, $post_data ) { @@ -584,12 +589,12 @@ protected function set_post_field_value( $post_column, $post_data ) { /** * Sets the WP taxonomy terms based on the item config. * - * @since 3.0.0 - * - * @param string $taxonomy The taxonomy name. - * @param array $post_data The WP Post data array. + * @param string $taxonomy The taxonomy name. + * @param array $post_data The WP Post data array. * * @return array $post_data The modified WP Post data array. + * @since 3.0.0 + * */ protected function set_taxonomy_field_value( $taxonomy, $post_data ) { $terms = $this->get_element_terms( $taxonomy ); @@ -601,18 +606,19 @@ protected function set_taxonomy_field_value( $taxonomy, $post_data ) { $post_data['tax_input'][ $taxonomy ] = $terms; } } + return $post_data; } /** * Sets the WP meta data based on the item config. * - * @since 3.0.0 - * - * @param string $meta_key The meta key. - * @param array $post_data The WP Post data array. + * @param string $meta_key The meta key. + * @param array $post_data The WP Post data array. * * @return array $post_data The modified WP Post data array. + * @since 3.0.0 + * */ protected function set_meta_field_value( $meta_key, $post_data ) { $value = $this->sanitize_element_meta(); @@ -629,8 +635,7 @@ protected function set_meta_field_value( $meta_key, $post_data ) { return $post_data; } - protected function set_database_field_value($destination, $post_data) - { + protected function set_database_field_value( $destination, $post_data ) { /** * Update the post_data array to contain a 'database' array where each * key is the `table.column` and the value is the content @@ -639,7 +644,7 @@ protected function set_database_field_value($destination, $post_data) * ...] */ - $post_data[ 'database' ][$destination] = $this->element->value; + $post_data['database'][ $destination ] = $this->element->value; return $post_data; } @@ -647,26 +652,26 @@ protected function set_database_field_value($destination, $post_data) /** * Sets the WP media destination. * - * @since 3.0.0 - * - * @param string $destination The media destination. - * @param array $post_data The WP Post data array. + * @param string $destination The media destination. + * @param array $post_data The WP Post data array. * * @return array $post_data The modified WP Post data array. + * @since 3.0.0 + * */ protected function set_media_field_value( $destination, $post_data ) { static $field_number = 0; - $media_items = $this->sanitize_element_media(); + $media_items = $this->sanitize_element_media(); if ( in_array( $destination, array( 'gallery', 'content_image', 'excerpt_image' ), true ) && is_array( $media_items ) ) { - $field_number++; + $field_number ++; $position = 0; foreach ( $media_items as $index => $media ) { - $media_items[ $index ]->position = ++$position; + $media_items[ $index ]->position = ++ $position; $media_items[ $index ]->field_number = $field_number; $token = '#_gc_media_id_' . $media->id . '#'; @@ -680,21 +685,22 @@ protected function set_media_field_value( $destination, $post_data ) { 'destination' => $destination, 'media' => $media_items, ); + return $post_data; } /** - * Sets the ACF field value in the post data. - * - * @since 3.0.0 - * - * @param string $group_key The ACF group key. - * @param string $field_key The ACF field key. - * @param array $post_data The WP Post data array. - * - * @return array $post_data The modified WP Post data array. - */ + * Sets the ACF field value in the post data. + * + * @param string $group_key The ACF group key. + * @param string $field_key The ACF field key. + * @param array $post_data The WP Post data array. + * + * @return array $post_data The modified WP Post data array. + * @since 3.0.0 + * + */ protected function set_acf_field_value( $post_data ) { // We are not sure of the incoming post_ID so let's get the current post ID @@ -704,36 +710,36 @@ protected function set_acf_field_value( $post_data ) { $updated_post_data = $post_data; // Loop through the mapping data array - foreach ($this->mapping->data as $key => $value) { + foreach ( $this->mapping->data as $key => $value ) { // When it is a component, the key sandwiches '_component_' so let's get the key itself - $content_key = explode('_component_', $key)[0]; + $content_key = explode( '_component_', $key )[0]; // Check if the item has type wp-type-acf. We are assuming some items managed to skip the case check in the set_post_values function so we double check here. - if (isset($value['type']) && $value['type'] === 'wp-type-acf') { + if ( isset( $value['type'] ) && $value['type'] === 'wp-type-acf' ) { // Fetch the corresponding value from $this->item->content - $field_value = isset($this->item->content->{$content_key}) ? $this->item->content->{$content_key} : ''; + $field_value = isset( $this->item->content->{$content_key} ) ? $this->item->content->{$content_key} : ''; // Check if item has subfields. If it has then it is a component from GC - if (isset($value['sub_fields'])) { + if ( isset( $value['sub_fields'] ) ) { // Prepare the subfield data $subfield_keys = array(); - foreach ($value['sub_fields'] as $sub_field_key) { - array_push($subfield_keys, $sub_field_key); + foreach ( $value['sub_fields'] as $sub_field_key ) { + array_push( $subfield_keys, $sub_field_key ); } // Let's ensure the repeater field is empty before adding rows - delete_field($value['field'], $post_id); + delete_field( $value['field'], $post_id ); // Let ACF add fields before rows. This order does some wonders and we need to revisit it. // update_field($value['field'], $component_row_data, $post_id); $row_index = 0; - foreach ($field_value as $subfield){ + foreach ( $field_value as $subfield ) { $row_index ++; - if (!is_object($subfield)) { + if ( ! is_object( $subfield ) ) { // When components are not set to be repeatable in GC we may end up getting non objects subfields. // Non objects like strings will fail for get_object_vars which expects objects // In such a situation the page breaks since the upload import can't be completed @@ -742,52 +748,52 @@ protected function set_acf_field_value( $post_data ) { continue; } // Check if the number of elements in $keys and $values match - if (count($subfield_keys) === count(get_object_vars($subfield))) { + if ( count( $subfield_keys ) === count( get_object_vars( $subfield ) ) ) { // Combine the arrays if the counts match - $component_row_data = array_combine($subfield_keys, get_object_vars($subfield)); + $component_row_data = array_combine( $subfield_keys, get_object_vars( $subfield ) ); } else { // error_log("Number of keys and values don't match for array_combine()"); // Skip the current iteration if component_row_data is not available continue; } // Convert object to associative array - $component_row_data = json_decode(json_encode($component_row_data), true); - add_row($value['field'], $component_row_data, $post_id); + $component_row_data = json_decode( json_encode( $component_row_data ), true ); + add_row( $value['field'], $component_row_data, $post_id ); - $subfield_key_id = -1; + $subfield_key_id = - 1; - foreach ($subfield as $key => $subsubfield){ + foreach ( $subfield as $key => $subsubfield ) { $subfield_key_id ++; - $item_key = $subfield_keys[$subfield_key_id]; - $item = get_field_object($item_key); + $item_key = $subfield_keys[ $subfield_key_id ]; + $item = get_field_object( $item_key ); - if (is_array($subsubfield)){ + if ( is_array( $subsubfield ) ) { - if ($item['parent']){ + if ( $item['parent'] ) { $parent_key = $item['parent']; } - if($item['sub_fields']){ + if ( $item['sub_fields'] ) { $children = array(); - foreach ($item['sub_fields'] as $child){ - array_push($children, $child['key']); + foreach ( $item['sub_fields'] as $child ) { + array_push( $children, $child['key'] ); } } - if ($item['type'] && ($item['type'] === 'checkbox')){ + if ( $item['type'] && ( $item['type'] === 'checkbox' ) ) { $checkbox_labels = []; // Extract labels from each stdClass object and add them to the $labels array for checkboxes - foreach ($subsubfield as $checkbox) { + foreach ( $subsubfield as $checkbox ) { $checkbox_labels[] = $checkbox->label; } } - foreach ($subsubfield as $subsubfield_field){ + foreach ( $subsubfield as $subsubfield_field ) { - if ($item['type'] == 'image'){ + if ( $item['type'] == 'image' ) { $upload_dir = wp_upload_dir(); - $image_url = $subsubfield_field->url; + $image_url = $subsubfield_field->url; $image_data = file_get_contents( $image_url ); - $filename = $subsubfield_field->filename; + $filename = $subsubfield_field->filename; // Check if the attachment already exists global $wpdb; @@ -812,46 +818,50 @@ protected function set_acf_field_value( $post_data ) { $attachment = array( 'post_mime_type' => $wp_filetype['type'], - 'post_title' => sanitize_file_name( $filename ), - 'post_content' => '', - 'post_status' => 'inherit' + 'post_title' => sanitize_file_name( $filename ), + 'post_content' => '', + 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment, $file ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); // Check if the attachment insertion was successful - if (!is_wp_error($attach_id)) { + if ( ! is_wp_error( $attach_id ) ) { // Generate attachment metadata - $attach_data = wp_generate_attachment_metadata($attach_id, $file); + $attach_data = wp_generate_attachment_metadata( $attach_id, $file ); // Update attachment metadata - wp_update_attachment_metadata($attach_id, $attach_data); + wp_update_attachment_metadata( $attach_id, $attach_data ); } else { // Log an error or handle the case where attachment insertion fails } } - update_row($parent_key, $row_index, [$item_key => $attach_id],$post_id); + update_row( $parent_key, $row_index, [ $item_key => $attach_id ], $post_id ); // Break out of the loop after processing the first image - break; + break; } - if ($item['type'] === 'repeater'){ - foreach ($children as $child_key){ + if ( $item['type'] === 'repeater' ) { + foreach ( $children as $child_key ) { // add_sub_row(['parent repeater', index, 'child repeater'], ['field_name' => $data], $post_id); - add_sub_row([$parent_key, $row_index, $item_key], [$child_key => $subsubfield_field], $post_id); + add_sub_row( [ + $parent_key, + $row_index, + $item_key + ], [ $child_key => $subsubfield_field ], $post_id ); } } - if ($item['type'] === 'checkbox'){ - update_row($parent_key, $row_index, [$item_key => $checkbox_labels],$post_id); + if ( $item['type'] === 'checkbox' ) { + update_row( $parent_key, $row_index, [ $item_key => $checkbox_labels ], $post_id ); } - if ($item['type'] === 'radio'){ - update_row($parent_key, $row_index, [$item_key => $subsubfield_field->label],$post_id); + if ( $item['type'] === 'radio' ) { + update_row( $parent_key, $row_index, [ $item_key => $subsubfield_field->label ], $post_id ); } @@ -861,32 +871,32 @@ protected function set_acf_field_value( $post_data ) { } - $updated_post_data = $this->maybe_append($value['field'], $field_value, $updated_post_data); + $updated_post_data = $this->maybe_append( $value['field'], $field_value, $updated_post_data ); - }else { + } else { // If it's not a component, update the single ACF field normally - $field_data = array(); + $field_data = array(); $fields_data = array(); - if (is_array($field_value)) { - foreach ($field_value as $row_data) { - if (! is_object($row_data)){ - array_push($field_data, $row_data); + if ( is_array( $field_value ) ) { + foreach ( $field_value as $row_data ) { + if ( ! is_object( $row_data ) ) { + array_push( $field_data, $row_data ); } } - array_push($fields_data, $field_data); + array_push( $fields_data, $field_data ); } $field_key = $value['field']; // Get information about the field - $field = get_field_object($field_key); + $field = get_field_object( $field_key ); // Let's hope the field exists and is really not a component - if ($field) { - if (!empty($field['sub_fields'])) { + if ( $field ) { + if ( ! empty( $field['sub_fields'] ) ) { $subsubfield_keys = array(); - foreach ($field['sub_fields'] as $sub_field) { - array_push($subsubfield_keys, $sub_field['key']); + foreach ( $field['sub_fields'] as $sub_field ) { + array_push( $subsubfield_keys, $sub_field['key'] ); } } else { // Field does not have subfields. We can possibly add some error handling @@ -899,18 +909,18 @@ protected function set_acf_field_value( $post_data ) { // This might be a secondary case to look at, so we are keeping things in arrays so we can later just improve on it to handle those wild cases. $key_value_mapping = []; - foreach ($fields_data[0] as $value) { + foreach ( $fields_data[0] as $value ) { // Assign each value to a sub-array with the key from subsubfield_keys - $key_value_mapping[] = [$subsubfield_keys[0] => $value]; + $key_value_mapping[] = [ $subsubfield_keys[0] => $value ]; } - foreach ($key_value_mapping as $key_value){ - add_row($field_key, $key_value, $post_id); + foreach ( $key_value_mapping as $key_value ) { + add_row( $field_key, $key_value, $post_id ); } - update_field($field_key, $key_value_mapping, $post_id); + update_field( $field_key, $key_value_mapping, $post_id ); // lets do updated_post_data in a way that will work - $updated_post_data = $this->maybe_append($field_key, $key_value_mapping, $updated_post_data); + $updated_post_data = $this->maybe_append( $field_key, $key_value_mapping, $updated_post_data ); } @@ -926,13 +936,13 @@ protected function set_acf_field_value( $post_data ) { /** * If field can append, then append the data, else set the data directly. * - * @since 3.0.0 - * - * @param string $field The field to set. - * @param mixed $value The value for the field. - * @param array $array The array to check against. + * @param string $field The field to set. + * @param mixed $value The value for the field. + * @param array $array The array to check against. * * @return array The modified array. + * @since 3.0.0 + * */ protected function maybe_append( $field, $value, $array ) { if ( $this->type_can_append( $field ) ) { @@ -951,16 +961,16 @@ protected function maybe_append( $field, $value, $array ) { /** * Specific sanitization for WP post column fields. * - * @since 3.0.0 - * - * @param string $field The post field to sanitize. - * @param mixed $value The post field value to sanitize. - * @param array $post_data The WP Post data array. + * @param string $field The post field to sanitize. + * @param mixed $value The post field value to sanitize. + * @param array $post_data The WP Post data array. * + * @return mixed The sanitized post field value. * @throws Exception Will fail if the wrong kind of GC field is * attempting to be sanitized. * - * @return mixed The sanitized post field value. + * @since 3.0.0 + * */ protected function sanitize_post_field( $field, $value, $post_data ) { if ( ! $value ) { @@ -998,24 +1008,24 @@ protected function sanitize_post_field( $field, $value, $post_data ) { /** * Gets the terms from the current item element object. * - * @since 3.0.0 - * - * @param string $taxonomy The taxonomy to determine data storage method. + * @param string $taxonomy The taxonomy to determine data storage method. * * @return mixed The terms. + * @since 3.0.0 + * */ protected function get_element_terms( $taxonomy ) { if ( 'text' === $this->element->type ) { $terms = array_map( 'trim', explode( ',', sanitize_text_field( $this->element->value ) ) ); } elseif ( 'choice_checkbox' === $this->element->type ) { - $terms = (array) (is_string($this->element->value) ? json_decode($this->element->value) : $this->element->value); + $terms = (array) ( is_string( $this->element->value ) ? json_decode( $this->element->value ) : $this->element->value ); } else { $terms = (array) $this->element->value; } if ( ! empty( $terms ) && is_taxonomy_hierarchical( $taxonomy ) ) { foreach ( $terms as $key => $term ) { // @codingStandardsIgnoreStart - if (!$term_info = term_exists($term, $taxonomy)) { + if ( ! $term_info = term_exists( $term, $taxonomy ) ) { // @codingStandardsIgnoreEnd // Skip if a non-existent term ID is passed. if ( is_int( $term ) ) { @@ -1038,9 +1048,9 @@ protected function get_element_terms( $taxonomy ) { * Specific sanitization for the element value when stored as post-meta. * Currently only filtered. * + * @return mixed Value for meta. * @since 3.0.0 * - * @return mixed Value for meta. */ protected function sanitize_element_meta() { return apply_filters( 'gc_sanitize_meta_field', $this->element->value, $this->element, $this->item ); @@ -1054,9 +1064,9 @@ protected function sanitize_element_meta() { * Specific sanitization for the element media. * Currently only filtered. * + * @return mixed Value for media. * @since 3.0.0 * - * @return mixed Value for media. */ protected function sanitize_element_media() { return apply_filters( 'gc_sanitize_media_field', $this->element->value, $this->element, $this->item ); @@ -1067,12 +1077,12 @@ protected function sanitize_element_media() { * then we send the attachments to the requested location. * (post content, excerpt post-meta, gallery, etc) * - * @since 3.0.0 - * - * @param array $attachments Array of attachments to sideload/attach/relocate. - * @param array $post_data The WP Post data array. + * @param array $attachments Array of attachments to sideload/attach/relocate. + * @param array $post_data The WP Post data array. * * @return array Array of replacement key/values for strtr. + * @since 3.0.0 + * */ protected function sideload_attachments( $attachments, $post_data ) { @@ -1100,7 +1110,10 @@ protected function sideload_attachments( $attachments, $post_data ) { if ( 'featured_image' === $attachment['destination'] ) { $featured_img_id = $attach_id; break; - } elseif ( in_array( $attachment['destination'], array( 'content_image', 'excerpt_image' ), true ) ) { + } elseif ( in_array( $attachment['destination'], array( + 'content_image', + 'excerpt_image' + ), true ) ) { $field = 'excerpt_image' === $attachment['destination'] ? 'post_excerpt' : 'post_content'; $atts = array( @@ -1220,12 +1233,12 @@ protected function sideload_attachments( $attachments, $post_data ) { * * Logic is based on whether media already exists and if it has been updated. * - * @since 3.0.0 - * - * @param object $media The GC media object. - * @param int $post_id The post ID. + * @param object $media The GC media object. + * @param int $post_id The post ID. * * @return int The sideloaded attachment ID. + * @since 3.0.0 + * */ protected function maybe_sideload_file( $media, $post_id ) { $attachment = \GatherContent\Importer\get_post_by_item_id( $media->id, array( 'post_status' => 'inherit' ) ); @@ -1258,19 +1271,20 @@ protected function maybe_sideload_file( $media, $post_id ) { /** * Downloads an image from the specified URL and attaches it to a post. * - * @param string $file_name The Name of the image file. - * @param string $download_url The download URL of the image. - * @param int $post_id The post ID the media is to be associated with. + * @param string $file_name The Name of the image file. + * @param string $download_url The download URL of the image. + * @param int $post_id The post ID the media is to be associated with. * @param string|null $alt_text Optional alt text to add to the image. + * * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise. */ protected function sideload_file( $file_name, $download_url, $post_id, $alt_text = '' ) { if ( ! empty( $download_url ) ) { - $file_array = $this->tmp_file( $file_name, $download_url ); - $file_array['type'] = mime_content_type($file_array['tmp_name']); - $extension = '.' . (new MimeTypes())->getExtension($file_array['type']); - $hasExtension = substr($file_array['name'], 0 - strlen($extension)) === $extension; - if (!$hasExtension) { + $file_array = $this->tmp_file( $file_name, $download_url ); + $file_array['type'] = mime_content_type( $file_array['tmp_name'] ); + $extension = '.' . ( new MimeTypes() )->getExtension( $file_array['type'] ); + $hasExtension = substr( $file_array['name'], 0 - strlen( $extension ) ) === $extension; + if ( ! $hasExtension ) { $file_array['name'] = $file_array['name'] . $extension; } @@ -1284,7 +1298,8 @@ protected function sideload_file( $file_name, $download_url, $post_id, $alt_text // If error storing permanently, unlink. if ( is_wp_error( $id ) ) { // @codingStandardsIgnoreStart - @unlink($file_array['tmp_name']); + @unlink( $file_array['tmp_name'] ); + // @codingStandardsIgnoreEnd return $id; } @@ -1300,16 +1315,16 @@ protected function sideload_file( $file_name, $download_url, $post_id, $alt_text /** * Handles re-sideloading attachment and replacing existing. * - * @since 3.0.0 - * - * @param string $file_name The file name. - * @param string $download_url The download url. - * @param object $attachment The attachment post object. - * @param bool $replace_data Whether to replace attachement title/content. + * @param string $file_name The file name. + * @param string $download_url The download url. + * @param object $attachment The attachment post object. + * @param bool $replace_data Whether to replace attachement title/content. * Default false. * @param string|null $alt_text Optional alt text to add to the image. * * @return int The sideloaded attachment ID. + * @since 3.0.0 + * */ protected function sideload_and_update_attachment( $file_name, $download_url, $attachment, $replace_data = false, $alt_text = '' ) { if ( ! isset( $attachment->ID ) || empty( $download_url ) ) { @@ -1318,7 +1333,7 @@ protected function sideload_and_update_attachment( $file_name, $download_url, $a // @codingStandardsIgnoreStart // 5 minutes per image should be PLENTY. - @set_time_limit(900); + @set_time_limit( 900 ); // @codingStandardsIgnoreEnd $time = substr( $attachment->post_date, 0, 4 ) > 0 @@ -1344,7 +1359,7 @@ protected function sideload_and_update_attachment( $file_name, $download_url, $a // Use image exif/iptc data for title and caption defaults if possible. // @codingStandardsIgnoreStart - if ($image_meta = @wp_read_image_metadata($_file)) { + if ( $image_meta = @wp_read_image_metadata( $_file ) ) { // @codingStandardsIgnoreEnd if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { $title = $image_meta['title']; @@ -1364,7 +1379,7 @@ protected function sideload_and_update_attachment( $file_name, $download_url, $a if ( is_wp_error( $id ) ) { // If error storing permanently, unlink. // @codingStandardsIgnoreStart - @unlink($file_array['tmp_name']); + @unlink( $file_array['tmp_name'] ); // @codingStandardsIgnoreEnd } else { update_post_meta( $id, '_wp_attachment_image_alt', $alt_text ); @@ -1377,12 +1392,12 @@ protected function sideload_and_update_attachment( $file_name, $download_url, $a /** * Download and create a temporary file. * - * @since 3.0.0 - * - * @param string $file_name The name of the file being downloaded. - * @param string $download_url The download URL of the file. + * @param string $file_name The name of the file being downloaded. + * @param string $download_url The download URL of the file. * * @return array The temporary file array. + * @since 3.0.0 + * */ protected function tmp_file( $file_name, $download_url ) { @@ -1410,11 +1425,11 @@ protected function tmp_file( $file_name, $download_url ) { /** * Checks an attachment's mime type to determine if it is an image. * - * @since 3.1.2 - * - * @param int $attach_id The attachement ID. + * @param int $attach_id The attachement ID. * * @return bool + * @since 3.1.2 + * */ public static function attachment_is_image( $attach_id ) { return preg_match( '~(jpe?g|jpe|gif|png|svg)\b~', get_post_mime_type( $attach_id ) ); @@ -1423,11 +1438,11 @@ public static function attachment_is_image( $attach_id ) { /** * wp_update_post wrapper that prevents a post revision. * - * @since 3.0.2 - * - * @param array $post_data Array of post data. + * @param array $post_data Array of post data. * * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success. + * @since 3.0.2 + * */ protected static function post_update_no_revision( $post_data ) { // Update post (but don't create a revision for it). @@ -1443,11 +1458,11 @@ protected static function post_update_no_revision( $post_data ) { * Defaults to `is_post_type_hierarchical` check. * Can be overridden with 'gc_map_hierarchy' filter. * - * @since 3.0.2 - * - * @param string $post_type Post type to check if `is_post_type_hierarchical` + * @param string $post_type Post type to check if `is_post_type_hierarchical` * * @return bool Whether post type supports hierarchy. + * @since 3.0.2 + * */ public function should_map_hierarchy( $post_type ) { return apply_filters( 'gc_map_hierarchy', is_post_type_hierarchical( $post_type ), $post_type, $this ); @@ -1456,11 +1471,11 @@ public function should_map_hierarchy( $post_type ) { /** * Add/create list of post/parent item ids to set WP hierarchy later. * - * @since 3.0.2 - * - * @param int $post_id WordPress post id to eventually update. + * @param int $post_id WordPress post id to eventually update. * * @return void + * @since 3.0.2 + * */ public function schedule_hierarchy_update( $post_id ) { @@ -1495,11 +1510,11 @@ public function schedule_hierarchy_update( $post_id ) { * Hooked into cron event, loops through list of pending hierarchies for given mapping, * and attempts to set the parent post id based on the parent GC item. * - * @since 3.0.2 - * - * @param int $mapping Mapping object or ID. + * @param int $mapping Mapping object or ID. * * @return void + * @since 3.0.2 + * */ public static function associate_hierarchy( $mapping ) { $mapping = Mapping_Post::get( $mapping, true ); diff --git a/includes/classes/sync/push.php b/includes/classes/sync/push.php index f3a33e31..ea6df150 100644 --- a/includes/classes/sync/push.php +++ b/includes/classes/sync/push.php @@ -46,7 +46,7 @@ class Push extends Base { * * @var string */ - protected $config = array(); + protected $config = array(); protected $item_config = array(); private $item_id = null; @@ -54,9 +54,10 @@ class Push extends Base { /** * Creates an instance of this class. * + * @param API $api API object. + * * @since 3.0.0 * - * @param API $api API object. */ public function __construct( API $api ) { parent::__construct( $api, new Async_Push_Action() ); @@ -65,9 +66,9 @@ public function __construct( API $api ) { /** * Initiate admin hooks * + * @return void * @since 3.0.0 * - * @return void */ public function init_hooks() { parent::init_hooks(); @@ -78,11 +79,11 @@ public function init_hooks() { /** * A method for trying to push directly (without async hooks). * - * @since 3.0.0 - * - * @param int $mapping_post_id Mapping post ID. + * @param int $mapping_post_id Mapping post ID. * * @return mixed Result of push. WP_Error on failure. + * @since 3.0.0 + * */ public function maybe_push_item( $mapping_post_id ) { try { @@ -104,13 +105,13 @@ public function maybe_push_item( $mapping_post_id ) { /** * Pushes WP post to GC after some sanitiy checks. * - * @since 3.0.0 - * - * @param int $id WP post ID. + * @param int $id WP post ID. * + * @return mixed Result of push. * @throws Exception On failure. * - * @return mixed Result of push. + * @since 3.0.0 + * */ protected function do_item( $id ) { @@ -143,13 +144,13 @@ protected function do_item( $id ) { /** * Pushes WP post to GC. * - * @since 3.0.0 - * - * @param array $update The item config update delta array. + * @param array $update The item config update delta array. * + * @return mixed Result of push. * @throws Exception On failure. * - * @return mixed Result of push. + * @since 3.0.0 + * */ public function maybe_do_item_update( $update ) { // Get our initial croonfig reference. @@ -163,8 +164,8 @@ public function maybe_do_item_update( $update ) { if ( $updated_element->repeatable ) { // $repeatable_value = ! empty( $updated_element->value ) ? @json_decode( $updated_element->value, true ) : $updated_element->value; - if (is_string($updated_element->value)) { - $repeatable_value = !empty( $updated_element->value ) ? json_decode( $updated_element->value, true) : $updated_element->value; + if ( is_string( $updated_element->value ) ) { + $repeatable_value = ! empty( $updated_element->value ) ? json_decode( $updated_element->value, true ) : $updated_element->value; } else { // Handle the case where $updated_element->value is already an array $repeatable_value = $updated_element->value; @@ -188,14 +189,14 @@ public function maybe_do_item_update( $update ) { $config->content->$component_uuid = (object) array(); } - if (is_array($config->content->$component_uuid)) { - if (is_array($updated_element->value)) { + if ( is_array( $config->content->$component_uuid ) ) { + if ( is_array( $updated_element->value ) ) { // Directly use the array $decoded_value = $updated_element->value; } else { // Decode JSON string - $decoded_value = json_decode($updated_element->value); - if ($decoded_value === null && json_last_error() !== JSON_ERROR_NONE) { + $decoded_value = json_decode( $updated_element->value ); + if ( $decoded_value === null && json_last_error() !== JSON_ERROR_NONE ) { // JSON decoding failed, handle the error // For example, you can log the error or take appropriate action // Here, we are setting an empty array @@ -205,13 +206,13 @@ public function maybe_do_item_update( $update ) { // Handle repeatable components $i = 0; - foreach ($decoded_value as $value) { - if (isset($config->content->$component_uuid[$i])) { - $config->content->$component_uuid[$i]->$element_id = $value; + foreach ( $decoded_value as $value ) { + if ( isset( $config->content->$component_uuid[ $i ] ) ) { + $config->content->$component_uuid[ $i ]->$element_id = $value; } - $i++; + $i ++; } - }else { + } else { $config->content->$component_uuid->$element_id = $updated_element->value; } @@ -253,7 +254,7 @@ public function maybe_do_item_update( $update ) { ); } - if ($result === false) { + if ( $result === false ) { wp_send_json_error( 'Failed to push content to Content Workflow' ); } @@ -263,14 +264,14 @@ public function maybe_do_item_update( $update ) { /** * Sets the item to be pushed to. If it doesn't exist yet, we create it now. * - * @since 3.0.0 - * * @param integer $item_id Item id. - * @param bool $exclude_status set this to true to avoid appending status data + * @param bool $exclude_status set this to true to avoid appending status data * + * @return $item * @throws Exception On failure. * - * @return $item + * @since 3.0.0 + * */ protected function set_item( $item_id, $exclude_status = false ) { $this->item_id = $item_id; @@ -292,9 +293,9 @@ protected function set_item( $item_id, $exclude_status = false ) { /** * Maps the WP post data to the GC item config. * + * @return array Item config array on success. * @since 3.0.0 * - * @return array Item config array on success. */ protected function map_wp_data_to_gc_data() { $config = $this->loop_item_elements_and_map(); @@ -305,9 +306,9 @@ protected function map_wp_data_to_gc_data() { /** * Loops the GC item config elements and maps the WP post data. * + * @return array Modified item config array on success. * @since 3.0.0 * - * @return array Modified item config array on success. */ public function loop_item_elements_and_map() { if ( empty( $this->item_config ) ) { @@ -336,8 +337,8 @@ public function loop_item_elements_and_map() { $component_uuid = 'component' === $field->field_type ? $field->uuid : ''; $is_component_repeatable = false; - if($component_uuid) { - $metadata = $field->metadata; + if ( $component_uuid ) { + $metadata = $field->metadata; $is_component_repeatable = ( is_object( $metadata ) && isset( $metadata->repeatable ) ) ? $metadata->repeatable->isRepeatable : false; } @@ -352,19 +353,19 @@ public function loop_item_elements_and_map() { $uuid = $this->element->name; if ( $component_uuid ) { $this->element->component_uuid = $component_uuid; - $uuid = $component_uuid . '_component_' . $component_uuid; + $uuid = $component_uuid . '_component_' . $component_uuid; } $source = $this->mapping->data( $uuid ); $source_type = isset( $source['type'] ) ? $source['type'] : ''; // Check if $source['field'] exists, then use it as the key - if (isset($source['field'])) { + if ( isset( $source['field'] ) ) { // not sure if the field can be empty, will need to check that later on $source_key = $source['field']; } else { // If $source['field'] doesn't exist, fall back to using $source['value'] - $source_key = isset($source['value']) ? $source['value'] : ''; + $source_key = isset( $source['value'] ) ? $source['value'] : ''; } @@ -400,11 +401,11 @@ public function loop_item_elements_and_map() { /** * Loops the $done array and looks for duplicates (unknowns) and removes them. * - * @todo Fix this. Probably need a reverse mapping UI for each item push, or something. - * + * @return void * @since 3.0.0 * - * @return void + * @todo Fix this. Probably need a reverse mapping UI for each item push, or something. + * */ protected function remove_unknowns() { foreach ( $this->done as $source_type => $keys ) { @@ -440,12 +441,12 @@ protected function remove_unknowns() { /** * Sets the item config element value, if it is determeined that the value changed. * - * @since 3.0.0 - * * @param string $source_type The data source type. - * @param string $source_key The data source key. + * @param string $source_key The data source key. * * @return array $updated Whether value was updated. + * @since 3.0.0 + * */ protected function set_values_from_wp( $source_type, $source_key ) { $updated = false; @@ -483,11 +484,11 @@ protected function set_values_from_wp( $source_type, $source_key ) { /** * Updates the featured image alt_text if changed * - * @since 3.2.0 - * * @param string $source_key source key. * * @return void + * @since 3.2.0 + * */ protected function set_featured_image_alt( $source_key ) { @@ -541,11 +542,11 @@ protected function set_featured_image_alt( $source_key ) { * Sets the item config element value for WP post fields, * if it is determeined that the value changed. * - * @since 3.0.0 - * * @param string $post_column The post data column. * * @return bool $updated Whether value was updated. + * @since 3.0.0 + * */ protected function set_post_field_value( $post_column ) { $updated = false; @@ -564,7 +565,7 @@ protected function set_post_field_value( $post_column ) { $el_value = wp_kses_post( $this->get_element_value() ); if ( 'post_content' === $post_column ) { $value = $this->ensureShortcodesAreNotConvertedToHtml( - function ($value) { + function ( $value ) { return apply_filters( 'the_content', $value ); }, $value @@ -593,17 +594,17 @@ protected function set_database_field_value( $tableColumnString ) { $updated = false; $el_value = $this->element->value; - $parts = explode('.', $tableColumnString); - if(count($parts) !== 2){ + $parts = explode( '.', $tableColumnString ); + if ( count( $parts ) !== 2 ) { return false; } - $table = $parts[0]; + $table = $parts[0]; $column = $parts[1]; global $wpdb; - $results = $wpdb->get_results($wpdb->prepare("SELECT %i as value from %i where post_id=%d;", $column, $table, $this->post->ID)); + $results = $wpdb->get_results( $wpdb->prepare( "SELECT %i as value from %i where post_id=%d;", $column, $table, $this->post->ID ) ); $value = $results[0]->value; // @codingStandardsIgnoreStart @@ -615,25 +616,24 @@ protected function set_database_field_value( $tableColumnString ) { } return $updated; - } - - private function ensureShortcodesAreNotConvertedToHtml(callable $callback, string $value): string - { + } + + private function ensureShortcodesAreNotConvertedToHtml( callable $callback, string $value ): string { preg_match_all( '/\[[\w\W]+?\]/', $value, $matches ); - foreach ($matches[0] as $match) { + foreach ( $matches[0] as $match ) { $value = str_replace( $match, - '' . base64_encode($match) . '', + '' . base64_encode( $match ) . '', $value ); } - $value = $callback($value); + $value = $callback( $value ); preg_match_all( '/([\w\W])+?<\/shortcode>/', @@ -641,10 +641,10 @@ private function ensureShortcodesAreNotConvertedToHtml(callable $callback, strin $matches ); - foreach ($matches[0] as $match) { + foreach ( $matches[0] as $match ) { $value = str_replace( $match, - base64_decode(strip_tags($match)), + base64_decode( strip_tags( $match ) ), $value ); } @@ -656,11 +656,11 @@ private function ensureShortcodesAreNotConvertedToHtml(callable $callback, strin * Sets the item config element value for WP taxonomy terms, * if it is determeined that the value changed. * - * @since 3.0.0 - * * @param string $taxonomy The taxonomy name. * * @return bool $updated Whether value was updated. + * @since 3.0.0 + * */ protected function set_taxonomy_field_value( $taxonomy ) { $terms = get_the_terms( $this->post, $taxonomy ); @@ -669,6 +669,7 @@ protected function set_taxonomy_field_value( $taxonomy ) { : array(); $updated = $this->set_taxonomy_field_value_from_names( $term_names ); + return apply_filters( 'gc_config_taxonomy_field_value_updated', $updated, $taxonomy, $terms, $this ); } @@ -694,7 +695,7 @@ public function set_taxonomy_field_value_from_names( $term_names ) { case 'choice_checkbox': case 'choice_radio': $updated = $this->update_element_selected_options( - function( $label ) use ( $term_names ) { + function ( $label ) use ( $term_names ) { return in_array( $label, $term_names, true ); } ); @@ -726,11 +727,11 @@ function( $label ) use ( $term_names ) { * Sets the item config element value for WP meta fields, * if it is determeined that the value changed. * - * @since 3.0.0 - * * @param string $meta_key The meta key. * * @return bool $updated Whether value was updated. + * @since 3.0.0 + * */ protected function set_meta_field_value( $meta_key ) { $updated = false; @@ -755,7 +756,7 @@ protected function set_meta_field_value( $meta_key ) { case 'choice_radio': $updated = $this->update_element_selected_options( - function( $label ) use ( $meta_value ) { + function ( $label ) use ( $meta_value ) { return $meta_value === $label; } ); @@ -769,7 +770,7 @@ function( $label ) use ( $meta_value ) { } $updated = $this->update_element_selected_options( - function( $label ) use ( $meta_value ) { + function ( $label ) use ( $meta_value ) { return in_array( $label, $meta_value, true ); } ); @@ -782,44 +783,44 @@ function( $label ) use ( $meta_value ) { /** - * Sets the item config element value for ACF fields, - * if it is determeined that the value changed. - * - * @since 3.0.0 - * - * @param string $group_key The ACF group key. - * @param string $field_key The ACF field key. - * @param array $post_data The WP Post data array. - * - * @return bool $updated Whether value was updated. - */ - - protected function set_acf_field_value($group_key) { + * Sets the item config element value for ACF fields, + * if it is determeined that the value changed. + * + * @param string $group_key The ACF group key. + * @param string $field_key The ACF field key. + * @param array $post_data The WP Post data array. + * + * @return bool $updated Whether value was updated. + * @since 3.0.0 + * + */ + + protected function set_acf_field_value( $group_key ) { $updated = false; // Get the post ID $post_id = $this->post->ID; // Fetch the ACF field group using the group key - $field_group = get_field($group_key, $post_id); + $field_group = get_field( $group_key, $post_id ); - $el = $this->element; + $el = $this->element; $el_value = $this->element->value; - if (is_object($el) && property_exists($el, 'component_uuid')) { + if ( is_object( $el ) && property_exists( $el, 'component_uuid' ) ) { // We have a component here - $structure_groups = $this->item->structure->groups; + $structure_groups = $this->item->structure->groups; $componentFieldsKeys = []; - foreach ($structure_groups as $group) { + foreach ( $structure_groups as $group ) { $fields = $group->fields; - foreach ($fields as $field) { - if ($field->uuid == $el->component_uuid) { + foreach ( $fields as $field ) { + if ( $field->uuid == $el->component_uuid ) { $component = $field->component; // Check if the component property exists and is an object - if (is_object($component) && property_exists($component, 'fields')) { + if ( is_object( $component ) && property_exists( $component, 'fields' ) ) { // Access the fields property of the component object $componentFields = $component->fields; - foreach ($componentFields as $componentField) { + foreach ( $componentFields as $componentField ) { $componentFieldsKeys[] = $componentField->uuid; } } @@ -827,61 +828,60 @@ protected function set_acf_field_value($group_key) { } } $groupData = []; - foreach ($field_group as $group) { + foreach ( $field_group as $group ) { // Combine keys from componentFieldsKeys with values from the current group - $new_group = array_combine($componentFieldsKeys, $group); + $new_group = array_combine( $componentFieldsKeys, $group ); $groupData[] = $new_group; } - // Define a mapping between field types and processing functions $fieldTypeProcessors = [ - 'text' => 'processTextField', - 'attachment' => 'processAttachmentField', + 'text' => 'processTextField', + 'attachment' => 'processAttachmentField', 'choice_checkbox' => 'processChoiceCheckboxField', - 'choice_radio' => 'processChoiceRadioField', + 'choice_radio' => 'processChoiceRadioField', // Add more field types and corresponding processing functions as needed ]; // Initialize an associative array to store grouped items $groupedData = []; // Iterate through each group data - foreach ($groupData as $dataInstance) { + foreach ( $groupData as $dataInstance ) { // Iterate through each field UUID and its corresponding value - foreach ($dataInstance as $field_uuid => $field_value) { + foreach ( $dataInstance as $field_uuid => $field_value ) { // Check if the field UUID exists as a key in the grouped data array - if (!isset($groupedData[$field_uuid])) { + if ( ! isset( $groupedData[ $field_uuid ] ) ) { // If the key doesn't exist, initialize it as an empty array - $groupedData[$field_uuid] = []; + $groupedData[ $field_uuid ] = []; } // Append the field value to the corresponding key in the grouped data array - $groupedData[$field_uuid][] = $field_value; + $groupedData[ $field_uuid ][] = $field_value; } } // Iterate through each field type and its corresponding field UUIDs - foreach ($groupedData as $field_uuid => $field_values) { + foreach ( $groupedData as $field_uuid => $field_values ) { // Process field values based on field type $field_type = null; - foreach ($componentFields as $componentField) { - if ($componentField->uuid === $field_uuid) { + foreach ( $componentFields as $componentField ) { + if ( $componentField->uuid === $field_uuid ) { $field_type = $componentField->field_type; break; // Stop iterating once the field with the matching UUID is found } } - if (isset($fieldTypeProcessors[$field_type])) { - if ($this->element->name == $field_uuid){ + if ( isset( $fieldTypeProcessors[ $field_type ] ) ) { + if ( $this->element->name == $field_uuid ) { // Call the corresponding processing function for each field UUID - $processorFunction = $fieldTypeProcessors[$field_type]; - $processorResult = $this->$processorFunction($field_values); + $processorFunction = $fieldTypeProcessors[ $field_type ]; + $processorResult = $this->$processorFunction( $field_values ); // Check if the result is an array with 'options' and 'value' - if (is_array($processorResult) && array_key_exists('options', $processorResult) && array_key_exists('value', $processorResult)) { + if ( is_array( $processorResult ) && array_key_exists( 'options', $processorResult ) && array_key_exists( 'value', $processorResult ) ) { // If the result contains both 'options' and 'value', extract them $jsonOptions = $processorResult['options']; - $jsonValue = $processorResult['value']; + $jsonValue = $processorResult['value']; } else { // If the result is not an array with 'options' and 'value', assume it's just the value $jsonValue = $processorResult; @@ -890,9 +890,9 @@ protected function set_acf_field_value($group_key) { // Assign the processed value to the corresponding element - if (($this->element->name == $field_uuid) && ($this->element->value != $jsonValue)){ + if ( ( $this->element->name == $field_uuid ) && ( $this->element->value != $jsonValue ) ) { $this->element->value = $jsonValue; - if ($jsonOptions){ + if ( $jsonOptions ) { $this->element->options = $jsonOptions; } $updated = true; @@ -901,74 +901,74 @@ protected function set_acf_field_value($group_key) { // Handle unknown field types or skip } } - }else { + } else { $outputArray = array(); - foreach ($field_group as $item) { + foreach ( $field_group as $item ) { // Get the values of the sub-array dynamically - $values = array_values($item); + $values = array_values( $item ); // Use json_encode to encode the value - $outputArray[] = json_encode($values[0]); + $outputArray[] = json_encode( $values[0] ); } - $jsonValue = '[' . implode(',', $outputArray) . ']'; - if ($this->element->value != $jsonValue){ + $jsonValue = '[' . implode( ',', $outputArray ) . ']'; + if ( $this->element->value != $jsonValue ) { $this->element->value = $jsonValue; - $updated = true; + $updated = true; } } return $updated; } - protected function processTextField($field_value) { + protected function processTextField( $field_value ) { // Handle text field type $jsonValues = []; // Array to store JSON encoded values // Check if the field value is an array - if (is_array($field_value)) { - foreach ($field_value as $item) { + if ( is_array( $field_value ) ) { + foreach ( $field_value as $item ) { // Check if the item is an array - if (is_array($item)) { + if ( is_array( $item ) ) { // If the item is an array, encode its elements separately $encodedValues = []; - foreach ($item as $value) { - if (!is_array($value)) { + foreach ( $item as $value ) { + if ( ! is_array( $value ) ) { // If the value is not an array, encode it directly - $trimmedValue = rtrim($value, "\n\r"); - $encodedValues[] = '"' . addslashes($trimmedValue) . '"'; + $trimmedValue = rtrim( $value, "\n\r" ); + $encodedValues[] = '"' . addslashes( $trimmedValue ) . '"'; } else { // If the value is an array, encode its elements separately $encodedInnerValues = []; - foreach ($value as $innerValue) { - $trimmedValue = rtrim($innerValue, "\n\r"); - $encodedInnerValues[] = '"' . addslashes($trimmedValue) . '"'; + foreach ( $value as $innerValue ) { + $trimmedValue = rtrim( $innerValue, "\n\r" ); + $encodedInnerValues[] = '"' . addslashes( $trimmedValue ) . '"'; } // Encode the inner array as a JSON array - $encodedValues[] = implode(',', $encodedInnerValues); + $encodedValues[] = implode( ',', $encodedInnerValues ); } } // Encode the outer array as a JSON array - $jsonValues[] = '[' . implode(',', $encodedValues) . ']'; + $jsonValues[] = '[' . implode( ',', $encodedValues ) . ']'; } else { // If the item is not an array, encode it directly - $trimmedValue = rtrim($item, "\n\r"); - $jsonValues[] = '"' . addslashes($trimmedValue) . '"'; + $trimmedValue = rtrim( $item, "\n\r" ); + $jsonValues[] = '"' . addslashes( $trimmedValue ) . '"'; } } } else { // If the field value is not an array, encode it directly - $trimmedValue = rtrim($field_value, "\n\r"); - $jsonValues[] = '"' . addslashes($trimmedValue) . '"'; + $trimmedValue = rtrim( $field_value, "\n\r" ); + $jsonValues[] = '"' . addslashes( $trimmedValue ) . '"'; } // Return the JSON encoded values - return '[' . implode(',', $jsonValues) . ']'; + return '[' . implode( ',', $jsonValues ) . ']'; } - protected function processAttachmentField($field_value) { + protected function processAttachmentField( $field_value ) { // Check if the field value is empty or not set - if (empty($field_value)) { + if ( empty( $field_value ) ) { // Field value is empty, meaning attachments should be removed return '[]'; // Send an empty array to remove all attachments } else { @@ -978,9 +978,9 @@ protected function processAttachmentField($field_value) { $fileIds = []; // Loop through each attachment data in the field value array - foreach ($field_value as $attachment) { + foreach ( $field_value as $attachment ) { // Check if the attachment has an 'ID' key - if (isset($attachment['ID'])) { + if ( isset( $attachment['ID'] ) ) { // Attachment already exists, add its ID to the file IDs array $fileIds[] = $attachment['ID']; } @@ -989,33 +989,33 @@ protected function processAttachmentField($field_value) { } // Return the file IDs as a JSON array - return json_encode($fileIds); + return json_encode( $fileIds ); } } - protected function processChoiceCheckboxField($field_value) { - $options = $this->element->options; // Get the options + protected function processChoiceCheckboxField( $field_value ) { + $options = $this->element->options; // Get the options $result_options = []; // Array to store the result for options - $result_value = []; // Array to store the result for value + $result_value = []; // Array to store the result for value // Iterate through each item in the field value array - foreach ($field_value as $value) { + foreach ( $field_value as $value ) { $selected_options = []; // Array to store options for this value - $selected_value = []; // Array to store value for this value + $selected_value = []; // Array to store value for this value // Iterate through each option and set 'selected' property accordingly - foreach ($options as $option) { + foreach ( $options as $option ) { $selected_option = clone $option; // Clone the option object // Set 'selected' property based on whether the label matches any value in the current $field_value item - $selected_option->selected = in_array($option->label, $value) ? 1 : 0; + $selected_option->selected = in_array( $option->label, $value ) ? 1 : 0; // Add the modified option to the array $selected_options[] = $selected_option; // If the label matches any value in the current $field_value item, store the value details - if (in_array($option->label, $value)) { - $selected_value[] = ['id' => $option->name, 'label' => $option->label]; + if ( in_array( $option->label, $value ) ) { + $selected_value[] = [ 'id' => $option->name, 'label' => $option->label ]; } } @@ -1026,32 +1026,32 @@ protected function processChoiceCheckboxField($field_value) { $result_value[] = $selected_value; } - return ['options' => $result_options, 'value' => $result_value]; // Return both results + return [ 'options' => $result_options, 'value' => $result_value ]; // Return both results } - protected function processChoiceRadioField($field_value) { - $options = $this->element->options; // Get the options + protected function processChoiceRadioField( $field_value ) { + $options = $this->element->options; // Get the options $result_options = []; // Array to store the result for options - $result_value = []; // Array to store the result for value + $result_value = []; // Array to store the result for value // Iterate through each item in the field value array - foreach ($field_value as $value) { + foreach ( $field_value as $value ) { $selected_options = []; // Array to store options for this value - $selected_value = []; // Array to store value for this value + $selected_value = []; // Array to store value for this value // Iterate through each option and set 'selected' property accordingly - foreach ($options as $option) { + foreach ( $options as $option ) { $selected_option = clone $option; // Clone the option object // Set 'selected' property based on whether the label matches the value - $selected_option->selected = ($option->label === $value) ? 1 : 0; + $selected_option->selected = ( $option->label === $value ) ? 1 : 0; // Add the modified option to the array $selected_options[] = $selected_option; // If the label matches the value, store the value details - if ($option->label === $value) { - $selected_value[] = ['id' => $option->name, 'label' => $option->label]; + if ( $option->label === $value ) { + $selected_value[] = [ 'id' => $option->name, 'label' => $option->label ]; } } @@ -1062,20 +1062,18 @@ protected function processChoiceRadioField($field_value) { $result_value[] = $selected_value; } - return ['options' => $result_options, 'value' => $result_value]; // Return both results + return [ 'options' => $result_options, 'value' => $result_value ]; // Return both results } - - /** * Uses $callback to determine if each option value should be selected, * - * @since 3.0.0 - * - * @param callable $callback Closure. + * @param callable $callback Closure. * * @return bool Whether the options were updated or not. + * @since 3.0.0 + * */ public function update_element_selected_options( $callback ) { $pre_options = wp_json_encode( $this->element->value ); @@ -1096,7 +1094,7 @@ public function update_element_selected_options( $callback ) { if ( $callback( self::remove_zero_width( $label ) ) ) { $values[] = [ - 'id' => $option->name, + 'id' => $option->name, 'label' => $option->label, ]; } else { @@ -1111,7 +1109,7 @@ public function update_element_selected_options( $callback ) { } $this->element->value = $values; - $post_options = wp_json_encode( $this->element->value ); + $post_options = wp_json_encode( $this->element->value ); // @codingStandardsIgnoreStart // Check if the values have been updated. diff --git a/includes/classes/utils.php b/includes/classes/utils.php index 40e4ee65..e57bf6ff 100644 --- a/includes/classes/utils.php +++ b/includes/classes/utils.php @@ -71,13 +71,13 @@ public static function doing_ajax() { /** * Determines if $date_check is within allowance of $date_compare. * - * @since 3.0.0 - * - * @param mixed $date_check Date to check. - * @param mixed $date_compare Date to compare with. - * @param integer $allowance Allowed tolerance. + * @param mixed $date_check Date to check. + * @param mixed $date_compare Date to compare with. + * @param integer $allowance Allowed tolerance. * * @return bool Whether $date_check is current with $date_compare. + * @since 3.0.0 + * */ public static function date_current_with( $date_check, $date_compare, $allowance = 0 ) { $date_compare = strtotime( $date_compare ); @@ -90,12 +90,12 @@ public static function date_current_with( $date_check, $date_compare, $allowance /** * Utility function for doing array_map recursively. * - * @since 3.0.0 - * - * @param callable $callback Callable function. - * @param array $array Array to recurse. + * @param callable $callback Callable function. + * @param array $array Array to recurse. * * @return array Updated array. + * @since 3.0.0 + * */ static function array_map_recursive( $callback, $array ) { foreach ( $array as $key => $value ) { @@ -105,17 +105,18 @@ static function array_map_recursive( $callback, $array ) { $array[ $key ] = call_user_func( $callback, $array[ $key ] ); } } + return $array; } /** * Convert a UTC date to human readable date using the WP timezone. * - * @since 3.0.0 - * - * @param string $utc_date UTC date. + * @param string $utc_date UTC date. * * @return string Human readable relative date. + * @since 3.0.0 + * */ public static function relative_date( $utc_date ) { static $tzstring = null; @@ -163,11 +164,11 @@ public static function relative_date( $utc_date ) { /** * Get the GatherContent item field type nice-name. * - * @since 3.0.0 - * - * @param string $type The type to get the name for. 'all' to get the entire array. + * @param string $type The type to get the name for. 'all' to get the entire array. * * @return mixed The type nice-name, or the entire types array. + * @since 3.0.0 + * */ public static function gc_field_type_name( $type ) { static $types = null; @@ -196,11 +197,11 @@ public static function gc_field_type_name( $type ) { /** * Get the GatherContent wizard step label. * - * @since 3.0.0 - * - * @param string $step The step to get the name for. 'all' to get the entire array. + * @param string $step The step to get the name for. 'all' to get the entire array. * * @return mixed The step nice-name, or the entire types array. + * @since 3.0.0 + * */ public static function get_step_label( $step ) { static $labels = null; @@ -225,16 +226,17 @@ public static function get_step_label( $step ) { /** * Check if enqueued version of script is at least $version. * - * @since 3.0.0.8 - * - * @param string $handle The script's registered handle. - * @param string $version Version string to compare. + * @param string $handle The script's registered handle. + * @param string $version Version string to compare. * * @return bool Result of comparison check. + * @since 3.0.0.8 + * */ public static function enqueued_at_least( $handle, $version ) { $wpjs = wp_scripts(); + return isset( $wpjs->registered[ $handle ] ) - && version_compare( $wpjs->registered[ $handle ]->ver, $version, '>=' ); + && version_compare( $wpjs->registered[ $handle ]->ver, $version, '>=' ); } } diff --git a/includes/classes/views/form-element.php b/includes/classes/views/form-element.php index fd9a899c..4f3dcc71 100644 --- a/includes/classes/views/form-element.php +++ b/includes/classes/views/form-element.php @@ -1,4 +1,5 @@ '; $index = 0; foreach ( $options as $option_val => $option_label ) { - $index++; + $index ++; $input_args = array( 'type' => 'radio', 'class' => 'radio-select', diff --git a/includes/classes/views/view.php b/includes/classes/views/view.php index 2764f5b6..80f55623 100644 --- a/includes/classes/views/view.php +++ b/includes/classes/views/view.php @@ -1,4 +1,5 @@ get( $arg, $default ); diff --git a/includes/functions/core.php b/includes/functions/core.php index 3bef7505..d012a3b4 100644 --- a/includes/functions/core.php +++ b/includes/functions/core.php @@ -10,10 +10,11 @@ /** * Will look for Some_Class\Name in /includes/classes/some-class/name.php * - * @since 3.0.0 + * @param string $class_name Class name. * - * @param string $class_name Class name. * @return void + * @since 3.0.0 + * */ function autoload( $class_name ) { @@ -50,19 +51,19 @@ function autoload( $class_name ) { /** * Default setup routine * - * @since 3.0.0 - * + * @return void * @uses add_action() * @uses do_action() * - * @return void + * @since 3.0.0 + * */ function setup() { - $n = function( $function ) { + $n = function ( $function ) { return __NAMESPACE__ . "\\$function"; }; - spl_autoload_register($n( 'autoload' )); + spl_autoload_register( $n( 'autoload' ) ); include_once GATHERCONTENT_PATH . 'vendor/autoload.php'; @@ -79,11 +80,11 @@ function setup() { /** * Initializes the plugin and fires an action other plugins can hook into. * - * @since 3.0.0 - * + * @return void * @uses do_action() * - * @return void + * @since 3.0.0 + * */ function init() { @@ -96,12 +97,12 @@ function init() { /** * Activate the plugin * - * @since 3.0.0 - * + * @return void * @uses init() * @uses flush_rewrite_rules() * - * @return void + * @since 3.0.0 + * */ function activate() { // First load the init scripts in case any rewrite functionality is being loaded. @@ -114,9 +115,9 @@ function activate() { * * Uninstall routines should be in uninstall.php * + * @return void * @since 3.0.0 * - * @return void */ function deactivate() { } diff --git a/includes/functions/functions.php b/includes/functions/functions.php index 10b3676c..0fa79d44 100644 --- a/includes/functions/functions.php +++ b/includes/functions/functions.php @@ -13,16 +13,16 @@ /** * Style enqueue helper w/ GC defaults. * - * @since 3.0.0 - * - * @param string $handle Name of the stylesheet. Should be unique. - * @param string $filename Path (w/o extension/suffix) to CSS file in /assets/css/. - * @param array $deps Optional. An array of registered stylesheet handles this stylesheet + * @param string $handle Name of the stylesheet. Should be unique. + * @param string $filename Path (w/o extension/suffix) to CSS file in /assets/css/. + * @param array $deps Optional. An array of registered stylesheet handles this stylesheet * depends on. Default empty array. - * @param string|bool|null $ver Optional. String specifying stylesheet version number, + * @param string|bool|null $ver Optional. String specifying stylesheet version number, * if it has one, which is added to the URL. * * @return void + * @since 3.0.0 + * */ function enqueue_style( $handle, $filename, $deps = array(), $ver = GATHERCONTENT_ENQUEUE_VERSION ) { $suffix = Utils::asset_suffix(); @@ -32,16 +32,16 @@ function enqueue_style( $handle, $filename, $deps = array(), $ver = GATHERCONTEN /** * Script enqueue helper w/ GC defaults. * - * @since 3.0.0 - * - * @param string $handle Name of the script. Should be unique. - * @param string $filename Path (w/o extension/suffix) to JS file in /assets/js/. - * @param array $deps Optional. An array of registered script handles this + * @param string $handle Name of the script. Should be unique. + * @param string $filename Path (w/o extension/suffix) to JS file in /assets/js/. + * @param array $deps Optional. An array of registered script handles this * script depends on. Default empty array. - * @param string|bool|null $ver Optional. String specifying script version number, + * @param string|bool|null $ver Optional. String specifying script version number, * if it has one, which is added to the URL. * * @return void + * @since 3.0.0 + * */ function enqueue_script( $handle, $filename, $deps = array(), $ver = GATHERCONTENT_ENQUEUE_VERSION ) { $suffix = Utils::asset_suffix(); @@ -51,12 +51,12 @@ function enqueue_script( $handle, $filename, $deps = array(), $ver = GATHERCONTE /** * Wrapper for WP_Query that gets the assocated post for a GatherContent Item Id. * - * @since 3.0.0 - * - * @param int $item_id GatherContent Item Id. - * @param array $args Optional array of WP_Query args. + * @param int $item_id GatherContent Item Id. + * @param array $args Optional array of WP_Query args. * * @return mixed WP_Post if an associated post is found. + * @since 3.0.0 + * */ function get_post_by_item_id( $item_id, $args = array() ) { global $wpml_query_filter; @@ -73,14 +73,14 @@ function get_post_by_item_id( $item_id, $args = array() ) { 'post_type' => \GatherContent\Importer\available_mapping_post_types(), 'posts_per_page' => 1, 'no_found_rows' => true, - // @codingStandardsIgnoreStart - 'meta_query' => array( - array( - 'key' => '_gc_mapped_item_id', - 'value' => $item_id, - ), - ), - // @codingStandardsIgnoreEnd + // @codingStandardsIgnoreStart + 'meta_query' => array( + array( + 'key' => '_gc_mapped_item_id', + 'value' => $item_id, + ), + ), + // @codingStandardsIgnoreEnd ) ) ); @@ -91,25 +91,25 @@ function get_post_by_item_id( $item_id, $args = array() ) { /** * Wrapper for get_post_meta that gets the associated GatherContent item ID, if it exists. * - * @since 3.0.0 - * * @param int $post_id The ID of the post to check. * * @return mixed Result of get_post_meta. + * @since 3.0.0 + * */ function get_post_item_id( $post_id ) { - return get_post_meta( $post_id, '_gc_mapped_item_id', 1 ); + return get_post_meta( $post_id, '_gc_mapped_item_id', 1 ); } /** * Wrapper for update_post_meta that saves the associated GatherContent item ID to the post's meta. * - * @since 3.0.0 - * * @param int $post_id The ID of the post to store the item ID against. * @param int $item_id The item id to store against the post. * * @return mixed Result of update_post_meta. + * @since 3.0.0 + * */ function update_post_item_id( $post_id, $item_id ) { return update_post_meta( $post_id, '_gc_mapped_item_id', $item_id ); @@ -118,39 +118,40 @@ function update_post_item_id( $post_id, $item_id ) { /** * Wrapper for get_post_meta that gets the associated GatherContent item meta, if it exists. * - * @since 3.0.0 - * * @param int $post_id The ID of the post to check. * * @return mixed Result of get_post_meta. + * @since 3.0.0 + * */ function get_post_item_meta( $post_id ) { $meta = get_post_meta( $post_id, '_gc_mapped_meta', 1 ); + return $meta; } /** * Wrapper for update_post_meta that saves the associated GatherContent item meta to the post's meta. * - * @since 3.0.0 - * - * @param int $post_id The ID of the post to update. - * @param mixed $meta The item meta to store against the post. + * @param int $post_id The ID of the post to update. + * @param mixed $meta The item meta to store against the post. * * @return mixed Result of update_post_meta. + * @since 3.0.0 + * */ function update_post_item_meta( $post_id, $meta ) { - return update_post_meta( $post_id, '_gc_mapped_meta', $meta ); + return update_post_meta( $post_id, '_gc_mapped_meta', $meta ); } /** * Wrapper for get_post_meta that gets the associated GatherContent mapping post ID, if it exists. * - * @since 3.0.0 - * * @param int $post_id The ID of the post to check. * * @return mixed Result of get_post_meta. + * @since 3.0.0 + * */ function get_post_mapping_id( $post_id ) { return get_post_meta( $post_id, '_gc_mapping_id', 1 ); @@ -159,26 +160,26 @@ function get_post_mapping_id( $post_id ) { /** * Wrapper for update_post_meta that saves the associated GatherContent mapping post ID to the post's meta. * - * @since 3.0.0 - * - * @param int $post_id The ID of the post to update. + * @param int $post_id The ID of the post to update. * @param int $mapping_post_id The ID of the mapping post. * * @return mixed Result of update_post_meta. + * @since 3.0.0 + * */ function update_post_mapping_id( $post_id, $mapping_post_id ) { - return update_post_meta( $post_id, '_gc_mapping_id', $mapping_post_id ); + return update_post_meta( $post_id, '_gc_mapping_id', $mapping_post_id ); } /** * Augment a GatherContent item object with additional data for JS templating. * - * @since 3.0.0 - * - * @param object $item GatherContent item object. - * @param int $mapping_id Optional. ID of the mapping post. + * @param object $item GatherContent item object. + * @param int $mapping_id Optional. ID of the mapping post. * * @return array Object prepared for JS. + * @since 3.0.0 + * */ function prepare_item_for_js( $item, $mapping_id = 0 ) { $post = \GatherContent\Importer\get_post_by_item_id( $item->id ); @@ -204,12 +205,12 @@ function prepare_item_for_js( $item, $mapping_id = 0 ) { /** * Get a an array of data from a WP_Post object to be used as a backbone model. * - * @since 3.0.0 - * - * @param mixed $post WP_Post or post ID. - * @param bool $uncached Whether to fetch item data uncached. Default is to ONLY fetch from cache. + * @param mixed $post WP_Post or post ID. + * @param bool $uncached Whether to fetch item data uncached. Default is to ONLY fetch from cache. * * @return array JS post array. + * @since 3.0.0 + * */ function prepare_post_for_js( $post, $uncached = false ) { $post = $post instanceof WP_Post ? $post : get_post( $post ); @@ -236,8 +237,8 @@ function prepare_post_for_js( $post, $uncached = false ) { $item = null; if ( $js_post['item'] ) { $item = $uncached - ? General::get_instance()->api->uncached()->get_item( $js_post['item'] ) - : General::get_instance()->api->only_cached()->get_item( $js_post['item'] ); + ? General::get_instance()->api->uncached()->get_item( $js_post['item'] ) + : General::get_instance()->api->only_cached()->get_item( $js_post['item'] ); } return \GatherContent\Importer\prepare_js_data( $js_post, $item ); @@ -246,13 +247,13 @@ function prepare_post_for_js( $post, $uncached = false ) { /** * Get a an array of data from a WP_Post or GC item object to be used as a backbone model. * - * @since 3.0.0 - * - * @param array $args Array of args to be added to. + * @param array $args Array of args to be added to. * @param object $item GatherContent item object. * @param string $type Which type of data we are preparing, 'post' or 'item'. * * @return array Array of modified args. + * @since 3.0.0 + * */ function prepare_js_data( $args, $item = null, $type = 'post' ) { $args = wp_parse_args( @@ -286,12 +287,12 @@ function prepare_js_data( $args, $item = null, $type = 'post' ) { } $args['status'] = isset( $item->status->data ) - ? $item->status->data - : (object) array(); + ? $item->status->data + : (object) array(); $args['typeName'] = isset( $item->type ) - ? Utils::gc_field_type_name( $item->type ) - : ''; + ? Utils::gc_field_type_name( $item->type ) + : ''; if ( isset( $item->updated_at ) ) { $args['updated_at'] = Utils::relative_date( $item->updated_at ); @@ -312,11 +313,11 @@ function prepare_js_data( $args, $item = null, $type = 'post' ) { /** * Gets the singular label for a post's post-type object. * - * @since 3.0.0 - * * @param mixed $post WP_Post * * @return string Singular post-type label. + * @since 3.0.0 + * */ function get_post_type_singular_label( $post ) { $label = __( 'Post', 'content-workflow-by-bynder' ); @@ -326,19 +327,19 @@ function get_post_type_singular_label( $post ) { $object = get_post_type_object( $post->post_type ); return isset( $object->labels->singular_name ) - ? $object->labels->singular_name - : $object->labels->name; + ? $object->labels->singular_name + : $object->labels->name; } /** * Checks to see if a post is current with a GatherContent item. * - * @since 3.0.0 - * - * @param int $post_id Post ID. - * @param mixed $item GatherContent item object. + * @param int $post_id Post ID. + * @param mixed $item GatherContent item object. * * @return bool Whether post is current. + * @since 3.0.0 + * */ function post_is_current( $post_id, $item ) { $meta = \GatherContent\Importer\get_post_item_meta( $post_id ); @@ -363,9 +364,9 @@ function post_is_current( $post_id, $item ) { /** * A button for flushing the cached connection to GC's API. * + * @return string URL for flushing cache. * @since 3.0.0 * - * @return string URL for flushing cache. */ function refresh_connection_link() { $args = array( @@ -379,7 +380,7 @@ function refresh_connection_link() { ); // @codingStandardsIgnoreStart if ( isset( $_GET['flush_cache'], $_GET['redirect'] ) ) { - // @codingStandardsIgnoreEnd + // @codingStandardsIgnoreEnd update_option( 'gc-api-updated', 1, false ); $args['redirect_url'] = remove_query_arg( 'flush_cache', remove_query_arg( 'redirect' ) ); } @@ -392,9 +393,9 @@ function refresh_connection_link() { /** * Determine if current user can view GC settings. * + * @return bool Whether current user can view GC settings. * @since 3.0.0 * - * @return bool Whether current user can view GC settings. */ function user_allowed() { return current_user_can( \GatherContent\Importer\view_capability() ); @@ -403,9 +404,9 @@ function user_allowed() { /** * Capability for user to be able to view GC settings. * + * @return string Capability * @since 3.0.0 * - * @return string Capability */ function view_capability() { return apply_filters( 'gathercontent_settings_view_capability', 'publish_pages' ); @@ -415,32 +416,35 @@ function view_capability() { * The filtered list of post-types available for mapping to GC items. * Modify with the 'gathercontent_mapping_post_types' filter. * + * @return array Array of post-type slugs. * @since 3.0.3 * - * @return array Array of post-type slugs. */ function available_mapping_post_types() { $post_types = get_post_types( array( 'public' => true ) ); + return apply_filters( 'gathercontent_mapping_post_types', $post_types ); } /** * Detect if HTTP Auth is enabled. * + * @return string|bool The Auth username if enabled, or false. * @since 3.0.7 * - * @return string|bool The Auth username if enabled, or false. */ function auth_enabled() { if ( ! empty( $_SERVER['REMOTE_USER'] ) ) { return $_SERVER['REMOTE_USER']; } - foreach ( array( - 'PHP_AUTH_USER', - 'PHP_AUTH_PW', - 'HTTP_AUTHORIZATION', - ) as $var ) { + foreach ( + array( + 'PHP_AUTH_USER', + 'PHP_AUTH_PW', + 'HTTP_AUTHORIZATION', + ) as $var + ) { if ( ! empty( $_SERVER[ $var ] ) ) { return true; } diff --git a/includes/vendor/edd/browser.php b/includes/vendor/edd/browser.php index f2d01a5e..36cace40 100644 --- a/includes/vendor/edd/browser.php +++ b/includes/vendor/edd/browser.php @@ -150,76 +150,75 @@ * Added detection for BlackBerry * Removed Netscape checks (matches heavily with firefox & mozilla) */ - class Browser { - public $_agent = ''; + public $_agent = ''; public $_browser_name = ''; - public $_version = ''; - public $_platform = ''; - public $_os = ''; - public $_is_aol = false; - public $_is_mobile = false; - public $_is_robot = false; - public $_aol_version = ''; + public $_version = ''; + public $_platform = ''; + public $_os = ''; + public $_is_aol = false; + public $_is_mobile = false; + public $_is_robot = false; + public $_aol_version = ''; public $BROWSER_UNKNOWN = 'unknown'; public $VERSION_UNKNOWN = 'unknown'; - public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/ - public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/ - public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/ - public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/ - public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile - public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/ - public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/ - public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/ - public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/ - public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html - public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/ - public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko - public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/ - public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/ - public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx - public $BROWSER_SAFARI = 'Safari'; // Http://apple.com - public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com - public $BROWSER_IPOD = 'iPod'; // Http://apple.com - public $BROWSER_IPAD = 'iPad'; // Http://apple.com - public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome - public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/ - public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot - public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp + public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/ + public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/ + public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/ + public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/ + public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile + public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/ + public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/ + public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/ + public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/ + public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html + public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/ + public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko + public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/ + public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/ + public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx + public $BROWSER_SAFARI = 'Safari'; // Http://apple.com + public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com + public $BROWSER_IPOD = 'iPod'; // Http://apple.com + public $BROWSER_IPAD = 'iPad'; // Http://apple.com + public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome + public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/ + public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot + public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/ - public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/ - public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat - public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60 - public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform - public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/ - public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm + public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/ + public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat + public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60 + public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform + public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/ + public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well) public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED) - public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED) - public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED) - public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED) - - public $PLATFORM_UNKNOWN = 'unknown'; - public $PLATFORM_WINDOWS = 'Windows'; - public $PLATFORM_WINDOWS_CE = 'Windows CE'; - public $PLATFORM_APPLE = 'Apple'; - public $PLATFORM_LINUX = 'Linux'; - public $PLATFORM_OS2 = 'OS/2'; - public $PLATFORM_BEOS = 'BeOS'; - public $PLATFORM_IPHONE = 'iPhone'; - public $PLATFORM_IPOD = 'iPod'; - public $PLATFORM_IPAD = 'iPad'; - public $PLATFORM_BLACKBERRY = 'BlackBerry'; - public $PLATFORM_NOKIA = 'Nokia'; - public $PLATFORM_FREEBSD = 'FreeBSD'; - public $PLATFORM_OPENBSD = 'OpenBSD'; - public $PLATFORM_NETBSD = 'NetBSD'; - public $PLATFORM_SUNOS = 'SunOS'; + public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED) + public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED) + public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED) + + public $PLATFORM_UNKNOWN = 'unknown'; + public $PLATFORM_WINDOWS = 'Windows'; + public $PLATFORM_WINDOWS_CE = 'Windows CE'; + public $PLATFORM_APPLE = 'Apple'; + public $PLATFORM_LINUX = 'Linux'; + public $PLATFORM_OS2 = 'OS/2'; + public $PLATFORM_BEOS = 'BeOS'; + public $PLATFORM_IPHONE = 'iPhone'; + public $PLATFORM_IPOD = 'iPod'; + public $PLATFORM_IPAD = 'iPad'; + public $PLATFORM_BLACKBERRY = 'BlackBerry'; + public $PLATFORM_NOKIA = 'Nokia'; + public $PLATFORM_FREEBSD = 'FreeBSD'; + public $PLATFORM_OPENBSD = 'OpenBSD'; + public $PLATFORM_NETBSD = 'NetBSD'; + public $PLATFORM_SUNOS = 'SunOS'; public $PLATFORM_OPENSOLARIS = 'OpenSolaris'; - public $PLATFORM_ANDROID = 'Android'; + public $PLATFORM_ANDROID = 'Android'; public $OPERATING_SYSTEM_UNKNOWN = 'unknown'; @@ -251,10 +250,12 @@ function reset() { * Check to see if the specific browser is valid * * @param string $browserName + * * @return True if the browser is the specified browser */ function isBrowser( $browserName ) { - return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); } + return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); + } /** * The name of the browser. All return types are from the class contants @@ -262,105 +263,135 @@ function isBrowser( $browserName ) { * @return string Name of the browser */ function getBrowser() { - return $this->_browser_name; } + return $this->_browser_name; + } + /** * Set the name of the browser * * @param unknown $browser The name of the Browser */ function setBrowser( $browser ) { - return $this->_browser_name = $browser; } + return $this->_browser_name = $browser; + } + /** * The name of the platform. All return types are from the class contants * * @return string Name of the browser */ function getPlatform() { - return $this->_platform; } + return $this->_platform; + } + /** * Set the name of the platform * * @param unknown $platform The name of the Platform */ function setPlatform( $platform ) { - return $this->_platform = $platform; } + return $this->_platform = $platform; + } + /** * The version of the browser. * * @return string Version of the browser (will only contain alpha-numeric characters and a period) */ function getVersion() { - return $this->_version; } + return $this->_version; + } + /** * Set the version of the browser * * @param unknown $version The version of the Browser */ function setVersion( $version ) { - $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); } + $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); + } + /** * The version of AOL. * * @return string Version of AOL (will only contain alpha-numeric characters and a period) */ function getAolVersion() { - return $this->_aol_version; } + return $this->_aol_version; + } + /** * Set the version of AOL * * @param unknown $version The version of AOL */ function setAolVersion( $version ) { - $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); } + $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); + } + /** * Is the browser from AOL? * * @return boolean True if the browser is from AOL otherwise false */ function isAol() { - return $this->_is_aol; } + return $this->_is_aol; + } + /** * Is the browser from a mobile device? * * @return boolean True if the browser is from a mobile device otherwise false */ function isMobile() { - return $this->_is_mobile; } + return $this->_is_mobile; + } + /** * Is the browser from a robot (ex Slurp,GoogleBot)? * * @return boolean True if the browser is from a robot otherwise false */ function isRobot() { - return $this->_is_robot; } + return $this->_is_robot; + } + /** * Set the browser to be from AOL * * @param unknown $isAol */ function setAol( $isAol ) { - $this->_is_aol = $isAol; } + $this->_is_aol = $isAol; + } + /** * Set the Browser to be mobile * * @param boolean $value is the browser a mobile brower or not */ function setMobile( $value = true ) { - $this->_is_mobile = $value; } + $this->_is_mobile = $value; + } + /** * Set the Browser to be a robot * * @param boolean $value is the browser a robot or not */ function setRobot( $value = true ) { - $this->_is_robot = $value; } + $this->_is_robot = $value; + } + /** * Get the user agent value in use to determine the browser * * @return string The user agent from the HTTP header */ function getUserAgent() { - return $this->_agent; } + return $this->_agent; + } + /** * Set the user agent value (the construction will use the HTTP header value - this will overwrite it) * @@ -371,15 +402,17 @@ function setUserAgent( $agent_string ) { $this->_agent = $agent_string; $this->determine(); } + /** * Used to determine if the browser is actually "chromeframe" * - * @since 1.7 * @return boolean True if the browser is using chromeframe + * @since 1.7 */ function isChromeFrame() { return strpos( $this->_agent, 'chromeframe' ) !== false; } + /** * Returns a formatted string with a summary of the details of the browser. * @@ -396,17 +429,19 @@ function __toString() { // $text2 to be printed off // But we need to add spaces before each line that is split other than line 1 $space = ''; - for ( $i = 0; $i < 25; $i++ ) { + for ( $i = 0; $i < 25; $i ++ ) { $space .= ' '; } // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting $wordwrapped = chunk_split( $towrapUA, 32, "\n $space" ); + return "Platform: {$this->getPlatform()} \n" . - "Browser Name: {$this->getBrowser()} \n" . - "Browser Version: {$this->getVersion()} \n" . - "User Agent String: $UAline1 \n\t\t\t " . - "$wordwrapped"; + "Browser Name: {$this->getBrowser()} \n" . + "Browser Version: {$this->getVersion()} \n" . + "User Agent String: $UAline1 \n\t\t\t " . + "$wordwrapped"; } + /** * Protected routine to calculate and determine what the browser is in use (including platform) */ @@ -415,6 +450,7 @@ function determine() { $this->checkBrowsers(); $this->checkForAol(); } + /** * Protected routine to determine the browser type * @@ -487,8 +523,10 @@ function checkBrowserBlackBerry() { $this->setVersion( $aversion[0] ); $this->_browser_name = $this->BROWSER_BLACKBERRY; $this->setMobile( true ); + return true; } + return false; } @@ -505,8 +543,10 @@ function checkForAol() { $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) ); $this->setAol( true ); $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) ); + return true; } + return false; } @@ -522,8 +562,10 @@ function checkBrowserGoogleBot() { $this->setVersion( str_replace( ';', '', $aversion[0] ) ); $this->_browser_name = $this->BROWSER_GOOGLEBOT; $this->setRobot( true ); + return true; } + return false; } @@ -539,8 +581,10 @@ function checkBrowserMSNBot() { $this->setVersion( str_replace( ';', '', $aversion[0] ) ); $this->_browser_name = $this->BROWSER_MSNBOT; $this->setRobot( true ); + return true; } + return false; } @@ -555,6 +599,7 @@ function checkBrowserW3CValidator() { $aversion = explode( ' ', $aresult[1] ); $this->setVersion( $aversion[0] ); $this->_browser_name = $this->BROWSER_W3CVALIDATOR; + return true; } elseif ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) { // Some of the Validator versions do not delineate w/ a slash - add it back in @@ -563,8 +608,10 @@ function checkBrowserW3CValidator() { $aversion = explode( ' ', $aresult[1] ); $this->setVersion( $aversion[0] ); $this->_browser_name = $this->BROWSER_W3CVALIDATOR; + return true; } + return false; } @@ -581,8 +628,10 @@ function checkBrowserSlurp() { $this->_browser_name = $this->BROWSER_SLURP; $this->setRobot( true ); $this->setMobile( false ); + return true; } + return false; } @@ -601,26 +650,27 @@ function checkBrowserInternetExplorer() { if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) { $this->setVersion( '1.5' ); } + return true; - } - // Test for versions > 1.5 + } // Test for versions > 1.5 elseif ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) { // See if the browser is the odd MSN Explorer if ( stripos( $this->_agent, 'msnb' ) !== false ) { $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) ); $this->setBrowser( $this->BROWSER_MSN ); $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); + return true; } $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) ); $this->setBrowser( $this->BROWSER_IE ); $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); + return true; - } - // Test for Pocket IE + } // Test for Pocket IE elseif ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) { $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) ); - $this->setPlatform( $this->PLATFORM_WINDOWS_CE ); + $this->setPlatform( $this->PLATFORM_WINDOWS_CE ); $this->setBrowser( $this->BROWSER_POCKET_IE ); $this->setMobile( true ); @@ -630,8 +680,10 @@ function checkBrowserInternetExplorer() { $aversion = explode( '/', $this->_agent ); $this->setVersion( $aversion[1] ); } + return true; } + return false; } @@ -653,6 +705,7 @@ function checkBrowserOpera() { } $this->_browser_name = $this->BROWSER_OPERA_MINI; $this->setMobile( true ); + return true; } elseif ( stripos( $this->_agent, 'opera' ) !== false ) { $resultant = stristr( $this->_agent, 'opera' ); @@ -667,8 +720,10 @@ function checkBrowserOpera() { $this->setVersion( isset( $aversion[1] ) ? $aversion[1] : '' ); } $this->_browser_name = $this->BROWSER_OPERA; + return true; } + return false; } @@ -683,8 +738,10 @@ function checkBrowserChrome() { $aversion = explode( ' ', $aresult[1] ); $this->setVersion( $aversion[0] ); $this->setBrowser( $this->BROWSER_CHROME ); + return true; } + return false; } @@ -700,8 +757,10 @@ function checkBrowserWebTv() { $aversion = explode( ' ', $aresult[1] ); $this->setVersion( $aversion[0] ); $this->setBrowser( $this->BROWSER_WEBTV ); + return true; } + return false; } @@ -716,8 +775,10 @@ function checkBrowserNetPositive() { $aversion = explode( ' ', $aresult[1] ); $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) ); $this->setBrowser( $this->BROWSER_NETPOSITIVE ); + return true; } + return false; } @@ -732,8 +793,10 @@ function checkBrowserGaleon() { $aversion = explode( '/', $aresult[0] ); $this->setVersion( $aversion[1] ); $this->setBrowser( $this->BROWSER_GALEON ); + return true; } + return false; } @@ -748,8 +811,10 @@ function checkBrowserKonqueror() { $aversion = explode( '/', $aresult[0] ); $this->setVersion( $aversion[1] ); $this->setBrowser( $this->BROWSER_KONQUEROR ); + return true; } + return false; } @@ -763,8 +828,10 @@ function checkBrowserIcab() { $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) ); $this->setVersion( $aversion[1] ); $this->setBrowser( $this->BROWSER_ICAB ); + return true; } + return false; } @@ -779,8 +846,10 @@ function checkBrowserOmniWeb() { $aversion = explode( ' ', isset( $aresult[1] ) ? $aresult[1] : '' ); $this->setVersion( $aversion[0] ); $this->setBrowser( $this->BROWSER_OMNIWEB ); + return true; } + return false; } @@ -794,8 +863,10 @@ function checkBrowserPhoenix() { $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) ); $this->setVersion( $aversion[1] ); $this->setBrowser( $this->BROWSER_PHOENIX ); + return true; } + return false; } @@ -809,8 +880,10 @@ function checkBrowserFirebird() { $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) ); $this->setVersion( $aversion[1] ); $this->setBrowser( $this->BROWSER_FIREBIRD ); + return true; } + return false; } @@ -824,12 +897,15 @@ function checkBrowserNetscapeNavigator9Plus() { if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) { $this->setVersion( $matches[1] ); $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR ); + return true; } elseif ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) { $this->setVersion( $matches[1] ); $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR ); + return true; } + return false; } @@ -842,8 +918,10 @@ function checkBrowserShiretoko() { if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) { $this->setVersion( $matches[1] ); $this->setBrowser( $this->BROWSER_SHIRETOKO ); + return true; } + return false; } @@ -856,8 +934,10 @@ function checkBrowserIceCat() { if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) { $this->setVersion( $matches[1] ); $this->setBrowser( $this->BROWSER_ICECAT ); + return true; } + return false; } @@ -875,8 +955,10 @@ function checkBrowserNokia() { $this->setBrowser( $this->BROWSER_NOKIA ); } $this->setMobile( true ); + return true; } + return false; } @@ -890,13 +972,16 @@ function checkBrowserFirefox() { if ( preg_match( '/Firefox[\/ \(]([^ ;\)]+)/i', $this->_agent, $matches ) ) { $this->setVersion( $matches[1] ); $this->setBrowser( $this->BROWSER_FIREFOX ); + return true; } elseif ( preg_match( '/Firefox$/i', $this->_agent, $matches ) ) { $this->setVersion( '' ); $this->setBrowser( $this->BROWSER_FIREFOX ); + return true; } } + return false; } @@ -911,10 +996,13 @@ function checkBrowserIceweasel() { $aversion = explode( ' ', $aresult[1] ); $this->setVersion( $aversion[0] ); $this->setBrowser( $this->BROWSER_ICEWEASEL ); + return true; } + return false; } + /** * Determine if the browser is Mozilla or not (last updated 1.7) * @@ -926,17 +1014,21 @@ function checkBrowserMozilla() { preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion ); $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); $this->setBrowser( $this->BROWSER_MOZILLA ); + return true; } elseif ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { $aversion = explode( '', stristr( $this->_agent, 'rv:' ) ); $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); $this->setBrowser( $this->BROWSER_MOZILLA ); + return true; } elseif ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) { $this->setVersion( $matches[1] ); $this->setBrowser( $this->BROWSER_MOZILLA ); + return true; } + return false; } @@ -951,8 +1043,10 @@ function checkBrowserLynx() { $aversion = explode( ' ', ( isset( $aresult[1] ) ? $aresult[1] : '' ) ); $this->setVersion( $aversion[0] ); $this->setBrowser( $this->BROWSER_LYNX ); + return true; } + return false; } @@ -967,8 +1061,10 @@ function checkBrowserAmaya() { $aversion = explode( ' ', $aresult[1] ); $this->setVersion( $aversion[0] ); $this->setBrowser( $this->BROWSER_AMAYA ); + return true; } + return false; } @@ -987,8 +1083,10 @@ function checkBrowserSafari() { $this->setVersion( $this->VERSION_UNKNOWN ); } $this->setBrowser( $this->BROWSER_SAFARI ); + return true; } + return false; } @@ -1008,8 +1106,10 @@ function checkBrowseriPhone() { } $this->setMobile( true ); $this->setBrowser( $this->BROWSER_IPHONE ); + return true; } + return false; } @@ -1029,8 +1129,10 @@ function checkBrowseriPad() { } $this->setMobile( true ); $this->setBrowser( $this->BROWSER_IPAD ); + return true; } + return false; } @@ -1050,8 +1152,10 @@ function checkBrowseriPod() { } $this->setMobile( true ); $this->setBrowser( $this->BROWSER_IPOD ); + return true; } + return false; } @@ -1071,8 +1175,10 @@ function checkBrowserAndroid() { } $this->setMobile( true ); $this->setBrowser( $this->BROWSER_ANDROID ); + return true; } + return false; } diff --git a/includes/views/admin-page.php b/includes/views/admin-page.php index d716d07b..cacdb034 100644 --- a/includes/views/admin-page.php +++ b/includes/views/admin-page.php @@ -13,7 +13,8 @@   get( 'go_back_url' ) ) : ?> - output( 'go_back_button_text' ); ?> + output( 'go_back_button_text' ); ?>   get( 'submit_button_text' ), 'primary large', 'submit', false ); ?> diff --git a/includes/views/bulk-edit-field.php b/includes/views/bulk-edit-field.php index f399c910..0b15f7ba 100644 --- a/includes/views/bulk-edit-field.php +++ b/includes/views/bulk-edit-field.php @@ -2,5 +2,6 @@ output( 'refresh_link' ); ?>

              - +

              diff --git a/includes/views/gc-items-list.php b/includes/views/gc-items-list.php index 0999ac70..3ad6d271 100644 --- a/includes/views/gc-items-list.php +++ b/includes/views/gc-items-list.php @@ -1,6 +1,8 @@ - + diff --git a/includes/views/gc-post-column-row.php b/includes/views/gc-post-column-row.php index e068026d..ec2394e5 100644 --- a/includes/views/gc-post-column-row.php +++ b/includes/views/gc-post-column-row.php @@ -1,11 +1,13 @@ - + get( 'status_name' ) ) : ?>
              - get( 'status_color' ) ) : ?> - gc-status-color-white" style="background-color:output( 'status_color' ); ?>;" data-id="output( 'status_id' ); ?>"> + gc-status-color-white" style="background-color:output( 'status_color' ); ?>;" + data-id="output( 'status_id' ); ?>"> output( 'status_name' ); ?>
              diff --git a/includes/views/graceful-degradation.php b/includes/views/graceful-degradation.php index 43191712..6d259e82 100644 --- a/includes/views/graceful-degradation.php +++ b/includes/views/graceful-degradation.php @@ -1,3 +1,3 @@
              -

              +

              diff --git a/includes/views/metabox.php b/includes/views/metabox.php index 2ed1b96a..3f3d6c1a 100644 --- a/includes/views/metabox.php +++ b/includes/views/metabox.php @@ -1,14 +1,18 @@ - "; +// echo "<# console.log( 'data', data ); #>"; diff --git a/includes/views/tmpl-gc-mapping-tab-row.php b/includes/views/tmpl-gc-mapping-tab-row.php index 45239f1e..5786dd7a 100644 --- a/includes/views/tmpl-gc-mapping-tab-row.php +++ b/includes/views/tmpl-gc-mapping-tab-row.php @@ -1,46 +1,58 @@ + * Component: Wrapper table - Open + ***********************************************/ ?> <# if ( data.typeName === 'component' ) { #> -<# } #> + <# } #> - - - - + - - - + + + + + <# index = index + 1; }); #> +
              class="gc-component gc-component-disabled column"<# } #>> - <# if ( ( data.limit && data.limit_type ) || data.instructions || data.typeName ) { #> - {{ JSON.stringify(data, null, 2) }}' ?> - <# if ( ( data.is_repeatable ) ) { #> + + + class="gc-component gc-component-disabled column"<# } #>> + <# if ( ( data.limit && data.limit_type ) || data.instructions || data.typeName ) { #> + {{ JSON.stringify(data, null, 2) }}' ?> + <# if ( ( data.is_repeatable ) ) { #> - <# } #> - {{ data.label }} {{ data.subtitle }} -
                - <# if ( data.typeName ) { #> -
              • {{ data.typeName }}
              • <# } #> + {{ + data.label }} {{ data.subtitle }} +
                  + <# if ( data.typeName ) { #> +
                • {{ data.typeName }}
                • + <# } #> - <# if ( data.limit && data.limit_type ) { #> -
                • {{ data.limit }} {{ data.limit_type }}
                • - <# } #> + <# if ( data.limit && data.limit_type ) { #> +
                • {{ data.limit }} {{ + data.limit_type }} +
                • + <# } #> - <# if ( data.instructions ) { #> -
                • {{ data.instructions }}
                • + <# if ( data.instructions ) { #> +
                • {{ data.instructions + }} +
                • + <# } #> +
                + <# } else { #> + {{ data.label }} <# } #> -
              - <# } else { #> - {{ data.label }} - <# } #>
              - + @@ -48,59 +60,70 @@ + * Component: Sub-Fields Row & Close Wrapper + ***********************************************/ ?> <# - var subfield_type_translate = { - 'text' : 'Rich Text', - 'text_rich' : 'Rich Text', - 'text_plain' : 'Plain Text', - 'choice_radio' : 'Muliple Choice', - 'choice_checkbox' : 'Checkboxes', - 'files' : 'Attachment', - 'attachment' : 'Attachment', - }; +var subfield_type_translate = { +'text' : 'Rich Text', +'text_rich' : 'Rich Text', +'text_plain' : 'Plain Text', +'choice_radio' : 'Muliple Choice', +'choice_checkbox' : 'Checkboxes', +'files' : 'Attachment', +'attachment' : 'Attachment', +}; #> <# if ( data.component ) { index = 1; #> -
              + +
              - - - <# _.each(data.component.fields, function(field) { #> - {{ JSON.stringify(data.component.fields[index], null, 2) }}' ?> - - + +
              - <# if ( field.metadata && field.metadata.repeatable && field.metadata.repeatable.isRepeatable ) { #> - - <# } #> - - {{ field.label }} {{ field.subtitle }} - - -
              + <# _.each(data.component.fields, function(field) { #> + {{ JSON.stringify(data.component.fields[index], null, 2) }}' ?> + + - - - - <# index = index + 1; }); #> -
              + <# if ( field.metadata && field.metadata.repeatable && field.metadata.repeatable.isRepeatable ) { #> + + <# } #> + + {{ field.label }} {{ field.subtitle }} + + + - -
              -
              + +
              + - - - + + + <# } #> diff --git a/includes/views/tmpl-gc-metabox-statuses.php b/includes/views/tmpl-gc-metabox-statuses.php index 21df0c58..fac74c3b 100644 --- a/includes/views/tmpl-gc-metabox-statuses.php +++ b/includes/views/tmpl-gc-metabox-statuses.php @@ -1,13 +1,19 @@ - + <# if ( data.status && data.status.display_name ) { #> - + + <# } else { #> diff --git a/includes/views/tmpl-gc-metabox.php b/includes/views/tmpl-gc-metabox.php index 0e9d7eba..96be7cee 100644 --- a/includes/views/tmpl-gc-metabox.php +++ b/includes/views/tmpl-gc-metabox.php @@ -1,9 +1,15 @@
              - <# if ( data.item ) { #><# } #>{{ data.itemName }}<# if ( data.item ) { #><# } #> + + <# if ( data.item ) { #><# + } #>{{ data.itemName }}<# if ( data.item ) { #><# } #>
              - args ); ?> + + args ); ?>
              @@ -15,12 +21,19 @@
              output( 'refresh_link' ); ?> - - - - + + + +
              "; +// echo "<# console.log( 'data', data ); #>"; diff --git a/includes/views/tmpl-gc-modal-window.php b/includes/views/tmpl-gc-modal-window.php index b3df32d9..04c50b9c 100644 --- a/includes/views/tmpl-gc-modal-window.php +++ b/includes/views/tmpl-gc-modal-window.php @@ -6,56 +6,61 @@ */ // echo "<# console.log( 'data', data ); #>"; ?> -
              - + -
              +
              -
              -
              - get( 'nav' ) as $url => $text ) { ?> - - - - +
              +
              + get( 'nav' ) as $url => $text ) { ?> + + + + +
              -
              -
              -

              - Content Workflow -

              -
              -
              +
              +

              + Content Workflow +

              +
              +
              - <# if ( data.navItems.length ) { #> -
              -
              - <# _.each( data.navItems, function( nav ) { #> - {{ nav.label }} - <# }); #> + <# if ( data.navItems.length ) { #> +
              +
              + <# _.each( data.navItems, function( nav ) { #> + {{ + nav.label }} + <# }); #> +
              -
              - <# } #> + <# } #> -
              - - +
              +
              + - args ); ?> - + - + - + - + - args ); ?> - -
              - checked="checked"<# } #> id="gc-select-all-1" type="checkbox"> + + checked="checked"<# } #> id="gc-select-all-1" + type="checkbox">
              @@ -64,35 +69,39 @@
              - checked="checked"<# } #> id="gc-select-all-2" type="checkbox"> + + checked="checked"<# } #> id="gc-select-all-2" + type="checkbox">
              -
              + + +
              -
              -
              -
              - <# if ( data.btns.length ) { _.each( data.btns, function( btn ) { #> - - <# }); } #> +
              +
              +
              + <# if ( data.btns.length ) { _.each( data.btns, function( btn ) { #> + + <# }); } #> +
              -
              -
              - +
              + +
              -
              "; +// echo "<# console.log( 'data', data ); #>"; diff --git a/includes/views/tmpl-gc-post-column-row.php b/includes/views/tmpl-gc-post-column-row.php index ed728fd9..46eb3af2 100644 --- a/includes/views/tmpl-gc-post-column-row.php +++ b/includes/views/tmpl-gc-post-column-row.php @@ -8,4 +8,4 @@ <# } #> "; +// echo "<# console.log( 'data', data ); #>"; diff --git a/includes/views/tmpl-gc-select2-item.php b/includes/views/tmpl-gc-select2-item.php index 64d80065..6e4f3b5b 100644 --- a/includes/views/tmpl-gc-select2-item.php +++ b/includes/views/tmpl-gc-select2-item.php @@ -1,7 +1,8 @@ {{ data.text }} <# if ( data.color ) { #> - + <# } #> <# if ( data.description ) { #> diff --git a/includes/views/tmpl-gc-status-select2.php b/includes/views/tmpl-gc-status-select2.php index c002d83e..3c4f404e 100644 --- a/includes/views/tmpl-gc-status-select2.php +++ b/includes/views/tmpl-gc-status-select2.php @@ -1,14 +1,17 @@ <# if ( data.statuses.length ) { #> - + <# } else { #> - + <# } #> "; +// echo "<# console.log( 'data', data ); #>"; diff --git a/includes/views/tmpl-gc-tab-wrapper.php b/includes/views/tmpl-gc-tab-wrapper.php index 922b35b4..fd56c057 100644 --- a/includes/views/tmpl-gc-tab-wrapper.php +++ b/includes/views/tmpl-gc-tab-wrapper.php @@ -1,12 +1,15 @@ -<# if ( data.label ) { #>{{ data.label }}<# } #> +<# if ( data.label ) { #> +{{ data.label }}<# } #> id="{{ data.table_id }}"<# } #>> - - - - - <# if ( data.col_headings.gcafter ) { #><# } #> - - - - + + + + + <# if ( data.col_headings.gcafter ) { #> + + <# } #> + + + +
              {{ data.col_headings.gc.label }}{{ data.col_headings.wp.label }}{{ data.col_headings.gcafter.label }}
              {{ data.col_headings.gc.label }}{{ data.col_headings.wp.label }}{{ data.col_headings.gcafter.label }}
              diff --git a/includes/views/tmpl-gc-table-nav.php b/includes/views/tmpl-gc-table-nav.php index 0f28f43f..07534761 100644 --- a/includes/views/tmpl-gc-table-nav.php +++ b/includes/views/tmpl-gc-table-nav.php @@ -1,7 +1,10 @@
              - {{ data.count }} + {{ data.count }} <# if ( data.selected ) { #> - | {{ data.selected }} + | {{ data.selected }} + <# } #>

              diff --git a/includes/views/tmpl-gc-table-search.php b/includes/views/tmpl-gc-table-search.php index a8a6e5ec..c0fe8143 100644 --- a/includes/views/tmpl-gc-table-search.php +++ b/includes/views/tmpl-gc-table-search.php @@ -1 +1,2 @@ - + diff --git a/includes/views/tmpl-gc-tabs-wrapper.php b/includes/views/tmpl-gc-tabs-wrapper.php index 4eb738ad..0eafcbbb 100644 --- a/includes/views/tmpl-gc-tabs-wrapper.php +++ b/includes/views/tmpl-gc-tabs-wrapper.php @@ -1,4 +1,5 @@
              -

              +

              diff --git a/includes/views/underscore-data-status.php b/includes/views/underscore-data-status.php index 102c1628..0e24dd54 100644 --- a/includes/views/underscore-data-status.php +++ b/includes/views/underscore-data-status.php @@ -1,2 +1,3 @@ - + {{ data.status_name ? data.status_name : ( data.status.display_name ?? 'N/A' ) }} diff --git a/includes/views/underscore-data-updated.php b/includes/views/underscore-data-updated.php index 6a9329de..bef49630 100644 --- a/includes/views/underscore-data-updated.php +++ b/includes/views/underscore-data-updated.php @@ -1,6 +1,9 @@ <# if ( false === data.current || data.current ) { #> -
              Your mapping was changed, please reimport.
              -{{{ data.updated_at }}} +
              Your mapping was changed, please + reimport. +
              +{{{ data.updated_at }}} <# } else { #> - {{{ data.updated_at }}} +{{{ data.updated_at }}} <# } #> diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a444c41d..25b1167b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,8 +14,8 @@ - - - + + + diff --git a/tasks/build.js b/tasks/build.js index a20a12e6..a4a264c7 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -1,3 +1,3 @@ module.exports = function (grunt) { - grunt.registerTask( 'build', ['css', 'js',/* 'clean', 'copy',*/ 'compress'] ); + grunt.registerTask('build', ['css', 'js',/* 'clean', 'copy',*/ 'compress']); }; diff --git a/tasks/css.js b/tasks/css.js index 79ecfa1d..f427dc49 100644 --- a/tasks/css.js +++ b/tasks/css.js @@ -1,3 +1,3 @@ module.exports = function (grunt) { - grunt.registerTask( 'css', ['sass', 'postcss', 'cssmin'] ); -}; \ No newline at end of file + grunt.registerTask('css', ['sass', 'postcss', 'cssmin']); +}; diff --git a/tasks/default.js b/tasks/default.js index 2af9cbe0..7ba5999b 100644 --- a/tasks/default.js +++ b/tasks/default.js @@ -1,3 +1,3 @@ module.exports = function (grunt) { - grunt.registerTask( 'default', ['css', 'js', 'compress'] ); + grunt.registerTask('default', ['css', 'js', 'compress']); }; diff --git a/tasks/js.js b/tasks/js.js index d11a550a..3131ec88 100644 --- a/tasks/js.js +++ b/tasks/js.js @@ -1,3 +1,3 @@ module.exports = function (grunt) { - grunt.registerTask( 'js', ['jshint', 'browserify', 'uglify'] ); + grunt.registerTask('js', ['jshint', 'browserify', 'uglify']); }; diff --git a/tasks/options/browserify.js b/tasks/options/browserify.js index cba92625..b09ad506 100644 --- a/tasks/options/browserify.js +++ b/tasks/options/browserify.js @@ -7,12 +7,14 @@ module.exports = { 'browserify-shim' ] }, - dist: { files: { - 'assets/js/gathercontent.js' : 'assets/js/src/components/main.js', - 'assets/js/gathercontent-general.js' : 'assets/js/src/components/general.js', - 'assets/js/gathercontent-single.js' : 'assets/js/src/components/single.js', - 'assets/js/gathercontent-mapping.js' : 'assets/js/src/components/mapping.js', - 'assets/js/gathercontent-database.js' : 'assets/js/src/components/database.js', - 'assets/js/gathercontent-sync.js' : 'assets/js/src/components/sync.js' - } } + dist: { + files: { + 'assets/js/gathercontent.js': 'assets/js/src/components/main.js', + 'assets/js/gathercontent-general.js': 'assets/js/src/components/general.js', + 'assets/js/gathercontent-single.js': 'assets/js/src/components/single.js', + 'assets/js/gathercontent-mapping.js': 'assets/js/src/components/mapping.js', + 'assets/js/gathercontent-database.js': 'assets/js/src/components/database.js', + 'assets/js/gathercontent-sync.js': 'assets/js/src/components/sync.js' + } + } }; diff --git a/tasks/options/concat.js b/tasks/options/concat.js index 6db14eea..0d33c84d 100644 --- a/tasks/options/concat.js +++ b/tasks/options/concat.js @@ -1,16 +1,16 @@ module.exports = { options: { stripBanners: true, - banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' + - ' * <%= pkg.homepage %>\n' + - ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + - ' * Licensed GPL-2.0+' + - ' */\n' + banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' + + ' * <%= pkg.homepage %>\n' + + ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + + ' * Licensed GPL-2.0+' + + ' */\n' }, main: { src: [ 'assets/js/src/gathercontent.js' ], - dest: 'assets/js/gathercontent.js' + dest: 'assets/js/gathercontent.js' } }; diff --git a/tasks/options/copy.js b/tasks/options/copy.js index bcb0d99f..103e57b0 100644 --- a/tasks/options/copy.js +++ b/tasks/options/copy.js @@ -2,7 +2,7 @@ module.exports = { // Copy the theme to a versioned release directory main: { expand: true, - src: [ + src: [ '**', '!**/.*', '!**/readme.md', diff --git a/tasks/options/cssmin.js b/tasks/options/cssmin.js index 76e535f9..c57b20eb 100644 --- a/tasks/options/cssmin.js +++ b/tasks/options/cssmin.js @@ -1,10 +1,10 @@ module.exports = { options: { banner: '/*! <%= pkg.title %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>' + - ' | <%= pkg.homepage %>' + - ' | Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' + - ' | Licensed <%= pkg.license %>' + - ' */\n' + ' | <%= pkg.homepage %>' + + ' | Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' + + ' | Licensed <%= pkg.license %>' + + ' */\n' }, minify: { expand: true, diff --git a/tasks/options/mocha.js b/tasks/options/mocha.js index 760c85e8..c52d8c32 100644 --- a/tasks/options/mocha.js +++ b/tasks/options/mocha.js @@ -2,7 +2,7 @@ var mochaPath = 'tests/mocha/'; module.exports = { test: { - src: [ mochaPath + '**/*.html' ], + src: [mochaPath + '**/*.html'], options: { run: true, timeout: 10000 diff --git a/tasks/options/postcss.js b/tasks/options/postcss.js index b0501206..c1454e1e 100644 --- a/tasks/options/postcss.js +++ b/tasks/options/postcss.js @@ -5,8 +5,8 @@ module.exports = { require('autoprefixer')({browsers: 'last 2 versions'}) ] }, - files: { - 'assets/css/gathercontent-importer.css': [ 'assets/css/gathercontent-importer.css' ] + files: { + 'assets/css/gathercontent-importer.css': ['assets/css/gathercontent-importer.css'] } } -}; \ No newline at end of file +}; diff --git a/tasks/options/uglify.js b/tasks/options/uglify.js index cf8a27a0..d8e7d127 100644 --- a/tasks/options/uglify.js +++ b/tasks/options/uglify.js @@ -1,19 +1,19 @@ module.exports = { all: { files: { - 'assets/js/gathercontent.min.js' : ['assets/js/gathercontent.js'], - 'assets/js/gathercontent-general.min.js' : ['assets/js/gathercontent-general.js'], - 'assets/js/gathercontent-single.min.js' : ['assets/js/gathercontent-single.js'], - 'assets/js/gathercontent-mapping.min.js' : ['assets/js/gathercontent-mapping.js'], - 'assets/js/gathercontent-database.min.js' : ['assets/js/gathercontent-database.js'], - 'assets/js/gathercontent-sync.min.js' : ['assets/js/gathercontent-sync.js'] + 'assets/js/gathercontent.min.js': ['assets/js/gathercontent.js'], + 'assets/js/gathercontent-general.min.js': ['assets/js/gathercontent-general.js'], + 'assets/js/gathercontent-single.min.js': ['assets/js/gathercontent-single.js'], + 'assets/js/gathercontent-mapping.min.js': ['assets/js/gathercontent-mapping.js'], + 'assets/js/gathercontent-database.min.js': ['assets/js/gathercontent-database.js'], + 'assets/js/gathercontent-sync.min.js': ['assets/js/gathercontent-sync.js'] }, options: { banner: '/*! <%= pkg.title %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>' + - ' | <%= pkg.homepage %>' + - ' | Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' + - ' | Licensed <%= pkg.license %>' + - ' */\n', + ' | <%= pkg.homepage %>' + + ' | Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' + + ' | Licensed <%= pkg.license %>' + + ' */\n', // mangle: { // except: ['jQuery'] // } diff --git a/tasks/options/watch.js b/tasks/options/watch.js index 0055d28a..f8beb391 100644 --- a/tasks/options/watch.js +++ b/tasks/options/watch.js @@ -14,8 +14,8 @@ module.exports = { }, js: { files: ['assets/js/src/components/**/*.js', 'assets/js/vendor/**/*.js'], - tasks: ['js'], - options: { + tasks: ['js'], + options: { debounceDelay: 500 } } diff --git a/tasks/test.js b/tasks/test.js index a92c7e3d..37084f34 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -1,3 +1,3 @@ module.exports = function (grunt) { - grunt.registerTask( 'test', ['phpunit', 'mocha'] ); + grunt.registerTask('test', ['phpunit', 'mocha']); }; diff --git a/tests/mocha/gathercontent-importer.html b/tests/mocha/gathercontent-importer.html index 3e73202e..2b979150 100644 --- a/tests/mocha/gathercontent-importer.html +++ b/tests/mocha/gathercontent-importer.html @@ -1,27 +1,27 @@ - - Mocha Tests - - - - -
              - - - - - + + Mocha Tests + + + + +
              + + + + + - + - - - - - + + + + + diff --git a/tests/mocha/tests/gathercontent-importer.js b/tests/mocha/tests/gathercontent-importer.js index 78a4e766..1362e20d 100644 --- a/tests/mocha/tests/gathercontent-importer.js +++ b/tests/mocha/tests/gathercontent-importer.js @@ -1,9 +1,9 @@ var assert = chai.assert; -describe( 'Array', function() { - it( 'should start empty', function() { +describe('Array', function () { + it('should start empty', function () { var arr = []; - assert.equal( arr.length, 0 ); - } ); -} ); + assert.equal(arr.length, 0); + }); +}); diff --git a/tests/phpunit/Core_Tests.php b/tests/phpunit/Core_Tests.php index b5f46411..267643b6 100644 --- a/tests/phpunit/Core_Tests.php +++ b/tests/phpunit/Core_Tests.php @@ -1,4 +1,5 @@ 1, - 'args' => array(), + 'times' => 1, + 'args' => array(), 'return' => 'en_US', ) ); \WP_Mock::onFilter( 'plugin_locale' )->with( 'en_US', 'gathercontent' )->reply( 'en_US' ); \WP_Mock::wpFunction( 'load_textdomain', array( 'times' => 1, - 'args' => array( 'gathercontent', 'lang_dir/gathercontent/gathercontent-en_US.mo' ), + 'args' => array( 'gathercontent', 'lang_dir/gathercontent/gathercontent-en_US.mo' ), ) ); \WP_Mock::wpFunction( 'plugin_basename', array( - 'times' => 1, - 'args' => array( 'path' ), + 'times' => 1, + 'args' => array( 'path' ), 'return' => 'path', ) ); \WP_Mock::wpFunction( 'load_plugin_textdomain', array( 'times' => 1, - 'args' => array( 'gathercontent', false, 'path/languages/' ), + 'args' => array( 'gathercontent', false, 'path/languages/' ), ) ); // Act diff --git a/tests/phpunit/test-tools/TestCase.php b/tests/phpunit/test-tools/TestCase.php index ecf91770..8356efaf 100644 --- a/tests/phpunit/test-tools/TestCase.php +++ b/tests/phpunit/test-tools/TestCase.php @@ -2,10 +2,11 @@ namespace GatherContent\Importer; +use PHPUnit\Util\Test; use Text_Template; use WP_Mock; -use PHPUnit\Util\Test; use WP_Mock\Tools\TestCase as BaseTestCase; + class TestCase extends BaseTestCase { protected $testFiles = array(); @@ -13,8 +14,8 @@ class TestCase extends BaseTestCase { public function setUp(): void { if ( ! empty( $this->testFiles ) ) { foreach ( $this->testFiles as $file ) { - if ( file_exists( dirname( __FILE__ ) . '/../../../includes/' . $file ) ) { - require_once( dirname( __FILE__ ) . '/../../../includes/' . $file ); + if ( file_exists( dirname( __FILE__ ) . '/../../../includes/' . $file ) ) { + require_once( dirname( __FILE__ ) . '/../../../includes/' . $file ); } } } @@ -23,19 +24,18 @@ public function setUp(): void { } /** - * Backported from PHPUnit 9.4 TestCase class. - * - * WP_Mock's TestCase expects that method to be present on {@see setUpContentFiltering()}. - * - * @return array - */ - public function getAnnotations() : array - { - return Test::parseTestMethodAnnotations( - static::class, - $this->getName(false) - ); - } + * Backported from PHPUnit 9.4 TestCase class. + * + * WP_Mock's TestCase expects that method to be present on {@see setUpContentFiltering()}. + * + * @return array + */ + public function getAnnotations(): array { + return Test::parseTestMethodAnnotations( + static::class, + $this->getName( false ) + ); + } public function assertActionsCalled() { $actions_not_added = $expected_actions = 0;