Skip to content

Commit

Permalink
remove showvideo, gather code into SignItCoreContent.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hugolpz committed Dec 14, 2023
1 parent 0fd25bc commit 4754542
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
26 changes: 23 additions & 3 deletions SignItCoreContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ var SignItCoreContent = function (banana) {
// // TODO: Do something
// }.bind( this ) );

// @saltykheera's toggle video solution :

/*
// @saltykheera's toggle video solution :
document.addEventListener("DOMContentLoaded", function(){
// Initializing the visibility state
let video_pop = false;
Expand All @@ -82,12 +84,30 @@ var SignItCoreContent = function (banana) {
video_pop = !video_pop;
$(".signit-panel-videos").toggle(video_pop);
$(".signit-panel-separator").toggle(video_pop);
}
}
// Button toggle video
$("#video_toggle").on("click", function () {
toggleVideoPop();
});
}); */
});
// @hugolpz toggle video solution :
// Create toggle button to add to definition panel:
showvideoWidget = new OO.ui.ToggleSwitchWidget( { value: true } ); // if choosepanels == both
showvideoWidget.setValue( _backgroundPage.params.choosepanels == 'both'? true:false; );
// Create legend:
showvideoLayout = new OO.ui.FieldLayout( showvideoWidget, {
label: banana.i18n("si-popup-settings-showvideo"),
align: 'top',
});
// Append in right place :
this.$definitionPanelContent.append( showvideoLayout.$element )
// On change : 1) change choosepanels value in local storage ; 2) refresh modal if possible or just directly toglle.
// showvideoWidget.on( 'change', _backgroundPage.storeParam.bind( _backgroundPage, 'choosepanels' ) );
// choosepanels= value==true?'both':'definition';
*/

SignItCoreContent.prototype.refresh = function (title, files) {
files = files || [];
Expand Down
6 changes: 1 addition & 5 deletions background-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ var state = 'up', // up, loading, ready, error
twospeed: true,
hinticon: true,
coloredwords: true,
// Preparation for issues/36
showvideo: true,
showdefinition: true,
choosepanels: 'both',
choosepanels: 'both', // issues/36
};

/* *************************************************************** */
Expand Down Expand Up @@ -410,7 +407,6 @@ async function main() {
// storeParam( 'twospeed', params.twospeed ); //
await getStoredParam( 'hinticon' );
await getStoredParam( 'coloredwords' );
await getStoredParam( 'showvideo' );
await getStoredParam( 'choosepanels' );

signLanguage = await getStoredParam( 'signLanguage' );
Expand Down
2 changes: 0 additions & 2 deletions content_scripts/signit.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@
}
// SignIt modal width depends on number of active panels
var signItModalWidth = async function(){
// var showvideo = Object.values( await browser.storage.local.get( 'showvideo' ) )[0];
// numberOfPanels = (showvideo?1:0)+1;
var activepanels = Object.values( await browser.storage.local.get( 'choosepanels' ) )[0];
var numberOfPanels = activepanels == 'both' ? 2:1;
return numberOfPanels==2? 850:450;
Expand Down
15 changes: 2 additions & 13 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,6 @@ var browser = browser || chrome;
label: banana.i18n("si-popup-settings-enlighten"),
align: 'top',
} );
// Show video panel
showvideoWidget = new OO.ui.ToggleSwitchWidget( {
value: true
} );
showvideoLayout = new OO.ui.FieldLayout( showvideoWidget, {
label: banana.i18n("si-popup-settings-showvideo"),
align: 'top',
} );

// Choose panels : both, definition, video
var panelsOption0 = new OO.ui.ButtonOptionWidget( {
Expand Down Expand Up @@ -282,8 +274,8 @@ var browser = browser || chrome;
twospeedWidget.setValue( _backgroundPage.params.twospeed );
hinticonWidget.setValue( _backgroundPage.params.hinticon );
coloredwordsWidget.setValue( _backgroundPage.params.coloredwords );
showvideoWidget.setValue( _backgroundPage.params.showvideo );
// TEST Tri-buttons : selectItemByData or setData

// Tri-buttons : selectItemByData or setData
choosepanelsWidget.setData( _backgroundPage.params.choosepanels );
choosepanelsWidget.selectItemByData( _backgroundPage.params.choosepanels );

Expand All @@ -301,8 +293,6 @@ var browser = browser || chrome;
// _backgroundPage.storeParam( 'twospeed', _backgroundPage.params.twospeed ); // twospeed in localStorage before first usage-change
hinticonWidget.on( 'change', _backgroundPage.storeParam.bind( _backgroundPage, 'hinticon' ) );
coloredwordsWidget.on( 'change', _backgroundPage.storeParam.bind( _backgroundPage, 'coloredwords' ) );
// TEST: Choose panels to display
showvideoWidget.on( 'change', _backgroundPage.storeParam.bind( _backgroundPage, 'showvideo' ) );
// Listen for item selection events
choosepanelsWidget.on('choose', (d)=>{
_backgroundPage.storeParam('choosepanels', d.getData());
Expand All @@ -317,7 +307,6 @@ var browser = browser || chrome;
.append( twospeedLayout.$element )
.append( hinticonLayout.$element )
.append( coloredwordsLayout.$element )
.append( showvideoLayout.$element )
.append( choosepanelsLayout.$element );
};

Expand Down

0 comments on commit 4754542

Please sign in to comment.