From 9ea7f416de41f47f6e5b4e75648bd0046c76a6f5 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 11 Jul 2017 01:05:39 +0300 Subject: [PATCH] more work on feature docs... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-widgets.js | 141 +++++++++++++++++++------------ ui (gen4)/lib/widget/browse.js | 7 ++ 2 files changed, 94 insertions(+), 54 deletions(-) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index ee96ac2f..323b8ef6 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -741,6 +741,19 @@ module.Dialogs = core.ImageGridFeatures.Feature({ /*********************************************************************/ +// XXX do not use the global ig for link click handling... +var action2lnk = +module.action2lnk = +function(action){ + return `${action}` } + +// XXX do not use the global ig for link click handling... +var feature2lnk = +module.feature2lnk = +function(tag){ + return `${tag}` } + +// XXX do not use the global ig for link click handling... var doc2html = module.doc2html = function(doc, skip_linking){ @@ -807,8 +820,9 @@ var UIIntrospectionActions = actions.Actions({ .append($('') .text(doc[action][0])) .append($('
') - .text('Features: ' + .html('Features: ' + that.getHandlerSourceTags(action) + .map(feature2lnk) .join(', '))) .append($('
')) // parse the action doc... @@ -830,9 +844,6 @@ var UIIntrospectionActions = actions.Actions({ .append($('
')
 						.text(this.getHandlerDocStr(action))) )
 		})],
-
-	// XXX not final...
-	// XXX should we list feature actions???
 	showFeatureDoc: ['Help/Feature help...',
 		makeUIDialog(function(features){
 			features = features || this.features.features
@@ -846,10 +857,7 @@ var UIIntrospectionActions = actions.Actions({
 				.addClass('help-dialog')
 
 			var tag2lnk = function(tag){
-				return tag != '-'?
-					`${tag}`
-					: '-'
-			}
+				return tag != '-'? feature2lnk(tag) : '-' }
 
 			features.forEach(function(tag){
 				var feature = featureset[tag.startsWith('-') ? tag.slice(1) : tag]
@@ -869,6 +877,7 @@ var UIIntrospectionActions = actions.Actions({
 								: 'loaded')) 
 					.append($('
') .html('Tag: '+ tag2lnk(tag) )) + .append($('
') .html('Priority: '+ (feature.getPriority ? feature.getPriority(true) @@ -895,6 +904,30 @@ var UIIntrospectionActions = actions.Actions({ + (feature.suggested || ['-']) .map(tag2lnk) .join(', '))) + + // list actions, props and handlers... + .append($('
')) + .append($('
') + .html('Props: not implemented')) + .append($('
') + .html('Actions: ' + + Object.keys(feature.actions || {'-': null}) + .filter(function(n){ + return n == '-' + || (Object.getOwnPropertyDescriptor(feature.actions, n) || {}).value instanceof actions.Action }) + .map(function(n){ + return n == '-' ? n : action2lnk(n) }) + .join(', '))) + .append($('
') + .html('Handlers: ' + + (feature.handlers || [['-']]) + .map(function(h){ return h[0] instanceof Array ? h[0] : [h[0]] }) + .reduce(function(a, b){ return a.concat(b) }, []) + .unique() + .map(function(n){ + return n == '-' ? n : action2lnk(n) }) + .join(', '))) + // doc... .append($('
')) .append($('
')
@@ -925,44 +958,44 @@ var UIIntrospectionActions = actions.Actions({
 		makeUIDialog(function(){
 			var that = this
 
-			var dialog = browse.makeLister(null, function(path, make){
-				var features = that.features || {}
+			return browse
+				.makeLister(null, function(path, make){
+					var features = that.features || {}
 
-				// XXX get feature doc...
-				var draw = function(heading, list){
-					make.Heading(heading)
-					;(list || [])
-						.forEach(function(tag){
-							make(tag)
-								.attr('feature', tag)
-								.on('open', function(){ that.showFeatureDoc(tag) })
-						}) }
+					// XXX get feature doc...
+					var draw = function(heading, list){
+						make.Heading(heading)
+						;(list || [])
+							.forEach(function(tag){
+								make(tag)
+									.attr('feature', tag)
+									.on('open', function(){ that.showFeatureDoc(tag) })
+							}) }
 
-				draw('Loaded (in order)', that.features.features)
-				draw('Excluded', that.features.excluded)
-				draw('Disabled', that.features.disabled)
-				draw('Not applicable', that.features.unapplicable)
+					draw('Loaded (in order)', that.features.features)
+					draw('Excluded', that.features.excluded)
+					draw('Disabled', that.features.disabled)
+					draw('Not applicable', that.features.unapplicable)
 
-				if(features.error){
-					var error = features.error
-					error.missing_suggested && error.missing_suggested.length > 0
-						&& draw('Missing (non-critical)', error.missing_suggested)
-					error.missing && error.missing.length > 0
-						&& draw('Missing (critical)', error.missing)
-					// XXX loops...
-					// XXX conflicts...
-				}
-			})
-
-			// handle '?' button to browse path...
-			dialog.showDoc = function(){
-				var feature = dialog.select('!').attr('feature')
-				feature 
-					&& that.showFeatureDoc(feature)
-			}
-			dialog.keyboard.handler('General', '?', 'showDoc')
-
-			return dialog
+					if(features.error){
+						var error = features.error
+						error.missing_suggested && error.missing_suggested.length > 0
+							&& draw('Missing (non-critical)', error.missing_suggested)
+						error.missing && error.missing.length > 0
+							&& draw('Missing (critical)', error.missing)
+						// XXX loops...
+						// XXX conflicts...
+					}
+				})
+				.run(function(){
+					// handle '?' button to browse path...
+					this.showDoc = function(){
+						var feature = this.select('!').attr('feature')
+						feature 
+							&& that.showFeatureDoc(feature)
+					}
+					this.keyboard.handler('General', '?', 'showDoc')
+				})
 		})],
 
 	// XXX is this the right way to go???
@@ -1509,17 +1542,18 @@ var BrowseActionsActions = actions.Actions({
 				config.showDisabled = dialog.options.showDisabled
 				config.showHidden = dialog.options.showHidden
 			})
+			.run(function(){
+				actions.config['browse-actions-keys'] 
+					&& this.dom.addClass('show-keys')
 
-			this.config['browse-actions-keys'] 
-				&& dialog.dom.addClass('show-keys')
-
-			// handle '?' button to browse path...
-			dialog.showDoc = function(){
-				var action = dialog.select('!').attr('action')
-				action 
-					&& actions.showDoc(action)
-			}
-			dialog.keyboard.handler('General', '?', 'showDoc')
+				// handle '?' button to browse path...
+				this.showDoc = function(){
+					var action = this.select('!').attr('action')
+					action 
+						&& this.showDoc(action)
+				}
+				this.keyboard.handler('General', '?', 'showDoc')
+			})
 
 			return dialog
 		})],
@@ -1532,7 +1566,6 @@ var BrowseActionsActions = actions.Actions({
 				this.modal.client.dom.hasClass('browse-actions')
 					&& this.modal.client.dom[state == 'on' ? 'addClass' : 'removeClass']('show-keys')
 			})],
-
 })
 
 var BrowseActions = 
diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js
index 0a642ef9..801d317e 100755
--- a/ui (gen4)/lib/widget/browse.js	
+++ b/ui (gen4)/lib/widget/browse.js	
@@ -3678,6 +3678,13 @@ var BrowserPrototype = {
 		return m ? m.apply(this, arguments) : []
 	},
 
+	// Run a function in the context of the object...
+	//
+	run: function(func){
+		var res = func ? func.call(this) : undefined
+		return res === undefined ? this : res
+	},
+
 	// XXX need to get a container -- UI widget API....
 	// XXX paste does not work on IE yet...
 	// XXX handle copy...