Action table is now actually a table

This commit is contained in:
Tamius Han 2018-12-13 23:09:29 +01:00
parent 7f185c80ef
commit c23445ba3f
5 changed files with 81 additions and 33 deletions

View File

@ -3,7 +3,7 @@ if(Debug.debug)
var ExtensionConf = { var ExtensionConf = {
basicExtensionMode: "blacklist", basicExtensionMode: "blacklist",
extensionMode: "whitelist", // how should this extension work? extensionMode: "blacklist", // how should this extension work?
// 'blacklist' - work everywhere except blacklist // 'blacklist' - work everywhere except blacklist
// 'whitelist' - only work on whitelisted sites // 'whitelist' - only work on whitelisted sites
// 'disabled' - work nowhere // 'disabled' - work nowhere
@ -209,6 +209,7 @@ var ExtensionConf = {
popup_site: false, // optional, false by default popup_site: false, // optional, false by default
popup_global: false,// optional, false by default popup_global: false,// optional, false by default
ui: true, ui: true,
ui_path: 'crop',
label: 'Automatic' label: 'Automatic'
},{ },{
cmd: [{ cmd: [{
@ -226,6 +227,7 @@ var ExtensionConf = {
}], }],
popup: true, popup: true,
ui: true, ui: true,
ui_path: 'crop',
label: 'Reset', label: 'Reset',
},{ },{
cmd: [{ cmd: [{
@ -243,6 +245,7 @@ var ExtensionConf = {
}], }],
popup: true, popup: true,
ui: true, ui: true,
ui_path: 'crop',
label: 'Fit width', label: 'Fit width',
},{ },{
cmd: [{ cmd: [{
@ -260,6 +263,7 @@ var ExtensionConf = {
}], }],
popup: true, popup: true,
ui: true, ui: true,
ui_path: 'crop',
label: 'Fit height', label: 'Fit height',
},{ },{
cmd: [{ cmd: [{
@ -277,6 +281,7 @@ var ExtensionConf = {
}], }],
popup: true, popup: true,
ui: true, ui: true,
ui_path: 'crop',
label: '16:9', label: '16:9',
},{ },{
cmd: [{ cmd: [{
@ -294,6 +299,7 @@ var ExtensionConf = {
}], }],
popup: true, popup: true,
ui: true, ui: true,
ui_path: 'crop',
label: '21:9' label: '21:9'
},{ },{
cmd: [{ cmd: [{
@ -311,6 +317,7 @@ var ExtensionConf = {
}], }],
popup: true, popup: true,
ui: true, ui: true,
ui_path: 'crop',
label: '2.35', label: '2.35',
},{ },{
cmd: [{ cmd: [{
@ -328,6 +335,7 @@ var ExtensionConf = {
}], }],
popup: true, popup: true,
ui: true, ui: true,
ui_path: 'crop',
label: '18:9' label: '18:9'
},{ },{
cmd: [{ cmd: [{
@ -345,6 +353,7 @@ var ExtensionConf = {
}], }],
popup: false, popup: false,
ui: false, ui: false,
ui_path: 'crop',
label: 'Zoom', label: 'Zoom',
},{ },{
cmd: [{ cmd: [{
@ -379,6 +388,7 @@ var ExtensionConf = {
}], }],
popup: true, popup: true,
ui: true, ui: true,
ui_path: 'crop',
label: 'Toggle panning mode', label: 'Toggle panning mode',
},{ },{
cmd: [{ cmd: [{
@ -396,6 +406,7 @@ var ExtensionConf = {
}], }],
popup: false, popup: false,
ui: false, ui: false,
ui_path: 'crop',
label: 'Pan (hold)' label: 'Pan (hold)'
}, },
// //
@ -420,6 +431,7 @@ var ExtensionConf = {
popup_site: true, popup_site: true,
popup_global: true, popup_global: true,
ui: true, ui: true,
ui_path: 'stretch',
label: 'Basic' label: 'Basic'
},{ },{
cmd: [{ cmd: [{
@ -430,6 +442,7 @@ var ExtensionConf = {
popup_site: true, popup_site: true,
popup_global: true, popup_global: true,
ui: true, ui: true,
ui_path: 'stretch',
label: 'Hybrid' label: 'Hybrid'
},{ },{
cmd: [{ cmd: [{
@ -440,6 +453,7 @@ var ExtensionConf = {
popup_site: true, popup_site: true,
popup_global: true, popup_global: true,
ui: true, ui: true,
ui_path: 'stretch',
label: 'Thin borders' label: 'Thin borders'
},{ },{
cmd: [{ cmd: [{
@ -464,6 +478,7 @@ var ExtensionConf = {
popup_site: true, popup_site: true,
popup_global: true, popup_global: true,
ui: true, ui: true,
ui_path: 'align',
label: 'Left', label: 'Left',
},{ },{
cmd: [{ cmd: [{
@ -474,6 +489,7 @@ var ExtensionConf = {
popup_site: true, popup_site: true,
popup_global: true, popup_global: true,
ui: true, ui: true,
ui_path: 'align',
label: 'Center', label: 'Center',
},{ },{
cmd: [{ cmd: [{
@ -484,6 +500,7 @@ var ExtensionConf = {
popup_site: true, popup_site: true,
popup_global: true, popup_global: true,
ui: true, ui: true,
ui_path: 'align',
label: 'Right', label: 'Right',
},{ },{
cmd: [{ cmd: [{
@ -511,6 +528,7 @@ var ExtensionConf = {
popup_global: true, popup_global: true,
popup_site: false, popup_site: false,
ui: true, ui: true,
ui_path: 'settings/global',
label: 'Enable' label: 'Enable'
},{ },{
cmd: [{ cmd: [{
@ -522,6 +540,7 @@ var ExtensionConf = {
popup_global: true, popup_global: true,
popup_site: false, popup_site: false,
ui: true, ui: true,
ui_path: 'settings/global',
label: 'On whitelisted only' label: 'On whitelisted only'
},{ },{
cmd: [{ cmd: [{
@ -533,6 +552,7 @@ var ExtensionConf = {
popup_global: true, popup_global: true,
popup_site: false, popup_site: false,
ui: true, ui: true,
ui_path: 'settings/global',
label: 'Disabled' label: 'Disabled'
},{ },{
// site-only // site-only
@ -545,6 +565,7 @@ var ExtensionConf = {
popup_global: false, popup_global: false,
popup_site: true, popup_site: true,
ui: true, ui: true,
ui_path: 'settings/site',
label: 'Enable' label: 'Enable'
},{ },{
cmd: [{ cmd: [{
@ -556,6 +577,7 @@ var ExtensionConf = {
popup_global: false, popup_global: false,
popup_site: true, popup_site: true,
ui: true, ui: true,
ui_path: 'settings/site',
label: 'Use default option' label: 'Use default option'
},{ },{
cmd: [{ cmd: [{
@ -567,6 +589,7 @@ var ExtensionConf = {
popup_global: false, popup_global: false,
popup_site: true, popup_site: true,
ui: true, ui: true,
ui_path: 'settings/site',
label: 'Disable' label: 'Disable'
},{ // extension options: },{ // extension options:
// global // global
@ -579,6 +602,7 @@ var ExtensionConf = {
popup_global: true, popup_global: true,
popup_site: false, popup_site: false,
ui: true, ui: true,
ui_path: 'settings/global',
label: 'Enable' label: 'Enable'
},{ },{
cmd: [{ cmd: [{
@ -590,6 +614,7 @@ var ExtensionConf = {
popup_global: true, popup_global: true,
popup_site: false, popup_site: false,
ui: true, ui: true,
ui_path: 'settings/global',
label: 'On whitelisted only' label: 'On whitelisted only'
},{ },{
cmd: [{ cmd: [{
@ -601,6 +626,7 @@ var ExtensionConf = {
popup_global: true, popup_global: true,
popup_site: false, popup_site: false,
ui: true, ui: true,
ui_path: 'settings/global',
label: 'Disabled' label: 'Disabled'
},{ },{
// site-only // site-only
@ -613,6 +639,7 @@ var ExtensionConf = {
popup_global: false, popup_global: false,
popup_site: true, popup_site: true,
ui: true, ui: true,
ui_path: 'settings/global',
label: 'Enable' label: 'Enable'
},{ },{
@ -625,6 +652,7 @@ var ExtensionConf = {
popup_global: false, popup_global: false,
popup_site: true, popup_site: true,
ui: true, ui: true,
ui_path: 'settings/global',
label: 'Use default option' label: 'Use default option'
},{ },{
cmd: [{ cmd: [{
@ -636,6 +664,7 @@ var ExtensionConf = {
popup_global: false, popup_global: false,
popup_site: true, popup_site: true,
ui: true, ui: true,
ui_path: 'settings/site',
label: 'Disable' label: 'Disable'
},], },],
// ----------------------------------------- // -----------------------------------------

View File

@ -1,39 +1,36 @@
class ActionItem extends BaseElement { class ActionItem extends BaseElement {
constructor(id, action, onClick) { constructor(id, action, onClick) {
super(id, undefined, onClick); super(id, undefined, onClick, undefined, document.createElement('tr'));
this.element.classList.add("action-list-item", "flex", "flex-row"); this.element.classList.add("action-list-item");
// action list item looks like this let cmd = "";
// [ action.label | shortcut | visibility checkboxes ]
var cmd = document.createElement('div')
var label = document.createElement('div');
var shortcut = document.createElement('div');
var popupVideoCb = document.createElement('div');
var popupSiteCb = document.createElement('div');
var popupGlobalCb = document.createElement('div');
var playerUi = document.createElement('div');
cmd.classList.add('cmd', 'flex');
label.classList.add('label', 'flex');
shortcut.classList.add('shortcut', 'flex');
popupVideoCb.classList.add('checkbox', 'flex');
popupSiteCb.classList.add('checkbox', 'flex');
popupGlobalCb.classList.add('checkbox', 'flex');
playerUi.classList.add('checkbox', 'flex');
for (var c in action.cmd) { for (var c in action.cmd) {
cmd.textContent += `${c > 0 ? '; ' : ''}${action.cmd[0].action} ${action.cmd[0].arg}` cmd += `${c > 0 ? '; ' : ''}${action.cmd[0].action} ${action.cmd[0].arg}`
} }
label.textContent = action.label;
shortcut.textContent = action.parsedShortcut;
this.element.appendChild(label); this.element.innerHTML = `
this.element.appendChild(cmd); <td class="cmd monospace">${cmd}</td>
this.element.appendChild(shortcut); <td class="label">${action.label ? action.label : ""}</td>
this.element.appendChild(popupVideoCb); <td class="shortcut">${action.parsedShortcut ? action.parsedShortcut : ""}</td>
this.element.appendChild(popupSiteCb); <td class="checkbox">
this.element.appendChild(popupGlobalCb); <input type="checkbox" disabled ${
this.element.appendChild(playerUi); action.shortcut && action.shortcut.length && (action.shortcut[0].onMouseMove || action.shortcut[0].onClick || action.shortcut[0].onScroll) ?
"checked" : ""
}>
</td>
<td class="checkbox">
<input type="checkbox" disabled ${action.popup_global ? "checked" : ""}>
</td>
<td class="checkbox">
<input type="checkbox" disabled ${action.popup_site ? "checked" : ""}>
</td>
<td class="checkbox">
<input type="checkbox" disabled ${action.popup_ ? "checked" : ""}>
</td>
<td class="checkbox">
<input type="checkbox" disabled ${action.ui ? "checked" : ""}>
</td>
<td>${action.ui_path ? action.ui_path : ""}</td>
`;
} }
} }

View File

@ -72,12 +72,18 @@ function loadFrames(videoTab) {
} }
} }
if (videoTab.frames.length < 2) {
return;
}
function onTabitemClick(item) { function onTabitemClick(item) {
tablist[selectedMenu].tab.selectSubitem(item); tablist[selectedMenu].tab.selectSubitem(item);
selectedSubitem[selectedMenu] = item; selectedSubitem[selectedMenu] = item;
port.postMessage({cmd: 'popup-set-selected-tab', selectedMenu: selectedMenu, selectedSubitem: item}); port.postMessage({cmd: 'popup-set-selected-tab', selectedMenu: selectedMenu, selectedSubitem: item});
} }
for (var option of [{id: '__all', label: 'All'},{id: '__playing', label: 'Currently playing'}]) { for (var option of [{id: '__all', label: 'All'},{id: '__playing', label: 'Currently playing'}]) {
const id = option.id; const id = option.id;
var newItem = new TabItem( var newItem = new TabItem(

View File

@ -30,10 +30,20 @@ function loadActions() {
zoomPanActions.indexOf(action) === -1 ) zoomPanActions.indexOf(action) === -1 )
); );
ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Crop actions");
ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element);
loadActionSection(cropActions, ui.customization.actionList); loadActionSection(cropActions, ui.customization.actionList);
ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Stretch actions");
ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element);
loadActionSection(stretchActions, ui.customization.actionList); loadActionSection(stretchActions, ui.customization.actionList);
ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Alignment actions");
ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element);
loadActionSection(alignActions, ui.customization.actionList); loadActionSection(alignActions, ui.customization.actionList);
ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Zoom actions");
ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element);
loadActionSection(zoomPanActions, ui.customization.actionList); loadActionSection(zoomPanActions, ui.customization.actionList);
ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Other actions");
ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element);
loadActionSection(otherActions, ui.customization.actionList); loadActionSection(otherActions, ui.customization.actionList);
ui.customization.actionItems.push(cropActions); ui.customization.actionItems.push(cropActions);
@ -45,6 +55,10 @@ function loadActions() {
console.log("ui.customization:", ui.customization) console.log("ui.customization:", ui.customization)
} }
function loadSectionHeader(title) {
}
function loadActionSection(actions, container) { function loadActionSection(actions, container) {
for(action of actions) { for(action of actions) {
if (action.shortcut && action.shortcut[0].key) { if (action.shortcut && action.shortcut[0].key) {

View File

@ -196,7 +196,7 @@
<div class="description"> <div class="description">
<p>In this sections, you can define custom actions, add or change keyboard shortcut or hide buttons from the popup.</p> <p>In this sections, you can define custom actions, add or change keyboard shortcut or hide buttons from the popup.</p>
</div> </div>
<div class="flex flex-column" id="_customization_action_list"> <table id="_customization_action_list">
</div> </div>
</div> </div>
@ -231,6 +231,8 @@
<!-- ui libs --> <!-- ui libs -->
<script src="../../js/lib/libghettoui/BaseElement.js"></script> <script src="../../js/lib/libghettoui/BaseElement.js"></script>
<script src="../../js/lib/libghettoui/settings/ActionItem.js"></script> <script src="../../js/lib/libghettoui/settings/ActionItem.js"></script>
<script src="../../js/lib/libghettoui/settings/ActionItemCategoryHeaderProcessor.js"></script>
<script src="js/settingsvars.js"></script> <script src="js/settingsvars.js"></script>
<script src="js/customization.js"></script> <script src="js/customization.js"></script>
<script src="js/settings.js"></script> <script src="js/settings.js"></script>