mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
added feature doc viewer + action code view...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
fee35dca32
commit
b1684c2d90
@ -404,8 +404,9 @@ module.makeUIDialog = function(a, b){
|
|||||||
return uiDialog(function(){
|
return uiDialog(function(){
|
||||||
var args = [].slice.call(arguments)
|
var args = [].slice.call(arguments)
|
||||||
|
|
||||||
|
|
||||||
// see if the first arg is a container spec...
|
// 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()
|
args.shift()
|
||||||
: (dfl || this.config['ui-default-container'] || 'Overlay')
|
: (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, '<')
|
||||||
|
.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, '<span class="comment">$1</span>\n')
|
||||||
|
// notes...
|
||||||
|
.replace(/NOTE:/g, '<b>NOTE:</b>')
|
||||||
|
.replace(/XXX/g, '<span class="warning">XXX</span>')
|
||||||
|
// action links...
|
||||||
|
.replace(/(\s)(\.([\w_]+[\w\d_]*)\([^)]*\))/g,
|
||||||
|
function(match, a, b, c){
|
||||||
|
return (skip_linking == '*' || skip_linking.indexOf(c) >= 0) ?
|
||||||
|
`${a}<i>${b}</i>`
|
||||||
|
: `${a}<a href="#" onclick="ig.showDoc('${c}')">${b}</a>`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var UIIntrospectionActions = actions.Actions({
|
var UIIntrospectionActions = actions.Actions({
|
||||||
// Show doc for action...
|
// Show doc for action...
|
||||||
//
|
//
|
||||||
@ -764,6 +795,7 @@ var UIIntrospectionActions = actions.Actions({
|
|||||||
actions = actions instanceof Array ? actions : [actions]
|
actions = actions instanceof Array ? actions : [actions]
|
||||||
|
|
||||||
var doc = this.getDoc(actions)
|
var doc = this.getDoc(actions)
|
||||||
|
|
||||||
var res = $('<div>')
|
var res = $('<div>')
|
||||||
.addClass('help-dialog')
|
.addClass('help-dialog')
|
||||||
|
|
||||||
@ -781,30 +813,92 @@ var UIIntrospectionActions = actions.Actions({
|
|||||||
.append($('<hr>'))
|
.append($('<hr>'))
|
||||||
// parse the action doc...
|
// parse the action doc...
|
||||||
.append($('<pre>')
|
.append($('<pre>')
|
||||||
.html((doc[action][1] || '')
|
.html(doc2html(doc[action][1] || '', [action])))
|
||||||
// html stuff...
|
// NOTE: we are quoting action in an array here to prevent
|
||||||
.replace(/&/g, '&')
|
// dialog actions from messing up the call...
|
||||||
.replace(/</g, '<')
|
.append($(`<a href="#" onclick="ig.showCode(['${action}'])">code...</a>`)) )
|
||||||
.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, '<span class="comment">$1</span>\n')
|
|
||||||
// notes...
|
|
||||||
.replace(/NOTE:/g, '<b>NOTE:</b>')
|
|
||||||
.replace(/XXX/g, '<span class="warning">XXX</span>')
|
|
||||||
// action links...
|
|
||||||
.replace(/(\s)(\.([\w_]+[\w\d_]*)\([^)]*\))/g,
|
|
||||||
function(match, a, b, c){
|
|
||||||
return c == action ?
|
|
||||||
`${a}<i>${b}</i>`
|
|
||||||
: `${a}<a href="#" onclick="ig.showDoc('${c}')">${b}</a>`
|
|
||||||
})
|
})
|
||||||
)))
|
|
||||||
|
return res
|
||||||
|
})],
|
||||||
|
|
||||||
|
showCode: ['- Help/',
|
||||||
|
makeUIDialog(function(action){
|
||||||
|
action = action instanceof Array ? action[0] : action
|
||||||
|
return $('<div>')
|
||||||
|
.addClass('help-dialog')
|
||||||
|
.append($('<div class="action">')
|
||||||
|
.append($('<pre>')
|
||||||
|
.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 = $('<div>')
|
||||||
|
.addClass('help-dialog')
|
||||||
|
|
||||||
|
var tag2lnk = function(tag){
|
||||||
|
return tag != '-'?
|
||||||
|
`<a href="#" onclick="ig.showFeatureDoc('${tag}')">${tag}</a>`
|
||||||
|
: '-'
|
||||||
|
}
|
||||||
|
|
||||||
|
features.forEach(function(tag){
|
||||||
|
var feature = featureset[tag.startsWith('-') ? tag.slice(1) : tag]
|
||||||
|
|
||||||
|
// skip unknown tags...
|
||||||
|
if(feature == null){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res.append($('<div class="feature">')
|
||||||
|
.prop('tabindex', true)
|
||||||
|
.append($('<h2>')
|
||||||
|
.text(feature.title || tag))
|
||||||
|
.append($('<i>')
|
||||||
|
.html(that.features.features.indexOf(tag) < 0 ?
|
||||||
|
'not loaded'
|
||||||
|
: 'loaded'))
|
||||||
|
.append($('<div>')
|
||||||
|
.html('Tag: '+ tag2lnk(tag) ))
|
||||||
|
.append($('<div>')
|
||||||
|
.html('Priority: '+ (feature.getPriority ?
|
||||||
|
feature.getPriority(true)
|
||||||
|
: (feature.priority || 'normal') )))
|
||||||
|
// list exclusive features...
|
||||||
|
.append($('<div>')
|
||||||
|
.html('Exclusive tag: '
|
||||||
|
+ (feature.exclusive || ['-'])
|
||||||
|
.map(function(tag){
|
||||||
|
if(tag == '-'){
|
||||||
|
return tag
|
||||||
|
}
|
||||||
|
var tags = featureset.getExclusive(tag)[tag].join('\', \'')
|
||||||
|
return `<a href="#" onclick="ig.showFeatureDoc(['${tags}'])">${tag}</a>`
|
||||||
|
})
|
||||||
|
.join(', ')))
|
||||||
|
.append($('<div>')
|
||||||
|
.html('Depends: '
|
||||||
|
+ (feature.depends || ['-'])
|
||||||
|
.map(tag2lnk)
|
||||||
|
.join(', ')))
|
||||||
|
.append($('<div>')
|
||||||
|
.html('Suggests: '
|
||||||
|
+ (feature.suggested || ['-'])
|
||||||
|
.map(tag2lnk)
|
||||||
|
.join(', ')))
|
||||||
|
// doc...
|
||||||
|
.append($('<hr>'))
|
||||||
|
.append($('<pre>')
|
||||||
|
.html(doc2html(feature.doc || ''))) )
|
||||||
})
|
})
|
||||||
|
|
||||||
return res
|
return res
|
||||||
@ -839,6 +933,7 @@ var UIIntrospectionActions = actions.Actions({
|
|||||||
;(list || [])
|
;(list || [])
|
||||||
.forEach(function(tag){
|
.forEach(function(tag){
|
||||||
make(tag)
|
make(tag)
|
||||||
|
.on('open', function(){ that.showFeatureDoc(tag) })
|
||||||
}) }
|
}) }
|
||||||
|
|
||||||
draw('Loaded (in order)', that.features.features)
|
draw('Loaded (in order)', that.features.features)
|
||||||
@ -891,6 +986,7 @@ var UIIntrospectionActions = actions.Actions({
|
|||||||
|
|
||||||
// XXX EXPERIMENTAL...
|
// XXX EXPERIMENTAL...
|
||||||
featureGraph: ['- Help/Generate feature graph (graphviz format)',
|
featureGraph: ['- Help/Generate feature graph (graphviz format)',
|
||||||
|
core.doc`Generate feature dependency graph in the graphviz format.`,
|
||||||
function(){
|
function(){
|
||||||
return this.features.FeatureSet.gvGraph(this.features.features) }],
|
return this.features.FeatureSet.gvGraph(this.features.features) }],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
"glob": "^4.0.6",
|
"glob": "^4.0.6",
|
||||||
"guarantee-events": "^1.0.0",
|
"guarantee-events": "^1.0.0",
|
||||||
"ig-actions": "^3.2.5",
|
"ig-actions": "^3.2.5",
|
||||||
"ig-features": "^3.2.4",
|
"ig-features": "^3.2.6",
|
||||||
"ig-object": "^1.0.1",
|
"ig-object": "^1.0.1",
|
||||||
"openseadragon": "^2.1.0",
|
"openseadragon": "^2.1.0",
|
||||||
"preact": "^8.1.0",
|
"preact": "^8.1.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user