Skip to content

Commit

Permalink
Merge pull request #228 from UIUCLibrary/default-interactive-lens
Browse files Browse the repository at this point in the history
Make lens interactive by default
  • Loading branch information
eloyer authored Feb 12, 2024
2 parents cc56ea7 + 164ef60 commit 2a4e163
Showing 1 changed file with 22 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,6 @@
} else {
$(snowflake).hide();
}

// if not logged in
// buttons can't be clicked
let lensButtons = $(this.element).find('.lens-editor .btn');
if(this.userId == 'unknown'){
lensButtons.addClass('disabled');
}
// load frozen lens if frozen is true
if(this.scalarLensObject.frozen === true){
$(this.element).find('.lens-tags .btn').addClass('disabled');
Expand Down Expand Up @@ -3258,12 +3251,7 @@
</div>
</div>`
);
// hide if user not logged in
if(this.userId == 'unknown'){
$(button).hide();
} else {
return button;
}
return button;
}

// update options menu
Expand Down Expand Up @@ -3723,23 +3711,29 @@

ScalarLenses.prototype.updateDuplicateCopyPrompt = function() {
$('#duplicate-copy-prompt').find('.save').off();
if (this.myLenses.length >= this.maxLenses) {
if (this.userId == 'unknown') {
$('#duplicate-copy-prompt .row').html(`<div class="col-xs-12">
<p class="caption_font"><strong>You have made edits to this lens which have not been saved, since you are not its owner.</strong>
As you have already reached the maximum of ${this.maxLenses} lenses, saving your changes to a new copy of the lens is not possible.</p>
<p class="caption_font"><strong>You have made edits to this lens which have not been saved because you are not logged in.</strong>
</div>`);
} else {
$('#duplicate-copy-prompt .row').html(`<div class="col-xs-10">
<p class="caption_font"><strong>You have made edits to this lens which have not been saved, since you are not its owner.</strong>
Would you like to save these changes to your own copy of the lens?</p>
</div>
<div class="col-xs-2">
<button type="button" class="btn btn-default pull-right save">Save</button>
</div>`);
// save create copy of lens
$('#duplicate-copy-prompt').find('.save').on('click', () => {
if (this.myLenses.length >= this.maxLenses) {
$('#duplicate-copy-prompt .row').html(`<div class="col-xs-12">
<p class="caption_font"><strong>You have made edits to this lens which have not been saved, since you are not its owner.</strong>
As you have already reached the maximum of ${this.maxLenses} lenses, saving your changes to a new copy of the lens is not possible.</p>
</div>`);
} else {
$('#duplicate-copy-prompt .row').html(`<div class="col-xs-10">
<p class="caption_font"><strong>You have made edits to this lens which have not been saved, since you are not its owner.</strong>
Would you like to save these changes to your own copy of the lens?</p>
</div>
<div class="col-xs-2">
<button type="button" class="btn btn-default pull-right save">Save</button>
</div>`);
// save create copy of lens
$('#duplicate-copy-prompt').find('.save').on('click', () => {
this.duplicateLensByUserId();
});
});
}
}
}

Expand Down Expand Up @@ -3996,8 +3990,8 @@
ScalarLenses.prototype.saveLens = function(successHandler){
//console.log(JSON.stringify(this.scalarLensObject, null, 2));

// reader not added to the book, or reader added to book
if ((this.userId != 'unknown' && this.userLevel == 'unknown') || this.userLevel == 'scalar:Reader') {
// refresh the visualization if the user isn't logged in or if they are a reader
if (this.userLevel == 'unknown' || this.userLevel == 'scalar:Reader') {
if (this.canSave == true) {
this.updateLensByUserId(successHandler);
return;
Expand Down

0 comments on commit 2a4e163

Please sign in to comment.