mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-11-03 20:40:10 +00:00 
			
		
		
		
	tweaking and refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									187e5ed9d0
								
							
						
					
					
						commit
						41fbe200f3
					
				@ -705,6 +705,7 @@ module.BaseStore = {
 | 
				
			|||||||
	//		| 'name'
 | 
						//		| 'name'
 | 
				
			||||||
	//		| 'title'
 | 
						//		| 'title'
 | 
				
			||||||
	//		| 'depth'
 | 
						//		| 'depth'
 | 
				
			||||||
 | 
						//		| 'number'
 | 
				
			||||||
	//		| <attr>
 | 
						//		| <attr>
 | 
				
			||||||
	//		| <cmp-func>
 | 
						//		| <cmp-func>
 | 
				
			||||||
	//
 | 
						//
 | 
				
			||||||
@ -712,7 +713,25 @@ module.BaseStore = {
 | 
				
			|||||||
	// NOTE: all path based <by> values are sync, not requireing a .gat(..) 
 | 
						// NOTE: all path based <by> values are sync, not requireing a .gat(..) 
 | 
				
			||||||
	// 		and thus faster than sorting via arbitrary <attr>...
 | 
						// 		and thus faster than sorting via arbitrary <attr>...
 | 
				
			||||||
	//
 | 
						//
 | 
				
			||||||
	// XXX add sort order saving???
 | 
						__sort_method__: {
 | 
				
			||||||
 | 
							// NOTE: path/location are special cases as they do not transform 
 | 
				
			||||||
 | 
							// 		the path -- they are hard-coded in .sort(..)...
 | 
				
			||||||
 | 
							//path: function(p){ return p },
 | 
				
			||||||
 | 
							//location: function(p){ return p },
 | 
				
			||||||
 | 
							dir: pwpath.dirname.bind(pwpath),
 | 
				
			||||||
 | 
							name: pwpath.basename.bind(pwpath),
 | 
				
			||||||
 | 
							title: function(p){
 | 
				
			||||||
 | 
								return pwpath.decodeElem(
 | 
				
			||||||
 | 
									pwpath.basename(p)) },
 | 
				
			||||||
 | 
							depth: function(p){
 | 
				
			||||||
 | 
								return pwpath.split(p).length },
 | 
				
			||||||
 | 
							// XXX this only accounts for the first number...
 | 
				
			||||||
 | 
							number: function(p){
 | 
				
			||||||
 | 
								return parseInt(p.split(/[^\d]+/)
 | 
				
			||||||
 | 
									.filter(function(e){ 
 | 
				
			||||||
 | 
										return e != '' })
 | 
				
			||||||
 | 
									.shift()) },
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	sort: function(paths, ...by){
 | 
						sort: function(paths, ...by){
 | 
				
			||||||
		var that = this
 | 
							var that = this
 | 
				
			||||||
		paths = 
 | 
							paths = 
 | 
				
			||||||
@ -747,15 +766,8 @@ module.BaseStore = {
 | 
				
			|||||||
						(cmp == 'path' 
 | 
											(cmp == 'path' 
 | 
				
			||||||
								|| cmp == 'location') ? 
 | 
													|| cmp == 'location') ? 
 | 
				
			||||||
							p
 | 
												p
 | 
				
			||||||
						: cmp == 'dir' ?
 | 
											: cmp in that.__sort_method__ ?
 | 
				
			||||||
							pwpath.dirname(p)
 | 
												that.__sort_method__[cmp].call(that, p)
 | 
				
			||||||
						: cmp == 'name' ?
 | 
					 | 
				
			||||||
							pwpath.basename(p)
 | 
					 | 
				
			||||||
						: cmp == 'title' ?
 | 
					 | 
				
			||||||
							pwpath.decodeElem(
 | 
					 | 
				
			||||||
								pwpath.basename(p)) 
 | 
					 | 
				
			||||||
						: cmp == 'depth' ?
 | 
					 | 
				
			||||||
							pwpath.split(p).length
 | 
					 | 
				
			||||||
						// async attr...
 | 
											// async attr...
 | 
				
			||||||
						: typeof(cmp) == 'string' ?
 | 
											: typeof(cmp) == 'string' ?
 | 
				
			||||||
							// NOTE: we only get page data once per page...
 | 
												// NOTE: we only get page data once per page...
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user