revised non-traversable handling + test...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-06-21 04:15:54 +03:00
parent fda402bcc9
commit 12f6488c80
3 changed files with 32 additions and 5 deletions

View File

@ -115,6 +115,9 @@
opacity: 0.7; opacity: 0.7;
} }
.browse .list div:not(.not-traversable):after {
content: "/";
}
.browse:focus .list div.selected, .browse:focus .list div.selected,
.browse .path .dir:hover, .browse .path .dir:hover,

View File

@ -142,6 +142,7 @@ TREE.dir_c.dir_b.tree = TREE
//--- //---
var use_disabled = true var use_disabled = true
var show_files = false
requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, browser){ requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, browser){
keyboard = k keyboard = k
@ -157,7 +158,7 @@ requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, br
return Object.keys(cur) return Object.keys(cur)
// remove all strings... // remove all strings...
.filter(function(k){ .filter(function(k){
return typeof(cur[k]) != typeof('str') return show_files || typeof(cur[k]) != typeof('str')
}) })
.map(function(k){ .map(function(k){
// make the element... // make the element...
@ -166,6 +167,9 @@ requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, br
if(use_disabled && k == 'dir_b'){ if(use_disabled && k == 'dir_b'){
e.addClass('disabled') e.addClass('disabled')
} }
if(typeof(cur[k]) == typeof('str')){
e.addClass('not-traversable')
}
return k return k
}) })
}, },
@ -202,6 +206,15 @@ function toggleDisabled(){
use_disabled ? b.disableElements('_b') : b.enableElements('_b') use_disabled ? b.disableElements('_b') : b.enableElements('_b')
} }
function toggleFiles(){
show_files = !show_files
// NOTE: we need to update only because .list(..) does not show
// files at all and we need to re-render them, another way
// would be render everything but hide and show files via CSS
// class...
b.update()
}
</script> </script>
@ -221,6 +234,11 @@ Theme: <button id="theme" onclick="themeToggler()">none</button>
Disabled: <button id="theme" onclick="toggleDisabled()">toggle</button> Disabled: <button id="theme" onclick="toggleDisabled()">toggle</button>
<br>
Files: <button id="theme" onclick="toggleFiles()">toggle</button>
<div class="container"> <div class="container">
<div class="browse"> <div class="browse">

View File

@ -648,9 +648,7 @@ var BrowserPrototype = {
path.push(elem.text()) path.push(elem.text())
// if not traversable call the action... // if not traversable call the action...
if(this.isTraversable != null if(elem.hasClass('not-traversable')){
&& (this.isTraversable !== false
|| ! this.isTraversable(path))){
return this.action(path) return this.action(path)
} }
@ -727,12 +725,20 @@ var BrowserPrototype = {
// - make should never get called // - make should never get called
// - the returned list will be rendered // - the returned list will be rendered
// //
//
// This can set the following classes on elements:
//
// .disabled
// an element is disabled.
//
// .non-traversable
// an element is not traversable/listable and will trigger the
// .action(..) on push...
list: function(path, make){ list: function(path, make){
path = path || this.path path = path || this.path
var m = this.options.list var m = this.options.list
return m ? m.apply(this, arguments) : [] return m ? m.apply(this, arguments) : []
}, },
isTraversable: null,
// XXX need to get a container.... // XXX need to get a container....
// XXX setup instance events... // XXX setup instance events...