This repository has been archived by the owner on Sep 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release/3.0.6
- Loading branch information
Showing
5 changed files
with
192 additions
and
40 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
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