Skip to content

Commit

Permalink
Merge e873ca1 into c443837
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyichen committed Mar 29, 2021
2 parents c443837 + e873ca1 commit bd9a559
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/js/widgets/list_of_things/item_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ define([

showLinks: function(e) {
var $c = $(e.currentTarget);
if (!$c.find('.active-link').length) {
if (
!$c.find('.active-link').length ||
this.model.get('isMobileOrTablet')
) {
return;
}

Expand Down
9 changes: 8 additions & 1 deletion src/js/widgets/list_of_things/model.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
define([
'backbone',
'underscore',
'bowser',
'js/mixins/add_stable_index_to_collection',
], function(Backbone, _, WidgetPaginationMixin) {
], function(Backbone, _, bowser, WidgetPaginationMixin) {
var ItemModel = Backbone.Model.extend({
defaults: function() {
return {
Expand All @@ -21,6 +22,7 @@ define([
visible: false,
actionsVisible: true,
showCheckbox: true,
isMobileOrTablet: false,
};
},
idAttribute: 'resultsIndex',
Expand Down Expand Up @@ -139,6 +141,9 @@ define([
var lastIdx = null;
var rIdx;

var platform = bowser.parse(window.navigator.userAgent).platform.type;
var isMobileOrTablet = platform === 'mobile' || platform === 'tablet';

this.each(function(model) {
rIdx = model.attributes.resultsIndex;

Expand All @@ -158,6 +163,8 @@ define([
} else {
model.set('visible', false);
}

model.set('isMobileOrTablet', isMobileOrTablet);
});

if (visible !== end - start + 1) {
Expand Down
2 changes: 1 addition & 1 deletion test/mocha/js/widgets/lot_derivates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ define([
},
]);
expect(JSON.stringify(w.hiddenCollection.toJSON())).to.eql(
'[{"bibcode":1,"resultsIndex":0,"emptyPlaceholder":false,"visible":false,"actionsVisible":true,"showCheckbox":true},{"bibcode":2,"resultsIndex":1,"emptyPlaceholder":false,"visible":false,"actionsVisible":true,"showCheckbox":true}]'
'[{"bibcode":1,"resultsIndex":0,"emptyPlaceholder":false,"visible":false,"actionsVisible":true,"showCheckbox":true,"isMobileOrTablet":false},{"bibcode":2,"resultsIndex":1,"emptyPlaceholder":false,"visible":false,"actionsVisible":true,"showCheckbox":true,"isMobileOrTablet":false}]'
);
//this will be triggered by TOC widget on a fresh "display_documents"
w.model.set('bibcode', 'new_bibcode');
Expand Down

0 comments on commit bd9a559

Please sign in to comment.