Skip to content

Commit

Permalink
Prefer dataset to jquery.data()
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Oct 17, 2023
1 parent 6c98119 commit aaa775c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/assets/javascripts/modules/media_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ export default (function() {

var thumbClass = 'sul-embed-slider-thumb sul-embed-media-slider-thumb ';
var labelClass = 'sul-embed-thumb-label';
var isStanfordRestricted = $(mediaDiv).data('stanford-only');
const isStanfordRestricted = mediaDiv.dataset.stanfordOnly === "true"
if (isStanfordRestricted) {
labelClass += ' sul-embed-thumb-stanford-only';
}

var thumbnailIcon = '';
var thumbnailUrl = $(mediaDiv).data('thumbnail-url');
const thumbnailUrl = mediaDiv.dataset.thumbnailUrl
if (thumbnailUrl !== '') {
thumbnailIcon = '<img class="sul-embed-media-square-icon" src="' + thumbnailUrl + '" />';
} else {
thumbnailIcon = '<i class="' + cssClass + '"></i>';
}

var isLocationRestricted = $(mediaDiv).data('location-restricted');
var fileLabel = String($(mediaDiv).data('file-label') || '');
var duration = String($(mediaDiv).data('duration') || '');
const isLocationRestricted = mediaDiv.dataset.locationRestricted === "true"
const fileLabel = String(mediaDiv.dataset.fileLabel || '');
const duration = String(mediaDiv.dataset.duration || '');
thumbs.push(
'<li class="' + thumbClass + activeClass + '">' +
thumbnailIcon +
Expand Down Expand Up @@ -146,7 +146,7 @@ export default (function() {
}

function authCheckForMediaObject(mediaObject, completeCallback) {
var authUrl = mediaObject.data('auth-url');
const authUrl = mediaObject.dataset.authUrl
jQuery.ajax({url: authUrl, dataType: 'jsonp'}).done(function(data) {
// present the auth link if it's stanford restricted and the user isn't logged in
if(jQuery.inArray('stanford_restricted', data.status) > -1) {
Expand Down

0 comments on commit aaa775c

Please sign in to comment.