Skip to content

Commit

Permalink
Custom service option to disable hover functions for certain document…
Browse files Browse the repository at this point in the history
… dislays (#1239)
  • Loading branch information
alexgao1 authored Aug 27, 2024
1 parent 362130d commit 4c2c2c6
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 40 deletions.
52 changes: 32 additions & 20 deletions nunaliit2-js/src/main/js/nunaliit2/n2.couchDisplayTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ var TiledDisplay = $n2.Class({
this.customService = opts.customService;
this.dispatchService = opts.dispatchService;
this.createDocProcess = opts.createDocProcess;

this.noDocumentHoverFunctions = false;

// Initialize display
this._getDisplayDiv();
Expand All @@ -246,6 +248,10 @@ var TiledDisplay = $n2.Class({
this.customService.getOption('restrictAddRelatedButtonToLoggedIn',false);
};

if (this.customService) {
this.noDocumentHoverFunctions = this.customService.getOption('disableDocumentHoverFunctions', false)
}

var dispatcher = this.dispatchService;
if( dispatcher ) {
var f = function(msg, addr, d){
Expand Down Expand Up @@ -364,28 +370,34 @@ var TiledDisplay = $n2.Class({
};

// Hover in and out
this.hoverInFn = function(){
var $tile = $(this);
var docId = $tile.attr('n2DocId');
if( docId && docId !== _this.hoverDocId ) {
_this.hoverDocId = docId;
_this._dispatch({
type: 'userFocusOn'
,docId: docId
});
if (this.noDocumentHoverFunctions) {
this.hoverInFn = () => {}
this.hoverOutFn = () => {}
}
else {
this.hoverInFn = function(){
var $tile = $(this);
var docId = $tile.attr('n2DocId');
if( docId && docId !== _this.hoverDocId ) {
_this.hoverDocId = docId;
_this._dispatch({
type: 'userFocusOn'
,docId: docId
});
};
};
};
this.hoverOutFn = function(){
var $tile = $(this);
var docId = $tile.attr('n2DocId');
if( docId && docId === _this.hoverDocId ) {
_this.hoverDocId = null;
_this._dispatch({
type: 'userFocusOff'
,docId: docId
});
this.hoverOutFn = function(){
var $tile = $(this);
var docId = $tile.attr('n2DocId');
if( docId && docId === _this.hoverDocId ) {
_this.hoverDocId = null;
_this._dispatch({
type: 'userFocusOff'
,docId: docId
});
};
};
};
}

// Detect changes in displayed current content size
var intervalID = window.setInterval(function(){
Expand Down
32 changes: 22 additions & 10 deletions nunaliit2-js/src/main/js/nunaliit2/n2.displayRibbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,8 @@ var RibbonDisplay = $n2.Class('RibbonDisplay', {
this.customService = opts.customService;
this.dispatchService = opts.dispatchService;
this.createDocProcess = opts.createDocProcess;

this.noDocumentHoverFunctions = false;

// Initialize display
this._getDisplayDiv();
Expand Down Expand Up @@ -1270,6 +1272,10 @@ var RibbonDisplay = $n2.Class('RibbonDisplay', {
documentSource: this.documentSource
});
};

if (this.customService) {
this.noDocumentHoverFunctions = this.customService.getOption('disableDocumentHoverFunctions', false)
}

// Document info function
this.documentInfoFunction = opts.documentInfoFunction;
Expand Down Expand Up @@ -1347,16 +1353,22 @@ var RibbonDisplay = $n2.Class('RibbonDisplay', {
};

// Hover in and out
this.hoverInFn = function(){
var $tile = $(this);
_this._hoverInTile($tile);
return false;
};
this.hoverOutFn = function(){
var $tile = $(this);
_this._hoverOutTile($tile);
return false;
};
if (this.noDocumentHoverFunctions) {
this.hoverInFn = () => {}
this.hoverOutFn = () => {}
}
else {
this.hoverInFn = function(){
var $tile = $(this);
_this._hoverInTile($tile);
return false;
};
this.hoverOutFn = function(){
var $tile = $(this);
_this._hoverOutTile($tile);
return false;
};
}

// Click function
this.clickFn = function(e){
Expand Down
32 changes: 22 additions & 10 deletions nunaliit2-js/src/main/js/nunaliit2/n2.displayRibbon2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,8 @@ var RibbonDisplay = $n2.Class('RibbonDisplay', {
this.customService = opts.customService;
this.dispatchService = opts.dispatchService;
this.createDocProcess = opts.createDocProcess;

this.noDocumentHoverFunctions = false;

// Initialize display
this._getDisplayDiv();
Expand Down Expand Up @@ -1345,6 +1347,10 @@ var RibbonDisplay = $n2.Class('RibbonDisplay', {
documentSource: this.documentSource
});
};

if (this.customService) {
this.noDocumentHoverFunctions = this.customService.getOption('disableDocumentHoverFunctions', false)
}

// Document info function
this.documentInfoFunction = opts.documentInfoFunction;
Expand Down Expand Up @@ -1422,16 +1428,22 @@ var RibbonDisplay = $n2.Class('RibbonDisplay', {
};

// Hover in and out
this.hoverInFn = function(){
var $tile = $(this);
_this._hoverInTile($tile);
return false;
};
this.hoverOutFn = function(){
var $tile = $(this);
_this._hoverOutTile($tile);
return false;
};
if (this.noDocumentHoverFunctions) {
this.hoverInFn = () => {}
this.hoverOutFn = () => {}
}
else {
this.hoverInFn = function(){
var $tile = $(this);
_this._hoverInTile($tile);
return false;
};
this.hoverOutFn = function(){
var $tile = $(this);
_this._hoverOutTile($tile);
return false;
};
}

// Click function
this.clickFn = function(){
Expand Down

0 comments on commit 4c2c2c6

Please sign in to comment.