tweaking + some refactoring and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-01-06 02:18:21 +03:00
parent 0a57cb7c3a
commit 6a7f440bc7
4 changed files with 121 additions and 55 deletions

View File

@ -317,10 +317,17 @@ body {
background: rgba(0, 0, 0, 0.7); background: rgba(0, 0, 0, 0.7);
} }
.browse-widget.key-bindings .list>.ignore .text:first-child { .browse-widget.key-bindings .list>.ignore-list .text:first-child {
font-weight: bold; font-weight: bold;
font-style: italic; font-style: italic;
} }
.browse-widget.key-bindings .list>.ignored .text:first-child {
font-style: italic;
font-weight: bold;
}
.browse-widget.key-bindings .list>.info {
font-style: italic;
}
.browse-widget.key-bindings .list>div .text:not(:first-child) { .browse-widget.key-bindings .list>div .text:not(:first-child) {
display: inline; display: inline;
@ -337,10 +344,6 @@ body {
.browse-widget.key-bindings.browse .list>div .text:last-child { .browse-widget.key-bindings.browse .list>div .text:last-child {
margin-right: 0em; margin-right: 0em;
} }
.browse-widget.key-bindings.browse .list>.ignored .text:first-child {
font-style: italic;
font-weight: bold;
}
.browse-widget.key-bindings .list>div:not(.selected):not(.mode):nth-child(even) { .browse-widget.key-bindings .list>div:not(.selected):not(.mode):nth-child(even) {
background: rgba(0, 0, 0, 0.03); background: rgba(0, 0, 0, 0.03);

View File

@ -50,7 +50,7 @@ module.GLOBAL_KEYBOARD = {
ignore: [ ignore: [
'Esc', 'Esc',
'Up', 'Down', 'Enter', 'Up', 'Down', 'Enter',
'R', 'L', 'G', 'R', 'L', 'G', 'T',
], ],
Esc: 'toggleSlideshow: "off" -- Exit slideshow', Esc: 'toggleSlideshow: "off" -- Exit slideshow',
@ -648,6 +648,7 @@ var KeyboardActions = actions.Actions({
Object.keys(keys) Object.keys(keys)
.forEach(function(mode){ .forEach(function(mode){
var ignored = actions.keyboard[mode].ignore || [] var ignored = actions.keyboard[mode].ignore || []
var bound_ignored = []
// section heading... // section heading...
make(keys[mode].doc ? make(keys[mode].doc ?
@ -660,48 +661,65 @@ var KeyboardActions = actions.Actions({
.append($('<span>') .append($('<span>')
.addClass('doc') .addClass('doc')
.html(keys[mode].doc)) .html(keys[mode].doc))
: mode) : mode,
// XXX should sections be searchable??? {
//.addClass('mode not-searchable') not_filtered_out: true,
.addClass('mode not-filterd-out') // XXX should sections be searchable???
//not_searchable: true,
})
.addClass('mode')
/* XXX not sure if we need this like this... // bindings...
// unpropagated keys... var c = 0
make(['Unpropagated keys:', Object.keys(keys[mode]).forEach(function(action){
action != 'doc'
// NOTE: wee need the button spec to be
// searchable, thus we are not using
// the keys attr as in .browseActions(..)
&& make([action, ' ', '$BUTTONS']
.concat($('<span>')
.addClass('text')
.html(keys[mode][action]
// mark key if it is in ignored...
.map(function(s){
s = s.split('+')
var k = s.pop()
var i = ignored.indexOf(k)
i >= 0
&& bound_ignored
.push(ignored[i])
s.push(k
+ (i >= 0 ? '<sup>*</sup>' : ''))
return s.join('+') })
.join(' / '))))
.addClass('key '
+ (action == 'IGNORE' ? 'ignored' : ''))
&& c++
})
// no keys in view mode...
// XXX is adding info stuff like this a correct
// thing to do in code?
c == 0 && !edit
&& make('No bindings...',
{
disabled: true,
hide_on_search: true,
})
.addClass('info')
// unpropagated and unbound keys...
make(['Unpropagated and unbound keys:',
// NOTE: this blank is so as to avoid // NOTE: this blank is so as to avoid
// sticking the action and keys // sticking the action and keys
// together in path... // together in path...
' ', ' ',
'$BUTTONS', '$BUTTONS',
(ignored).join(' / ')]) ignored
.addClass('ignore') .filter(function(k){
//*/ return bound_ignored.indexOf(k) == -1 })
.join(' / ')])
// bindings... .addClass('ignore-list')
Object.keys(keys[mode])
.forEach(function(action){
action == 'Ignored' && console.log('!!!!!!!')
action != 'doc'
// NOTE: wee need the button
// spec to be searchable,
// thus we are not using
// the keys attr as in
// .browseActions(..)
&& make([action, ' ', '$BUTTONS']
.concat(keys[mode][action]
// mark key if it is in ignored...
.map(function(s){
s = s.split('+')
var k = s.pop()
s.push(k
+ (ignored.indexOf(k) >= 0 ?
'*'
: ''))
return s.join('+') })
.join(' / ')))
.addClass('key'
+ (action == 'Ignored' ? ' ignored' : ''))
})
// controls... // controls...
if(edit){ if(edit){
@ -721,6 +739,19 @@ var KeyboardActions = actions.Actions({
.addClass('new') .addClass('new')
} }
}) })
// notes...
// XXX is adding info stuff like this a correct
// thing to do in code?
make('---')
make($('<span>')
.addClass('text')
.html('<sup>*</sup> keys not propogated to next section.'),
{
disabled: true ,
hide_on_search: true,
})
.addClass('info')
}, { }, {
cls: [ cls: [
'key-bindings', 'key-bindings',

View File

@ -859,7 +859,7 @@ function buildKeybindingsHelp(keybindings, shifted_keys, actions, doc_getter){
if(handler == 'IGNORE'){ if(handler == 'IGNORE'){
// XXX do we show ignored keys??? // XXX do we show ignored keys???
var doc = 'Ignored' var doc = handler
//continue //continue
// custom doc getter... // custom doc getter...

View File

@ -831,6 +831,24 @@ var BrowserPrototype = {
// // // //
// push_on_open: <bool>, // push_on_open: <bool>,
// //
// // If true this element will be uncondionally hidden on search...
// //
// // NOTE: this is equivalent to setting .hide-on-search class
// // on the element...
// hide_on_search: <bool>,
//
// // If true the item will not get searched...
// //
// // NOTE: this is equivalent to setting .not-searchable class
// // on the element...
// not_searchable: <bool>,
//
// // If true item will not get hidden on filtering...
// //
// // NOTE: this is equivalent to setting .not-filtered-out class
// // on the element...
// not_filtered_out: <bool>,
//
// // element button spec... // // element button spec...
// buttons: <bottons>, // buttons: <bottons>,
// } // }
@ -1011,8 +1029,9 @@ var BrowserPrototype = {
// XXX revise signature... // XXX revise signature...
var make = function(p, traversable, disabled, buttons){ var make = function(p, traversable, disabled, buttons){
var opts = {}
var hidden = false var hidden = false
var push_on_open = false
if(that.options.holdSize){ if(that.options.holdSize){
// we've started, no need to hold the size any more... // we've started, no need to hold the size any more...
@ -1022,13 +1041,12 @@ var BrowserPrototype = {
// options passed as an object... // options passed as an object...
if(traversable != null && typeof(traversable) == typeof({})){ if(traversable != null && typeof(traversable) == typeof({})){
var opts = traversable opts = traversable
traversable = opts.traversable traversable = opts.traversable
disabled = opts.disabled disabled = opts.disabled
buttons = opts.buttons buttons = opts.buttons
hidden = opts.hidden hidden = opts.hidden
push_on_open = opts.push_on_open
} }
buttons = buttons buttons = buttons
@ -1064,8 +1082,10 @@ var BrowserPrototype = {
// XXX check if traversable... // XXX check if traversable...
p = $(p.map(function(t){ p = $(p.map(function(t){
return t == '$BUTTONS' ? return t == '$BUTTONS' ?
$('<span/>') $('<span/>')
.addClass('button-container')[0] .addClass('button-container')[0]
: t instanceof jQuery ?
t[0]
: $('<span>') : $('<span>')
.addClass('text') .addClass('text')
// here we also replace empty strings with &nbsp;... // here we also replace empty strings with &nbsp;...
@ -1114,10 +1134,17 @@ var BrowserPrototype = {
// append text elements... // append text elements...
.append(p) .append(p)
!traversable && res.addClass('not-traversable') res.addClass([
disabled && res.addClass('disabled') !traversable ? 'not-traversable' : '',
hidden && res.addClass('hidden') disabled ? 'disabled' : '',
push_on_open && res.attr('push-on-open', 'on') hidden ? 'hidden' : '',
opts.hide_on_search ? 'hide-on-search' : '',
(opts.hide_on_search || opts.not_searchable) ? 'not-searchable' : '',
opts.not_filtered_out ? 'not_filtered_out' : '',
].join(' '))
opts.push_on_open && res.attr('push-on-open', 'on')
// buttons... // buttons...
// button container... // button container...
@ -1464,7 +1491,7 @@ var BrowserPrototype = {
var browser = this.dom var browser = this.dom
// show all... // show all...
if(pattern == null || pattern.trim() == '*'){ if(pattern == null || pattern.trim() == '*' || pattern == ''){
browser.find('.filtered-out') browser.find('.filtered-out')
.removeClass('filtered-out') .removeClass('filtered-out')
// clear the highlighting... // clear the highlighting...
@ -1473,6 +1500,10 @@ var BrowserPrototype = {
// basic filter... // basic filter...
} else { } else {
// hide stuff that needs to be unconditionally hidden...
browser.find('.hide-on-search')
.addClass('filtered-out')
var p = RegExp('(' var p = RegExp('('
+ pattern + pattern
.trim() .trim()
@ -1491,6 +1522,7 @@ var BrowserPrototype = {
function(i, e){ function(i, e){
!e.hasClass('not-filterd-out') !e.hasClass('not-filterd-out')
&& e.addClass('filtered-out') && e.addClass('filtered-out')
e.removeClass('selected') e.removeClass('selected')
}, },
// NOTE: setting this to true will not remove disabled // NOTE: setting this to true will not remove disabled