diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 09473755..22e7e00a 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -404,8 +404,9 @@ module.makeUIDialog = function(a, b){ return uiDialog(function(){ var args = [].slice.call(arguments) + // see if the first arg is a container spec... - var container = this.isUIContainer(args[0]) ? + var container = !(args[0] instanceof Array) && this.isUIContainer(args[0]) ? args.shift() : (dfl || this.config['ui-default-container'] || 'Overlay') @@ -740,6 +741,36 @@ module.Dialogs = core.ImageGridFeatures.Feature({ /*********************************************************************/ +var doc2html = +module.doc2html = +function(doc, skip_linking){ + skip_linking = skip_linking || [] + return doc + // html stuff... + .replace(/&/g, '&') + .replace(//g, '>') + // normalize tabs -- convert tabs and tabbed + // spaces into 4 spaces... + // NOTE: the code internally uses only tabs, + // but this will help make the view + // consistent. + .replace(/ {0,3}\t/g, ' ') + // comments... + .replace(/(\/\/.*)\n/g, '$1\n') + // notes... + .replace(/NOTE:/g, 'NOTE:') + .replace(/XXX/g, 'XXX') + // action links... + .replace(/(\s)(\.([\w_]+[\w\d_]*)\([^)]*\))/g, + function(match, a, b, c){ + return (skip_linking == '*' || skip_linking.indexOf(c) >= 0) ? + `${a}${b}` + : `${a}${b}` + }) +} + + var UIIntrospectionActions = actions.Actions({ // Show doc for action... // @@ -764,6 +795,7 @@ var UIIntrospectionActions = actions.Actions({ actions = actions instanceof Array ? actions : [actions] var doc = this.getDoc(actions) + var res = $('
')
- .html((doc[action][1] || '')
- // html stuff...
- .replace(/&/g, '&')
- .replace(//g, '>')
- // normalize tabs -- convert tabs and tabbed
- // spaces into 4 spaces...
- // NOTE: the code internally uses only tabs,
- // but this will help make the view
- // consistent.
- .replace(/ {0,3}\t/g, ' ')
- // comments...
- .replace(/(\/\/.*)\n/g, '$1\n')
- // notes...
- .replace(/NOTE:/g, 'NOTE:')
- .replace(/XXX/g, 'XXX')
- // action links...
- .replace(/(\s)(\.([\w_]+[\w\d_]*)\([^)]*\))/g,
- function(match, a, b, c){
- return c == action ?
- `${a}${b}`
- : `${a}${b}`
+ .html(doc2html(doc[action][1] || '', [action])))
+ // NOTE: we are quoting action in an array here to prevent
+ // dialog actions from messing up the call...
+ .append($(`code...`)) )
+ })
+
+ return res
+ })],
+
+ showCode: ['- Help/',
+ makeUIDialog(function(action){
+ action = action instanceof Array ? action[0] : action
+ return $('')
+ .addClass('help-dialog')
+ .append($('')
+ .append($('')
+ .text(this.getHandlerDocStr(action))) )
+ })],
+
+ // XXX not final...
+ showFeatureDoc: ['Help/Feature help...',
+ makeUIDialog(function(features){
+ features = features || this.features.features
+ features = features == '*' ? this.features.FeatureSet.features
+ : features instanceof Array ? features
+ : [features]
+
+ var that = this
+ var featureset = this.features.FeatureSet
+ var res = $('')
+ .addClass('help-dialog')
+
+ var tag2lnk = function(tag){
+ return tag != '-'?
+ `${tag}`
+ : '-'
+ }
+
+ features.forEach(function(tag){
+ var feature = featureset[tag.startsWith('-') ? tag.slice(1) : tag]
+
+ // skip unknown tags...
+ if(feature == null){
+ return
+ }
+
+ res.append($('')
+ .prop('tabindex', true)
+ .append($('')
+ .text(feature.title || tag))
+ .append($('')
+ .html(that.features.features.indexOf(tag) < 0 ?
+ 'not loaded'
+ : 'loaded'))
+ .append($('')
+ .html('Tag: '+ tag2lnk(tag) ))
+ .append($('')
+ .html('Priority: '+ (feature.getPriority ?
+ feature.getPriority(true)
+ : (feature.priority || 'normal') )))
+ // list exclusive features...
+ .append($('')
+ .html('Exclusive tag: '
+ + (feature.exclusive || ['-'])
+ .map(function(tag){
+ if(tag == '-'){
+ return tag
+ }
+ var tags = featureset.getExclusive(tag)[tag].join('\', \'')
+ return `${tag}`
})
- )))
+ .join(', ')))
+ .append($('')
+ .html('Depends: '
+ + (feature.depends || ['-'])
+ .map(tag2lnk)
+ .join(', ')))
+ .append($('')
+ .html('Suggests: '
+ + (feature.suggested || ['-'])
+ .map(tag2lnk)
+ .join(', ')))
+ // doc...
+ .append($('
'))
+ .append($('')
+ .html(doc2html(feature.doc || ''))) )
})
return res
@@ -839,6 +933,7 @@ var UIIntrospectionActions = actions.Actions({
;(list || [])
.forEach(function(tag){
make(tag)
+ .on('open', function(){ that.showFeatureDoc(tag) })
}) }
draw('Loaded (in order)', that.features.features)
@@ -891,6 +986,7 @@ var UIIntrospectionActions = actions.Actions({
// XXX EXPERIMENTAL...
featureGraph: ['- Help/Generate feature graph (graphviz format)',
+ core.doc`Generate feature dependency graph in the graphviz format.`,
function(){
return this.features.FeatureSet.gvGraph(this.features.features) }],
})
diff --git a/ui (gen4)/package.json b/ui (gen4)/package.json
index 2eef1ca2..b0f02bf2 100755
--- a/ui (gen4)/package.json
+++ b/ui (gen4)/package.json
@@ -23,7 +23,7 @@
"glob": "^4.0.6",
"guarantee-events": "^1.0.0",
"ig-actions": "^3.2.5",
- "ig-features": "^3.2.4",
+ "ig-features": "^3.2.6",
"ig-object": "^1.0.1",
"openseadragon": "^2.1.0",
"preact": "^8.1.0",