-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from mailjet/develop
Develop
- Loading branch information
Showing
8 changed files
with
67 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(function ($) { | ||
|
||
// Sorted field is empty by default | ||
var sortedFieldsArray = []; | ||
|
||
// Get last saved data value | ||
var sortFieldsValue = $('#edit-sort-fields').val(); | ||
if (sortFieldsValue !== '') { | ||
// Split last saved data to an array | ||
sortedFieldsArray = $('#edit-sort-fields').val().split(','); | ||
} | ||
|
||
$("#mailjet-subscription-form-edit-form .form-checkboxes .form-checkbox").click(function () { | ||
// Value of the checkbox that just has been clicked | ||
var selectedProperty = $(this).val(); | ||
|
||
// Check if the property is alredy in the sorted array | ||
var index = sortedFieldsArray.indexOf(selectedProperty); | ||
|
||
if (index === -1) { | ||
// Add property to the sorted array | ||
sortedFieldsArray.push(selectedProperty); | ||
} else { | ||
// Remove property from the sorted array | ||
sortedFieldsArray.splice($.inArray(selectedProperty, sortedFieldsArray), 1); | ||
} | ||
|
||
var sortedFieldsString = ''; | ||
if (sortedFieldsArray.length > 0) { | ||
// Implode as string comma separated string | ||
sortedFieldsString = sortedFieldsArray.join(','); | ||
} | ||
|
||
// Fill the sort field | ||
$('#edit-sort-fields').val(sortedFieldsString); | ||
}); | ||
|
||
})(jQuery); |
6 changes: 6 additions & 0 deletions
6
modules/mailjet_subscription/mailjet_subscription.libraries.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sort_properties: | ||
version: 1.0 | ||
js: | ||
js/sort_properties.js: {} | ||
dependencies: | ||
- core/jquery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters