diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 42565efe..f50b23dc 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -46,6 +46,7 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Validate composer files run: | + composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true composer validate --strict composer.json # Check that dependencies resolve. composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction @@ -77,6 +78,7 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Install Dependencies run: | + composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true composer install --no-interaction --no-progress - name: PHPCS run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a7585d8..9003889e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,25 @@ before starting to add changes. Use example [placed in the end of the page](#exa ## [Unreleased] +- [OS-119] Keeping value of CPR clean, not adding address protection text +- Applied coding standards + +## [3.16.0-beta1] 2024-08-27 + +[#110](https://github.com/OS2Forms/os2forms/pull/110) + +- Obsolete module removing - os2forms_consent +- Obsolete module removing - webform_embed +- Obsolete module removing - field_color +- Obsolete patch removing - dynamic_entity_reference +- Obsolete patch removing - user_default_page +- Reduntand dependency removing - linkit +- Reduntand dependency removing - chosen +- Reduntand dependency removing - queue_ui +- Reduntand dependency removing - simple_ldap +- Reduntand dependency removing - webform_scheduled_tasks +- Drupal 10 compability fixes + ## [3.15.8] 2024-08-26 - [#127](https://github.com/OS2Forms/os2forms/pull/127) @@ -262,7 +281,8 @@ before starting to add changes. Use example [placed in the end of the page](#exa - Security in case of vulnerabilities. ``` -[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.15.8...HEAD +[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.16.0-beta1...HEAD +[3.16.0-beta1]: https://github.com/OS2Forms/os2forms/compare/3.15.8...3.16.0-beta1 [3.15.8]: https://github.com/OS2Forms/os2forms/compare/3.15.7...3.15.8 [3.15.7]: https://github.com/OS2Forms/os2forms/compare/3.15.6...3.15.7 [3.15.6]: https://github.com/OS2Forms/os2forms/compare/3.15.5...3.15.6 diff --git a/composer.json b/composer.json index 38ab90b0..b2ccef7e 100644 --- a/composer.json +++ b/composer.json @@ -23,25 +23,21 @@ "dompdf/dompdf": "^2.0", "drupal/admin_toolbar": "^3.0", "drupal/advancedqueue": "^1.0", - "drupal/chosen": "^2.10", - "drupal/ckeditor_a11ychecker": "^2.0@alpha", - "drupal/clientside_validation": "^3.0", + "drupal/clientside_validation": "^4.0", "drupal/coc_forms_auto_export": "^2.0@alpha", - "drupal/config_entity_revisions": "^1.7.0", + "drupal/config_entity_revisions": "dev-2.0.x", "drupal/diff": "^1.0", "drupal/embed": "^1.4", "drupal/entity_print": "^2.1", "drupal/eu_cookie_compliance": "^1.8", - "drupal/events_logging": "^1.5", - "drupal/header_and_footer_scripts": "^3.0", + "drupal/events_logging": "^2.0@beta", "drupal/honeypot": "^2.0", "drupal/image_widget_crop": "^2.3", "drupal/ldap": "^4.2", "drupal/ldap_auth": "^1.17", "drupal/leaflet": "^10.0", "drupal/leaflet_layers": "^1.1", - "drupal/libraries": "^3.0@beta", - "drupal/linkit": "^5.0", + "drupal/libraries": "^4.0", "drupal/logging_alerts": "^2.0", "drupal/maestro": "^3.1", "drupal/mailsystem": "^4.1", @@ -49,42 +45,40 @@ "drupal/pathauto": "^1.5", "drupal/permissions_by_term": "^3.1 || ^2.25", "drupal/queue_mail": "^1.4", - "drupal/queue_ui": "^2.1", "drupal/r4032login": "^2.1", "drupal/redirect": "^1.4", - "drupal/simple_ldap": "^1.0@alpha", - "drupal/simplesamlphp_auth": "^3.2", + "drupal/simplesamlphp_auth": "^4.0", "drupal/smtp": "^1.0@beta", "drupal/sodium": "^2.4", "drupal/switch_page_theme": "^4.0", "drupal/telephone_validation": "^2.2", "drupal/token": "^1.5", "drupal/ultimate_cron": "^2.0.0", - "drupal/user_default_page": "^2.1", + "drupal/user_default_page": "^9.0", "drupal/webform": "^6.1", "drupal/webform_composite": "^1.0@RC", "drupal/webform_encrypt": "^2.0@alpha", - "drupal/webform_migrate": "^1.1", + "drupal/webform_migrate": "^2.0@alpha", "drupal/webform_node_element": "^1.2", - "drupal/webform_remote_handlers": "^1.6.0", + "drupal/webform_remote_handlers": "^3.0", "drupal/webform_remote_select": "^1.0.6", "drupal/webform_rest": "^4.0.0-beta2", - "drupal/webform_scheduled_tasks": "^2.0", "drupal/webform_validation": "^2.0", "drupal/webform_views": "^5.0@alpha", - "drupal/workflow_participants": "^2.4", + "drupal/workflow_participants": "^3.0@RC", "http-interop/http-factory-guzzle": "^1.0.0", "itk-dev/beskedfordeler-drupal": "^1.0", - "itk-dev/serviceplatformen": "dev-feature/guzzle6-adapter as 1.5", + "itk-dev/serviceplatformen": "^1.5", "os2web/os2web_datalookup": "^1.5", "os2web/os2web_nemlogin": "^1.0", - "php-http/guzzle6-adapter": "^2.0", + "php-http/guzzle7-adapter": "^1.0", "phpoffice/phpword": "^0.18.2", "symfony/options-resolver": "^5.4 || ^6.0", "tecnickcom/tcpdf": "~6", "webmozart/path-util": "^2.3", "wsdltophp/packagebase": "^5.0", - "zaporylie/composer-drupal-optimizations": "^1.2" + "zaporylie/composer-drupal-optimizations": "^1.2", + "mglaman/composer-drupal-lenient": "^1.0" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", @@ -107,19 +101,24 @@ "Unlock possibility of using Entity print module export to Word": "https://www.drupal.org/files/issues/2020-02-29/3096552-6.patch", "Webform computed element post save alter": "https://www.drupal.org/files/issues/2024-06-25/webform_computed_post_save_field_alter.patch" }, - "drupal/user_default_page": { - "Warning: in_array() expects parameter 2 to be array, null given in user_default_page_user_logout() (https://www.drupal.org/node/3246986)": "https://www.drupal.org/files/issues/2021-11-01/user_default_page-3246986-2.patch" - }, "drupal/coc_forms_auto_export": { - "3240592 - Problem with phpseclib requirement in 2.x (https://www.drupal.org/project/coc_forms_auto_export/issues/3240592)": "https://www.drupal.org/files/issues/2021-10-04/requirement-namespace-3240592-1.patch" + "3240592 - Problem with phpseclib requirement in 2.x (https://www.drupal.org/project/coc_forms_auto_export/issues/3240592)": "https://www.drupal.org/files/issues/2021-10-04/requirement-namespace-3240592-1.patch", + "3286562 - Automated Drupal 10 compatibility fixes" : "https://www.drupal.org/files/issues/2022-06-15/coc_forms_auto_export.2.0.x-dev.rector.patch", + "3259009 - PHP Warnings/Notices on Download Page" : "https://git.drupalcode.org/project/coc_forms_auto_export/-/merge_requests/1.diff" }, - "drupal/dynamic_entity_reference": { - "entityQuery reference JOINs should specify target_type (https://www.drupal.org/project/dynamic_entity_reference/issues/3120952#comment-14141038)": "https://www.drupal.org/files/issues/2021-06-22/entityquery-reference-joins-should-specify-target_type-3120952-24.patch" + "drupal/webform_node_element": { + "3290637 - Automated Drupal 10 compatibility fixes": "https://www.drupal.org/files/issues/2023-05-12/webform_node_element_d10-3290637-11.patch" }, "drupal/webform_encrypt": { "Ensure data is base64 encoded (https://www.drupal.org/project/webform_encrypt/issues/3399414)": "https://git.drupalcode.org/project/webform_encrypt/-/merge_requests/4.patch", "PHP Warning if unserialize fails (https://www.drupal.org/project/webform_encrypt/issues/3292305)": "https://www.drupal.org/files/issues/2022-06-23/unserialize-php-notice.patch" } + }, + "drupal-lenient": { + "allowed-list": [ + "drupal/coc_forms_auto_export", + "drupal/webform_node_element" + ] } }, "scripts": { @@ -150,7 +149,8 @@ "phpstan/extension-installer": true, "simplesamlphp/composer-module-installer": true, "vaimo/composer-patches": true, - "zaporylie/composer-drupal-optimizations": true + "zaporylie/composer-drupal-optimizations": true, + "mglaman/composer-drupal-lenient": true } } } diff --git a/modules/os2forms_attachment/os2forms_attachment.info.yml b/modules/os2forms_attachment/os2forms_attachment.info.yml index 55a3d2bb..1687014f 100644 --- a/modules/os2forms_attachment/os2forms_attachment.info.yml +++ b/modules/os2forms_attachment/os2forms_attachment.info.yml @@ -2,8 +2,7 @@ name: 'OS2forms Attachment' type: module description: 'Provides OS2forms attachment field' package: OS2Forms -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'drupal:os2forms' diff --git a/modules/os2forms_attachment/src/Form/AttachmentComponentForm.php b/modules/os2forms_attachment/src/Form/AttachmentComponentForm.php index 05dd93a6..2a096e31 100644 --- a/modules/os2forms_attachment/src/Form/AttachmentComponentForm.php +++ b/modules/os2forms_attachment/src/Form/AttachmentComponentForm.php @@ -133,6 +133,7 @@ public function save(array $form, FormStateInterface $form_state) { public function exists($id) { $entity = $this->entityTypeManager->getStorage('os2forms_attachment_component') ->getQuery() + ->accessCheck(FALSE) ->condition('id', $id) ->execute(); return (bool) $entity; diff --git a/modules/os2forms_autocomplete/os2forms_autocomplete.info.yml b/modules/os2forms_autocomplete/os2forms_autocomplete.info.yml index 007fa23e..22db8a02 100644 --- a/modules/os2forms_autocomplete/os2forms_autocomplete.info.yml +++ b/modules/os2forms_autocomplete/os2forms_autocomplete.info.yml @@ -2,8 +2,7 @@ name: 'OS2forms Autocomplete' type: module description: 'Provides autocomplete field' package: OS2Forms -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'drupal:os2forms' diff --git a/modules/os2forms_autocomplete/src/Plugin/WebformElement/AutocompleteElement.php b/modules/os2forms_autocomplete/src/Plugin/WebformElement/AutocompleteElement.php index 56411df8..71985177 100644 --- a/modules/os2forms_autocomplete/src/Plugin/WebformElement/AutocompleteElement.php +++ b/modules/os2forms_autocomplete/src/Plugin/WebformElement/AutocompleteElement.php @@ -38,7 +38,7 @@ protected function defineDefaultProperties() { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { parent::prepare($element, $webform_submission); if (isset($element['#webform_key'])) { diff --git a/modules/os2forms_consent/README.md b/modules/os2forms_consent/README.md deleted file mode 100644 index 45c89fca..00000000 --- a/modules/os2forms_consent/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# OS2forms Consent Drupal module - -## Module purpose -The aim of this module is to provide integration consent provider. - -## How does it work - - diff --git a/modules/os2forms_consent/os2forms_consent.info.yml b/modules/os2forms_consent/os2forms_consent.info.yml deleted file mode 100644 index b636d113..00000000 --- a/modules/os2forms_consent/os2forms_consent.info.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'OS2forms Declaration of Consent' -type: module -description: 'Provides Consent.' -package: OS2Forms -core: 8.x -core_version_requirement: ^8 || ^9 - -dependencies: - - 'drupal:os2forms' - - 'drupal:os2forms_nemid' - - 'drupal:os2web_datalookup' - - 'drupal:serialization' diff --git a/modules/os2forms_consent/os2forms_consent.module b/modules/os2forms_consent/os2forms_consent.module deleted file mode 100644 index 71bcdd69..00000000 --- a/modules/os2forms_consent/os2forms_consent.module +++ /dev/null @@ -1,89 +0,0 @@ -getSourceProperty('nid'); - $default = $source->getDatabase()->select('os2forms_frontend_webform_settings', 'of') - ->fields('of') - ->condition('nid', $nid, '=') - ->condition('submodule', 'os2forms_consent', '=') - ->execute() - ->fetchAssoc(); - - if (empty($default['data'])) { - return; - } - - $query = $source->getDatabase()->select('webform_component', 'wc'); - $query->fields('wc', [ - 'pid', - 'form_key', - ]); - $components = $query->condition('nid', $nid)->execute(); - $keys = []; - foreach ($components as $component) { - $keys[$component->form_key] = $component->form_key . ($component->pid ? '_' . $component->pid : ''); - } - - $data = unserialize($default['data'], ['allowed_classes' => FALSE]); - $os2forms_consent = []; - $properties = [ - 'os2formsId', - 'kle', - 'sagSkabelonId', - 'nemid_cpr', - 'nemid_name', - 'nemid_address', - 'nemid_zipcode', - 'nemid_city', - 'bodyText', - ]; - foreach ($properties as $property) { - $os2forms_consent['#' . $property . '_custom'] = ''; - if (!empty($data[$property])) { - $value = $data[$property]; - if ($value == 'custom') { - $os2forms_consent['#' . $property . '_custom'] = Yaml::dump($data[$property . '_custom'], 2, 1); - $os2forms_consent['#' . $property] = '_custom_'; - } - else { - $os2forms_consent['#' . $property] = $keys[$value]; - } - } - } - - if (!empty($data['MaaSendesTilDFF'])) { - $os2forms_consent['#MaaSendesTilDFF'] = $data['MaaSendesTilDFF']; - } - - if (!empty($os2forms_consent)) { - $markup = "webform_attachment_os2forms_consent_xml:\n"; - $markup .= " '#title': 'Consent Attachment'\n"; - $markup .= " '#type': webform_attachment_os2forms_consent_xml\n"; - foreach ($os2forms_consent as $key => $value) { - $markup .= " '$key': $value\n"; - } - $elements = $row->getSourceProperty('elements'); - $elements .= $markup; - $row->setSourceProperty('elements', $elements); - - $dependencies = $row->getDestinationProperty('dependencies'); - if (empty($dependencies) || !array_search('os2forms', $dependencies)) { - $dependencies['module'][] = 'os2forms'; - $row->setDestinationProperty('dependencies', $dependencies); - } - } - -} diff --git a/modules/os2forms_consent/src/Element/WebformAttachmentConsentXml.php b/modules/os2forms_consent/src/Element/WebformAttachmentConsentXml.php deleted file mode 100644 index 9f7eaa6f..00000000 --- a/modules/os2forms_consent/src/Element/WebformAttachmentConsentXml.php +++ /dev/null @@ -1,296 +0,0 @@ -createDefaultInstanceByGroup('cpr_lookup'); - - if (!empty($nemid_cpr) && $cprPlugin->isReady()) { - $cprResult = $cprPlugin->lookup($nemid_cpr); - if ($cprResult->isSuccessful()) { - $nemid_name = htmlspecialchars($cprResult->getName()); - } - } - /** @var \Drupal\os2web_datalookup\Plugin\DataLookupManager $pluginManager */ - $pluginManager = \Drupal::service('plugin.manager.os2web_datalookup'); - /** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCompany $cvrPlugin */ - $cvrPlugin = $pluginManager->createDefaultInstanceByGroup('cvr_lookup'); - - if (!empty($nemid_com_cvr) && $cvrPlugin->isReady()) { - $cvrResult = $cvrPlugin->lookup($nemid_com_cvr); - - if ($cvrResult->isSuccessful()) { - $nemid_name = htmlspecialchars($cvrResult->getName()); - } - } - - $config = self::getElementConfiguration($element); - $nemid_cpr_mapping_value = self::getConfigurationValue('nemid_cpr', $config, $webform_submission); - $nemid_name_mapping_value = self::getConfigurationValue('nemid_name', $config, $webform_submission); - - if ($nemid_cpr_mapping_value && $nemid_cpr_mapping_value != 'default_nemid_value') { - $nemid_cpr = $nemid_cpr_mapping_value; - } - if ($nemid_name_mapping_value && $nemid_name_mapping_value != 'default_nemid_value') { - $nemid_name = $nemid_name_mapping_value; - } - - $fields = self::getWebformElementsAsList($webform_submission); - - $structuredData = []; - foreach ($fields as $field_name => $field_value) { - // Taking care of the array values. - if (is_array($field_value)) { - $field_value = implode(', ', $field_value); - } - - $field_value = htmlspecialchars($field_value); - $structuredData[$field_name] = $field_value; - } - - $xml_data = [ - 'ID' => 'urn:uuid:333e4567-e89b-12d3-a456-426655440000', - 'Attestation' => [ - 'Format' => 'systembevis', - 'Underskriftstidspunkt' => '2022-07-30T12:30:06.0724725', - 'ViljestilkendegiverID' => 'urn:uuid:323e4567-e89b-12d3-a456-426655440000', - ], - 'ErklaeringHeader' => [ - 'Erklaeringsskabelon' => 'http//digst.dk/samtykke/skabeloner/personoplysninger/', - 'Adgangspolitik' => [ - 'Gruppe' => 'digikoebingKommuneogLaegehus', - 'Tilladelse' => 'laes', - ], - 'Administrator' => [ - 'Administratorrolle' => 'forretningsansvarlig', - 'Organisation' => [ - 'Identifikator' => [ - 'Vaerdi' => '6807115500826', - 'Klassifikation' => 'EAN', - ], - ], - ], - 'Aktoer' => [ - [ - 'ID' => 'urn:uuid:323e4567-e89b-12d3-a456-426655440000', - 'PaakraevetSignatur' => 'true', - 'Aktoerrolle' => 'viljestilkendegivelsessubjekt', - 'Person' => [ - 'Navn' => $nemid_name, - 'Identifikator' => [ - 'Vaerdi' => $nemid_cpr, - 'Klassifikation' => 'CPR', - ], - ], - ], - [ - 'ID' => 'urn:uuid:323e4567-e89b-12d3-a456-426655440000', - 'PaakraevetSignatur' => 'false', - 'Aktoerrolle' => 'viljetilkendegivelsesrekvirent', - 'Organisation' => [ - 'Identifikator' => [ - 'Vaerdi' => '11782812', - 'Klassifikation' => 'CVR', - ], - ], - ], - ], - 'Domaenekontekst' => [ - 'Forvaltningshandling' => [ - 'ForetrukkenTerm' => 'G01. Generelle sager', - 'Identifikator' => [ - 'Vaerdi' => '27.69.24', - 'Klassifikation' => 'KLE Online Marts 2022', - ], - ], - 'Sagskontekst' => [ - 'Titel' => 'Sag om revalidering', - 'Identifikator' => [ - 'Vaerdi' => 'rvle3473-dcce-31c7-a4dc-16395242974b', - 'Klassifikation' => 'Digikøbing kommune SagsID', - ], - ], - ], - 'Erklaeringsmetadata' => [ - 'Status' => 'gaeldende', - 'Titel' => 'Samtykke til indhentning og/eller videregivelse af personoplysninger', - ], - 'Viljestilkendegivelsestype' => 'samtykke', - ], - 'ErklaeringBody' => [ - 'ID' => 'urn:uuid:721a4565-e89b-12d3-a456-426655440000', - 'Erklaeringsobjekt' => [ - [ - 'Format' => 'pdf', - 'DokumentFil' => 'sg015_BJ2022.07.30.pdf', - ], - [ - 'Format' => 'tekst', - 'Tekst' => 'Jeg giver hermed mit samtykke til indhentning og deling af oplysninger fra egen læge og tidligere bopælskommune', - ], - [ - 'Format' => 'struktureret_data', - 'Maskinlaesbartindhold' => [ - 'StruktureretData' => $structuredData, - 'Stylesheet' => 'html', - ], - ], - ], - ], - ]; - - return \Drupal::service('serializer')->serialize($xml_data, 'xml', self::getXmlContext()); - } - - /** - * Retrieves configuration array from webform attachment element. - * - * @param array $element - * The webform attachment element. - * - * @return array - * Configuration array. - */ - public static function getElementConfiguration(array $element) { - $config = []; - foreach (WebformElementAttachmentConsentXml::getConsentDefaultProperties() as $key => $value) { - if (isset($element['#' . $key])) { - $config[$key] = $element['#' . $key]; - } - } - return $config; - } - - /** - * Gets first element by field type. - * - * @param string $type - * Element value type. - * @param \Drupal\webform\WebformSubmissionInterface $webform_submission - * A webform submission. - * - * @return mixed - * Submission value. - */ - protected static function getFirstValueByType($type, WebformSubmissionInterface $webform_submission) { - $webform = $webform_submission->getWebform(); - - $webform_elements = $webform->getElementsDecodedAndFlattened(); - - foreach ($webform_elements as $key => $webform_element) { - if ($webform_element['#type'] == $type) { - return $webform_submission->getElementData($key); - } - } - } - - /** - * Helper function the returns the list of the fields + values as an array. - * - * All field except the field with type markup (used for formatting) - * are returned. - * - * @param \Drupal\webform\WebformSubmissionInterface $webform_submission - * A webform submission. - * - * @return array - * Webform elements as simple array. - */ - protected static function getWebformElementsAsList(WebformSubmissionInterface $webform_submission) { - $nemid_cpr = self::getFirstValueByType('os2forms_nemid_cpr', $webform_submission); - $nemid_com_cvr = self::getFirstValueByType('os2forms_nemid_company_cvr', $webform_submission); - $webform = $webform_submission->getWebform(); - $data = $webform_submission->getData(); - $webform_elements = $webform->getElementsInitializedFlattenedAndHasValue(); - $elements_list = []; - foreach ($webform_elements as $key => $webform_element) { - $field_name = $key; - $field_name = preg_replace('/\W/', '_', $field_name); - $webform_element['#type']; - if ($webform_element['#type'] == 'markup') { - $elements_list[$field_name] = $webform_element['value']; - } - elseif ($data && isset($data[$key])) { - if ($webform_element['#type'] == 'os2forms_nemid_cpr') { - if (!empty($nemid_cpr) && empty($nemid_com_cvr)) { - $elements_list[$field_name] = $data[$key]; - } - } - else { - $elements_list[$field_name] = $data[$key]; - } - } - } - return $elements_list; - } - - /** - * Fetching element configuration value from configuration array. - * - * @param string $name - * Configuration name key. - * @param array $config - * Configuration array. - * @param \Drupal\webform\WebformSubmissionInterface $webform_submission - * A webform submission. - * - * @return string - * Element configuration value - */ - public static function getConfigurationValue($name, array $config, WebformSubmissionInterface $webform_submission) { - if ($config[$name] == 'default_nemid_value') { - return 'default_nemid_value'; - } - $data = $webform_submission->getData(); - if ($config[$name] != '_custom_') { - return isset($data[$config[$name]]) ? htmlspecialchars($data[$config[$name]]) : ''; - } - else { - return isset($config[$name . "_custom"]) ? htmlspecialchars($config[$name . "_custom"]) : ''; - } - } - -} diff --git a/modules/os2forms_consent/src/Plugin/WebformElement/WebformAttachmentConsentXml.php b/modules/os2forms_consent/src/Plugin/WebformElement/WebformAttachmentConsentXml.php deleted file mode 100644 index c7f01abb..00000000 --- a/modules/os2forms_consent/src/Plugin/WebformElement/WebformAttachmentConsentXml.php +++ /dev/null @@ -1,210 +0,0 @@ -elementManager = $container->get('plugin.manager.webform.element'); - return $instance; - } - - /** - * {@inheritdoc} - */ - public function getDefaultProperties() { - return array_merge(parent::getDefaultProperties(), $this->getConsentDefaultProperties()); - } - - /** - * Gets array of Consent plugin properties. - * - * @param bool $only_basic - * Flag to get only basic properties, without custom values. - * - * @return array - * Array of properties. - */ - public static function getConsentDefaultProperties($only_basic = FALSE) { - $basic_properties = [ - 'os2formsId' => '', - 'kle' => '', - 'sagSkabelonId' => '', - 'nemid_cpr' => '', - 'nemid_name' => '', - 'nemid_address' => '', - 'nemid_zipcode' => '', - 'nemid_city' => '', - 'bodyText' => '', - ]; - if ($only_basic) { - return $basic_properties; - } - - $properties = $basic_properties; - foreach ($basic_properties as $key => $value) { - $properties[$key . '_custom'] = ''; - } - $properties['MaaSendesTilDFF'] = ''; - $properties['filename'] = 'os2forms.xml'; - - return $properties; - } - - /** - * {@inheritdoc} - */ - protected function getConsentPropertyType($propertyName) { - $propertyTypes = [ - 'os2formsId' => 'textfield', - 'kle' => 'textfield', - 'sagSkabelonId' => 'textfield', - 'nemid_cpr' => 'nemid_field', - 'nemid_name' => 'nemid_field', - 'nemid_address' => 'nemid_field', - 'nemid_zipcode' => 'nemid_field', - 'nemid_city' => 'nemid_field', - 'bodyText' => 'textarea', - ]; - return $propertyTypes[$propertyName] ?? 'textfield'; - } - - /** - * {@inheritdoc} - */ - public function form(array $form, FormStateInterface $form_state) { - $form['consent_setting'] = [ - '#type' => 'fieldset', - '#title' => $this->t('Consent settings'), - ]; - - /** @var \Drupal\webform_ui\Form\WebformUiElementFormInterface $form_object */ - $form_object = $form_state->getFormObject(); - $form = parent::form($form, $form_state); - $webform = $form_object->getWebform(); - $elements = $webform->getElementsInitializedAndFlattened(); - $element_options = ['' => $this->t('None')]; - foreach ($elements as $element_key => $element) { - $element_plugin = $this->elementManager->getElementInstance($element); - $allowed_elements = [ - 'textfield', - 'select', - 'email', - 'os2forms_nemid_cpr', - 'os2forms_nemid_name', - 'os2forms_nemid_pid', - 'os2forms_nemid_address', - 'os2forms_nemid_coaddress', - 'os2forms_nemid_zipcode', - 'os2forms_nemid_city', - 'os2forms_nemid_company_cvr', - 'os2forms_nemid_company_name', - 'os2forms_nemid_company_address', - 'os2forms_nemid_company_city', - 'os2forms_nemid_company_rid', - 'date', - ]; - if (!$element_plugin->isInput($element) - || !isset($element['#type']) - || !in_array($element['#type'], $allowed_elements) - || $element_plugin->hasMultipleValues($element)) { - continue; - } - $element_options[$element_key] = (isset($element['#title'])) ? new FormattableMarkup('@title (@key)', [ - '@title' => $element['#title'], - '@key' => $element_key, - ]) : $element_key; - } - $element_options['_custom_'] = $this->t('Custom text ...'); - $nemid_field_element_options = array_merge( - [ - '' => $this->t('None'), - 'default_nemid_value' => $this->t('Get value from nemid'), - ], - $element_options - ); - - foreach ($this->getConsentDefaultProperties(TRUE) as $propertyName => $propertyDefauleValue) { - $options = $this->getConsentPropertyType($propertyName) == 'nemid_field' ? $nemid_field_element_options : $element_options; - $this->addConfigurationField($form, $propertyName, $propertyDefauleValue, $options, $this->getConsentPropertyType($propertyName)); - } - - $form['consent_setting']['MaaSendesTilDFF'] = [ - '#type' => 'select', - '#title' => $this->t('MaaSendesTilDFF value'), - '#options' => ['ja' => 'Ja', 'nej' => 'Nej'], - '#description' => $this->t('Select a value from form submitted fields or provide a custom static value'), - ]; - - return $form; - } - - /** - * Helper method that defines configuration field with custom value. - */ - protected function addConfigurationField(&$form, $field_name, $default, $components_options, $field_type = 'textfield') { - $fields = &$form['consent_setting']; - $fields[$field_name] = [ - '#type' => 'select', - '#title' => $this->t('@field_name value', ['@field_name' => $field_name]), - '#options' => $components_options, - '#description' => $this->t('Select a value from form submitted fields or provide a custom static value'), - ]; - if ($field_type == 'nemid_field' && empty($default[$field_name])) { - $fields[$field_name]['#default_value'] = 'default_nemid_value'; - } - if ($field_type == 'textfield' || $field_type == 'nemid_field') { - $fields[$field_name . '_custom'] = [ - '#type' => 'textfield', - '#title' => $this->t('@field_name custom text', ['@field_name' => $field_name]), - '#size' => 60, - '#maxlength' => 128, - '#states' => [ - 'visible' => [ - 'select[name="properties[' . $field_name . ']"]' => ['value' => '_custom_'], - ], - ], - '#description' => $this->t('Provide a custom static value'), - ]; - } - else { - $fields[$field_name . '_custom'] = [ - '#type' => 'textarea', - '#title' => $this->t('@field_name custom text', ['@field_name' => $field_name]), - '#states' => [ - 'visible' => [ - 'select[name="properties[' . $field_name . ']"]' => ['value' => '_custom_'], - ], - ], - '#description' => $this->t('Provide a custom static value'), - ]; - } - } - -} diff --git a/modules/os2forms_dawa/os2forms_dawa.info.yml b/modules/os2forms_dawa/os2forms_dawa.info.yml index e7b6d7ef..bab9de83 100644 --- a/modules/os2forms_dawa/os2forms_dawa.info.yml +++ b/modules/os2forms_dawa/os2forms_dawa.info.yml @@ -2,8 +2,7 @@ name: 'OS2forms DAWA' type: module description: 'Provides integration with Danish Addresses Web API (DAWA https://dawa.aws.dk) and provide address autocomplete fields.' package: OS2Forms -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'drupal:os2forms' diff --git a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementAddress.php b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementAddress.php index ac7ae6a6..93f809da 100644 --- a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementAddress.php +++ b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementAddress.php @@ -31,7 +31,7 @@ public function getDefaultProperties() { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { parent::prepare($element, $webform_submission); $element['#autocomplete_route_parameters']['remove_place_name'] = $element['#remove_place_name'] ?? FALSE; diff --git a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementAddressMatrikula.php b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementAddressMatrikula.php index 6394bd5b..5d211db0 100644 --- a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementAddressMatrikula.php +++ b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementAddressMatrikula.php @@ -36,7 +36,7 @@ public function getDefaultProperties() { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { parent::prepare($element, $webform_submission); $element['#webform_composite_elements']['address']['#remove_place_name'] = TRUE; diff --git a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php index 0e4de82e..e0877871 100644 --- a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php +++ b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php @@ -25,7 +25,7 @@ public function getDefaultProperties() { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { parent::prepare($element, $webform_submission); $element['#autocomplete_route_name'] = 'os2forms_dawa.element.autocomplete'; diff --git a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBlock.php b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBlock.php index 70ed5f90..cb0b832f 100644 --- a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBlock.php +++ b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBlock.php @@ -30,7 +30,7 @@ public function getDefaultProperties() { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { parent::prepare($element, $webform_submission); $element['#autocomplete_route_parameters']['remove_code'] = $element['#remove_code'] ?? FALSE; diff --git a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementMatrikula.php b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementMatrikula.php index 4714b21d..34654769 100644 --- a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementMatrikula.php +++ b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementMatrikula.php @@ -31,7 +31,7 @@ public function getDefaultProperties() { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { parent::prepare($element, $webform_submission); $element['#autocomplete_route_parameters']['remove_code'] = $element['#remove_code'] ?? FALSE; diff --git a/modules/os2forms_digital_post/modules/os2forms_digital_post_examples/os2forms_digital_post_examples.info.yml b/modules/os2forms_digital_post/modules/os2forms_digital_post_examples/os2forms_digital_post_examples.info.yml index 39db3823..3863214f 100644 --- a/modules/os2forms_digital_post/modules/os2forms_digital_post_examples/os2forms_digital_post_examples.info.yml +++ b/modules/os2forms_digital_post/modules/os2forms_digital_post_examples/os2forms_digital_post_examples.info.yml @@ -3,6 +3,6 @@ type: module description: 'Example forms for OS2Forms Digital Post.' package: 'OS2Forms' -core_version_requirement: ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'os2forms_digital_post:os2forms_digital_post' diff --git a/modules/os2forms_digital_post/os2forms_digital_post.info.yml b/modules/os2forms_digital_post/os2forms_digital_post.info.yml index 266ecf78..39ebe91c 100644 --- a/modules/os2forms_digital_post/os2forms_digital_post.info.yml +++ b/modules/os2forms_digital_post/os2forms_digital_post.info.yml @@ -2,7 +2,7 @@ name: 'OS2Forms Digital Post' type: module description: 'Provides integration to Print service provided by Serviceplatformen.' package: 'OS2Forms' -core_version_requirement: ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'beskedfordeler:beskedfordeler' - 'drupal:advancedqueue' diff --git a/modules/os2forms_digital_post/src/Drush/Commands/DigitalPostTestCommands.php b/modules/os2forms_digital_post/src/Drush/Commands/DigitalPostTestCommands.php index 8db7f4f1..248452a3 100644 --- a/modules/os2forms_digital_post/src/Drush/Commands/DigitalPostTestCommands.php +++ b/modules/os2forms_digital_post/src/Drush/Commands/DigitalPostTestCommands.php @@ -2,7 +2,7 @@ namespace Drupal\os2forms_digital_post\Drush\Commands; -use Drupal\Core\Serialization\Yaml; +use Drupal\Component\Serialization\Yaml; use Drupal\Core\Utility\Token; use Drupal\entity_print\Plugin\EntityPrintPluginManagerInterface; use Drupal\os2forms_digital_post\Helper\DigitalPostHelper; diff --git a/modules/os2forms_digital_post/src/Helper/CertificateLocatorHelper.php b/modules/os2forms_digital_post/src/Helper/CertificateLocatorHelper.php index 7c4d4117..10e6ac57 100644 --- a/modules/os2forms_digital_post/src/Helper/CertificateLocatorHelper.php +++ b/modules/os2forms_digital_post/src/Helper/CertificateLocatorHelper.php @@ -4,7 +4,7 @@ use Drupal\os2forms_digital_post\Exception\CertificateLocatorException; use GuzzleHttp\Client; -use Http\Adapter\Guzzle6\Client as GuzzleAdapter; +use Http\Adapter\Guzzle7\Client as GuzzleAdapter; use Http\Factory\Guzzle\RequestFactory; use ItkDev\AzureKeyVault\Authorisation\VaultToken; use ItkDev\AzureKeyVault\KeyVault\VaultSecret; diff --git a/modules/os2forms_digital_post/src/Helper/DigitalPostHelper.php b/modules/os2forms_digital_post/src/Helper/DigitalPostHelper.php index c51f0dee..9d3d3a87 100644 --- a/modules/os2forms_digital_post/src/Helper/DigitalPostHelper.php +++ b/modules/os2forms_digital_post/src/Helper/DigitalPostHelper.php @@ -11,8 +11,8 @@ use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCompany; use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCpr; use Drupal\webform\WebformSubmissionInterface; -use ItkDev\Serviceplatformen\Service\SF1601\Serializer; use ItkDev\Serviceplatformen\Service\SF1601\SF1601; +use ItkDev\Serviceplatformen\Service\SF1601\Serializer; use Oio\Fjernprint\ForsendelseI; use Psr\Log\LoggerInterface; use Psr\Log\LoggerTrait; @@ -55,7 +55,7 @@ public function __construct( * * @phpstan-return array */ - public function sendDigitalPost(string $type, Message $message, ?ForsendelseI $forsendelse, WebformSubmissionInterface $submission = NULL): array { + public function sendDigitalPost(string $type, Message $message, ?ForsendelseI $forsendelse, ?WebformSubmissionInterface $submission = NULL): array { $senderSettings = $this->settings->getSender(); $options = [ 'test_mode' => (bool) $this->settings->getTestMode(), @@ -76,6 +76,15 @@ public function sendDigitalPost(string $type, Message $message, ?ForsendelseI $f /** * {@inheritdoc} + * + * @param mixed $level + * The level. + * @param string $message + * The message. + * @param array $context + * The context. + * + * @phpstan-param array $context */ public function log($level, $message, array $context = []): void { $this->logger->log($level, $message, $context); diff --git a/modules/os2forms_digital_post/src/Helper/MeMoHelper.php b/modules/os2forms_digital_post/src/Helper/MeMoHelper.php index 769dcad9..3ec8b7ed 100644 --- a/modules/os2forms_digital_post/src/Helper/MeMoHelper.php +++ b/modules/os2forms_digital_post/src/Helper/MeMoHelper.php @@ -19,8 +19,8 @@ use Drupal\os2web_datalookup\LookupResult\CompanyLookupResult; use Drupal\os2web_datalookup\LookupResult\CprLookupResult; use Drupal\webform\WebformSubmissionInterface; -use ItkDev\Serviceplatformen\Service\SF1601\Serializer; use ItkDev\Serviceplatformen\Service\SF1601\SF1601; +use ItkDev\Serviceplatformen\Service\SF1601\Serializer; /** * MeMo helper. diff --git a/modules/os2forms_digital_post/src/Helper/SF1461Helper.php b/modules/os2forms_digital_post/src/Helper/SF1461Helper.php index 171abe1e..adc8a670 100644 --- a/modules/os2forms_digital_post/src/Helper/SF1461Helper.php +++ b/modules/os2forms_digital_post/src/Helper/SF1461Helper.php @@ -15,7 +15,7 @@ class SF1461Helper { * See "BeskedFåTilsendt" on * https://digitaliseringskataloget.dk/integration/sf1461. */ - public function buildResponseDocument(int $statusCode, string $errorMessage = NULL): \DOMDocument { + public function buildResponseDocument(int $statusCode, ?string $errorMessage = NULL): \DOMDocument { $xml = <<<'XML' diff --git a/modules/os2forms_digital_post/src/Helper/WebformHelperSF1601.php b/modules/os2forms_digital_post/src/Helper/WebformHelperSF1601.php index f3054f8b..fa0a0584 100644 --- a/modules/os2forms_digital_post/src/Helper/WebformHelperSF1601.php +++ b/modules/os2forms_digital_post/src/Helper/WebformHelperSF1601.php @@ -2,12 +2,12 @@ namespace Drupal\os2forms_digital_post\Helper; -use Drupal\advancedqueue\Entity\QueueInterface; -use Drupal\advancedqueue\Job; -use Drupal\advancedqueue\JobResult; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Logger\LoggerChannelInterface; +use Drupal\advancedqueue\Entity\QueueInterface; +use Drupal\advancedqueue\Job; +use Drupal\advancedqueue\JobResult; use Drupal\os2forms_digital_post\Exception\InvalidRecipientIdentifierElementException; use Drupal\os2forms_digital_post\Exception\RuntimeException; use Drupal\os2forms_digital_post\Exception\SubmissionNotFoundException; @@ -199,6 +199,15 @@ private function loadQueue(): QueueInterface { /** * {@inheritdoc} + * + * @param mixed $level + * The level. + * @param string $message + * The message. + * @param array $context + * The context. + * + * @phpstan-param array $context */ public function log($level, $message, array $context = []): void { $this->logger->log($level, $message, $context); diff --git a/modules/os2forms_digital_post/src/Plugin/AdvancedQueue/JobType/SendDigitalPostSF1601.php b/modules/os2forms_digital_post/src/Plugin/AdvancedQueue/JobType/SendDigitalPostSF1601.php index 3e9cd0a0..3952d333 100644 --- a/modules/os2forms_digital_post/src/Plugin/AdvancedQueue/JobType/SendDigitalPostSF1601.php +++ b/modules/os2forms_digital_post/src/Plugin/AdvancedQueue/JobType/SendDigitalPostSF1601.php @@ -2,10 +2,10 @@ namespace Drupal\os2forms_digital_post\Plugin\AdvancedQueue\JobType; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\advancedqueue\Job; use Drupal\advancedqueue\JobResult; use Drupal\advancedqueue\Plugin\AdvancedQueue\JobType\JobTypeBase; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\os2forms_digital_post\Helper\WebformHelperSF1601; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/modules/os2forms_encrypt/src/WebformOs2FormsEncryptSubmissionStorage.php b/modules/os2forms_encrypt/src/WebformOs2FormsEncryptSubmissionStorage.php index 4416f4ff..d23ee152 100644 --- a/modules/os2forms_encrypt/src/WebformOs2FormsEncryptSubmissionStorage.php +++ b/modules/os2forms_encrypt/src/WebformOs2FormsEncryptSubmissionStorage.php @@ -35,7 +35,7 @@ class WebformOs2FormsEncryptSubmissionStorage extends WebformEncryptSubmissionSt * * @see Drupal\webform\WebformSubmissionStorage::getColumns */ - public function getColumns(WebformInterface $webform = NULL, EntityInterface $source_entity = NULL, AccountInterface $account = NULL, $include_elements = TRUE) { + public function getColumns(?WebformInterface $webform = NULL, ?EntityInterface $source_entity = NULL, ?AccountInterface $account = NULL, $include_elements = TRUE) { if (!\Drupal::moduleHandler()->moduleExists('webform_revisions')) { return parent::getColumns($webform, $source_entity, $account, $include_elements); } diff --git a/modules/os2forms_fbs_handler/os2forms_fbs_handler.info.yml b/modules/os2forms_fbs_handler/os2forms_fbs_handler.info.yml index 53bba305..7d43a273 100644 --- a/modules/os2forms_fbs_handler/os2forms_fbs_handler.info.yml +++ b/modules/os2forms_fbs_handler/os2forms_fbs_handler.info.yml @@ -2,7 +2,7 @@ name: 'FBS Handler' type: module description: 'Provides integration to FBS.' package: 'OS2Forms' -core_version_requirement: ^8.8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'webform:webform' - 'advancedqueue:advancedqueue' diff --git a/modules/os2forms_fbs_handler/src/Plugin/AdvancedQueue/JobType/FbsCreateUser.php b/modules/os2forms_fbs_handler/src/Plugin/AdvancedQueue/JobType/FbsCreateUser.php index 2ed0908c..daf34793 100644 --- a/modules/os2forms_fbs_handler/src/Plugin/AdvancedQueue/JobType/FbsCreateUser.php +++ b/modules/os2forms_fbs_handler/src/Plugin/AdvancedQueue/JobType/FbsCreateUser.php @@ -2,12 +2,12 @@ namespace Drupal\os2forms_fbs_handler\Plugin\AdvancedQueue\JobType; -use Drupal\advancedqueue\Job; -use Drupal\advancedqueue\JobResult; -use Drupal\advancedqueue\Plugin\AdvancedQueue\JobType\JobTypeBase; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Logger\LoggerChannelInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\advancedqueue\Job; +use Drupal\advancedqueue\JobResult; +use Drupal\advancedqueue\Plugin\AdvancedQueue\JobType\JobTypeBase; use Drupal\os2forms_fbs_handler\Client\FBS; use Drupal\os2forms_fbs_handler\Client\Model\Guardian; use Drupal\os2forms_fbs_handler\Client\Model\Patron; diff --git a/modules/os2forms_fbs_handler/src/Plugin/WebformHandler/FbsWebformHandler.php b/modules/os2forms_fbs_handler/src/Plugin/WebformHandler/FbsWebformHandler.php index 2eaf0465..25625145 100644 --- a/modules/os2forms_fbs_handler/src/Plugin/WebformHandler/FbsWebformHandler.php +++ b/modules/os2forms_fbs_handler/src/Plugin/WebformHandler/FbsWebformHandler.php @@ -2,14 +2,14 @@ namespace Drupal\os2forms_fbs_handler\Plugin\WebformHandler; -use Drupal\advancedqueue\Entity\Queue; -use Drupal\advancedqueue\Job; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Logger\LoggerChannelInterface; use Drupal\Core\Render\RendererInterface; +use Drupal\advancedqueue\Entity\Queue; +use Drupal\advancedqueue\Job; use Drupal\os2forms_fbs_handler\Plugin\AdvancedQueue\JobType\FbsCreateUser; use Drupal\webform\Plugin\WebformHandlerBase; use Drupal\webform\WebformSubmissionConditionsValidatorInterface; diff --git a/modules/os2forms_forloeb/src/Controller/MaestroNotificationController.php b/modules/os2forms_forloeb/src/Controller/MaestroNotificationController.php index e60a51f8..c01185a2 100644 --- a/modules/os2forms_forloeb/src/Controller/MaestroNotificationController.php +++ b/modules/os2forms_forloeb/src/Controller/MaestroNotificationController.php @@ -57,6 +57,7 @@ public static function create(ContainerInterface $container) { public function preview(Request $request, WebformInterface $webform, string $handler, string $notification_type, string $content_type): array { $handler = $webform->getHandler($handler); $submissionIds = array_keys($this->webformSubmissionStorage->getQuery() + ->accessCheck() ->condition('webform_id', $webform->id()) ->sort('created', 'DESC') ->execute()); diff --git a/modules/os2forms_forloeb/src/MaestroHelper.php b/modules/os2forms_forloeb/src/MaestroHelper.php index f4d045b3..d2dd0c52 100644 --- a/modules/os2forms_forloeb/src/MaestroHelper.php +++ b/modules/os2forms_forloeb/src/MaestroHelper.php @@ -4,9 +4,6 @@ use DigitalPost\MeMo\Action; use DigitalPost\MeMo\EntryPoint; -use Drupal\advancedqueue\Entity\QueueInterface; -use Drupal\advancedqueue\Job; -use Drupal\advancedqueue\JobResult; use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Config\ConfigFactoryInterface; @@ -19,6 +16,9 @@ use Drupal\Core\Render\Markup; use Drupal\Core\Site\Settings; use Drupal\Core\Url; +use Drupal\advancedqueue\Entity\QueueInterface; +use Drupal\advancedqueue\Job; +use Drupal\advancedqueue\JobResult; use Drupal\entity_print\Plugin\EntityPrintPluginManagerInterface; use Drupal\maestro\Engine\MaestroEngine; use Drupal\maestro\Utility\TaskHandler; @@ -456,7 +456,7 @@ private function sendNotificationDigitalPost( * * @see self::renderHtml() */ - public function renderNotification(WebformSubmissionInterface $submission, string $handlerId, string $notificationType, array $templateTask, int $maestroQueueID, string $contentType = NULL): array { + public function renderNotification(WebformSubmissionInterface $submission, string $handlerId, string $notificationType, array $templateTask, int $maestroQueueID, ?string $contentType = NULL): array { $handler = $submission->getWebform()->getHandler($handlerId); $settings = $handler->getSettings(); diff --git a/modules/os2forms_forloeb/src/Plugin/AdvancedQueue/JobType/SendMeastroNotification.php b/modules/os2forms_forloeb/src/Plugin/AdvancedQueue/JobType/SendMeastroNotification.php index 7c236f61..1cf267de 100644 --- a/modules/os2forms_forloeb/src/Plugin/AdvancedQueue/JobType/SendMeastroNotification.php +++ b/modules/os2forms_forloeb/src/Plugin/AdvancedQueue/JobType/SendMeastroNotification.php @@ -2,10 +2,10 @@ namespace Drupal\os2forms_forloeb\Plugin\AdvancedQueue\JobType; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\advancedqueue\Job; use Drupal\advancedqueue\JobResult; use Drupal\advancedqueue\Plugin\AdvancedQueue\JobType\JobTypeBase; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\os2forms_forloeb\MaestroHelper; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroSelectContentTask.php b/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroSelectContentTask.php index 64141120..5991a0f2 100644 --- a/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroSelectContentTask.php +++ b/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroSelectContentTask.php @@ -207,6 +207,7 @@ public function getExecutableForm($modal, MaestroExecuteInteractive $parent) { // Query for all webforms. $webforms = []; $nids = \Drupal::entityQuery('node') + ->accessCheck(FALSE) ->condition('type', 'webform') ->execute(); $webform_nodes = Node::loadMultiple($nids); diff --git a/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformInheritTask.php b/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformInheritTask.php index 8bd0040e..9544cee5 100644 --- a/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformInheritTask.php +++ b/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformInheritTask.php @@ -30,7 +30,7 @@ class MaestroWebformInheritTask extends MaestroWebformTask { * [1] - is the queue ID * The processID and queueID properties are defined in the MaestroTaskTrait. */ - public function __construct(array $configuration = NULL) { + public function __construct(?array $configuration = NULL) { if (is_array($configuration)) { $this->processID = $configuration[0]; $this->queueID = $configuration[1]; diff --git a/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformMultipleTask.php b/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformMultipleTask.php index 22c26a71..71a31155 100644 --- a/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformMultipleTask.php +++ b/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformMultipleTask.php @@ -27,7 +27,7 @@ class MaestroWebformMultipleTask extends MaestroWebformTask { * [1] - is the queue ID * The processID and queueID properties are defined in the MaestroTaskTrait. */ - public function __construct(array $configuration = NULL) { + public function __construct(?array $configuration = NULL) { if (is_array($configuration)) { $this->processID = $configuration[0]; $this->queueID = $configuration[1]; diff --git a/modules/os2forms_nemid/os2forms_nemid.info.yml b/modules/os2forms_nemid/os2forms_nemid.info.yml index d42ab3bd..2a2e81f1 100644 --- a/modules/os2forms_nemid/os2forms_nemid.info.yml +++ b/modules/os2forms_nemid/os2forms_nemid.info.yml @@ -2,8 +2,7 @@ name: 'OS2forms NemID' type: module description: 'Provides custom NemID fields and integration with NemID' package: OS2Forms -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'drupal:os2forms' diff --git a/modules/os2forms_nemid/src/EventSubscriber/NemloginRedirectSubscriber.php b/modules/os2forms_nemid/src/EventSubscriber/NemloginRedirectSubscriber.php index bbc734e9..3d69ffb9 100644 --- a/modules/os2forms_nemid/src/EventSubscriber/NemloginRedirectSubscriber.php +++ b/modules/os2forms_nemid/src/EventSubscriber/NemloginRedirectSubscriber.php @@ -14,7 +14,7 @@ use Drupal\webform\Entity\Webform; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -103,10 +103,10 @@ public function __construct( * * Only if current webform has nemlogin_auto_redirect on. * - * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event + * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event * The subscribed event. */ - public function redirectToNemlogin(GetResponseEvent $event) { + public function redirectToNemlogin(RequestEvent $event) { $request = $event->getRequest(); // This is necessary because this also gets called on @@ -173,7 +173,6 @@ public function redirectToNemlogin(GetResponseEvent $event) { // Redirect directly to the external IdP. $response = new RedirectResponse($this->nemloginAuthProvider->getLoginUrl([], $authProviderPlugin->getPluginId())->toString()); $event->setResponse($response); - $event->stopPropagation(); } else { $settingFormConfig = $this->configFactory->get(SettingsForm::$configName); diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidChildrenRadios.php b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidChildrenRadios.php index fb88f35f..0e287fd1 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidChildrenRadios.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidChildrenRadios.php @@ -61,7 +61,7 @@ public function getElementSelectorSourceValues(array $element) { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { // Setting empty options to avoid errors during load. $element['#options'] = []; parent::prepare($element, $webform_submission); diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidChildrenSelect.php b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidChildrenSelect.php index eb12d834..9d2e0497 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidChildrenSelect.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidChildrenSelect.php @@ -61,7 +61,7 @@ public function getElementSelectorSourceValues(array $element) { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { // Setting empty options to avoid errors during load. $element['#options'] = []; parent::prepare($element, $webform_submission); diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidCpr.php b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidCpr.php index 9abd1f9e..aa34826a 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidCpr.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidCpr.php @@ -29,7 +29,7 @@ public function getPrepopulateFieldFieldKey(array &$element) { /** * {@inheritdoc} */ - public function appendNameAddressProtectedText(CprLookupResult $cprLookupResult) { + public function getNameAddressProtectedText(CprLookupResult $cprLookupResult) { return ''; } diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidNemloginLink.php b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidNemloginLink.php index 48fffbf9..a41d7121 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidNemloginLink.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidNemloginLink.php @@ -42,7 +42,7 @@ public function getTranslatableProperties() { /** * {@inheritdoc} */ - public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + public function prepare(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { parent::prepare($element, $webform_submission); $element['#attributes']['class'][] = 'nemlogin-button-link'; diff --git a/modules/os2forms_permissions_by_term/os2forms_permissions_by_term.info.yml b/modules/os2forms_permissions_by_term/os2forms_permissions_by_term.info.yml index 50ffef53..05721595 100644 --- a/modules/os2forms_permissions_by_term/os2forms_permissions_by_term.info.yml +++ b/modules/os2forms_permissions_by_term/os2forms_permissions_by_term.info.yml @@ -2,8 +2,7 @@ name: OS2Forms permissions by term type: module description: Adds taxonomy to webform configuration package: OS2Web -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'drupal:webform' - 'drupal:permissions_by_term' diff --git a/modules/os2forms_permissions_by_term/src/Helper/Helper.php b/modules/os2forms_permissions_by_term/src/Helper/Helper.php index 47c6d306..d7ff395a 100644 --- a/modules/os2forms_permissions_by_term/src/Helper/Helper.php +++ b/modules/os2forms_permissions_by_term/src/Helper/Helper.php @@ -264,7 +264,7 @@ public function fieldWidgetWebformEntityReferenceFormAlter(array &$elements) { * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ - private function filterWebformSelectOptions(array $options, array &$result = [], string $parent = NULL) { + private function filterWebformSelectOptions(array $options, array &$result = [], ?string $parent = NULL) { foreach ($options as $key => $option) { if ($option instanceof FieldFilteredMarkup) { $webform = $this->entityTypeManager->getStorage('webform')->load($key); diff --git a/modules/os2forms_permissions_by_term/src/Helper/MaestroTemplateHelper.php b/modules/os2forms_permissions_by_term/src/Helper/MaestroTemplateHelper.php index 1b72a4e3..50521547 100644 --- a/modules/os2forms_permissions_by_term/src/Helper/MaestroTemplateHelper.php +++ b/modules/os2forms_permissions_by_term/src/Helper/MaestroTemplateHelper.php @@ -296,7 +296,7 @@ public function viewsQueryAlter(ViewExecutable $view, QueryPluginBase $query) { $displayId = $view->getDisplay()->display['id']; /** @var \Drupal\Core\Session\AccountInterface $user */ $user = $this->entityTypeManager->getStorage('user')->load($this->account->id()); - $maestroTemplates = $this->entityTypeManager->getStorage('maestro_template')->getQuery()->execute(); + $maestroTemplates = $this->entityTypeManager->getStorage('maestro_template')->getQuery()->accessCheck(FALSE)->execute(); $allowedList = []; foreach ($maestroTemplates as $template) { /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $templateEntity */ diff --git a/modules/os2forms_sbsys/os2forms_sbsys.info.yml b/modules/os2forms_sbsys/os2forms_sbsys.info.yml index 680d06a9..e6358f66 100644 --- a/modules/os2forms_sbsys/os2forms_sbsys.info.yml +++ b/modules/os2forms_sbsys/os2forms_sbsys.info.yml @@ -2,8 +2,7 @@ name: 'OS2forms SBSYS integration' type: module description: 'Provides integration with SBSYS ESDH provider.' package: OS2Forms -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'drupal:os2forms' diff --git a/modules/os2forms_webform_list/os2forms_webform_list.info.yml b/modules/os2forms_webform_list/os2forms_webform_list.info.yml index c8d45360..c9b90d42 100644 --- a/modules/os2forms_webform_list/os2forms_webform_list.info.yml +++ b/modules/os2forms_webform_list/os2forms_webform_list.info.yml @@ -3,7 +3,7 @@ type: module description: Alters display of webform list and maestro template list package: OS2Web core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^8 || ^9 || ^10 dependencies: - 'drupal:webform' - 'drupal:maestro' diff --git a/modules/os2forms_webform_maps/modules/field_color/LICENSE.txt b/modules/os2forms_webform_maps/modules/field_color/LICENSE.txt deleted file mode 100644 index d159169d..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/LICENSE.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/modules/os2forms_webform_maps/modules/field_color/README.txt b/modules/os2forms_webform_maps/modules/field_color/README.txt deleted file mode 100644 index 6880b221..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/README.txt +++ /dev/null @@ -1 +0,0 @@ -Field Color diff --git a/modules/os2forms_webform_maps/modules/field_color/css/spectrum.css b/modules/os2forms_webform_maps/modules/field_color/css/spectrum.css deleted file mode 100644 index 2c4d42d8..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/css/spectrum.css +++ /dev/null @@ -1,586 +0,0 @@ -/*** -Spectrum Colorpicker v2.0.0 -https://github.com/seballot/spectrum -Author: Brian Grinstead and spectrum contributors -License: MIT -***/ - -.sp-container { - position: absolute; - top: 0; - left: 0; - display: inline-block; - *display: inline; - *zoom: 1; - /* https://github.com/seballot/spectrum/issues/40 */ - z-index: 9999994; - overflow: hidden; -} -.sp-original-input-container { - position: relative; - display: inline-flex; -} -.sp-original-input-container input { - margin: 0 !important; -} -.sp-original-input-container .sp-add-on { - width: 40px; - border-top-right-radius: 0 !important; - border-bottom-right-radius: 0 !important; -} -input.spectrum.with-add-on { - /*padding-left: 45px;*/ - border-top-left-radius: 0; - border-bottom-left-radius: 0; - border-left: 0; -} -.sp-original-input-container .sp-add-on .sp-colorize { - height: 100%; - width: 100%; - border-radius: inherit; -} -.sp-colorize-container { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==); -} -.sp-container.sp-flat { - position: relative; -} - -/* Fix for * { box-sizing: border-box; } */ -.sp-container, -.sp-container * { - -webkit-box-sizing: content-box; - -moz-box-sizing: content-box; - box-sizing: content-box; -} - -/* http://ansciath.tumblr.com/post/7347495869/css-aspect-ratio */ -.sp-top { - position: relative; - width: 100%; - display: inline-block; -} -.sp-top-inner { - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 0; -} -.sp-color { - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 20px !important; -} -.sp-hue { - position: absolute; - top: 0; - right: 0; - bottom: 0; - width: 12px; - height: 100%; - left: initial !important; -} - -.sp-clear-enabled .sp-hue { - top: 15%; - height: 85%; -} - -.sp-fill { - padding-top: 80%; -} -.sp-sat, -.sp-val { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; -} - -.sp-alpha-enabled .sp-top { - margin-bottom: 28px !important; -} -.sp-alpha-enabled .sp-alpha { - display: block; -} -.sp-alpha-handle { - position: absolute; - top: -3px; - cursor: pointer; - height: 16px; - border-radius: 50%; - width: 16px; - margin-right: 5px; - left: -2px; - right: 0; - background: #f9f9f9; - box-shadow: 0 0 2px 0px #3a3a3a; -} -.sp-alpha { - display: none; - position: absolute; - bottom: -18px; - right: 0; - left: 0; - height: 10px; -} -.sp-alpha-inner { - border-radius: 4px; -} - -.sp-clear { - display: none; -} - -.sp-clear.sp-clear-display { - background-position: center; -} - -.sp-clear-enabled .sp-clear { - display: block; - position: absolute; - top: 3px; - right: 0; - bottom: 0; - cursor: pointer; - left: initial; - height: 12px; - width: 12px; -} - -/* Don't allow text selection */ -.sp-container, -.sp-replacer, -.sp-preview, -.sp-dragger, -.sp-slider, -.sp-alpha, -.sp-clear, -.sp-alpha-handle, -.sp-container.sp-dragging .sp-input, -.sp-container button { - -webkit-user-select: none; - -moz-user-select: -moz-none; - -o-user-select: none; - user-select: none; -} - -.sp-container.sp-input-disabled .sp-input-container { - display: none; -} -.sp-container.sp-buttons-disabled .sp-button-container { - display: none; -} -.sp-container.sp-palette-buttons-disabled .sp-palette-button-container { - display: none; -} -.sp-palette-only .sp-picker-container { - display: none; -} -.sp-palette-disabled .sp-palette-container { - display: none; -} - -.sp-initial-disabled .sp-initial { - display: none; -} - - -/* Gradients for hue, saturation and value instead of images. Not pretty... but it works */ -.sp-sat { - background-image: -webkit-gradient(linear, 0 0, 100% 0, from(#fff), to(rgba(204, 154, 129, 0))); - background-image: -webkit-linear-gradient(left, #fff, rgba(204, 154, 129, 0)); - background-image: -moz-linear-gradient(left, #fff, rgba(204, 154, 129, 0)); - background-image: -o-linear-gradient(left, #fff, rgba(204, 154, 129, 0)); - background-image: -ms-linear-gradient(left, #fff, rgba(204, 154, 129, 0)); - background-image: linear-gradient(to right, #fff, rgba(204, 154, 129, 0)); - -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr=#FFFFFFFF, endColorstr=#00CC9A81)"; - filter: "progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr='#FFFFFFFF', endColorstr='#00CC9A81')"; -} -.sp-val { - border-radius: 4px; - background-image: -webkit-gradient(linear, 0 100%, 0 0, from(#000000), to(rgba(204, 154, 129, 0))); - background-image: -webkit-linear-gradient(bottom, #000000, rgba(204, 154, 129, 0)); - background-image: -moz-linear-gradient(bottom, #000, rgba(204, 154, 129, 0)); - background-image: -o-linear-gradient(bottom, #000, rgba(204, 154, 129, 0)); - background-image: -ms-linear-gradient(bottom, #000, rgba(204, 154, 129, 0)); - background-image: linear-gradient(to top, #000, rgba(204, 154, 129, 0)); - -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00CC9A81, endColorstr=#FF000000)"; - filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#00CC9A81', endColorstr='#FF000000')"; -} - -.sp-hue { - background: -moz-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%); - background: -ms-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%); - background: -o-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%); - background: -webkit-gradient(linear, left top, left bottom, from(#ff0000), color-stop(0.17, #ffff00), color-stop(0.33, #00ff00), color-stop(0.5, #00ffff), color-stop(0.67, #0000ff), color-stop(0.83, #ff00ff), to(#ff0000)); - background: -webkit-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%); - background: linear-gradient(to bottom, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%); -} - -/* IE filters do not support multiple color stops. - Generate 6 divs, line them up, and do two color gradients for each. - Yes, really. - */ -.sp-1 { - height: 17%; - filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0000', endColorstr='#ffff00')"; -} -.sp-2 { - height: 16%; - filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff00', endColorstr='#00ff00')"; -} -.sp-3 { - height: 17%; - filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ff00', endColorstr='#00ffff')"; -} -.sp-4 { - height: 17%; - filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ffff', endColorstr='#0000ff')"; -} -.sp-5 { - height: 16%; - filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#0000ff', endColorstr='#ff00ff')"; -} -.sp-6 { - height: 17%; - filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff00ff', endColorstr='#ff0000')"; -} - -.sp-hidden { - display: none !important; -} - -/* Clearfix hack */ -.sp-cf:before, -.sp-cf:after { - content: ""; - display: table; -} -.sp-cf:after { - clear: both; -} -.sp-cf { - *zoom: 1; -} - -/* Mobile devices, make hue slider bigger so it is easier to slide */ -@media (max-device-width: 480px) { - .sp-color { - right: 40%; -} - .sp-hue { - left: 63%; -} - .sp-fill { - padding-top: 60%; -} -} -.sp-dragger { - border-radius: 5px; - height: 10px; - width: 10px; - border: 1px solid #fff; - cursor: pointer; - position: absolute; - top: 0; - left: 0; - margin-left: 3px; - margin-top: 3px; - box-shadow: 0 0 2px 1px rgba(0, 0, 0, .2); -} -.sp-slider { - position: absolute; - top: 0; - cursor: pointer; - height: 16px; - border-radius: 50%; - width: 16px; - left: -2px; - background: #f9f9f9; - box-shadow: 0 0 2px 0px #3a3a3a; - margin-top: 8px; -} - -/* -Theme authors: -Here are the basic themeable display options (colors, fonts, global widths) -*/ - -.sp-container { - display: inline-flex; - border-radius: 0; - background-color: white; - padding: 0; - border-radius: 4px; - color: black; - box-shadow: 0 0 0 1px rgba(99,114,130,.16), 0 8px 16px rgba(27,39,51,.08); -} -.sp-container, -.sp-container button, -.sp-container input, -.sp-color, -.sp-hue, -.sp-clear { - font-size: 12px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; -} -.sp-top { - margin-bottom: 10px; -} -.sp-color, -.sp-hue, -.sp-clear, -.sp-val, -.sp-sat { - border-radius: 3px; -} - -.sp-input-container { - margin-top: -5px; -} -.sp-input-container.sp-cf, -.sp-initial.sp-thumb.sp-cf, -.sp-button-container.sp-cf { - height: 25px; -} -.sp-picker-container .sp-cf { - margin-bottom: 10px; -} - -.sp-palette-row-initial > span:first-child { - cursor: pointer; -} - -/* Input */ -.sp-initial-disabled .sp-input-container { - width: 100%; -} -.sp-input { - padding: 0px 5px !important; - margin: 0; - width: 100%; - box-shadow: none !important; - height: 100% !important; - background: transparent; - color: #3a3a3a; - border-radius: 2px !important; - border: 1px solid #e0e0e0 !important; - text-align: center; - font-family: monospace; - font-size: inherit !important; -} -.sp-input:focus { - border: 1px solid orange; -} -.sp-input.sp-validation-error { - border: 1px solid red; - background: #fdd; -} -.sp-picker-container , -.sp-palette-container { - position: relative; - padding: 10px; -} -.sp-picker-container { - width: 200px; - padding-bottom: 0; -} - -/* Palettes */ -.sp-palette-container { - border-right: solid 1px #ccc; -} - -.sp-palette-only .sp-palette-container { - border: 0; -} - -.sp-palette .sp-thumb-el { - display: block; - position: relative; - float: left; - width: 24px; - height: 15px; - margin: 3px; - cursor: pointer; - border: solid 2px transparent; -} -.sp-palette .sp-thumb-el:hover, -.sp-palette .sp-thumb-el.sp-thumb-active { - border-color: orange; -} -.sp-thumb-el { - position: relative; -} - -/* Initial */ -.sp-initial { - float: left; -} -.sp-initial span { - width: 30px; - height: 25px; - border: none; - display: block; - float: left; - margin: 0; -} -.sp-initial .spe-thumb-el.sp-thumb-active { - border-radius: 0 5px 5px 0; -} -.sp-initial .spe-thumb-el { - border-radius: 5px 0 0 5px; -} - -.sp-initial .sp-clear-display { - background-position: center; -} - -/* Buttons */ -.sp-button-container { - float: right; -} -.sp-palette-button-container { - margin-top: 10px; -} - -/* Replacer (the little preview div that shows up instead of the ) */ -.sp-replacer { - position: relative; - overflow: hidden; - cursor: pointer; - display: inline-block; - border-radius: 3px; - border: 1px solid #aaa; - color: #666; - transition: border-color .3s; - vertical-align: middle; - width: 3rem; - height: 1.5rem; -} -.sp-replacer:hover, -.sp-replacer.sp-active { - border: 1px solid #666; - color: black; -} -.sp-replacer.sp-disabled { - cursor: default; - border-color: silver; - color: silver; -} -.sp-dd { - position: absolute; - font-size: 10px; - right: 0; - top: 0; - bottom: 0; - padding: 0 2px; - line-height: 1.6rem; - background-color: white; -} -.sp-preview { - position: relative; - width: 100%; - height: 100%; - float: left; - z-index: 0; -} -.sp-preview-inner { - transition: background-color .2s; -} -.sp-preview-inner.sp-clear-display { - /*width: 20px; - margin-left: 10px; - margin-top: 2px;*/ - display: none; -} - -/* Color Picker */ -.sp-palette .sp-thumb-el { - width: 16px; - height: 16px; - margin: 3px; - border: none; - border-radius: 3px; -} - - -/* Buttons: http://hellohappy.org/css3-buttons/ */ -.sp-container button { - border-radius: 3px; - border: none; - background: transparent; - line-height: 1; - padding: 0 8px; - height: 25px; - text-transform: capitalize; - text-align: center; - vertical-align: middle; - cursor: pointer; - color: #606c72; - font-weight: bold; -} -.sp-container button.sp-choose { - background-color: #3cab3b; - color: #fff; - margin-left: 5px; -} -.sp-container button:hover { - opacity: .8; -} -.sp-container button.sp-palette-toggle { - width: 100%; - background-color: #f3f3f3; - margin: 0; -} - - -.sp-palette span:hover, -.sp-palette span.sp-thumb-active { - border-color: #000; -} - -.sp-preview, -.sp-alpha, -.sp-thumb-el { - position: relative; - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==); -} -.sp-preview-inner, -.sp-alpha-inner, -.sp-thumb-inner { - display: block; - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 0; -} - -.sp-palette .sp-thumb-inner { - border-radius: 3px; - background-position: 50% 50%; - background-repeat: no-repeat; -} - -.sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIVJREFUeNpiYBhsgJFMffxAXABlN5JruT4Q3wfi/0DsT64h8UD8HmpIPCWG/KemIfOJCUB+Aoacx6EGBZyHBqI+WsDCwuQ9mhxeg2A210Ntfo8klk9sOMijaURm7yc1UP2RNCMbKE9ODK1HM6iegYLkfx8pligC9lCD7KmRof0ZhjQACDAAceovrtpVBRkAAAAASUVORK5CYII=); -} - -.sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAMdJREFUOE+tkgsNwzAMRMugEAahEAahEAZhEAqlEAZhEAohEAYh81X2dIm8fKpEspLGvudPOsUYpxE2BIJCroJmEW9qJ+MKaBFhEMNabSy9oIcIPwrB+afvAUFoK4H0tMaQ3XtlrggDhOVVMuT4E5MMG0FBbCEYzjYT7OxLEvIHQLY2zWwQ3D+9luyOQTfKDiFD3iUIfPk8VqrKjgAiSfGFPecrg6HN6m/iBcwiDAo7WiBeawa+Kwh7tZoSCGLMqwlSAzVDhoK+6vH4G0P5wdkAAAAASUVORK5CYII=); -} - -.sp-clear-display { - background-repeat: no-repeat; - background-position: center; - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAABe0lEQVQokYXSsUtcQRTF4d8Jj+VhHSxkEQuLsEUKK0nhTBFTmLSSUhBCMCAWsmgIwWrBLk0akfwLCaSQKBJmtrIIISwpRFKIhViETScphGMzysMtvOVwvpm5d0bGNCuGWAOPgYdl6S8wSDn9b+bUhDHEKWAdeAFMANg+l/TV9ofcz6cjMIbYBvaBMds7QCqZ58CmpBNgPuV0DvAAIMyFGugWtJr7eTv38xEwkPRPErY7QDeG2LqFkjrAgu0dSd/KDVqSNmxvAZ8lfbS9AHRuYemnLWkv5XRVBrQMbAI/gTXgEzAJtJuwBVS2L2OIle03QA/4Lmkl5XQBXEqqbFcAVYFDYChpFngiqWf7l6TXKaezMt2Zkhk24THwG+jZriX9AFZvUAyxLbRke2D75O5zPAO+ADXwEtizjaRHwDvbTyUtppwOmicCHAJvbXcl9YA1SQDjtseA97YPRz7ATcUQp2y/kjRdevsjaTfldNrMjcDGBjXA3T96L7yvrgFzP69+0Ao/HAAAAABJRU5ErkJggg==); -} diff --git a/modules/os2forms_webform_maps/modules/field_color/css/style.css b/modules/os2forms_webform_maps/modules/field_color/css/style.css deleted file mode 100644 index 99fed40c..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/css/style.css +++ /dev/null @@ -1,16 +0,0 @@ -.sp-original-input-container .sp-add-on { - width: 40px!important; -} - -.input-field-color { - padding: 0.3em 0.4em 0.3em 0.5em; - -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; - transition: border linear 0.2s, box-shadow linear 0.2s; - color: #595959; - border: 1px solid #b8b8b8; - border-top-color: #999; - border-radius: 2px; - background: #fcfcfa; - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.125); - font-size: 1em; -} diff --git a/modules/os2forms_webform_maps/modules/field_color/field_color.info.yml b/modules/os2forms_webform_maps/modules/field_color/field_color.info.yml deleted file mode 100644 index 1e1206e1..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/field_color.info.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: Field Color -type: module -core: 8.x -core_version_requirement: ^8 || ^9 -description: 'Provides a color picker.' -package: Custom -# Information added by Drupal.org packaging script on 2020-10-28 -version: '1.0.x-dev' -project: 'field_color' -datestamp: 1603925235 diff --git a/modules/os2forms_webform_maps/modules/field_color/field_color.libraries.yml b/modules/os2forms_webform_maps/modules/field_color/field_color.libraries.yml deleted file mode 100644 index 78441c47..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/field_color.libraries.yml +++ /dev/null @@ -1,11 +0,0 @@ -field_color.admin: - css: - theme: - css/spectrum.css: {} - css/style.css: {} - js: - js/spectrum.js: {} - js/main.js: {} - dependencies: - - core/jquery - - core/drupalSettings diff --git a/modules/os2forms_webform_maps/modules/field_color/field_color.module b/modules/os2forms_webform_maps/modules/field_color/field_color.module deleted file mode 100644 index b2333989..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/field_color.module +++ /dev/null @@ -1,18 +0,0 @@ - [ - 'render element' => 'element', - 'template' => 'input-color', - ], - ]; -} diff --git a/modules/os2forms_webform_maps/modules/field_color/field_color.schema.yml b/modules/os2forms_webform_maps/modules/field_color/field_color.schema.yml deleted file mode 100644 index 01ee4ca7..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/field_color.schema.yml +++ /dev/null @@ -1,7 +0,0 @@ -field.widget.settings.field_color_widget_type: - type: mapping - label: 'Field color widget type widget settings' - mapping: - size: - type: integer - label: 'Size' \ No newline at end of file diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ar.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ar.js deleted file mode 100644 index a2071898..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ar.js +++ /dev/null @@ -1,15 +0,0 @@ -// Spectrum Colorpicker -// Arabic (ar) localization -// https://github.com/seballot/spectrum -(function ( $ ) { - - var localization = $.spectrum.localization["ar"] = { - cancelText: "إلغاء", - chooseText: "إختار", - clearText: "إرجاع الألوان على ما كانت", - noColorSelectedText: "لم تختار أي لون", - togglePaletteMoreText: "أكثر", - togglePaletteLessText: "أقل" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ca.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ca.js deleted file mode 100644 index 03f43fb3..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ca.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Catalan (ca) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["ca"] = { - cancelText: "Cancel·lar", - chooseText: "Escollir", - clearText: "Esborrar color seleccionat", - noColorSelectedText: "Cap color seleccionat", - togglePaletteMoreText: "Més", - togglePaletteLessText: "Menys" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-cs.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-cs.js deleted file mode 100644 index abe82377..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-cs.js +++ /dev/null @@ -1,17 +0,0 @@ -// Spectrum Colorpicker -// Czech (cs) localization -// https://github.com/seballot/spectrum -// author localization cs Pavel Laupe Dvorak pavel@pavel-dvorak.cz - -(function ( $ ) { - - var localization = $.spectrum.localization["cs"] = { - cancelText: "zrušit", - chooseText: "vybrat", - clearText: "Resetovat výměr barev", - noColorSelectedText: "Žádná barva nebyla vybrána", - togglePaletteMoreText: "více", - togglePaletteLessText: "méně" - }; - -})( jQuery ); \ No newline at end of file diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-de.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-de.js deleted file mode 100644 index 02a59ce8..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-de.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// German (de) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["de"] = { - cancelText: "Abbrechen", - chooseText: "Wählen", - clearText: "Farbauswahl zurücksetzen", - noColorSelectedText: "Keine Farbe ausgewählt", - togglePaletteMoreText: "Mehr", - togglePaletteLessText: "Weniger" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-dk.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-dk.js deleted file mode 100644 index 7519145c..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-dk.js +++ /dev/null @@ -1,12 +0,0 @@ -// Spectrum Colorpicker -// Danish (dk) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["dk"] = { - cancelText: "annuller", - chooseText: "Vælg" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-es.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-es.js deleted file mode 100644 index d6176f19..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-es.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Spanish (es) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["es"] = { - cancelText: "Cancelar", - chooseText: "Elegir", - clearText: "Borrar color seleccionado", - noColorSelectedText: "Ningún color seleccionado", - togglePaletteMoreText: "Más", - togglePaletteLessText: "Menos" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-et.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-et.js deleted file mode 100644 index 963071eb..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-et.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Estonian (et) localization -// https://github.com/bgrins/spectrum - - (function ( $ ) { - - var localization = $.spectrum.localization["et"] = { - cancelText: "Katkesta", - chooseText: "Vali", - clearText: "Tühista värvivalik", - noColorSelectedText: "Ühtki värvi pole valitud", - togglePaletteMoreText: "Rohkem", - togglePaletteLessText: "Vähem" - }; - - })( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fa.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fa.js deleted file mode 100644 index 4d1e6a21..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fa.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Persian (fa) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["fa"] = { - cancelText: "لغو", - chooseText: "انتخاب", - clearText: "تنظیم مجدد رنگ", - noColorSelectedText: "هیچ رنگی انتخاب نشده است!", - togglePaletteMoreText: "بیشتر", - togglePaletteLessText: "کمتر" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fi.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fi.js deleted file mode 100644 index a08c5b86..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fi.js +++ /dev/null @@ -1,12 +0,0 @@ -// Spectrum Colorpicker -// Finnish (fi) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["fi"] = { - cancelText: "Kumoa", - chooseText: "Valitse" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fr.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fr.js deleted file mode 100644 index e749ade8..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-fr.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// French (fr) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["fr"] = { - cancelText: "Annuler", - chooseText: "Valider", - clearText: "Effacer couleur sélectionnée", - noColorSelectedText: "Aucune couleur sélectionnée", - togglePaletteMoreText: "Plus", - togglePaletteLessText: "Moins" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-gr.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-gr.js deleted file mode 100644 index 0bf38bf5..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-gr.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Greek (gr) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["gr"] = { - cancelText: "Ακύρωση", - chooseText: "Επιλογή", - clearText: "Καθαρισμός επιλεγμένου χρώματος", - noColorSelectedText: "Δεν έχει επιλεχθεί κάποιο χρώμα", - togglePaletteMoreText: "Περισσότερα", - togglePaletteLessText: "Λιγότερα" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-he.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-he.js deleted file mode 100644 index b503cfe5..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-he.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Hebrew (he) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["he"] = { - cancelText: "בטל בחירה", - chooseText: "בחר צבע", - clearText: "אפס בחירה", - noColorSelectedText: "לא נבחר צבע", - togglePaletteMoreText: "עוד צבעים", - togglePaletteLessText: "פחות צבעים" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-hr.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-hr.js deleted file mode 100644 index 6014f0be..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-hr.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Croatian (hr) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["hr"] = { - cancelText: "Odustani", - chooseText: "Odaberi", - clearText: "Poništi odabir", - noColorSelectedText: "Niti jedna boja nije odabrana", - togglePaletteMoreText: "Više", - togglePaletteLessText: "Manje" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-hu.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-hu.js deleted file mode 100644 index 2f8207d4..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-hu.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Hungarian (hu) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["hu"] = { - cancelText: "Mégsem", - chooseText: "Mentés", - clearText: "A színválasztás visszaállítása", - noColorSelectedText: "Nincs szín kijelölve", - togglePaletteMoreText: "Több", - togglePaletteLessText: "Kevesebb" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-id.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-id.js deleted file mode 100644 index 7481a54e..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-id.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Indonesia/Bahasa Indonesia (id) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["id"] = { - cancelText: "Batal", - chooseText: "Pilih", - clearText: "Hapus Pilihan Warna", - noColorSelectedText: "Warna Tidak Dipilih", - togglePaletteMoreText: "tambah", - togglePaletteLessText: "kurangi" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-it.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-it.js deleted file mode 100644 index 4c866a15..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-it.js +++ /dev/null @@ -1,14 +0,0 @@ -// Spectrum Colorpicker -// Italian (it) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["it"] = { - cancelText: "annulla", - chooseText: "scegli", - clearText: "Annulla selezione colore", - noColorSelectedText: "Nessun colore selezionato" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ja.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ja.js deleted file mode 100644 index f0d1b7bd..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ja.js +++ /dev/null @@ -1,12 +0,0 @@ -// Spectrum Colorpicker -// Japanese (ja) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["ja"] = { - cancelText: "中止", - chooseText: "選択" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ko.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ko.js deleted file mode 100644 index 5c31ff12..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ko.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Korean (ko) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["ko"] = { - cancelText: "취소", - chooseText: "선택", - clearText: "선택 초기화", - noColorSelectedText: "선택된 색상 없음", - togglePaletteMoreText: "더보기", - togglePaletteLessText: "줄이기" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-lt.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-lt.js deleted file mode 100644 index 71bf6397..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-lt.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Lithuanian (lt) localization -// https://github.com/liesislukas - -(function ( $ ) { - - var localization = $.spectrum.localization["lt"] = { - cancelText: "Atšaukti", - chooseText: "Pasirinkti", - clearText: "Išvalyti pasirinkimą", - noColorSelectedText: "Spalva nepasirinkta", - togglePaletteMoreText: "Daugiau", - togglePaletteLessText: "Mažiau" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-nb-no.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-nb-no.js deleted file mode 100644 index ff49ca1c..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-nb-no.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Norwegian, Bokmål (nb-no) localization -// https://github.com/greendimka - -(function ( $ ) { - - var localization = $.spectrum.localization["nb-no"] = { - cancelText: "Avbryte", - chooseText: "Velg", - clearText: "Tilbakestill", - noColorSelectedText: "Farge er ikke valgt", - togglePaletteMoreText: "Mer", - togglePaletteLessText: "Mindre" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-nl.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-nl.js deleted file mode 100644 index 8ffe9ba5..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-nl.js +++ /dev/null @@ -1,15 +0,0 @@ -// Spectrum Colorpicker -// Dutch (nl-nl) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["nl-nl"] = { - cancelText: "Annuleer", - chooseText: "Kies", - clearText: "Wis kleur selectie", - togglePaletteMoreText: 'Meer', - togglePaletteLessText: 'Minder' - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pl.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pl.js deleted file mode 100644 index 84657357..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pl.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Polish (pl) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["pl"] = { - cancelText: "Anuluj", - chooseText: "Wybierz", - clearText: "Usuń wybór koloru", - noColorSelectedText: "Nie wybrano koloru", - togglePaletteMoreText: "Więcej", - togglePaletteLessText: "Mniej" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pt-br.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pt-br.js deleted file mode 100644 index dac28e24..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pt-br.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Brazilian (pt-br) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["pt-br"] = { - cancelText: "Cancelar", - chooseText: "Escolher", - clearText: "Limpar cor selecionada", - noColorSelectedText: "Nenhuma cor selecionada", - togglePaletteMoreText: "Mais", - togglePaletteLessText: "Menos" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pt-pt.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pt-pt.js deleted file mode 100644 index fbb6cfb6..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-pt-pt.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Portuguese (pt-pt) localization -// https://github.com/bgrins/spectrum - - (function ( $ ) { - - var localization = $.spectrum.localization["pt-pt"] = { - cancelText: "Cancelar", - chooseText: "Escolher", - clearText: "Limpar cor seleccionada", - noColorSelectedText: "Nenhuma cor seleccionada", - togglePaletteMoreText: "Mais", - togglePaletteLessText: "Menos" - }; - - })( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ru.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ru.js deleted file mode 100644 index d6dad16d..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-ru.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Russian (ru) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["ru"] = { - cancelText: "Отмена", - chooseText: "Выбрать", - clearText: "Сбросить", - noColorSelectedText: "Цвет не выбран", - togglePaletteMoreText: "Ещё", - togglePaletteLessText: "Скрыть" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-sv.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-sv.js deleted file mode 100644 index 3d6a4148..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-sv.js +++ /dev/null @@ -1,12 +0,0 @@ -// Spectrum Colorpicker -// Swedish (sv) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["sv"] = { - cancelText: "Avbryt", - chooseText: "Välj" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-tr.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-tr.js deleted file mode 100644 index 3d94203c..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-tr.js +++ /dev/null @@ -1,12 +0,0 @@ -// Spectrum Colorpicker -// Turkish (tr) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["tr"] = { - cancelText: "iptal", - chooseText: "tamam" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-zh-cn.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-zh-cn.js deleted file mode 100644 index a126a24e..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-zh-cn.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Simplified Chinese (zh-cn) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["zh-cn"] = { - cancelText: "取消", - chooseText: "选择", - clearText: "清除", - togglePaletteMoreText: "更多选项", - togglePaletteLessText: "隐藏", - noColorSelectedText: "尚未选择任何颜色" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-zh-tw.js b/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-zh-tw.js deleted file mode 100644 index e1d5fd6e..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/i18n/jquery.spectrum-zh-tw.js +++ /dev/null @@ -1,16 +0,0 @@ -// Spectrum Colorpicker -// Traditional Chinese (zh-tw) localization -// https://github.com/seballot/spectrum - -(function ( $ ) { - - var localization = $.spectrum.localization["zh-tw"] = { - cancelText: "取消", - chooseText: "選擇", - clearText: "清除", - togglePaletteMoreText: "更多選項", - togglePaletteLessText: "隱藏", - noColorSelectedText: "尚未選擇任何顏色" - }; - -})( jQuery ); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/main.js b/modules/os2forms_webform_maps/modules/field_color/js/main.js deleted file mode 100644 index 0a87772a..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/main.js +++ /dev/null @@ -1,36 +0,0 @@ - -(function ($, Drupal) { - Drupal.behaviors.field_color = { - attach: function (context, settings) { - $(".input-field-color").once().spectrum({ - type: settings.type, - showInput: settings.showInput, - showInitial: settings.showInitial, - allowEmpty: settings.allowEmpty, - showButtons: settings.showButtons, - showAlpha: settings.showAlpha, - disabled: settings.disabled, - localStorageKey: settings.localStorageKey, - showPalette: settings.showPalette, - showPaletteOnly: settings.showPaletteOnly, - togglePaletteOnly: settings.togglePaletteOnly, - showSelectionPalette: settings.showSelectionPalette, - clickoutFiresChange: settings.clickoutFiresChange, - containerClassName: settings.containerClassName, - replacerClassName: settings.replacerClassName, - preferredFormat: settings.preferredFormat, - maxSelectionSize: settings.maxSelectionSize, - locale: settings.locale, - cancelText: settings.cancelText, - chooseText: settings.chooseText, - togglePaletteMoreText: settings.togglePaletteMoreText, - togglePaletteLessText: settings.togglePaletteLessText, - clearText: settings.clearText, - noColorSelectedText: settings.noColorSelectedText, - palette: settings.palette, - selectionPalette: settings.selectionPalette, - // color: settings.color, - }); - } - } -})(jQuery, Drupal); diff --git a/modules/os2forms_webform_maps/modules/field_color/js/spectrum.js b/modules/os2forms_webform_maps/modules/field_color/js/spectrum.js deleted file mode 100644 index a9027a87..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/js/spectrum.js +++ /dev/null @@ -1,2549 +0,0 @@ -// Spectrum Colorpicker v2.0.0 -// https://github.com/seballot/spectrum -// Author: Brian Grinstead and spectrum contributors -// License: MIT - -(function (factory) { - "use strict"; - - if (typeof define === 'function' && define.amd) { // AMD - define(['jquery'], factory); - } - else if (typeof exports == "object" && typeof module == "object") { // CommonJS - module.exports = factory(require('jquery')); - } - else { // Browser - factory(jQuery); - } -})(function ($, undefined) { - "use strict"; - - var defaultOpts = { - - // Callbacks - beforeShow: noop, - move: noop, - change: noop, - show: noop, - hide: noop, - - // Options - flat: false, // Deprecated - use type instead - type: 'component', // text, color, component or flat - showInput: true, - allowEmpty: true, - showButtons: true, - clickoutFiresChange: true, - showInitial: true, - showPalette: true, - showPaletteOnly: false, - hideAfterPaletteSelect: true, - togglePaletteOnly: true, - showSelectionPalette: true, - localStorageKey: false, - appendTo: "body", - maxSelectionSize: 8, - locale: "en", - cancelText: "cancel", - chooseText: "choose", - togglePaletteMoreText: "more", - togglePaletteLessText: "less", - clearText: "Clear Color Selection", - noColorSelectedText: "No Color Selected", - preferredFormat: "name", - className: "", // Deprecated - use containerClassName and - // replacerClassName instead. - containerClassName: "", - replacerClassName: "", - showAlpha: true, - theme: "sp-light", - palette: [ - ["#000", "#444", "#5b5b5b", "#999", "#bcbcbc", "#eee", "#f3f6f4", "#fff"], - ["#f44336", "#744700", "#ce7e00", "#8fce00", "#2986cc", "#16537e", "#6a329f", "#c90076"], - ["#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#cfe2f3", "#d9d2e9", "#ead1dc"], - ["#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#9fc5e8", "#b4a7d6", "#d5a6bd"], - ["#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6fa8dc", "#8e7cc3", "#c27ba0"], - ["#c00", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3d85c6", "#674ea7", "#a64d79"], - ["#900", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#0b5394", "#351c75", "#741b47"], - ["#600", "#783f04", "#7f6000", "#274e13", "#0c343d", "#073763", "#20124d", "#4c1130"] - ], - selectionPalette: [], - disabled: false, - offset: null - }, - spectrums = [], - IE = !!/msie/i.exec(window.navigator.userAgent), - rgbaSupport = (function () { - function contains(str, substr) { - return !!~('' + str).indexOf(substr); - } - - var elem = document.createElement('div'); - var style = elem.style; - style.cssText = 'background-color:rgba(0,0,0,.5)'; - return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla'); - })(), - replaceInput = [ - "
", - "
", - "
", - "
" - ].join(''), - markup = (function () { - - // IE does not support gradients with multiple stops, so we need to - // simulate that for the rainbow slider with 8 divs that each have a - // single gradient - var gradientFix = ""; - if (IE) { - for (var i = 1; i <= 6; i++) { - gradientFix += "
"; - } - } - - return [ - "
", - "
", - "
", - "
", - "", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - gradientFix, - "
", - "
", - "
", - "
", - "
", - "", - "
", - "
", - "
", - "", - "", - "
", - "
", - "
" - ].join(""); - })(); - - function paletteTemplate(p, color, className, opts) { - var html = []; - for (var i = 0; i < p.length; i++) { - var current = p[i]; - if (current) { - var tiny = tinycolor(current); - var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light"; - c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : ""; - var formattedString = tiny.toString(opts.preferredFormat || "rgb"); - var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter(); - html.push(''); - } - else { - html.push(''); - } - } - return "
" + html.join('') + "
"; - } - - function hideAll() { - for (var i = 0; i < spectrums.length; i++) { - if (spectrums[i]) { - spectrums[i].hide(); - } - } - } - - function instanceOptions(o, callbackContext) { - o.locale = o.locale || window.navigator.language; - if (o.locale) { - o.locale = o.locale.split('-')[0].toLowerCase(); - } // handle locale like "fr-FR" - if (o.locale != 'en' && $.spectrum.localization[o.locale]) { - o = $.extend({}, $.spectrum.localization[o.locale], o); - } - var opts = $.extend({}, defaultOpts, o); - - opts.callbacks = { - 'move': bind(opts.move, callbackContext), - 'change': bind(opts.change, callbackContext), - 'show': bind(opts.show, callbackContext), - 'hide': bind(opts.hide, callbackContext), - 'beforeShow': bind(opts.beforeShow, callbackContext) - }; - - return opts; - } - - function spectrum(element, o) { - - var opts = instanceOptions(o, element), - type = opts.type, - flat = (type == 'flat'), - showSelectionPalette = opts.showSelectionPalette, - localStorageKey = opts.localStorageKey, - theme = opts.theme, - callbacks = opts.callbacks, - resize = throttle(reflow, 10), - visible = false, - isDragging = false, - dragWidth = 0, - dragHeight = 0, - dragHelperHeight = 0, - slideHeight = 0, - slideWidth = 0, - alphaWidth = 0, - alphaSlideHelperWidth = 0, - slideHelperHeight = 0, - currentHue = 0, - currentSaturation = 0, - currentValue = 0, - currentAlpha = 1, - palette = [], - paletteArray = [], - paletteLookup = {}, - selectionPalette = opts.selectionPalette.slice(0), - maxSelectionSize = opts.maxSelectionSize, - draggingClass = "sp-dragging", - abortNextInputChange = false, - shiftMovementDirection = null; - - var doc = element.ownerDocument, - body = doc.body, - boundElement = $(element), - disabled = false, - container = $(markup, doc).addClass(theme), - pickerContainer = container.find(".sp-picker-container"), - dragger = container.find(".sp-color"), - dragHelper = container.find(".sp-dragger"), - slider = container.find(".sp-hue"), - slideHelper = container.find(".sp-slider"), - alphaSliderInner = container.find(".sp-alpha-inner"), - alphaSlider = container.find(".sp-alpha"), - alphaSlideHelper = container.find(".sp-alpha-handle"), - textInput = container.find(".sp-input"), - paletteContainer = container.find(".sp-palette"), - initialColorContainer = container.find(".sp-initial"), - cancelButton = container.find(".sp-cancel"), - clearButton = container.find(".sp-clear"), - chooseButton = container.find(".sp-choose"), - toggleButton = container.find(".sp-palette-toggle"), - isInput = boundElement.is("input"), - isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(), - shouldReplace = isInput && type == 'color', - replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]), - offsetElement = (shouldReplace) ? replacer : boundElement, - previewElement = replacer.find(".sp-preview-inner"), - initialColor = opts.color || (isInput && boundElement.val()), - colorOnShow = false, - currentPreferredFormat = opts.preferredFormat, - clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange, - isEmpty = !initialColor, - allowEmpty = opts.allowEmpty; - - // Element to be updated with the input color. Populated in initialize - // method - var originalInputContainer = null, - colorizeElement = null, - colorizeElementInitialColor = null, - colorizeElementInitialBackground = null; - - //If there is a label for this element, when clicked on, show the colour - // picker - var thisId = boundElement.attr('id'); - if (thisId !== undefined && thisId.length > 0) { - var label = $('label[for="' + thisId + '"]'); - if (label.length) { - label.on('click', function (e) { - e.preventDefault(); - boundElement.spectrum('show'); - return false; - }); - } - } - - function applyOptions() { - - if (opts.showPaletteOnly) { - opts.showPalette = true; - } - - toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText); - - if (opts.palette) { - palette = opts.palette.slice(0); - paletteArray = $.isArray(palette[0]) ? palette : [palette]; - paletteLookup = {}; - for (var i = 0; i < paletteArray.length; i++) { - for (var j = 0; j < paletteArray[i].length; j++) { - var rgb = tinycolor(paletteArray[i][j]).toRgbString(); - paletteLookup[rgb] = true; - } - } - - // if showPaletteOnly and didn't set initialcolor - // set initialcolor to first palette - if (opts.showPaletteOnly && !opts.color) { - initialColor = (palette[0][0] === '') ? palette[0][0] : Object.keys(paletteLookup)[0]; - } - } - - container.toggleClass("sp-flat", flat); - container.toggleClass("sp-input-disabled", !opts.showInput); - container.toggleClass("sp-alpha-enabled", opts.showAlpha); - container.toggleClass("sp-clear-enabled", allowEmpty); - container.toggleClass("sp-buttons-disabled", !opts.showButtons); - container.toggleClass("sp-palette-buttons-disabled", !opts.togglePaletteOnly); - container.toggleClass("sp-palette-disabled", !opts.showPalette); - container.toggleClass("sp-palette-only", opts.showPaletteOnly); - container.toggleClass("sp-initial-disabled", !opts.showInitial); - container.addClass(opts.className).addClass(opts.containerClassName); - - reflow(); - } - - function initialize() { - - if (IE) { - container.find("*:not(input)").attr("unselectable", "on"); - } - - applyOptions(); - - originalInputContainer = $(''); - ['margin'].forEach(function (cssProp) { - originalInputContainer.css(cssProp, boundElement.css(cssProp)); - }); - // inline-flex by default, switching to flex if needed - if (boundElement.css('display') == 'block') { - originalInputContainer.css('display', 'flex'); - } - - if (shouldReplace) { - boundElement.after(replacer).hide(); - } - else if (type == 'text') { - originalInputContainer.addClass('sp-colorize-container'); - boundElement.addClass('spectrum sp-colorize').wrap(originalInputContainer); - } - else if (type == 'component') { - boundElement.addClass('spectrum').wrap(originalInputContainer); - var addOn = $(["
", - "
", - "
"].join('')); - addOn.width(boundElement.outerHeight() + 'px') - .css('border-radius', boundElement.css('border-radius')) - .css('border', boundElement.css('border')); - boundElement.addClass('with-add-on').before(addOn); - } - - colorizeElement = boundElement.parent().find('.sp-colorize'); - colorizeElementInitialColor = colorizeElement.css('color'); - colorizeElementInitialBackground = colorizeElement.css('background-color'); - - if (!allowEmpty) { - clearButton.hide(); - } - - if (flat) { - boundElement.after(container).hide(); - } - else { - - var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo); - if (appendTo.length !== 1) { - appendTo = $("body"); - } - - appendTo.append(container); - } - - updateSelectionPaletteFromStorage(); - - offsetElement.on("click.spectrum touchstart.spectrum", function (e) { - if (!disabled) { - toggle(); - } - - e.stopPropagation(); - - if (!$(e.target).is("input")) { - e.preventDefault(); - } - }); - - if (boundElement.is(":disabled") || (opts.disabled === true)) { - disable(); - } - - // Prevent clicks from bubbling up to document. This would cause it to - // be hidden. - container.click(stopPropagation); - - // Handle user typed input - [textInput, boundElement].forEach(function (input) { - input.change(function () { - setFromTextInput(input.val()); - }); - input.on("paste", function () { - setTimeout(function () { - setFromTextInput(input.val()); - }, 1); - }); - input.keydown(function (e) { - if (e.keyCode == 13) { - setFromTextInput($(input).val()); - if (input == boundElement) { - hide(); - } - } - }); - }); - - cancelButton.text(opts.cancelText); - cancelButton.on("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - revert(); - hide(); - }); - - clearButton.attr("title", opts.clearText); - clearButton.on("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - isEmpty = true; - move(); - - if (flat) { - //for the flat style, this is a change event - updateOriginalInput(true); - } - }); - - chooseButton.text(opts.chooseText); - chooseButton.on("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - - if (IE && textInput.is(":focus")) { - textInput.trigger('change'); - } - - if (isValid()) { - updateOriginalInput(true); - hide(); - } - }); - - toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText); - toggleButton.on("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - - opts.showPaletteOnly = !opts.showPaletteOnly; - - // To make sure the Picker area is drawn on the right, next to the - // Palette area (and not below the palette), first move the Palette - // to the left to make space for the picker, plus 5px extra. - // The 'applyOptions' function puts the whole container back into place - // and takes care of the button-text and the sp-palette-only CSS class. - if (!opts.showPaletteOnly && !flat) { - container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5)); - } - applyOptions(); - }); - - draggable(alphaSlider, function (dragX, dragY, e) { - currentAlpha = (dragX / alphaWidth); - isEmpty = false; - if (e.shiftKey) { - currentAlpha = Math.round(currentAlpha * 10) / 10; - } - - move(); - }, dragStart, dragStop); - - draggable(slider, function (dragX, dragY) { - currentHue = parseFloat(dragY / slideHeight); - isEmpty = false; - if (!opts.showAlpha) { - currentAlpha = 1; - } - move(); - }, dragStart, dragStop); - - draggable(dragger, function (dragX, dragY, e) { - - // shift+drag should snap the movement to either the x or y axis. - if (!e.shiftKey) { - shiftMovementDirection = null; - } - else if (!shiftMovementDirection) { - var oldDragX = currentSaturation * dragWidth; - var oldDragY = dragHeight - (currentValue * dragHeight); - var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY); - - shiftMovementDirection = furtherFromX ? "x" : "y"; - } - - var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x"; - var setValue = !shiftMovementDirection || shiftMovementDirection === "y"; - - if (setSaturation) { - currentSaturation = parseFloat(dragX / dragWidth); - } - if (setValue) { - currentValue = parseFloat((dragHeight - dragY) / dragHeight); - } - - isEmpty = false; - if (!opts.showAlpha) { - currentAlpha = 1; - } - - move(); - - }, dragStart, dragStop); - - if (!!initialColor) { - set(initialColor); - - // In case color was black - update the preview UI and set the format - // since the set function will not run (default color is black). - updateUI(); - currentPreferredFormat = tinycolor(initialColor).format || opts.preferredFormat; - addColorToSelectionPalette(initialColor); - } - else if (initialColor === '') { - set(initialColor); - updateUI(); - } - else { - updateUI(); - } - - if (flat) { - show(); - } - - function paletteElementClick(e) { - if (e.data && e.data.ignore) { - set($(e.target).closest(".sp-thumb-el").data("color")); - move(); - } - else { - set($(e.target).closest(".sp-thumb-el").data("color")); - move(); - - // If the picker is going to close immediately, a palette selection - // is a change. Otherwise, it's a move only. - if (opts.hideAfterPaletteSelect) { - updateOriginalInput(true); - hide(); - } - else { - updateOriginalInput(); - } - } - - return false; - } - - var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum"; - paletteContainer.on(paletteEvent, ".sp-thumb-el", paletteElementClick); - initialColorContainer.on(paletteEvent, ".sp-thumb-el:nth-child(1)", {ignore: true}, paletteElementClick); - } - - function updateSelectionPaletteFromStorage() { - - if (localStorageKey) { - // Migrate old palettes over to new format. May want to remove this - // eventually. - try { - var localStorage = window.localStorage; - var oldPalette = localStorage[localStorageKey].split(",#"); - if (oldPalette.length > 1) { - delete localStorage[localStorageKey]; - $.each(oldPalette, function (i, c) { - addColorToSelectionPalette(c); - }); - } - } - catch (e) { - } - - try { - selectionPalette = window.localStorage[localStorageKey].split(";"); - } - catch (e) { - } - } - } - - function addColorToSelectionPalette(color) { - if (showSelectionPalette) { - var rgb = tinycolor(color).toRgbString(); - if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) { - selectionPalette.push(rgb); - while (selectionPalette.length > maxSelectionSize) { - selectionPalette.shift(); - } - } - - if (localStorageKey) { - try { - window.localStorage[localStorageKey] = selectionPalette.join(";"); - } - catch (e) { - } - } - } - } - - function getUniqueSelectionPalette() { - var unique = []; - if (opts.showPalette) { - for (var i = 0; i < selectionPalette.length; i++) { - var rgb = tinycolor(selectionPalette[i]).toRgbString(); - - if (!paletteLookup[rgb]) { - unique.push(selectionPalette[i]); - } - } - } - - return unique.reverse().slice(0, opts.maxSelectionSize); - } - - function drawPalette() { - - var currentColor = get(); - - var html = $.map(paletteArray, function (palette, i) { - return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i, opts); - }); - - updateSelectionPaletteFromStorage(); - - if (selectionPalette) { - html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection", opts)); - } - - paletteContainer.html(html.join("")); - } - - function drawInitial() { - if (opts.showInitial) { - var initial = colorOnShow; - var current = get(); - initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial", opts)); - } - } - - function dragStart() { - if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) { - reflow(); - } - isDragging = true; - container.addClass(draggingClass); - shiftMovementDirection = null; - boundElement.trigger('dragstart.spectrum', [get()]); - } - - function dragStop() { - isDragging = false; - container.removeClass(draggingClass); - boundElement.trigger('dragstop.spectrum', [get()]); - } - - function setFromTextInput(value) { - if (abortNextInputChange) { - abortNextInputChange = false; - return; - } - if ((value === null || value === "") && allowEmpty) { - set(null); - move(); - updateOriginalInput(); - } - else { - var tiny = tinycolor(value); - if (tiny.isValid()) { - set(tiny); - move(); - updateOriginalInput(); - } - else { - textInput.addClass("sp-validation-error"); - } - } - } - - function toggle() { - if (visible) { - hide(); - } - else { - show(); - } - } - - function show() { - // debugger; - var event = $.Event('beforeShow.spectrum'); - - if (visible) { - reflow(); - return; - } - - boundElement.trigger(event, [get()]); - - if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) { - return; - } - - hideAll(); - visible = true; - - $(doc).on("keydown.spectrum", onkeydown); - $(doc).on("click.spectrum", clickout); - $(window).on("resize.spectrum", resize); - replacer.addClass("sp-active"); - container.removeClass("sp-hidden"); - - reflow(); - updateUI(); - - colorOnShow = get(); - - drawInitial(); - callbacks.show(colorOnShow); - boundElement.trigger('show.spectrum', [colorOnShow]); - } - - function onkeydown(e) { - // Close on ESC - if (e.keyCode === 27) { - hide(); - } - } - - function clickout(e) { - // Return on right click. - if (e.button == 2) { - return; - } - - // If a drag event was happening during the mouseup, don't hide - // on click. - if (isDragging) { - return; - } - - if (clickoutFiresChange) { - updateOriginalInput(true); - } - else { - revert(); - } - hide(); - } - - function hide() { - // Return if hiding is unnecessary - if (!visible || flat) { - return; - } - visible = false; - - $(doc).off("keydown.spectrum", onkeydown); - $(doc).off("click.spectrum", clickout); - $(window).off("resize.spectrum", resize); - - replacer.removeClass("sp-active"); - container.addClass("sp-hidden"); - - callbacks.hide(get()); - boundElement.trigger('hide.spectrum', [get()]); - } - - function revert() { - set(colorOnShow, true); - updateOriginalInput(true); - } - - function set(color, ignoreFormatChange) { - if (tinycolor.equals(color, get())) { - // Update UI just in case a validation error needs - // to be cleared. - updateUI(); - return; - } - - var newColor, newHsv; - if ((!color || color === undefined) && allowEmpty) { - isEmpty = true; - } - else { - isEmpty = false; - newColor = tinycolor(color); - newHsv = newColor.toHsv(); - - currentHue = (newHsv.h % 360) / 360; - currentSaturation = newHsv.s; - currentValue = newHsv.v; - currentAlpha = newHsv.a; - } - updateUI(); - - if (newColor && newColor.isValid() && !ignoreFormatChange) { - currentPreferredFormat = opts.preferredFormat || newColor.getFormat(); - } - } - - function get(opts) { - opts = opts || {}; - - if (allowEmpty && isEmpty) { - return null; - } - - return tinycolor.fromRatio({ - h: currentHue, - s: currentSaturation, - v: currentValue, - a: Math.round(currentAlpha * 1000) / 1000 - }, {format: opts.format || currentPreferredFormat}); - } - - function isValid() { - return !textInput.hasClass("sp-validation-error"); - } - - function move() { - updateUI(); - - callbacks.move(get()); - boundElement.trigger('move.spectrum', [get()]); - } - - function updateUI() { - - textInput.removeClass("sp-validation-error"); - - updateHelperLocations(); - - // Update dragger background color (gradients take care of saturation and - // value). - var flatColor = tinycolor.fromRatio({h: currentHue, s: 1, v: 1}); - dragger.css("background-color", flatColor.toHexString()); - - // Get a format that alpha will be included in (hex and names ignore - // alpha) - var format = currentPreferredFormat; - if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) { - if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") { - format = "rgb"; - } - } - - var realColor = get({format: format}), - displayColor = ''; - - //reset background info for preview element - previewElement.removeClass("sp-clear-display"); - previewElement.css('background-color', 'transparent'); - - if (!realColor && allowEmpty) { - // Update the replaced elements background with icon indicating no - // color selection - previewElement.addClass("sp-clear-display"); - } - else { - var realHex = realColor.toHexString(), - realRgb = realColor.toRgbString(); - - // Update the replaced elements background color (with actual selected - // color) - if (rgbaSupport || realColor.alpha === 1) { - previewElement.css("background-color", realRgb); - } - else { - previewElement.css("background-color", "transparent"); - previewElement.css("filter", realColor.toFilter()); - } - - if (opts.showAlpha) { - var rgb = realColor.toRgb(); - rgb.a = 0; - var realAlpha = tinycolor(rgb).toRgbString(); - var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")"; - - if (IE) { - alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({gradientType: 1}, realHex)); - } - else { - alphaSliderInner.css("background", "-webkit-" + gradient); - alphaSliderInner.css("background", "-moz-" + gradient); - alphaSliderInner.css("background", "-ms-" + gradient); - // Use current syntax gradient on unprefixed property. - alphaSliderInner.css("background", - "linear-gradient(to right, " + realAlpha + ", " + realHex + ")"); - } - } - - displayColor = realColor.toString(format); - } - - // Update the text entry input as it changes happen - if (opts.showInput) { - textInput.val(displayColor); - } - boundElement.val(displayColor); - if (opts.type == "text" || opts.type == "component") { - var color = realColor; - if (color && colorizeElement) { - var textColor = (color.isLight() || color.getAlpha() < 0.4) ? 'black' : 'white'; - colorizeElement.css('background-color', color.toRgbString()).css('color', textColor); - } - else { - colorizeElement.css('background-color', colorizeElementInitialBackground) - .css('color', colorizeElementInitialColor); - } - } - - if (opts.showPalette) { - drawPalette(); - } - - drawInitial(); - } - - function updateHelperLocations() { - var s = currentSaturation; - var v = currentValue; - - if (allowEmpty && isEmpty) { - //if selected color is empty, hide the helpers - alphaSlideHelper.hide(); - slideHelper.hide(); - dragHelper.hide(); - } - else { - //make sure helpers are visible - alphaSlideHelper.show(); - slideHelper.show(); - dragHelper.show(); - - // Where to show the little circle in that displays your current - // selected color - var dragX = s * dragWidth; - var dragY = dragHeight - (v * dragHeight); - dragX = Math.max( - -dragHelperHeight, - Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight) - ); - dragY = Math.max( - -dragHelperHeight, - Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight) - ); - dragHelper.css({ - "top": dragY + "px", - "left": dragX + "px" - }); - - var alphaX = currentAlpha * alphaWidth; - alphaSlideHelper.css({ - "left": (alphaX - (alphaSlideHelperWidth / 2)) + "px" - }); - - // Where to show the bar that displays your current selected hue - var slideY = (currentHue) * slideHeight; - slideHelper.css({ - "top": (slideY - slideHelperHeight) + "px" - }); - } - } - - function updateOriginalInput(fireCallback) { - var color = get(), - displayColor = '', - hasChanged = !tinycolor.equals(color, colorOnShow); - - if (color) { - displayColor = color.toString(currentPreferredFormat); - // Update the selection palette with the current color - addColorToSelectionPalette(color); - } - - if (fireCallback && hasChanged) { - callbacks.change(color); - // we trigger the change event or input, but the input change event is - // also binded to some spectrum processing, that we do no need - abortNextInputChange = true; - boundElement.trigger('change', [color]); - } - } - - function reflow() { - if (!visible) { - return; // Calculations would be useless and wouldn't be reliable - // anyways - } - dragWidth = dragger.width(); - dragHeight = dragger.height(); - dragHelperHeight = dragHelper.height(); - slideWidth = slider.width(); - slideHeight = slider.height(); - slideHelperHeight = slideHelper.height(); - alphaWidth = alphaSlider.width(); - alphaSlideHelperWidth = alphaSlideHelper.width(); - - if (!flat) { - container.css("position", "absolute"); - if (opts.offset) { - container.offset(opts.offset); - } - else { - container.offset(getOffset(container, offsetElement)); - } - } - - updateHelperLocations(); - - if (opts.showPalette) { - drawPalette(); - } - - boundElement.trigger('reflow.spectrum'); - } - - function destroy() { - boundElement.show().removeClass('spectrum with-add-on sp-colorize'); - offsetElement.off("click.spectrum touchstart.spectrum"); - container.remove(); - replacer.remove(); - if (colorizeElement) { - colorizeElement.css('background-color', colorizeElementInitialBackground) - .css('color', colorizeElementInitialColor); - } - var originalInputContainer = boundElement.closest('.sp-original-input-container'); - if (originalInputContainer.length > 0) { - originalInputContainer.after(boundElement).remove(); - } - spectrums[spect.id] = null; - } - - function option(optionName, optionValue) { - if (optionName === undefined) { - return $.extend({}, opts); - } - if (optionValue === undefined) { - return opts[optionName]; - } - - opts[optionName] = optionValue; - - if (optionName === "preferredFormat") { - currentPreferredFormat = opts.preferredFormat; - } - applyOptions(); - } - - function enable() { - disabled = false; - boundElement.attr("disabled", false); - offsetElement.removeClass("sp-disabled"); - } - - function disable() { - hide(); - disabled = true; - boundElement.attr("disabled", true); - offsetElement.addClass("sp-disabled"); - } - - function setOffset(coord) { - opts.offset = coord; - reflow(); - } - - initialize(); - - var spect = { - show: show, - hide: hide, - toggle: toggle, - reflow: reflow, - option: option, - enable: enable, - disable: disable, - offset: setOffset, - set: function (c) { - set(c); - updateOriginalInput(); - }, - get: get, - destroy: destroy, - container: container - }; - - spect.id = spectrums.push(spect) - 1; - - return spect; - } - - /** - * checkOffset - get the offset below/above and left/right element depending - * on screen position Thanks - * https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js - */ - function getOffset(picker, input) { - var extraY = 0; - var dpWidth = picker.outerWidth(); - var dpHeight = picker.outerHeight(); - var inputHeight = input.outerHeight(); - var doc = picker[0].ownerDocument; - var docElem = doc.documentElement; - var viewWidth = docElem.clientWidth + $(doc).scrollLeft(); - var viewHeight = docElem.clientHeight + $(doc).scrollTop(); - var offset = input.offset(); - var offsetLeft = offset.left; - var offsetTop = offset.top; - - offsetTop += inputHeight; - - offsetLeft -= - Math.min(offsetLeft, (offsetLeft + dpWidth > viewWidth && viewWidth > dpWidth) ? - Math.abs(offsetLeft + dpWidth - viewWidth) : 0); - - offsetTop -= - Math.min(offsetTop, ((offsetTop + dpHeight > viewHeight && viewHeight > dpHeight) ? - Math.abs(dpHeight + inputHeight - extraY) : extraY)); - - return { - top: offsetTop, - bottom: offset.bottom, - left: offsetLeft, - right: offset.right, - width: offset.width, - height: offset.height - }; - } - - /** - * noop - do nothing - */ - function noop() { - - } - - /** - * stopPropagation - makes the code only doing this a little easier to read - * in line - */ - function stopPropagation(e) { - e.stopPropagation(); - } - - /** - * Create a function bound to a given object - * Thanks to underscore.js - */ - function bind(func, obj) { - var slice = Array.prototype.slice; - var args = slice.call(arguments, 2); - return function () { - return func.apply(obj, args.concat(slice.call(arguments))); - }; - } - - /** - * Lightweight drag helper. Handles containment within the element, so that - * when dragging, the x is within [0,element.width] and y is within - * [0,element.height] - */ - function draggable(element, onmove, onstart, onstop) { - onmove = onmove || function () { - }; - onstart = onstart || function () { - }; - onstop = onstop || function () { - }; - var doc = document; - var dragging = false; - var offset = {}; - var maxHeight = 0; - var maxWidth = 0; - var hasTouch = ('ontouchstart' in window); - - var duringDragEvents = {}; - duringDragEvents["selectstart"] = prevent; - duringDragEvents["dragstart"] = prevent; - duringDragEvents["touchmove mousemove"] = move; - duringDragEvents["touchend mouseup"] = stop; - - function prevent(e) { - if (e.stopPropagation) { - e.stopPropagation(); - } - if (e.preventDefault) { - e.preventDefault(); - } - e.returnValue = false; - } - - function move(e) { - if (dragging) { - // Mouseup happened outside of window - if (IE && doc.documentMode < 9 && !e.button) { - return stop(); - } - - var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0]; - var pageX = t0 && t0.pageX || e.pageX; - var pageY = t0 && t0.pageY || e.pageY; - - var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth)); - var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight)); - - if (hasTouch) { - // Stop scrolling in iOS - prevent(e); - } - - onmove.apply(element, [dragX, dragY, e]); - } - } - - function start(e) { - var rightclick = (e.which) ? (e.which == 3) : (e.button == 2); - - if (!rightclick && !dragging) { - if (onstart.apply(element, arguments) !== false) { - dragging = true; - maxHeight = $(element).height(); - maxWidth = $(element).width(); - offset = $(element).offset(); - - $(doc).on(duringDragEvents); - $(doc.body).addClass("sp-dragging"); - - move(e); - - prevent(e); - } - } - } - - function stop() { - if (dragging) { - $(doc).off(duringDragEvents); - $(doc.body).removeClass("sp-dragging"); - - // Wait a tick before notifying observers to allow the click event - // to fire in Chrome. - setTimeout(function () { - onstop.apply(element, arguments); - }, 0); - } - dragging = false; - } - - $(element).on("touchstart mousedown", start); - } - - function throttle(func, wait, debounce) { - var timeout; - return function () { - var context = this, args = arguments; - var throttler = function () { - timeout = null; - func.apply(context, args); - }; - if (debounce) { - clearTimeout(timeout); - } - if (debounce || !timeout) { - timeout = setTimeout(throttler, wait); - } - }; - } - - function inputTypeColorSupport() { - return $.fn.spectrum.inputTypeColorSupport(); - } - - /** - * Define a jQuery plugin - */ - var dataID = "spectrum.id"; - $.fn.spectrum = function (opts, extra) { - - if (typeof opts == "string") { - - var returnValue = this; - var args = Array.prototype.slice.call(arguments, 1); - - this.each(function () { - var spect = spectrums[$(this).data(dataID)]; - if (spect) { - var method = spect[opts]; - if (!method) { - throw new Error("Spectrum: no such method: '" + opts + "'"); - } - - if (opts == "get") { - returnValue = spect.get(); - } - else if (opts == "container") { - returnValue = spect.container; - } - else if (opts == "option") { - returnValue = spect.option.apply(spect, args); - } - else if (opts == "destroy") { - spect.destroy(); - $(this).removeData(dataID); - } - else { - method.apply(spect, args); - } - } - }); - - return returnValue; - } - - // Initializing a new instance of spectrum - return this.spectrum("destroy").each(function () { - var options = $.extend({}, $(this).data(), opts); - // Infer default type from input params and deprecated options - if (!$(this).is('input')) { - options.type = 'noInput'; - } - else if (options.flat || options.type == "flat") { - options.type = 'flat'; - } - else if ($(this).attr('type') == 'color') { - options.type = 'color'; - } - else { - options.type = options.type || 'component'; - } - - var spect = spectrum(this, options); - $(this).data(dataID, spect.id); - }); - }; - - $.fn.spectrum.load = true; - $.fn.spectrum.loadOpts = {}; - $.fn.spectrum.draggable = draggable; - $.fn.spectrum.defaults = defaultOpts; - $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() { - if (typeof inputTypeColorSupport._cachedResult === "undefined") { - var colorInput = $("")[0]; // if color element is - // supported, value will - // default to not null - inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== ""; - } - return inputTypeColorSupport._cachedResult; - }; - - $.spectrum = {}; - $.spectrum.localization = {}; - $.spectrum.palettes = {}; - - $.fn.spectrum.processNativeColorInputs = function () { - var colorInputs = $("input[type=color]"); - if (colorInputs.length && !inputTypeColorSupport()) { - colorInputs.spectrum({ - preferredFormat: "hex6" - }); - } - }; - - // TinyColor v1.1.2 - // https://github.com/bgrins/TinyColor - // Brian Grinstead, MIT License - - (function () { - - var trimLeft = /^[\s,#]+/, - trimRight = /\s+$/, - tinyCounter = 0, - math = Math, - mathRound = math.round, - mathMin = math.min, - mathMax = math.max, - mathRandom = math.random; - - var tinycolor = function (color, opts) { - - color = (color) ? color : ''; - opts = opts || {}; - - // If input is already a tinycolor, return itself - if (color instanceof tinycolor) { - return color; - } - // If we are called as a function, call using new instead - if (!(this instanceof tinycolor)) { - return new tinycolor(color, opts); - } - - var rgb = inputToRGB(color); - this._originalInput = color; - this._r = rgb.r; - this._g = rgb.g; - this._b = rgb.b; - this._a = rgb.a; - this._roundA = mathRound(1000 * this._a) / 1000; - this._format = opts.format || rgb.format; - this._gradientType = opts.gradientType; - - // Don't let the range of [0,255] come back in [0,1]. - // Potentially lose a little bit of precision here, but will fix issues - // where .5 gets interpreted as half of the total, instead of half of 1 - // If it was supposed to be 128, this was already taken care of by - // `inputToRgb` - if (this._r < 1) { - this._r = mathRound(this._r); - } - if (this._g < 1) { - this._g = mathRound(this._g); - } - if (this._b < 1) { - this._b = mathRound(this._b); - } - - this._ok = rgb.ok; - this._tc_id = tinyCounter++; - }; - - tinycolor.prototype = { - isDark: function () { - return this.getBrightness() < 128; - }, - isLight: function () { - return !this.isDark(); - }, - isValid: function () { - return this._ok; - }, - getOriginalInput: function () { - return this._originalInput; - }, - getFormat: function () { - return this._format; - }, - getAlpha: function () { - return this._a; - }, - getBrightness: function () { - var rgb = this.toRgb(); - return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; - }, - setAlpha: function (value) { - this._a = boundAlpha(value); - this._roundA = mathRound(1000 * this._a) / 1000; - return this; - }, - toHsv: function () { - var hsv = rgbToHsv(this._r, this._g, this._b); - return {h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a}; - }, - toHsvString: function () { - var hsv = rgbToHsv(this._r, this._g, this._b); - var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), - v = mathRound(hsv.v * 100); - return (this._a == 1) ? - "hsv(" + h + ", " + s + "%, " + v + "%)" : - "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")"; - }, - toHsl: function () { - var hsl = rgbToHsl(this._r, this._g, this._b); - return {h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a}; - }, - toHslString: function () { - var hsl = rgbToHsl(this._r, this._g, this._b); - var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), - l = mathRound(hsl.l * 100); - return (this._a == 1) ? - "hsl(" + h + ", " + s + "%, " + l + "%)" : - "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")"; - }, - toHex: function (allow3Char) { - return rgbToHex(this._r, this._g, this._b, allow3Char); - }, - toHexString: function (allow3Char) { - return '#' + this.toHex(allow3Char); - }, - toHex8: function () { - return rgbaToHex(this._r, this._g, this._b, this._a); - }, - toHex8String: function () { - return '#' + this.toHex8(); - }, - toRgb: function () { - return { - r: mathRound(this._r), - g: mathRound(this._g), - b: mathRound(this._b), - a: this._a - }; - }, - toRgbString: function () { - return (this._a == 1) ? - "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : - "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; - }, - toPercentageRgb: function () { - return { - r: mathRound(bound01(this._r, 255) * 100) + "%", - g: mathRound(bound01(this._g, 255) * 100) + "%", - b: mathRound(bound01(this._b, 255) * 100) + "%", - a: this._a - }; - }, - toPercentageRgbString: function () { - return (this._a == 1) ? - "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : - "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; - }, - toName: function () { - if (this._a === 0) { - return "transparent"; - } - - if (this._a < 1) { - return false; - } - - return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; - }, - toFilter: function (secondColor) { - var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); - var secondHex8String = hex8String; - var gradientType = this._gradientType ? "GradientType = 1, " : ""; - - if (secondColor) { - var s = tinycolor(secondColor); - secondHex8String = s.toHex8String(); - } - - return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")"; - }, - toString: function (format) { - var formatSet = !!format; - format = format || this._format; - - var formattedString = false; - var hasAlpha = this._a < 1 && this._a >= 0; - var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name"); - - if (needsAlphaFormat) { - // Special case for "transparent", all other non-alpha formats - // will return rgba when there is transparency. - if (format === "name" && this._a === 0) { - return this.toName(); - } - return this.toRgbString(); - } - if (format === "rgb") { - formattedString = this.toRgbString(); - } - if (format === "prgb") { - formattedString = this.toPercentageRgbString(); - } - if (format === "hex" || format === "hex6") { - formattedString = this.toHexString(); - } - if (format === "hex3") { - formattedString = this.toHexString(true); - } - if (format === "hex8") { - formattedString = this.toHex8String(); - } - if (format === "name") { - formattedString = this.toName(); - } - if (format === "hsl") { - formattedString = this.toHslString(); - } - if (format === "hsv") { - formattedString = this.toHsvString(); - } - - return formattedString || this.toHexString(); - }, - - _applyModification: function (fn, args) { - var color = fn.apply(null, [this].concat([].slice.call(args))); - this._r = color._r; - this._g = color._g; - this._b = color._b; - this.setAlpha(color._a); - return this; - }, - lighten: function () { - return this._applyModification(lighten, arguments); - }, - brighten: function () { - return this._applyModification(brighten, arguments); - }, - darken: function () { - return this._applyModification(darken, arguments); - }, - desaturate: function () { - return this._applyModification(desaturate, arguments); - }, - saturate: function () { - return this._applyModification(saturate, arguments); - }, - greyscale: function () { - return this._applyModification(greyscale, arguments); - }, - spin: function () { - return this._applyModification(spin, arguments); - }, - - _applyCombination: function (fn, args) { - return fn.apply(null, [this].concat([].slice.call(args))); - }, - analogous: function () { - return this._applyCombination(analogous, arguments); - }, - complement: function () { - return this._applyCombination(complement, arguments); - }, - monochromatic: function () { - return this._applyCombination(monochromatic, arguments); - }, - splitcomplement: function () { - return this._applyCombination(splitcomplement, arguments); - }, - triad: function () { - return this._applyCombination(triad, arguments); - }, - tetrad: function () { - return this._applyCombination(tetrad, arguments); - } - }; - - // If input is an object, force 1 into "1.0" to handle ratios properly - // String input requires "1.0" as input, so 1 will be treated as 1 - tinycolor.fromRatio = function (color, opts) { - if (typeof color == "object") { - var newColor = {}; - for (var i in color) { - if (color.hasOwnProperty(i)) { - if (i === "a") { - newColor[i] = color[i]; - } - else { - newColor[i] = convertToPercentage(color[i]); - } - } - } - color = newColor; - } - - return tinycolor(color, opts); - }; - - // Given a string or object, convert that input to RGB - // Possible string inputs: - // - // "red" - // "#f00" or "f00" - // "#ff0000" or "ff0000" - // "#ff000000" or "ff000000" - // "rgb 255 0 0" or "rgb (255, 0, 0)" - // "rgb 1.0 0 0" or "rgb (1, 0, 0)" - // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" - // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" - // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" - // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" - // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" - // - function inputToRGB(color) { - - var rgb = {r: 0, g: 0, b: 0}; - var a = 1; - var ok = false; - var format = false; - - if (typeof color == "string") { - color = stringInputToObject(color); - } - - if (typeof color == "object") { - if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) { - rgb = rgbToRgb(color.r, color.g, color.b); - ok = true; - format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; - } - else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) { - color.s = convertToPercentage(color.s); - color.v = convertToPercentage(color.v); - rgb = hsvToRgb(color.h, color.s, color.v); - ok = true; - format = "hsv"; - } - else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) { - color.s = convertToPercentage(color.s); - color.l = convertToPercentage(color.l); - rgb = hslToRgb(color.h, color.s, color.l); - ok = true; - format = "hsl"; - } - - if (color.hasOwnProperty("a")) { - a = color.a; - } - } - - a = boundAlpha(a); - - return { - ok: ok, - format: color.format || format, - r: mathMin(255, mathMax(rgb.r, 0)), - g: mathMin(255, mathMax(rgb.g, 0)), - b: mathMin(255, mathMax(rgb.b, 0)), - a: a - }; - } - - - // Conversion Functions - // -------------------- - - // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: - // - - // `rgbToRgb` - // Handle bounds / percentage checking to conform to CSS color spec - // - // *Assumes:* r, g, b in [0, 255] or [0, 1] - // *Returns:* { r, g, b } in [0, 255] - function rgbToRgb(r, g, b) { - return { - r: bound01(r, 255) * 255, - g: bound01(g, 255) * 255, - b: bound01(b, 255) * 255 - }; - } - - // `rgbToHsl` - // Converts an RGB color value to HSL. - // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] - // *Returns:* { h, s, l } in [0,1] - function rgbToHsl(r, g, b) { - - r = bound01(r, 255); - g = bound01(g, 255); - b = bound01(b, 255); - - var max = mathMax(r, g, b), min = mathMin(r, g, b); - var h, s, l = (max + min) / 2; - - if (max == min) { - h = s = 0; // achromatic - } - else { - var d = max - min; - s = l > 0.5 ? d / (2 - max - min) : d / (max + min); - switch (max) { - case r: - h = (g - b) / d + (g < b ? 6 : 0); - break; - case g: - h = (b - r) / d + 2; - break; - case b: - h = (r - g) / d + 4; - break; - } - - h /= 6; - } - - return {h: h, s: s, l: l}; - } - - // `hslToRgb` - // Converts an HSL color value to RGB. - // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are - // contained [0, 1] or [0, 100] *Returns:* { r, g, b } in the set [0, 255] - function hslToRgb(h, s, l) { - var r, g, b; - - h = bound01(h, 360); - s = bound01(s, 100); - l = bound01(l, 100); - - function hue2rgb(p, q, t) { - if (t < 0) { - t += 1; - } - if (t > 1) { - t -= 1; - } - if (t < 1 / 6) { - return p + (q - p) * 6 * t; - } - if (t < 1 / 2) { - return q; - } - if (t < 2 / 3) { - return p + (q - p) * (2 / 3 - t) * 6; - } - return p; - } - - if (s === 0) { - r = g = b = l; // achromatic - } - else { - var q = l < 0.5 ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - r = hue2rgb(p, q, h + 1 / 3); - g = hue2rgb(p, q, h); - b = hue2rgb(p, q, h - 1 / 3); - } - - return {r: r * 255, g: g * 255, b: b * 255}; - } - - // `rgbToHsv` - // Converts an RGB color value to HSV - // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] - // *Returns:* { h, s, v } in [0,1] - function rgbToHsv(r, g, b) { - - r = bound01(r, 255); - g = bound01(g, 255); - b = bound01(b, 255); - - var max = mathMax(r, g, b), min = mathMin(r, g, b); - var h, s, v = max; - - var d = max - min; - s = max === 0 ? 0 : d / max; - - if (max == min) { - h = 0; // achromatic - } - else { - switch (max) { - case r: - h = (g - b) / d + (g < b ? 6 : 0); - break; - case g: - h = (b - r) / d + 2; - break; - case b: - h = (r - g) / d + 4; - break; - } - h /= 6; - } - return {h: h, s: s, v: v}; - } - - // `hsvToRgb` - // Converts an HSV color value to RGB. - // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are - // contained in [0, 1] or [0, 100] *Returns:* { r, g, b } in the set [0, - // 255] - function hsvToRgb(h, s, v) { - - h = bound01(h, 360) * 6; - s = bound01(s, 100); - v = bound01(v, 100); - - var i = math.floor(h), - f = h - i, - p = v * (1 - s), - q = v * (1 - f * s), - t = v * (1 - (1 - f) * s), - mod = i % 6, - r = [v, q, p, p, t, v][mod], - g = [t, v, v, q, p, p][mod], - b = [p, p, t, v, v, q][mod]; - - return {r: r * 255, g: g * 255, b: b * 255}; - } - - // `rgbToHex` - // Converts an RGB color to hex - // Assumes r, g, and b are contained in the set [0, 255] - // Returns a 3 or 6 character hex - function rgbToHex(r, g, b, allow3Char) { - - var hex = [ - pad2(mathRound(r).toString(16)), - pad2(mathRound(g).toString(16)), - pad2(mathRound(b).toString(16)) - ]; - - // Return a 3 character hex if possible - if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { - return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); - } - - return hex.join(""); - } - - // `rgbaToHex` - // Converts an RGBA color plus alpha transparency to hex - // Assumes r, g, b and a are contained in the set [0, 255] - // Returns an 8 character hex - function rgbaToHex(r, g, b, a) { - - var hex = [ - pad2(convertDecimalToHex(a)), - pad2(mathRound(r).toString(16)), - pad2(mathRound(g).toString(16)), - pad2(mathRound(b).toString(16)) - ]; - - return hex.join(""); - } - - // `equals` - // Can be called with any tinycolor input - tinycolor.equals = function (color1, color2) { - if (!color1 || !color2) { - return false; - } - return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); - }; - tinycolor.random = function () { - return tinycolor.fromRatio({ - r: mathRandom(), - g: mathRandom(), - b: mathRandom() - }); - }; - - - // Modification Functions - // ---------------------- - // Thanks to less.js for some of the basics here - // - - function desaturate(color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var hsl = tinycolor(color).toHsl(); - hsl.s -= amount / 100; - hsl.s = clamp01(hsl.s); - return tinycolor(hsl); - } - - function saturate(color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var hsl = tinycolor(color).toHsl(); - hsl.s += amount / 100; - hsl.s = clamp01(hsl.s); - return tinycolor(hsl); - } - - function greyscale(color) { - return tinycolor(color).desaturate(100); - } - - function lighten(color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var hsl = tinycolor(color).toHsl(); - hsl.l += amount / 100; - hsl.l = clamp01(hsl.l); - return tinycolor(hsl); - } - - function brighten(color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var rgb = tinycolor(color).toRgb(); - rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * -(amount / 100)))); - rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * -(amount / 100)))); - rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * -(amount / 100)))); - return tinycolor(rgb); - } - - function darken(color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var hsl = tinycolor(color).toHsl(); - hsl.l -= amount / 100; - hsl.l = clamp01(hsl.l); - return tinycolor(hsl); - } - - // Spin takes a positive or negative amount within [-360, 360] indicating - // the change of hue. Values outside of this range will be wrapped into - // this range. - function spin(color, amount) { - var hsl = tinycolor(color).toHsl(); - var hue = (mathRound(hsl.h) + amount) % 360; - hsl.h = hue < 0 ? 360 + hue : hue; - return tinycolor(hsl); - } - - // Combination Functions - // --------------------- - // Thanks to jQuery xColor for some of the ideas behind these - // - - function complement(color) { - var hsl = tinycolor(color).toHsl(); - hsl.h = (hsl.h + 180) % 360; - return tinycolor(hsl); - } - - function triad(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [ - tinycolor(color), - tinycolor({h: (h + 120) % 360, s: hsl.s, l: hsl.l}), - tinycolor({h: (h + 240) % 360, s: hsl.s, l: hsl.l}) - ]; - } - - function tetrad(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [ - tinycolor(color), - tinycolor({h: (h + 90) % 360, s: hsl.s, l: hsl.l}), - tinycolor({h: (h + 180) % 360, s: hsl.s, l: hsl.l}), - tinycolor({h: (h + 270) % 360, s: hsl.s, l: hsl.l}) - ]; - } - - function splitcomplement(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [ - tinycolor(color), - tinycolor({h: (h + 72) % 360, s: hsl.s, l: hsl.l}), - tinycolor({h: (h + 216) % 360, s: hsl.s, l: hsl.l}) - ]; - } - - function analogous(color, results, slices) { - results = results || 6; - slices = slices || 30; - - var hsl = tinycolor(color).toHsl(); - var part = 360 / slices; - var ret = [tinycolor(color)]; - - for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results;) { - hsl.h = (hsl.h + part) % 360; - ret.push(tinycolor(hsl)); - } - return ret; - } - - function monochromatic(color, results) { - results = results || 6; - var hsv = tinycolor(color).toHsv(); - var h = hsv.h, s = hsv.s, v = hsv.v; - var ret = []; - var modification = 1 / results; - - while (results--) { - ret.push(tinycolor({h: h, s: s, v: v})); - v = (v + modification) % 1; - } - - return ret; - } - - // Utility Functions - // --------------------- - - tinycolor.mix = function (color1, color2, amount) { - amount = (amount === 0) ? 0 : (amount || 50); - - var rgb1 = tinycolor(color1).toRgb(); - var rgb2 = tinycolor(color2).toRgb(); - - var p = amount / 100; - var w = p * 2 - 1; - var a = rgb2.a - rgb1.a; - - var w1; - - if (w * a == -1) { - w1 = w; - } - else { - w1 = (w + a) / (1 + w * a); - } - - w1 = (w1 + 1) / 2; - - var w2 = 1 - w1; - - var rgba = { - r: rgb2.r * w1 + rgb1.r * w2, - g: rgb2.g * w1 + rgb1.g * w2, - b: rgb2.b * w1 + rgb1.b * w2, - a: rgb2.a * p + rgb1.a * (1 - p) - }; - - return tinycolor(rgba); - }; - - - // Readability Functions - // --------------------- - // - - // `readability` - // Analyze the 2 colors and returns an object with the following properties: - // `brightness`: difference in brightness between the two colors - // `color`: difference in color/hue between the two colors - tinycolor.readability = function (color1, color2) { - var c1 = tinycolor(color1); - var c2 = tinycolor(color2); - var rgb1 = c1.toRgb(); - var rgb2 = c2.toRgb(); - var brightnessA = c1.getBrightness(); - var brightnessB = c2.getBrightness(); - var colorDiff = ( - Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) + - Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) + - Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b) - ); - - return { - brightness: Math.abs(brightnessA - brightnessB), - color: colorDiff - }; - }; - - // `readable` - // http://www.w3.org/TR/AERT#color-contrast - // Ensure that foreground and background color combinations provide - // sufficient contrast. *Example* tinycolor.isReadable("#000", "#111") => - // false - tinycolor.isReadable = function (color1, color2) { - var readability = tinycolor.readability(color1, color2); - return readability.brightness > 125 && readability.color > 500; - }; - - // `mostReadable` - // Given a base color and a list of possible foreground or background - // colors for that base, returns the most readable color. - // *Example* - // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000" - tinycolor.mostReadable = function (baseColor, colorList) { - var bestColor = null; - var bestScore = 0; - var bestIsReadable = false; - for (var i = 0; i < colorList.length; i++) { - - // We normalize both around the "acceptable" breaking point, - // but rank brightness constrast higher than hue. - - var readability = tinycolor.readability(baseColor, colorList[i]); - var readable = readability.brightness > 125 && readability.color > 500; - var score = 3 * (readability.brightness / 125) + (readability.color / 500); - - if ((readable && !bestIsReadable) || - (readable && bestIsReadable && score > bestScore) || - ((!readable) && (!bestIsReadable) && score > bestScore)) { - bestIsReadable = readable; - bestScore = score; - bestColor = tinycolor(colorList[i]); - } - } - return bestColor; - }; - - - // Big List of Colors - // ------------------ - // - var names = tinycolor.names = { - aliceblue: "f0f8ff", - antiquewhite: "faebd7", - aqua: "0ff", - aquamarine: "7fffd4", - azure: "f0ffff", - beige: "f5f5dc", - bisque: "ffe4c4", - black: "000", - blanchedalmond: "ffebcd", - blue: "00f", - blueviolet: "8a2be2", - brown: "a52a2a", - burlywood: "deb887", - burntsienna: "ea7e5d", - cadetblue: "5f9ea0", - chartreuse: "7fff00", - chocolate: "d2691e", - coral: "ff7f50", - cornflowerblue: "6495ed", - cornsilk: "fff8dc", - crimson: "dc143c", - cyan: "0ff", - darkblue: "00008b", - darkcyan: "008b8b", - darkgoldenrod: "b8860b", - darkgray: "a9a9a9", - darkgreen: "006400", - darkgrey: "a9a9a9", - darkkhaki: "bdb76b", - darkmagenta: "8b008b", - darkolivegreen: "556b2f", - darkorange: "ff8c00", - darkorchid: "9932cc", - darkred: "8b0000", - darksalmon: "e9967a", - darkseagreen: "8fbc8f", - darkslateblue: "483d8b", - darkslategray: "2f4f4f", - darkslategrey: "2f4f4f", - darkturquoise: "00ced1", - darkviolet: "9400d3", - deeppink: "ff1493", - deepskyblue: "00bfff", - dimgray: "696969", - dimgrey: "696969", - dodgerblue: "1e90ff", - firebrick: "b22222", - floralwhite: "fffaf0", - forestgreen: "228b22", - fuchsia: "f0f", - gainsboro: "dcdcdc", - ghostwhite: "f8f8ff", - gold: "ffd700", - goldenrod: "daa520", - gray: "808080", - green: "008000", - greenyellow: "adff2f", - grey: "808080", - honeydew: "f0fff0", - hotpink: "ff69b4", - indianred: "cd5c5c", - indigo: "4b0082", - ivory: "fffff0", - khaki: "f0e68c", - lavender: "e6e6fa", - lavenderblush: "fff0f5", - lawngreen: "7cfc00", - lemonchiffon: "fffacd", - lightblue: "add8e6", - lightcoral: "f08080", - lightcyan: "e0ffff", - lightgoldenrodyellow: "fafad2", - lightgray: "d3d3d3", - lightgreen: "90ee90", - lightgrey: "d3d3d3", - lightpink: "ffb6c1", - lightsalmon: "ffa07a", - lightseagreen: "20b2aa", - lightskyblue: "87cefa", - lightslategray: "789", - lightslategrey: "789", - lightsteelblue: "b0c4de", - lightyellow: "ffffe0", - lime: "0f0", - limegreen: "32cd32", - linen: "faf0e6", - magenta: "f0f", - maroon: "800000", - mediumaquamarine: "66cdaa", - mediumblue: "0000cd", - mediumorchid: "ba55d3", - mediumpurple: "9370db", - mediumseagreen: "3cb371", - mediumslateblue: "7b68ee", - mediumspringgreen: "00fa9a", - mediumturquoise: "48d1cc", - mediumvioletred: "c71585", - midnightblue: "191970", - mintcream: "f5fffa", - mistyrose: "ffe4e1", - moccasin: "ffe4b5", - navajowhite: "ffdead", - navy: "000080", - oldlace: "fdf5e6", - olive: "808000", - olivedrab: "6b8e23", - orange: "ffa500", - orangered: "ff4500", - orchid: "da70d6", - palegoldenrod: "eee8aa", - palegreen: "98fb98", - paleturquoise: "afeeee", - palevioletred: "db7093", - papayawhip: "ffefd5", - peachpuff: "ffdab9", - peru: "cd853f", - pink: "ffc0cb", - plum: "dda0dd", - powderblue: "b0e0e6", - purple: "800080", - rebeccapurple: "663399", - red: "f00", - rosybrown: "bc8f8f", - royalblue: "4169e1", - saddlebrown: "8b4513", - salmon: "fa8072", - sandybrown: "f4a460", - seagreen: "2e8b57", - seashell: "fff5ee", - sienna: "a0522d", - silver: "c0c0c0", - skyblue: "87ceeb", - slateblue: "6a5acd", - slategray: "708090", - slategrey: "708090", - snow: "fffafa", - springgreen: "00ff7f", - steelblue: "4682b4", - tan: "d2b48c", - teal: "008080", - thistle: "d8bfd8", - tomato: "ff6347", - turquoise: "40e0d0", - violet: "ee82ee", - wheat: "f5deb3", - white: "fff", - whitesmoke: "f5f5f5", - yellow: "ff0", - yellowgreen: "9acd32" - }; - - // Make it easy to access colors via `hexNames[hex]` - var hexNames = tinycolor.hexNames = flip(names); - - - // Utilities - // --------- - - // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` - function flip(o) { - var flipped = {}; - for (var i in o) { - if (o.hasOwnProperty(i)) { - flipped[o[i]] = i; - } - } - return flipped; - } - - // Return a valid alpha value [0,1] with all invalid values being set to 1 - function boundAlpha(a) { - a = parseFloat(a); - - if (isNaN(a) || a < 0 || a > 1) { - a = 1; - } - - return a; - } - - // Take input from [0, n] and return it as [0, 1] - function bound01(n, max) { - if (isOnePointZero(n)) { - n = "100%"; - } - - var processPercent = isPercentage(n); - n = mathMin(max, mathMax(0, parseFloat(n))); - - // Automatically convert percentage into number - if (processPercent) { - n = parseInt(n * max, 10) / 100; - } - - // Handle floating point rounding errors - if ((math.abs(n - max) < 0.000001)) { - return 1; - } - - // Convert into [0, 1] range if it isn't already - return (n % max) / parseFloat(max); - } - - // Force a number between 0 and 1 - function clamp01(val) { - return mathMin(1, mathMax(0, val)); - } - - // Parse a base-16 hex value into a base-10 integer - function parseIntFromHex(val) { - return parseInt(val, 16); - } - - // Need to handle 1.0 as 100%, since once it is a number, there is no - // difference between it and 1 - // - function isOnePointZero(n) { - return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; - } - - // Check to see if string passed in is a percentage - function isPercentage(n) { - return typeof n === "string" && n.indexOf('%') != -1; - } - - // Force a hex value to have 2 characters - function pad2(c) { - return c.length == 1 ? '0' + c : '' + c; - } - - // Replace a decimal with it's percentage value - function convertToPercentage(n) { - if (n <= 1) { - n = (n * 100) + "%"; - } - - return n; - } - - // Converts a decimal to a hex value - function convertDecimalToHex(d) { - return Math.round(parseFloat(d) * 255).toString(16); - } - - // Converts a hex value to a decimal - function convertHexToDecimal(h) { - return (parseIntFromHex(h) / 255); - } - - var matchers = (function () { - - // - var CSS_INTEGER = "[-\\+]?\\d+%?"; - - // - var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; - - // Allow positive/negative integer/number. Don't capture the either/or, - // just the entire outcome. - var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; - - // Actual matching. - // Parentheses and commas are optional, but not required. - // Whitespace can take the place of commas or opening paren - var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; - var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; - - return { - rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), - rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), - hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), - hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), - hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), - hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), - hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, - hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, - hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ - }; - })(); - - // `stringInputToObject` - // Permissive string parsing. Take in a number of formats, and output an - // object based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` - // or `{ h, s, v}` - function stringInputToObject(color) { - - color = color.replace(trimLeft, '').replace(trimRight, '').toLowerCase(); - var named = false; - if (names[color]) { - color = names[color]; - named = true; - } - else if (color == 'transparent') { - return {r: 0, g: 0, b: 0, a: 0, format: "name"}; - } - - // Try to match string input using regular expressions. - // Keep most of the number bounding out of this function - don't worry - // about [0,1] or [0,100] or [0,360] Just return an object and let the - // conversion functions handle that. This way the result will be the same - // whether the tinycolor is initialized with string or object. - var match; - if ((match = matchers.rgb.exec(color))) { - return {r: match[1], g: match[2], b: match[3]}; - } - if ((match = matchers.rgba.exec(color))) { - return {r: match[1], g: match[2], b: match[3], a: match[4]}; - } - if ((match = matchers.hsl.exec(color))) { - return {h: match[1], s: match[2], l: match[3]}; - } - if ((match = matchers.hsla.exec(color))) { - return {h: match[1], s: match[2], l: match[3], a: match[4]}; - } - if ((match = matchers.hsv.exec(color))) { - return {h: match[1], s: match[2], v: match[3]}; - } - if ((match = matchers.hsva.exec(color))) { - return {h: match[1], s: match[2], v: match[3], a: match[4]}; - } - if ((match = matchers.hex8.exec(color))) { - return { - a: convertHexToDecimal(match[1]), - r: parseIntFromHex(match[2]), - g: parseIntFromHex(match[3]), - b: parseIntFromHex(match[4]), - format: named ? "name" : "hex8" - }; - } - if ((match = matchers.hex6.exec(color))) { - return { - r: parseIntFromHex(match[1]), - g: parseIntFromHex(match[2]), - b: parseIntFromHex(match[3]), - format: named ? "name" : "hex" - }; - } - if ((match = matchers.hex3.exec(color))) { - return { - r: parseIntFromHex(match[1] + '' + match[1]), - g: parseIntFromHex(match[2] + '' + match[2]), - b: parseIntFromHex(match[3] + '' + match[3]), - format: named ? "name" : "hex" - }; - } - - return false; - } - - window.tinycolor = tinycolor; - })(); - - $(function () { - if ($.fn.spectrum.load) { - $.fn.spectrum.processNativeColorInputs(); - } - }); - -}); diff --git a/modules/os2forms_webform_maps/modules/field_color/src/Component/FieldColorValidation.php b/modules/os2forms_webform_maps/modules/field_color/src/Component/FieldColorValidation.php deleted file mode 100644 index 9d6403fc..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/src/Component/FieldColorValidation.php +++ /dev/null @@ -1,19 +0,0 @@ - TRUE, - '#process' => [ - [$class, 'processTestElement'], - [$class, 'processGroup'], - ], - '#pre_render' => [ - [$class, 'preRenderColor'], - [$class, 'preRenderGroup'], - ], - '#element_validate' => [ - [$class, 'validateColor'], - ], - '#theme' => 'input_color', - '#theme_wrappers' => ['form_element'], - ]; - } - - /** - * {@inheritdoc} - */ - public static function processTestElement(&$element, FormStateInterface $form_state, &$form) { - return $element; - } - - /** - * Prepares a #type 'color' render element for input.html.twig. - * - * @param array $element - * An associative array containing the properties of the element. - * Properties used: #title, #value, #description, #attributes. - * - * @return array - * The $element with prepared variables ready for input.html.twig. - */ - public static function preRenderColor(array $element) { - $element['#attributes']['type'] = 'text'; - $element['#attributes']['class'] = []; - $element['#attributes']['class'][] = 'input-field-color'; - Element::setAttributes($element, [ - 'id', 'name', 'value', 'class', 'size', 'field-color', - ]); - - $element['#palette'] = preg_replace("/[\r\n]+/", "", $element['#palette']); - $element['#selectionPalette'] = preg_replace("/[\r\n]+/", "", $element['#selectionPalette']); - $element['#default_value'] = $element['#color']; - - $element['#attached'] = [ - 'library' => [ - 'field_color/field_color.admin', - ], - 'drupalSettings' => [ - 'size' => $element['#size'] ?? 22, - 'type_' => $element['#type_'] ?? 'component', -// 'color' => $element['#color'], - 'showInput' => (Boolean)($element['#showInput'] ?? true), - 'showInitial' => (Boolean)($element['#showInitial'] ?? false), - 'allowEmpty' => (Boolean)($element['#allowEmpty'] ?? false), - 'showAlpha' => (Boolean)($element['#showAlpha'] ?? true), - 'disabled' => (Boolean)($element['#disabled'] ?? false), - 'localStorageKey' => $element['#localStorageKey'] ?? false, - 'showPalette' => (Boolean)($element['#showPalette'] ?? true), - 'showButtons' => (Boolean)($element['#showButtons'] ?? true), - 'showPaletteOnly' => (Boolean)($element['#showPaletteOnly'] ?? false), - 'togglePaletteOnly' => (Boolean)($element['#togglePaletteOnly'] ?? true), - 'showSelectionPalette' => (Boolean)($element['#showSelectionPalette'] ?? true), - 'clickoutFiresChange' => (Boolean)($element['#clickoutFiresChange'] ?? true), - 'hideAfterPaletteSelect' => (Boolean)($element['#hideAfterPaletteSelect'] ?? true), - 'containerClassName' => $element['#containerClassName'] ?? '', - 'replacerClassName' => $element['#replacerClassName'] ?? '', - 'preferredFormat' => $element['#preferredFormat'] ?? 'hex', - 'cancelText' => $element['#cancelText'] ?? 'cancel', - 'chooseText' => $element['#chooseText'] ?? 'choose', - 'togglePaletteMoreText' => $element['#togglePaletteMoreText'] ?? 'more', - 'togglePaletteLessText' => $element['#togglePaletteLessText'] ?? 'less', - 'clearText' => $element['#clearText'] ?? 'Clear Color Selection', - 'noColorSelectedText' => $element['#noColorSelectedText'] ?? 'No Color Selected', - 'palette' => json_decode($element['#palette'], TRUE) ?? [ - ["#000", "#444", "#5b5b5b", "#999", "#bcbcbc", "#eee", "#f3f6f4", "#fff"], - ["#f44336", "#744700", "#ce7e00", "#8fce00", "#2986cc", "#16537e", "#6a329f", "#c90076"], - ["#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#cfe2f3", "#d9d2e9", "#ead1dc"], - ["#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#9fc5e8", "#b4a7d6", "#d5a6bd"], - ["#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6fa8dc", "#8e7cc3", "#c27ba0"], - ["#c00", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3d85c6", "#674ea7", "#a64d79"], - ["#900", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#0b5394", "#351c75", "#741b47"], - ["#600", "#783f04", "#7f6000", "#274e13", "#0c343d", "#073763", "#20124d", "#4c1130"] - ], - 'selectionPalette' => json_decode($element['#selectionPalette']) ?? [], - 'maxSelectionSize' => $element['#maxSelectionSize'] ?? 8, - 'locale' => $element['#locale'] ?? 'en', - ], - ]; - - return $element; - } - - /** - * Form element validation handler for #type 'color'. - */ - public static function validateColor(&$element, FormStateInterface $form_state, &$complete_form) { - $value = trim($element['#value']); - if (!empty($value) && !FieldColorValidation::all($value)) { - error_log($value); - $form_state->setError($element, t('Field %name must be a valid color.', ['%name' => empty($element['#title']) ? $element['#parents'][0] : $element['#title']])); - } - } - - /** - * {@inheritdoc} - */ - public static function valueCallback(&$element, $input, FormStateInterface $form_state) { - if ($input !== FALSE && $input !== NULL) { - // This should be a string, but allow other scalars since they might be - // valid input in programmatic form submissions. - return is_scalar($input) ? (string) $input : ''; - } - return NULL; - } - -} diff --git a/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldFormatter/FieldColorFormatterType.php b/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldFormatter/FieldColorFormatterType.php deleted file mode 100644 index 8b91f2e3..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldFormatter/FieldColorFormatterType.php +++ /dev/null @@ -1,74 +0,0 @@ - $item) { - $elements[$delta] = ['#markup' => $this->viewValue($item)]; - } - - return $elements; - } - - /** - * Generate the output appropriate for one field item. - * - * @param \Drupal\Core\Field\FieldItemInterface $item - * One field item. - * - * @return string - * The textual output generated. - */ - protected function viewValue(FieldItemInterface $item) { - // The text value has no text format assigned to it, so the user input - // should equal the output, including newlines. - return nl2br(Html::escape($item->value)); - } - -} diff --git a/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldType/FieldColor.php b/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldType/FieldColor.php deleted file mode 100644 index 335c5434..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldType/FieldColor.php +++ /dev/null @@ -1,127 +0,0 @@ - 255, - 'is_ascii' => FALSE, - 'case_sensitive' => FALSE, - ] + parent::defaultStorageSettings(); - } - - /** - * {@inheritdoc} - */ - public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { - // Prevent early t() calls by using the TranslatableMarkup. - $properties['value'] = DataDefinition::create('string') - ->setLabel(new TranslatableMarkup('Text value')) - ->setSetting('case_sensitive', $field_definition->getSetting('case_sensitive')) - ->setRequired(TRUE); - - return $properties; - } - - /** - * {@inheritdoc} - */ - public static function schema(FieldStorageDefinitionInterface $field_definition) { - $schema = [ - 'columns' => [ - 'value' => [ - 'type' => $field_definition->getSetting('is_ascii') === TRUE ? 'varchar_ascii' : 'varchar', - 'length' => (int) $field_definition->getSetting('max_length'), - 'binary' => $field_definition->getSetting('case_sensitive'), - ], - ], - ]; - - return $schema; - } - - /** - * {@inheritdoc} - */ - public function getConstraints() { - $constraints = parent::getConstraints(); - - if ($max_length = $this->getSetting('max_length')) { - $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); - $constraints[] = $constraint_manager->create('ComplexData', [ - 'value' => [ - 'Length' => [ - 'max' => $max_length, - 'maxMessage' => $this->t('%name: may not be longer than @max characters.', [ - '%name' => $this->getFieldDefinition()->getLabel(), - '@max' => $max_length, - ]), - ], - ], - ]); - } - - return $constraints; - } - - /** - * {@inheritdoc} - */ - public static function generateSampleValue(FieldDefinitionInterface $field_definition) { - $random = new Random(); - $values['value'] = $random->word(mt_rand(1, $field_definition->getSetting('max_length'))); - return $values; - } - - /** - * {@inheritdoc} - */ - public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) { - $elements = []; - - $elements['max_length'] = [ - '#type' => 'number', - '#title' => $this->t('Maximum length'), - '#default_value' => $this->getSetting('max_length'), - '#required' => TRUE, - '#description' => $this->t('The maximum length of the field in characters.'), - '#min' => 1, - '#disabled' => $has_data, - ]; - - return $elements; - } - - /** - * {@inheritdoc} - */ - public function isEmpty() { - $value = $this->get('value')->getValue(); - return $value === NULL || $value === ''; - } - -} diff --git a/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldWidget/FieldColorWidgetType.php b/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldWidget/FieldColorWidgetType.php deleted file mode 100644 index 36218224..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/src/Plugin/Field/FieldWidget/FieldColorWidgetType.php +++ /dev/null @@ -1,345 +0,0 @@ - 22, - 'placeholder' => '', - 'preferredFormat' => 'hex', - 'type_' => 'color', - 'showInput' => 1, - 'showInitial' => 0, - 'allowEmpty' => 1, - 'showAlpha' => 1, - 'disabled' => 0, - 'showButtons' => 1, - 'localStorageKey' => FALSE, - 'showPalette' => 1, - 'showPaletteOnly' => 0, - 'togglePaletteOnly' => 0, - 'showSelectionPalette' => 1, - 'selectionPalette' => '[]', - 'clickoutFiresChange' => 1, - 'hideAfterPaletteSelect' => 0, - 'containerClassName' => '', - 'replacerClassName' => '', - 'cancelText' => 'Cancel', - 'chooseText' => 'Choose', - 'togglePaletteMoreText' => 'More', - 'togglePaletteLessText' => 'Less', - 'clearText' => 'Clear Color Selection', - 'noColorSelectedText' => 'No Color Selected', - 'palette' => '[ - ["#000000","#444444","#5b5b5b","#999999","#bcbcbc","#eeeeee","#f3f6f4","#ffffff"], - ["#f44336","#744700","#ce7e00","#8fce00","#2986cc","#16537e","#6a329f","#c90076"], - ["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"], - ["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"], - ["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"], - ["#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"], - ["#990000","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"], - ["#660000","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"] - ]', - 'maxSelectionSize' => 6, - 'locale' => 'en', - ] + parent::defaultSettings(); - } - - /** - * {@inheritdoc} - */ - public function settingsForm(array $form, FormStateInterface $form_state) { - $elements = []; - - $elements['size'] = [ - '#type' => 'number', - '#title' => $this->t('Size of textfield'), - '#default_value' => $this->getSetting('size'), - '#required' => TRUE, - '#min' => 1, - ]; - $elements['placeholder'] = [ - '#type' => 'textfield', - '#title' => $this->t('Placeholder'), - '#default_value' => $this->getSetting('placeholder'), - '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ]; - $elements['preferredFormat'] = [ - '#type' => 'select', - '#title' => $this->t('Preferred Format'), - '#default_value' => $this->getSetting('preferredFormat'), - '#options' => [ - 'hex' => $this->t('hex'), - 'hex3' => $this->t('hex3'), - 'hsl' => $this->t('hsl'), - 'rgb' => $this->t('rgb'), - 'name' => $this->t('name'), - ], - ]; - $elements['type_'] = [ - '#type' => 'select', - '#title' => $this->t('type'), - '#default_value' => $this->getSetting('type'), - '#options' => [ - 'color' => $this->t('color'), - 'text' => $this->t('text'), - 'component' => $this->t('component'), - 'float' => $this->t('float'), - ], - ]; - $elements['showInput'] = [ - '#type' => 'select', - '#title' => $this->t('Show Input'), - '#default_value' => $this->getSetting('showInput'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['showInitial'] = [ - '#type' => 'select', - '#title' => $this->t('Show Initial'), - '#default_value' => $this->getSetting('showInitial'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['allowEmpty'] = [ - '#type' => 'select', - '#title' => $this->t('Allow Empty'), - '#default_value' => $this->getSetting('allowEmpty'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['showAlpha'] = [ - '#type' => 'select', - '#title' => $this->t('Show Alpha'), - '#default_value' => $this->getSetting('showAlpha'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['showButtons'] = [ - '#type' => 'select', - '#title' => $this->t('Show Buttons'), - '#default_value' => $this->getSetting('showButtons'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['disabled'] = [ - '#type' => 'select', - '#title' => $this->t('Disabled'), - '#default_value' => $this->getSetting('disabled'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['localStorageKey'] = [ - '#type' => 'textfield', - '#title' => $this->t('Local Storage Key'), - '#default_value' => $this->getSetting('localStorageKey'), - ]; - $elements['showPalette'] = [ - '#type' => 'select', - '#title' => $this->t('Show Palette'), - '#default_value' => $this->getSetting('showPalette'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['showPaletteOnly'] = [ - '#type' => 'select', - '#title' => $this->t('Show Palette Only'), - '#default_value' => $this->getSetting('showPaletteOnly'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['togglePaletteOnly'] = [ - '#type' => 'select', - '#title' => $this->t('Toggle Palette Only'), - '#default_value' => $this->getSetting('togglePaletteOnly'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['showSelectionPalette'] = [ - '#type' => 'select', - '#title' => $this->t('Show Selection Palette'), - '#default_value' => $this->getSetting('showSelectionPalette'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['selectionPalette'] = [ - '#type' => 'textarea', - '#title' => $this->t('Selection Palette'), - '#default_value' => $this->getSetting('selectionPalette'), - ]; - $elements['clickoutFiresChange'] = [ - '#type' => 'select', - '#title' => $this->t('Clickout Fires Change'), - '#default_value' => $this->getSetting('clickoutFiresChange'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['hideAfterPaletteSelect'] = [ - '#type' => 'select', - '#title' => $this->t('Hide After Palette Select'), - '#default_value' => $this->getSetting('hideAfterPaletteSelect'), - '#options' => [ - 0 => $this->t('FALSE'), - 1 => $this->t('TRUE'), - ], - ]; - $elements['containerClassName'] = [ - '#type' => 'textfield', - '#title' => $this->t('Container Class Name'), - '#default_value' => $this->getSetting('containerClassName'), - ]; - $elements['replacerClassName'] = [ - '#type' => 'textfield', - '#title' => $this->t('Replacer Class Name'), - '#default_value' => $this->getSetting('replacerClassName'), - ]; - $elements['cancelText'] = [ - '#type' => 'textfield', - '#title' => $this->t('Cancel Text'), - '#default_value' => $this->getSetting('cancelText'), - ]; - $elements['chooseText'] = [ - '#type' => 'textfield', - '#title' => $this->t('Choose Text'), - '#default_value' => $this->getSetting('chooseText'), - ]; - $elements['togglePaletteMoreText'] = [ - '#type' => 'textfield', - '#title' => $this->t('Toggle Palette More Text'), - '#default_value' => $this->getSetting('togglePaletteMoreText'), - ]; - $elements['togglePaletteLessText'] = [ - '#type' => 'textfield', - '#title' => $this->t('Toggle Palette Less Text'), - '#default_value' => $this->getSetting('togglePaletteLessText'), - ]; - $elements['clearText'] = [ - '#type' => 'textfield', - '#title' => $this->t('Clear Text'), - '#default_value' => $this->getSetting('clearText'), - ]; - $elements['noColorSelectedText'] = [ - '#type' => 'textfield', - '#title' => $this->t('No Color Selected Text'), - '#default_value' => $this->getSetting('noColorSelectedText'), - ]; - $elements['palette'] = [ - '#type' => 'textarea', - '#title' => $this->t('Palette'), - '#default_value' => $this->getSetting('palette'), - ]; - $elements['maxSelectionSize'] = [ - '#type' => 'textfield', - '#title' => $this->t('Max Selection Size'), - '#default_value' => $this->getSetting('maxSelectionSize'), - ]; - $elements['locale'] = [ - '#type' => 'textfield', - '#title' => $this->t('Locale'), - '#default_value' => $this->getSetting('locale'), - ]; - - return $elements; - } - - /** - * {@inheritdoc} - */ - public function settingsSummary() { - $summary = []; - - $summary[] = $this->t('Textfield size: @size', ['@size' => $this->getSetting('size')]); - if (!empty($this->getSetting('placeholder'))) { - $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $this->getSetting('placeholder')]); - } - - return $summary; - } - - /** - * {@inheritdoc} - */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $element['value'] = $element + [ - '#type' => 'input_color', - '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, - '#size' => $this->getSetting('size'), - '#placeholder' => $this->getSetting('placeholder'), - '#preferredFormat' => $this->getSetting('preferredFormat'), - '#showInput' => $this->getSetting('showInput'), - '#showInitial' => $this->getSetting('showInitial'), - '#allowEmpty' => $this->getSetting('allowEmpty'), - '#showAlpha' => $this->getSetting('showAlpha'), - '#showButtons' => $this->getSetting('showButtons'), - '#disabled' => $this->getSetting('disabled'), - '#localStorageKey' => $this->getSetting('localStorageKey'), - '#showPalette' => $this->getSetting('showPalette'), - '#showPaletteOnly' => $this->getSetting('showPaletteOnly'), - '#togglePaletteOnly' => $this->getSetting('togglePaletteOnly'), - '#showSelectionPalette' => $this->getSetting('showSelectionPalette'), - '#selectionPalette' => $this->getSetting('selectionPalette'), - '#clickoutFiresChange' => $this->getSetting('clickoutFiresChange'), - '#containerClassName' => $this->getSetting('containerClassName'), - '#replacerClassName' => $this->getSetting('replacerClassName'), - '#cancelText' => $this->getSetting('cancelText'), - '#chooseText' => $this->getSetting('chooseText'), - '#togglePaletteMoreText' => $this->getSetting('togglePaletteMoreText'), - '#togglePaletteLessText' => $this->getSetting('togglePaletteLessText'), - '#clearText' => $this->getSetting('clearText'), - '#noColorSelectedText' => $this->getSetting('noColorSelectedText'), - '#palette' => $this->getSetting('palette'), - '#type_' => $this->getSetting('type_'), - '#maxSelectionSize' => $this->getSetting('maxSelectionSize'), - '#locale' => $this->getSetting('locale'), - '#hideAfterPaletteSelect' => $this->getSetting('hideAfterPaletteSelect'), - '#maxlength' => $this->getFieldSetting('max_length'), - ]; - - - return $element; - } - -} diff --git a/modules/os2forms_webform_maps/modules/field_color/templates/input-color.html.twig b/modules/os2forms_webform_maps/modules/field_color/templates/input-color.html.twig deleted file mode 100644 index dbbcdbb4..00000000 --- a/modules/os2forms_webform_maps/modules/field_color/templates/input-color.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ children }} diff --git a/modules/os2forms_webform_maps/os2forms_webform_maps.module b/modules/os2forms_webform_maps/os2forms_webform_maps.module index 819b988a..af545a5d 100644 --- a/modules/os2forms_webform_maps/os2forms_webform_maps.module +++ b/modules/os2forms_webform_maps/os2forms_webform_maps.module @@ -41,7 +41,7 @@ function os2forms_webform_maps_preprocess_webform_element_base_html__webform_map $variables['value']['#plain_text'] = $decoded_value->geojson; // Load the webform element base HTML template. - \Drupal::moduleHandler()->loadInclude('webform', 'inc', 'webform.theme.template'); + \Drupal::moduleHandler()->loadInclude('webform', 'inc', 'includes/webform.theme.template'); template_preprocess_webform_element_base_html($variables); // Generate a unique ID for the map image. diff --git a/modules/os2forms_webform_texts/os2forms_webform_texts.info.yml b/modules/os2forms_webform_texts/os2forms_webform_texts.info.yml index 60829e61..a341d77c 100644 --- a/modules/os2forms_webform_texts/os2forms_webform_texts.info.yml +++ b/modules/os2forms_webform_texts/os2forms_webform_texts.info.yml @@ -2,8 +2,7 @@ name: 'OS2forms webform texts' type: module description: 'Provides reusable webform tekst.' package: OS2Forms -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'drupal:webform_node_element' diff --git a/modules/webform_embed/README.md b/modules/webform_embed/README.md deleted file mode 100644 index cfb42400..00000000 --- a/modules/webform_embed/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Webform Embed - -This is a copy of the abandoned project https://www.drupal.org/project/webform_embed. - -Since there is no drupal 9 version available and there probably never will be, future maintenance of this module must be -handled by the os2forms development team. diff --git a/modules/webform_embed/src/Controller/WebformEmbedController.php b/modules/webform_embed/src/Controller/WebformEmbedController.php deleted file mode 100644 index 52cc90ea..00000000 --- a/modules/webform_embed/src/Controller/WebformEmbedController.php +++ /dev/null @@ -1,97 +0,0 @@ -entityManager = $entity_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity_type.manager') - ); - } - - /** - * @param $webform - * - * @return array - * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException - * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException - */ - public function displayForm($webform) { - - $form = $this->loadForm($webform); - if ($form) { - $output = $this->renderForm($form); - } - else { - $output = "No webform to display."; - } - - return [ - '#theme' => 'page__webform_embed', - '#webform_output' => $output, - ]; - - } - - /** - * @param $machineName - * - * @return \Drupal\Core\Entity\EntityInterface|null - * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException - * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException - */ - protected function loadForm($machineName) { - try { - $form = $this->entityManager - ->getStorage('webform') - ->load($machineName); - return $form; - } - catch (RequestException $e) { - $message = 'Webform failed to load ::' . $e->getMessage(); - \Drupal::logger('webform_embed')->error($message); - } - return NULL; - } - - /** - * @param $form - * - * @return array - */ - protected function renderForm($form) { - $output = $this->entityManager - ->getViewBuilder('webform') - ->view($form); - return $output; - } - -} diff --git a/modules/webform_embed/src/EventSubscriber/WebformEmbedSubscriber.php b/modules/webform_embed/src/EventSubscriber/WebformEmbedSubscriber.php deleted file mode 100644 index e41878f1..00000000 --- a/modules/webform_embed/src/EventSubscriber/WebformEmbedSubscriber.php +++ /dev/null @@ -1,39 +0,0 @@ -getPath(); - $patterns = "/webform_embed/displayForm/*\n/form/*"; - $match = \Drupal::service('path.matcher')->matchPath($current_path, $patterns); - - if ($match == TRUE) { - $response = $event->getResponse(); - $response->headers->remove('X-Frame-Options'); - } - } - -} diff --git a/modules/webform_embed/templates/page--webform-embed.html.twig b/modules/webform_embed/templates/page--webform-embed.html.twig deleted file mode 100644 index c4c0cf81..00000000 --- a/modules/webform_embed/templates/page--webform-embed.html.twig +++ /dev/null @@ -1,8 +0,0 @@ -{# -/** - * @file - * Webform Embed Page template overide. - */ -#} -
{{ webform_output }}
-{{ page.content }} diff --git a/modules/webform_embed/webform_embed.info.yml b/modules/webform_embed/webform_embed.info.yml deleted file mode 100644 index 401cca68..00000000 --- a/modules/webform_embed/webform_embed.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: 'Webform Embed' -type: module -description: 'Allows you to embed webforms within an iframe on another site.' -core: 8.x -core_version_requirement: ^8 || ^9 -package: 'Webform' diff --git a/modules/webform_embed/webform_embed.module b/modules/webform_embed/webform_embed.module deleted file mode 100644 index 2a31e7cd..00000000 --- a/modules/webform_embed/webform_embed.module +++ /dev/null @@ -1,75 +0,0 @@ -' . t('About') . ''; - $output .= '

' . t('Allows you to embed webforms within an iframe on another site.') . '

'; - return $output; - - default: - } -} - -/** - * @param $existing - * @param $type - * @param $theme - * @param $path - * - * @return array - */ -function webform_embed_theme($existing, $type, $theme, $path) { - - return [ - 'page__webform_embed' => [ - 'variables' => ['webform_output' => NULL], - ], - ]; - -} - -/** - * Implements hook_menu_local_tasks_alter(). - * - * @param $data - * @param $route_name - */ -function webform_embed_menu_local_tasks_alter(&$data, $route_name) { - $webform = \Drupal::routeMatch()->getParameter('webform'); - $routeName = \Drupal::routeMatch()->getRouteName(); - if ($webform && $routeName == $route_name) { - if (is_object($webform)) { - $webform = $webform->id(); - } - $data['tabs'][0]['entity.webform.embed'] = [ - '#theme' => 'menu_local_task', - '#link' => [ - 'title' => t('Embed'), - 'url' => Url::fromRoute('webform_embed.webform_embed_controller_display_form', ['webform' => $webform]), - 'localized_options' => [ - 'attributes' => [ - 'title' => t('Embed Webform'), - ], - ], - ], - ]; - } - -} diff --git a/modules/webform_embed/webform_embed.routing.yml b/modules/webform_embed/webform_embed.routing.yml deleted file mode 100644 index 26d317f1..00000000 --- a/modules/webform_embed/webform_embed.routing.yml +++ /dev/null @@ -1,7 +0,0 @@ -webform_embed.webform_embed_controller_display_form: - path: '/webform_embed/displayForm/{webform}' - defaults: - _controller: '\Drupal\webform_embed\Controller\WebformEmbedController::displayForm' - _title: 'Display Form' - requirements: - _permission: 'access content' diff --git a/modules/webform_embed/webform_embed.services.yml b/modules/webform_embed/webform_embed.services.yml deleted file mode 100644 index c162e4ca..00000000 --- a/modules/webform_embed/webform_embed.services.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - webform_embed.subscriber: - class: Drupal\webform_embed\EventSubscriber\WebformEmbedSubscriber - arguments: [] - tags: - - { name: event_subscriber } diff --git a/os2forms.info.yml b/os2forms.info.yml index 43eaf79e..f28e5d4a 100644 --- a/os2forms.info.yml +++ b/os2forms.info.yml @@ -2,8 +2,7 @@ name: 'OS2Forms' type: module description: 'Provides advanced webform functionality for Danish Municipalities.' package: OS2Forms -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - 'drupal:ckeditor' diff --git a/os2forms.install b/os2forms.install index fe2c0018..d7d9975d 100644 --- a/os2forms.install +++ b/os2forms.install @@ -17,7 +17,7 @@ use Symfony\Component\Yaml\Yaml; * Configuration name. */ function os2forms_read_in_new_config($config_name, $moduleName = '') { - $path = drupal_get_path('module', $moduleName ?: 'os2forms'); + $path = \Drupal::service('extension.list.module')->getPath($moduleName ?: 'os2forms'); /** @var \Drupal\Core\Config\StorageInterface $active_storage */ $active_storage = \Drupal::service('config.storage'); $active_storage->write($config_name, Yaml::parse(file_get_contents($path . '/config/optional/' . $config_name . '.yml'))); @@ -140,24 +140,25 @@ function os2forms_update_8904() { // Add field field.field.node.webform.field_os2forms_wff_area. // Field storage. - $field_storage_yml = Yaml::parse(file_get_contents(drupal_get_path('module', 'os2forms') . "/config/optional/field.storage.node.field_os2forms_wff_area.yml")); + $path = \Drupal::service('extension.list.module')->getPath('os2forms'); + $field_storage_yml = Yaml::parse(file_get_contents("$path/config/optional/field.storage.node.field_os2forms_wff_area.yml")); if (!FieldStorageConfig::loadByName('node', 'field_os2forms_wff_area')) { FieldStorageConfig::create($field_storage_yml)->save(); } // Field instance. - $field_yml = Yaml::parse(file_get_contents(drupal_get_path('module', 'os2forms') . "/config/optional/field.field.node.webform.field_os2forms_wff_area.yml")); + $field_yml = Yaml::parse(file_get_contents("$path/config/optional/field.field.node.webform.field_os2forms_wff_area.yml")); if (!FieldConfig::loadByName('node', 'webform', 'field_os2forms_wff_area')) { FieldConfig::create($field_yml)->save(); } // Add field field.field.node.webform.field_os2forms_wff_application. // Field storage. - $field_storage_yml = Yaml::parse(file_get_contents(drupal_get_path('module', 'os2forms') . "/config/optional/field.storage.node.field_os2forms_wff_application.yml")); + $field_storage_yml = Yaml::parse(file_get_contents("$path/config/optional/field.storage.node.field_os2forms_wff_application.yml")); if (!FieldStorageConfig::loadByName('node', 'field_os2forms_wff_application')) { FieldStorageConfig::create($field_storage_yml)->save(); } // Field instance. - $field_yml = Yaml::parse(file_get_contents(drupal_get_path('module', 'os2forms') . "/config/optional/field.field.node.webform.field_os2forms_wff_application.yml")); + $field_yml = Yaml::parse(file_get_contents("$path/config/optional/field.field.node.webform.field_os2forms_wff_application.yml")); if (!FieldConfig::loadByName('node', 'webform', 'field_os2forms_wff_application')) { FieldConfig::create($field_yml)->save(); } diff --git a/scripts/code-analysis b/scripts/code-analysis index f8ace6c7..9fec0f46 100755 --- a/scripts/code-analysis +++ b/scripts/code-analysis @@ -11,9 +11,9 @@ drupal_composer() { composer --working-dir="$drupal_dir" --no-interaction "$@" } -# Create new Drupal 9 project +# Create new Drupal 10 project if [ ! -f "$drupal_dir/composer.json" ]; then - composer --no-interaction create-project drupal/recommended-project:^9 "$drupal_dir" + composer --no-interaction create-project drupal/recommended-project:^10 "$drupal_dir" fi # Copy our code into the modules folder mkdir -p "$drupal_dir/$module_path" @@ -26,6 +26,11 @@ drupal_composer config minimum-stability dev # https://getcomposer.org/doc/06-config.md#allow-plugins drupal_composer config --no-plugins allow-plugins true +# Making Drupal 10 compatible +drupal_composer require psr/http-message:^1.0 +drupal_composer require mglaman/composer-drupal-lenient +drupal_composer config --merge --json extra.drupal-lenient.allowed-list '["drupal/coc_forms_auto_export", "drupal/webform_node_element"]' + drupal_composer require wikimedia/composer-merge-plugin drupal_composer config extra.merge-plugin.include "$module_path/composer.json" # https://www.drupal.org/project/drupal/issues/3220043#comment-14845434 diff --git a/src/Plugin/WebformElement/Os2formsPersonLookup.php b/src/Plugin/WebformElement/Os2formsPersonLookup.php index b3bee21e..54ad0b94 100644 --- a/src/Plugin/WebformElement/Os2formsPersonLookup.php +++ b/src/Plugin/WebformElement/Os2formsPersonLookup.php @@ -46,7 +46,7 @@ protected function defineDefaultProperties() { /** * {@inheritdoc} */ - protected function prepareElementValidateCallbacks(array &$element, WebformSubmissionInterface $webform_submission = NULL) { + protected function prepareElementValidateCallbacks(array &$element, ?WebformSubmissionInterface $webform_submission = NULL) { parent::prepareElementValidateCallbacks($element, $webform_submission); $element['#element_validate'][] = [get_class($this), 'validatePerson'];