some cleanup and notes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-01-30 20:01:24 +03:00
parent 848577f339
commit dc4eaa2973
3 changed files with 48 additions and 52 deletions

View File

@ -1277,6 +1277,7 @@ var KeyboardUIActions = actions.Actions({
reset_on_commit: false, reset_on_commit: false,
buttons: [ buttons: [
['&ctdot;', function(evt, elem){ ['&ctdot;', function(evt, elem){
code = code || ''
// highlight the current action... // highlight the current action...
var a = keyboard.parseActionCall(code) var a = keyboard.parseActionCall(code)
var p = a.action in that ? var p = a.action in that ?

View File

@ -1550,7 +1550,7 @@ var WidgetTestActions = actions.Actions({
return browse.makeLister(null, function(path, make){ return browse.makeLister(null, function(path, make){
var that = this var that = this
make.Heading('Letters:', { make.Heading('Numbers:', {
doc: 'List editor with all the buttons enabled...', doc: 'List editor with all the buttons enabled...',
}) })
make.EditableList(numbers, { make.EditableList(numbers, {
@ -1560,7 +1560,7 @@ var WidgetTestActions = actions.Actions({
to_bottom_button: true, to_bottom_button: true,
}) })
make.Heading('Numbers:', { make.Heading('Letters:', {
doc: 'Sortable list, use sort handle to the right to sort...' doc: 'Sortable list, use sort handle to the right to sort...'
}) })
make.EditableList(letters, { make.EditableList(letters, {

View File

@ -20,12 +20,6 @@ var widget = require('./widget')
/*********************************************************************/ /*********************************************************************/
// Helpers... // Helpers...
// XXX why do we need this???
var quoteWS = function(str){
return str.replace(/(\s)/g, '\\$1')
}
// Quote a string and convert to RegExp to match self literally. // Quote a string and convert to RegExp to match self literally.
// XXX this depends on jli.quoteRegExp(..) // XXX this depends on jli.quoteRegExp(..)
function toRegExp(str){ function toRegExp(str){
@ -92,6 +86,7 @@ function makeSimpleAction(direction){
// make protocol, i.e. make(content[, options]) or their own... // make protocol, i.e. make(content[, options]) or their own...
var Items = module.items = function(){} var Items = module.items = function(){}
// NOTE: this is the same as make('---'[, options]) // NOTE: this is the same as make('---'[, options])
Items.Separator = Items.Separator =
function(options){ function(options){
@ -510,6 +505,7 @@ function(data, options){
// // false - disable // // false - disable
// // // //
// // NOTE: this will force .groupList to true. // // NOTE: this will force .groupList to true.
// // NOTE: this depends on jquery-ui's Sortable...
// sortable: false, // sortable: false,
// //
// // This is called when a new value is added via new_item but // // This is called when a new value is added via new_item but
@ -873,29 +869,30 @@ function(list, options){
var Buttons = var Buttons =
Items.buttons = Items.buttons =
module.buttons = { module.buttons = {}
// Mark an item for removal and add it to a list of marked items...
//
markForRemoval: function(list, html){
return [html || '&times;',
function(p, e){
e.toggleClass('strike-out')
if(list == null){
return
}
if(e.hasClass('strike-out')){ // Mark an item for removal and add it to a list of marked items...
list.indexOf(p) < 0 //
&& list.push(p) Buttons.markForRemoval = function(list, html){
return [html || '&times;',
function(p, e){
e.toggleClass('strike-out')
} else { if(list == null){
var i = list.indexOf(p) return
i >= 0 }
&& list.splice(i, 1)
} if(e.hasClass('strike-out')){
}] list.indexOf(p) < 0
}, && list.push(p)
} else {
var i = list.indexOf(p)
i >= 0
&& list.splice(i, 1)
}
}]
} }
@ -1023,6 +1020,14 @@ var BrowserClassPrototype = {
// XXX might be a good idea to add a ctrl-c/copy handler... // XXX might be a good idea to add a ctrl-c/copy handler...
// ...copy path by default but overloadable with something like // ...copy path by default but overloadable with something like
// .getCopyValue() which would return .strPath by default... // .getCopyValue() which would return .strPath by default...
// XXX feels a bit over-complicated...
// ...might be a good idea to split this into:
// - base
// - structure
// - path/traversable
// - navigation (mouse/keyboard)
// - search/filtering
// - buttons
var BrowserPrototype = { var BrowserPrototype = {
dom: null, dom: null,
@ -1406,6 +1411,16 @@ var BrowserPrototype = {
} }
this.options.flat = value this.options.flat = value
}, },
get traversable(){
return !this.dom.hasClass('not-traversable') && this.options.traversable },
set traversable(value){
if(value){
this.dom.removeClass('not-traversable')
} else {
this.dom.addClass('not-traversable')
}
this.options.traversable = value
},
get cloud(){ get cloud(){
return this.dom.hasClass('cloud-view') || this.options.cloudView }, return this.dom.hasClass('cloud-view') || this.options.cloudView },
@ -1418,18 +1433,6 @@ var BrowserPrototype = {
this.options.cloudView = value this.options.cloudView = value
}, },
// XXX should these set both the options and dom???
get traversable(){
return !this.dom.hasClass('not-traversable') && this.options.traversable },
set traversable(value){
if(value){
this.dom.removeClass('not-traversable')
} else {
this.dom.addClass('not-traversable')
}
this.options.traversable = value
},
// Get/set the listed path... // Get/set the listed path...
// //
// On more info on setting the path see .update(..) // On more info on setting the path see .update(..)
@ -1535,8 +1538,7 @@ var BrowserPrototype = {
}, },
/* /*/ Copy/Paste actions...
// Copy/Paste actions...
// //
// XXX use 'Text' for IE... // XXX use 'Text' for IE...
copy: function(){ copy: function(){
@ -1572,7 +1574,7 @@ var BrowserPrototype = {
return this return this
}, },
*/ //*/
// update (load) path... // update (load) path...
// - build the path // - build the path
@ -1851,13 +1853,6 @@ var BrowserPrototype = {
.on('blur', function(){ .on('blur', function(){
that.toggleFilter('off') that.toggleFilter('off')
}) })
/* XXX does the right thing (replaces the later .focus(..)
* and .keyup(..)) but does not work in IE...
.on('input', function(){
//that.filterList(quoteWS($(this).text()))
that.filterList($(this).text())
})
*/
// only update if text changed... // only update if text changed...
.focus(function(){ .focus(function(){
txt = $(this).text() txt = $(this).text()
@ -1882,6 +1877,7 @@ var BrowserPrototype = {
p.scrollLeft(0) p.scrollLeft(0)
} }
//---------------------------------------------------- make --- //---------------------------------------------------- make ---
var sort_traversable = this.options.sortTraversable var sort_traversable = this.options.sortTraversable
var section_tail var section_tail
@ -2172,6 +2168,7 @@ var BrowserPrototype = {
} }
make.dialog = this make.dialog = this
//------------------------------------------ build the list --- //------------------------------------------ build the list ---
var res = list.call(this, path, make) var res = list.call(this, path, make)
@ -3128,8 +3125,6 @@ var BrowserPrototype = {
var path = this.path var path = this.path
//path.push(quoteWS(elem.find('.text').text()))
//path.push('"'+ elem.find('.text').text() +'"')
path.push(elem.find('.text').text()) path.push(elem.find('.text').text())
var res = this.open(path) var res = this.open(path)