mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-17 08:41:40 +00:00
minor refactoring and updated docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
253f5f1128
commit
f3dc8e1e30
@ -257,6 +257,10 @@ var BrowserPrototype = {
|
|||||||
// representation, taking care of relative path constructs including
|
// representation, taking care of relative path constructs including
|
||||||
// '.' (current path) and '..' (up one level)
|
// '.' (current path) and '..' (up one level)
|
||||||
//
|
//
|
||||||
|
// XXX does this need to handle trailing '/'???
|
||||||
|
// ...the problem is mainly encoding a trailing '/' into an
|
||||||
|
// array, adding a '' at the end seems both obvious and
|
||||||
|
// artificial...
|
||||||
// XXX is this the correct name???
|
// XXX is this the correct name???
|
||||||
path2lst: function(path){
|
path2lst: function(path){
|
||||||
var splitter = /[\\\/]/
|
var splitter = /[\\\/]/
|
||||||
@ -298,7 +302,7 @@ var BrowserPrototype = {
|
|||||||
// event object triggered.
|
// event object triggered.
|
||||||
//
|
//
|
||||||
// NOTE: event propagation for some events is disabled by binding
|
// NOTE: event propagation for some events is disabled by binding
|
||||||
// handlers that stop propagation in .__init__(..).
|
// to them handlers that stop propagation in .__init__(..).
|
||||||
// The list of non-propagated events in defined in
|
// The list of non-propagated events in defined in
|
||||||
// .options.nonPropagatedEvents
|
// .options.nonPropagatedEvents
|
||||||
trigger: function(){
|
trigger: function(){
|
||||||
@ -359,12 +363,11 @@ var BrowserPrototype = {
|
|||||||
this.options.traversable = value
|
this.options.traversable = value
|
||||||
},
|
},
|
||||||
|
|
||||||
// Get/set the path...
|
// Get/set the listed path...
|
||||||
//
|
//
|
||||||
// On more info on setting the path see .update(..)
|
// On more info on setting the path see .update(..)
|
||||||
//
|
//
|
||||||
// NOTE: .path = <some-path> is equivalent to .update(<some-path>)
|
// NOTE: .path = <path> is equivalent to .update(<path>)
|
||||||
// both exist at the same time to enable chaining...
|
|
||||||
// NOTE: if the string path assigned does not contain a trailing '/'
|
// NOTE: if the string path assigned does not contain a trailing '/'
|
||||||
// the path will be loaded up to the last item and the last item
|
// the path will be loaded up to the last item and the last item
|
||||||
// will be selected (see .update(..) for example).
|
// will be selected (see .update(..) for example).
|
||||||
@ -385,6 +388,10 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
// String path...
|
// String path...
|
||||||
//
|
//
|
||||||
|
// This is the same as .path but returns a string result.
|
||||||
|
//
|
||||||
|
// NOTE: this does not include the selected element, i.e. the returned
|
||||||
|
// path always ends with a trailing '/'.
|
||||||
// NOTE: the setter is just a shorthand to .path setter for uniformity...
|
// NOTE: the setter is just a shorthand to .path setter for uniformity...
|
||||||
get strPath(){
|
get strPath(){
|
||||||
return '/' + this.path.join('/') + '/'
|
return '/' + this.path.join('/') + '/'
|
||||||
@ -395,6 +402,9 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
// Get/set path with selection...
|
// Get/set path with selection...
|
||||||
//
|
//
|
||||||
|
// NOTE: this always returns the selected element last if one is
|
||||||
|
// selected, if no element is selected this is equivalent to
|
||||||
|
// .strPath
|
||||||
// NOTE: the setter is just a shorthand to .path setter for uniformity...
|
// NOTE: the setter is just a shorthand to .path setter for uniformity...
|
||||||
get selectionPath(){
|
get selectionPath(){
|
||||||
return this.strPath +'/'+ (this.selected || '')
|
return this.strPath +'/'+ (this.selected || '')
|
||||||
@ -405,8 +415,8 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
// Get/set current selection (text)...
|
// Get/set current selection (text)...
|
||||||
//
|
//
|
||||||
// NOTE: setting the selection accepts the same values as .select(..),
|
// NOTE: .selected = <value> is equivalent to .select(<value>) for
|
||||||
// see it for more docs.
|
// more info on accepted values see .select(..)
|
||||||
get selected(){
|
get selected(){
|
||||||
var e = this.select('!')
|
var e = this.select('!')
|
||||||
if(e.length <= 0){
|
if(e.length <= 0){
|
||||||
@ -460,6 +470,8 @@ var BrowserPrototype = {
|
|||||||
// - build the element list
|
// - build the element list
|
||||||
// - bind to control events
|
// - bind to control events
|
||||||
//
|
//
|
||||||
|
// This will trigger the 'update' event.
|
||||||
|
//
|
||||||
// For uniformity and ease of access from DOM, this will also set the
|
// For uniformity and ease of access from DOM, this will also set the
|
||||||
// 'path' html attribute on the .browse element.
|
// 'path' html attribute on the .browse element.
|
||||||
//
|
//
|
||||||
@ -641,7 +653,6 @@ var BrowserPrototype = {
|
|||||||
// NOTE: unlike .select(..) index overflow will produce empty
|
// NOTE: unlike .select(..) index overflow will produce empty
|
||||||
// lists rather than to/bottom elements.
|
// lists rather than to/bottom elements.
|
||||||
//
|
//
|
||||||
//
|
|
||||||
// If <rejected-handler> function is passed it will get called with
|
// If <rejected-handler> function is passed it will get called with
|
||||||
// every element that was rejected by the predicate / not matching
|
// every element that was rejected by the predicate / not matching
|
||||||
// the pattern.
|
// the pattern.
|
||||||
@ -916,7 +927,7 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
return this
|
return this
|
||||||
}),
|
}),
|
||||||
// shorthands mostly for use in actions and for chaining...
|
// shorthands mostly for use as actions...
|
||||||
startFilter: function(){ return this.toggleFilter('on') },
|
startFilter: function(){ return this.toggleFilter('on') },
|
||||||
stopFilter: function(){ return this.toggleFilter('off') },
|
stopFilter: function(){ return this.toggleFilter('off') },
|
||||||
|
|
||||||
@ -997,6 +1008,8 @@ var BrowserPrototype = {
|
|||||||
//
|
//
|
||||||
// This will return a jQuery object.
|
// This will return a jQuery object.
|
||||||
//
|
//
|
||||||
|
// This will trigger the 'select' or 'deselect' events.
|
||||||
|
//
|
||||||
// For uniformity and ease of access from DOM, this will also set
|
// For uniformity and ease of access from DOM, this will also set
|
||||||
// the value attr on the .browse element.
|
// the value attr on the .browse element.
|
||||||
// NOTE: this is one way and setting the html attribute "value" will
|
// NOTE: this is one way and setting the html attribute "value" will
|
||||||
@ -1152,6 +1165,8 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
// Push an element to path / go down one level...
|
// Push an element to path / go down one level...
|
||||||
//
|
//
|
||||||
|
// This will trigger the 'push' event.
|
||||||
|
//
|
||||||
// NOTE: if the element is not traversable it will be opened.
|
// NOTE: if the element is not traversable it will be opened.
|
||||||
//
|
//
|
||||||
// XXX might be a good idea to add a live traversable check...
|
// XXX might be a good idea to add a live traversable check...
|
||||||
@ -1195,6 +1210,8 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
// Pop an element off the path / go up one level...
|
// Pop an element off the path / go up one level...
|
||||||
//
|
//
|
||||||
|
// This will trigger the 'pop' event.
|
||||||
|
//
|
||||||
// XXX revise event...
|
// XXX revise event...
|
||||||
pop: function(){
|
pop: function(){
|
||||||
var browser = this.dom
|
var browser = this.dom
|
||||||
@ -1275,42 +1292,38 @@ var BrowserPrototype = {
|
|||||||
// .open('first')
|
// .open('first')
|
||||||
// .open('last')
|
// .open('last')
|
||||||
// -> this
|
// -> this
|
||||||
// -> object
|
|
||||||
//
|
//
|
||||||
// Open next/prev element...
|
// Open next/prev element...
|
||||||
// .open('next')
|
// .open('next')
|
||||||
// .open('prev')
|
// .open('prev')
|
||||||
// -> this
|
// -> this
|
||||||
// -> object
|
|
||||||
//
|
//
|
||||||
// Open active element at index...
|
// Open active element at index...
|
||||||
// .open(<number>)
|
// .open(<number>)
|
||||||
// -> this
|
// -> this
|
||||||
// -> object
|
|
||||||
//
|
//
|
||||||
// Open element by absolute index...
|
// Open element by absolute index...
|
||||||
// .open('<number>!')
|
// .open('<number>!')
|
||||||
// -> this
|
// -> this
|
||||||
// -> object
|
|
||||||
//
|
//
|
||||||
// Open element by full or partial text...
|
// Open element by full or partial text...
|
||||||
// .open('<text>')
|
// .open('<text>')
|
||||||
// .open("'<text>'")
|
// .open("'<text>'")
|
||||||
// .open('"<text>"')
|
// .open('"<text>"')
|
||||||
// -> this
|
// -> this
|
||||||
// -> object
|
|
||||||
//
|
//
|
||||||
// Open first element matching a regexp...
|
// Open first element matching a regexp...
|
||||||
// .open(<regexp>)
|
// .open(<regexp>)
|
||||||
// -> this
|
// -> this
|
||||||
// -> object
|
|
||||||
//
|
//
|
||||||
// Open an element explicitly...
|
// Open an element explicitly...
|
||||||
// .open(<elem>)
|
// .open(<elem>)
|
||||||
// -> this
|
// -> this
|
||||||
// -> object
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
// This will trigger the 'open' event on the opened element and the
|
||||||
|
// widget.
|
||||||
|
//
|
||||||
// This is called when an element is selected and opened.
|
// This is called when an element is selected and opened.
|
||||||
//
|
//
|
||||||
// By default this happens in the following situations:
|
// By default this happens in the following situations:
|
||||||
@ -1434,6 +1447,11 @@ var BrowserPrototype = {
|
|||||||
// .open(..) on push...
|
// .open(..) on push...
|
||||||
//
|
//
|
||||||
// XXX need a way to constructively communicate errors up...
|
// XXX need a way to constructively communicate errors up...
|
||||||
|
// XXX also need a load strategy when something bad happens...
|
||||||
|
// ...e.g. load up until the first error, or something like:
|
||||||
|
// while(!this.list(path, make)){
|
||||||
|
// path.pop()
|
||||||
|
// }
|
||||||
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
|
||||||
@ -1443,7 +1461,6 @@ var BrowserPrototype = {
|
|||||||
// XXX need to get a container -- UI widget API....
|
// XXX need to get a container -- UI widget API....
|
||||||
// XXX paste does not work on IE yet...
|
// XXX paste does not work on IE yet...
|
||||||
// XXX handle copy...
|
// XXX handle copy...
|
||||||
// XXX trigger started event...
|
|
||||||
__init__: function(parent, options){
|
__init__: function(parent, options){
|
||||||
var that = this
|
var that = this
|
||||||
options = options || {}
|
options = options || {}
|
||||||
@ -1513,11 +1530,12 @@ var BrowserPrototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load the initial state...
|
// load the initial state...
|
||||||
// XXX check if this default is correct...
|
this.update(options.path || this.path || '/')
|
||||||
this.update(options.path || this.path)
|
|
||||||
|
|
||||||
this.on(this.options.nonPropagatedEvents.join(''),
|
if(this.options.nonPropagatedEvents != null){
|
||||||
function(evt){ evt.stopPropagation() })
|
this.on(this.options.nonPropagatedEvents.join(''),
|
||||||
|
function(evt){ evt.stopPropagation() })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user