-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDPA-6253] Added custom previous button for media embed select modal in CKEditor. #87
Merged
MdNadimHossain
merged 13 commits into
develop
from
feature/SDPA-6253-media-library-inspect-item-improvements
Aug 17, 2022
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3161577
[SDPA-6253] Added custom previous button for media embed select modal…
MdNadimHossain 45828fb
Updated lint.
MdNadimHossain 97cf5be
Updated lint.
MdNadimHossain 1109004
Updated css.
MdNadimHossain a45e09d
Added dev-tools hash.
MdNadimHossain 290c778
Reverted dev tools hash.
MdNadimHossain 0612791
Added check on iframe name.
MdNadimHossain 96d2bb9
Updated var type.
MdNadimHossain 3618a7b
Updated var name.
MdNadimHossain 31e3bb8
Updated js.
MdNadimHossain 845ca60
Updated js.
MdNadimHossain 4b3f6b6
Updated composer alias for tide_core.
MdNadimHossain de565af
Reverted tide_core reference.
MdNadimHossain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
a#entity-embed-dialog-tide-media-browser-home { | ||
text-decoration: none; | ||
color: #0074bd; | ||
padding: 0 0 0.75em; | ||
} |
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,89 @@ | ||
/** | ||
* @file | ||
* Adds the back button for embeded media select modal in CKEditor. | ||
* Everytime the user goes to different page within the media embed select modal | ||
* it will save the filter values to retrive the search result when user | ||
* comes back to the first page. | ||
*/ | ||
|
||
(function ($, Drupal) { | ||
'use strict'; | ||
|
||
Drupal.behaviors.tide_media_browser_iframe = { | ||
attach: function (context, settings) { | ||
if (!window.CKEDITOR) { | ||
return; | ||
} | ||
let iframePath, itemName, licenseType, mediaType, status, site | ||
const iframeName = 'entity_browser_iframe_tide_media_browser_iframe' | ||
const homePagePath = '/entity-browser/iframe/tide_media_browser_iframe' | ||
const backButton = $('#entity-embed-dialog-tide-media-browser-home') | ||
$(document).ready(function () { | ||
// Remove the filter values on modal first load if any. | ||
localStorage.removeItem('tideMediaBrowserNameFilterVal'); | ||
localStorage.removeItem('tideMediaBrowserLicenseTypeFilterVal'); | ||
localStorage.removeItem('tideMediaBrowserMediaTypeFilterVal'); | ||
localStorage.removeItem('tideMediaBrowserStatusFilterVal'); | ||
localStorage.removeItem('tideMediaBrowserSiteFilterVal'); | ||
$('iframe').on('load', function() { | ||
if ($('iframe') && $('iframe').length > 0) { | ||
for (let i = 0; i < $('iframe').length; i++) { | ||
if ($('iframe')[i].name && $('iframe')[i].name === iframeName) { | ||
iframePath = $('iframe')[i].contentWindow.location.pathname | ||
// Shows the back button when iframe is not in the first page. | ||
if (iframePath && iframePath !== homePagePath) { | ||
backButton.css('display', 'block'); | ||
} | ||
// Hides the back button for the first page. | ||
if (iframePath && iframePath === homePagePath) { | ||
backButton.css('display', 'none'); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
// Disable back button when it is on the first page. | ||
backButton.click(function() { | ||
history.back() | ||
$('iframe').on('load', function() { | ||
// Get the filter values on iframe load. | ||
itemName = localStorage.getItem('tideMediaBrowserNameFilterVal') | ||
$(this).contents().find('input[name=name]').val(itemName) | ||
licenseType = checkFilterValueInStorage('tideMediaBrowserLicenseTypeFilterVal') | ||
$(this).contents().find('select[name=field_license_type_target_id_1]').val(licenseType) | ||
mediaType = checkFilterValueInStorage('tideMediaBrowserMediaTypeFilterVal') | ||
$(this).contents().find('select[name=bundle]').val(mediaType) | ||
status = checkFilterValueInStorage('tideMediaBrowserStatusFilterVal') | ||
$(this).contents().find('select[name=status]').val(status) | ||
site = checkFilterValueInStorage('tideMediaBrowserSiteFilterVal') | ||
$(this).contents().find('select[name=field_media_site_target_id]').val(site) | ||
// Trigger ajax call submit to retrive the user search for current session. | ||
// Will only trigger if there is any filter value set for this session. | ||
if (checkFilterValuesOnLoad (itemName, licenseType, mediaType, status, site)) { | ||
$(this).contents().find('input[value=Apply]').trigger('click'); | ||
} | ||
}) | ||
}); | ||
// Check filter values on load. | ||
function checkFilterValuesOnLoad (itemName, licenseType, mediaType, status, site) { | ||
const defaultValue = "All" | ||
if ((itemName && itemName !== 'undefined') || | ||
(licenseType && licenseType !== defaultValue) || | ||
(mediaType && mediaType !== defaultValue) || | ||
(status && status !== defaultValue) || | ||
(site && site !== defaultValue)) { | ||
return true | ||
} | ||
return false | ||
} | ||
// Value check on localStorage, if empty set to default. | ||
function checkFilterValueInStorage (filterValName) { | ||
if (localStorage.getItem(filterValName)) { | ||
return localStorage.getItem(filterValName) | ||
} | ||
return 'All' | ||
} | ||
}, | ||
}; | ||
}(jQuery, Drupal)); |
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,31 @@ | ||
/** | ||
* @file | ||
* Retrieve the name user input for embed media select iframe. | ||
* Everytime the user goes to different page within the media embed select modal | ||
* it will save the name field value to retrive the search result when user | ||
* comes back to the first page. | ||
*/ | ||
|
||
(function ($, Drupal) { | ||
'use strict'; | ||
|
||
Drupal.behaviors.tide_media_media_form = { | ||
attach: function (context, settings) { | ||
const nameField = $('#views-exposed-form-tide-media-browser-media-browser input[name=name]') | ||
const licenseType = $('#views-exposed-form-tide-media-browser-media-browser select[name=field_license_type_target_id_1]') | ||
const mediaType = $('#views-exposed-form-tide-media-browser-media-browser select[name=bundle]') | ||
const status = $('#views-exposed-form-tide-media-browser-media-browser select[name=status]') | ||
const site = $('#views-exposed-form-tide-media-browser-media-browser select[name=field_media_site_target_id]') | ||
const formSubmit = $('#views-exposed-form-tide-media-browser-media-browser input[type=submit]') | ||
// On every submit it will save the namefield value to the localstorage. | ||
formSubmit.click(function () { | ||
// Store user set values on every click. | ||
localStorage.setItem('tideMediaBrowserNameFilterVal', nameField.val()); | ||
localStorage.setItem('tideMediaBrowserLicenseTypeFilterVal', licenseType.val()); | ||
localStorage.setItem('tideMediaBrowserMediaTypeFilterVal', mediaType.val()); | ||
localStorage.setItem('tideMediaBrowserStatusFilterVal', status.val()); | ||
localStorage.setItem('tideMediaBrowserSiteFilterVal', site.val()); | ||
}) | ||
} | ||
}; | ||
}(jQuery, Drupal)); | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a separate js to manipulate the name filter field. This only gets loaded when the view gets loaded