Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
5250a8d1
Commit
5250a8d1
authored
Feb 26, 2013
by
Marcel
Browse files
Small changes to the extension management. Check the ExtensionContent init arguments!
parent
90098dcb
Changes
6
Hide whitespace changes
Inline
Side-by-side
vispa/extensions/dummy/static/js/extension.js
View file @
5250a8d1
...
...
@@ -35,7 +35,7 @@ var DummyFactory = ExtensionFactoryFull.extend({
label
:
'
new Dummy ...
'
,
icon
:
'
ui-icon-plus
'
,
callback
:
function
()
{
_this
.
_create
(
1
,
2
,
3
,
4
);
_this
.
_create
(
'
~/user/vispa/analyses/ttH.txt
'
);
}
}
];
...
...
@@ -68,8 +68,8 @@ var DummyFactory = ExtensionFactoryFull.extend({
var
DummyContent
=
ExtensionContentFull
.
extend
({
init
:
function
(
vispa
,
config
)
{
this
.
_super
(
vispa
,
config
);
init
:
function
(
vispa
,
config
,
identifier
)
{
this
.
_super
(
vispa
,
config
,
identifier
);
var
_this
=
this
;
// attributes
...
...
@@ -91,17 +91,12 @@ var DummyContent = ExtensionContentFull.extend({
return
this
;
},
getIdentifier
:
function
()
{
return
'
/user/vispa/analyses/ttH.txt
'
;
},
getContent
:
function
()
{
this
.
nodes
.
content
=
$
(
'
<div />
'
)
return
this
.
nodes
.
content
=
$
(
'
<div />
'
)
.
addClass
(
'
dummy-full-body
'
)
.
css
(
'
background-color
'
,
this
.
config
.
backgroundColor
)
.
html
(
$
.
Helpers
.
strFormat
(
'
Dummy Content<br />Number: {0}
'
,
this
.
_number
))
.
get
(
0
);
return
this
.
nodes
.
content
;
}
});
...
...
vispa/filesystem.py
View file @
5250a8d1
...
...
@@ -134,7 +134,7 @@ class FileSystem(object):
# resort?
if
append_hidden
:
files
=
sorted
(
files
,
cmp
=
file_compare
,
key
=
str
.
lower
)
while
len
(
suggestions
)
<
length
and
len
(
files
):
while
(
len
(
suggestions
)
<
length
or
length
==
0
)
and
len
(
files
):
file
=
files
.
pop
(
0
)
if
filter
and
not
file
.
startswith
(
filter
):
continue
...
...
vispa/static/css/sites/index/pathbar.css
View file @
5250a8d1
...
...
@@ -90,7 +90,6 @@
}
.pathbar-input-loader-filelabel
{
background-color
:
#3383bb
;
color
:
white
;
font-family
:
Arial
;
font-weight
:
bold
;
...
...
@@ -101,12 +100,22 @@
padding
:
1px
6px
2px
6px
;
border-radius
:
5px
;
text-shadow
:
0px
1px
1px
rgba
(
0
,
0
,
0
,
0.8
);
background-image
:
linear-gradient
(
top
,
#3383bb
0%
,
black
300%
);
background-image
:
-webkit-linear-gradient
(
top
,
#3383bb
0%
,
black
300%
);
background-image
:
-moz-linear-gradient
(
top
,
#3383bb
0%
,
black
300%
);
background-image
:
-o-linear-gradient
(
top
,
#3383bb
0%
,
black
300%
);
}
.pathbar-input-loader-filelabel-true
{
background-image
:
linear-gradient
(
top
,
green
0%
,
black
300%
);
background-image
:
-webkit-linear-gradient
(
top
,
green
0%
,
black
300%
);
background-image
:
-moz-linear-gradient
(
top
,
green
0%
,
black
300%
);
background-image
:
-o-linear-gradient
(
top
,
green
0%
,
black
300%
);
}
.pathbar-input-loader-filelabel-false
{
background-image
:
linear-gradient
(
top
,
red
0%
,
black
300%
);
background-image
:
-webkit-linear-gradient
(
top
,
red
0%
,
black
300%
);
background-image
:
-moz-linear-gradient
(
top
,
red
0%
,
black
300%
);
background-image
:
-o-linear-gradient
(
top
,
red
0%
,
black
300%
);
}
\ No newline at end of file
vispa/static/js/sites/index/extensionmanager.js
View file @
5250a8d1
...
...
@@ -169,6 +169,25 @@ var ExtensionManager = VispaModule.extend({
var
args
=
$
.
makeArray
(
arguments
);
args
.
splice
(
0
,
4
);
// the first arg is supposed to be the identifier
// if it's set and there is aleady an instance of that factory
// with that identifier, switch the view to that instance
// but don't create a new one
var
identifier
=
args
.
length
?
(
args
[
0
]
||
null
)
:
null
;
var
targetInstance
=
null
;
$
.
each
(
factory
.
_instances
,
function
(
i
,
instance
)
{
var
_identifier
=
instance
.
getIdentifier
()
||
null
;
if
(
_identifier
==
identifier
)
{
targetInstance
=
instance
;
return
false
;
}
});
if
(
targetInstance
)
{
// show it
this
.
showInstance
(
targetInstance
,
byUrl
);
return
this
;
}
// max_instances reached?
var
max
=
factory
.
maxInstances
;
var
count
=
$
.
Helpers
.
objectKeys
(
factory
.
_instances
).
length
;
...
...
@@ -300,6 +319,10 @@ var ExtensionManager = VispaModule.extend({
showInstance
:
function
(
instance
,
byUrl
)
{
instance
=
this
.
getInstance
(
instance
);
if
(
instance
instanceof
ExtensionContentFull
)
{
// already shown?
if
(
this
.
vispa
.
extensionView
.
workflow
.
currentFullInstance
==
instance
.
_id
)
{
return
this
;
}
// call before show
if
(
instance
.
beforeShow
()
===
false
)
{
return
this
;
...
...
@@ -423,14 +446,14 @@ var ExtensionManager = VispaModule.extend({
// create a new instance
var
args
=
[
extension
,
factory
,
null
,
true
].
concat
(
_this
.
splitArgs
(
value
));
_this
.
createInstance
.
apply
(
_this
,
args
);
}
else
if
(
!
factory
.
_instances
[
key
])
{
}
else
{
//
if(!factory._instances[key]) {
var
args
=
[
extension
,
factory
,
obj
.
number
,
true
].
concat
(
_this
.
splitArgs
(
value
));
_this
.
createInstance
.
apply
(
_this
,
args
);
}
else
{
}
/*
else {
// the instance exists, pass 'value' to it
console.log("pass", value, "to instance with id", key);//TODO
_this.showInstance(key, true);
}
}
*/
hit
=
true
;
});
if
(
!
hit
)
{
...
...
@@ -467,15 +490,19 @@ var ExtensionManager = VispaModule.extend({
return
this
;
},
registerFileHandler
:
function
(
factory
,
fileExtension
,
handler
)
{
registerFileHandler
:
function
(
owner
,
fileExtension
,
handler
)
{
var
obj
=
this
.
fileHandlers
[
fileExtension
]
=
this
.
fileHandlers
[
fileExtension
]
||
[];
var
data
=
$
.
extend
({
factory
:
factory
},
handler
);
var
data
=
$
.
extend
({
owner
:
owner
},
handler
);
obj
.
push
(
data
);
return
this
;
},
getFileHandlers
:
function
(
fileExtension
)
{
return
this
.
fileHandlers
[
fileExtension
]
||
[];
getFileHandlers
:
function
(
fileExtension
,
sorted
)
{
var
handlers
=
this
.
fileHandlers
[
fileExtension
];
if
(
!
handlers
||
sorted
!==
true
)
{
return
handlers
||
[];
}
return
this
.
sortHandlers
(
handlers
);
},
getDefaultFileHandler
:
function
(
fileExtension
)
{
...
...
@@ -490,15 +517,45 @@ var ExtensionManager = VispaModule.extend({
return
target
;
},
registerUrlChannelHandler
:
function
(
factory
,
channel
,
handler
)
{
registerUrlChannelHandler
:
function
(
owner
,
channel
,
handler
)
{
var
obj
=
this
.
urlChannelHandlers
[
channel
]
=
this
.
urlChannelHandlers
[
channel
]
||
[];
var
data
=
$
.
extend
({
factory
:
factory
},
handler
);
var
data
=
$
.
extend
({
owner
:
owner
},
handler
);
obj
.
push
(
data
);
return
this
;
},
getUrlChannelHandlers
:
function
(
channel
)
{
return
this
.
urlChannelHandlers
[
channel
]
||
[];
var
handlers
=
this
.
urlChannelHandlers
[
channel
];
if
(
!
handlers
||
sorted
!==
true
)
{
return
handlers
||
[];
}
return
this
.
sortHandlers
(
handlers
);
},
sortHandlers
:
function
(
handlers
)
{
var
dummy
=
handlers
.
concat
([]);
var
sortedHandlers
=
[];
while
(
dummy
.
length
)
{
var
maxHandler
=
null
;
var
idx
=
null
;
$
.
each
(
dummy
,
function
(
i
,
handler
)
{
if
(
!
maxHandler
)
{
maxHandler
=
handler
;
idx
=
i
;
return
;
}
if
(
handler
.
priority
>
maxHandler
.
priority
)
{
maxHandler
=
handler
;
idx
=
i
;
}
});
if
(
!
maxHandler
)
{
break
;
}
sortedHandlers
.
push
(
maxHandler
);
dummy
.
splice
(
idx
,
1
);
}
return
sortedHandlers
;
},
getDefaultUrlChannelHandler
:
function
(
channel
)
{
...
...
@@ -721,7 +778,8 @@ var ExtensionFactoryBase = Class.extend({
// ExtensionContent Base class
var
ExtensionContentBase
=
Class
.
extend
({
init
:
function
(
vispa
,
config
)
{
init
:
function
(
vispa
,
config
,
identifier
)
{
// there might be additional arguments
this
.
vispa
=
vispa
;
// private attributes
...
...
@@ -729,6 +787,7 @@ var ExtensionContentBase = Class.extend({
this
.
_factory
=
null
;
this
.
_number
=
null
;
this
.
_id
=
null
;
this
.
_identifier
=
identifier
;
// public attributes
this
.
logger
=
null
;
this
.
config
=
config
;
...
...
@@ -755,7 +814,7 @@ var ExtensionContentBase = Class.extend({
},
getIdentifier
:
function
()
{
return
null
;
return
this
.
_identifier
;
},
getTitle
:
function
()
{
...
...
@@ -803,8 +862,9 @@ var ExtensionFactoryFull = ExtensionFactoryBase.extend({
// ExtensionContent Base class for 'full' window instances
var
ExtensionContentFull
=
ExtensionContentBase
.
extend
({
init
:
function
(
vispa
,
config
)
{
this
.
_super
(
vispa
,
config
);
init
:
function
(
vispa
,
config
,
identifier
)
{
// there might be additional arguments
this
.
_super
(
vispa
,
config
,
identifier
);
// public attributes
this
.
shortcuts
=
null
;
...
...
vispa/static/js/sites/index/extensionview.js
View file @
5250a8d1
...
...
@@ -570,11 +570,7 @@ var ExtensionView = VispaModule.extend({
$
(
data
.
menu
).
show
();
// update the pathbar
var
value
=
instance
.
getIdentifier
();
if
(
value
)
{
this
.
vispa
.
pathBar
.
setValue
(
value
).
show
();
}
else
{
this
.
vispa
.
pathBar
.
hide
();
}
this
.
vispa
.
pathBar
.
setValue
(
value
).
show
();
return
this
;
},
...
...
vispa/static/js/sites/index/pathbar.js
View file @
5250a8d1
...
...
@@ -5,7 +5,7 @@ var PathBar = VispaModule.extend({
nSuggestions
:
{
descr
:
'
The number of received suggestions
'
,
type
:
'
integer
'
,
range
:
[
1
,
50
],
select
:
[
1
,
5
,
10
,
20
,
30
,
40
,
50
],
value
:
10
},
appendHiddenFiles
:
{
...
...
@@ -17,6 +17,7 @@ var PathBar = VispaModule.extend({
this
.
_super
(
vispa
,
'
pathBar
'
,
this
.
defaultConfig
,
config
);
// attributes
this
.
preferenceSettings
=
{
priority
:
3
,
entryOrder
:
[
'
nSuggestions
'
]};
this
.
settings
=
{
shortcut
:
'
ctrl+shift+g
'
,
checkDelay
:
1000
,
...
...
@@ -27,6 +28,7 @@ var PathBar = VispaModule.extend({
mode
:
'
display
'
,
checkTimeout
:
null
,
isGettingSuggestion
:
false
,
autocompleteVisible
:
false
,
fileExtensions
:
[]
};
this
.
nodes
=
{
...
...
@@ -127,7 +129,7 @@ var PathBar = VispaModule.extend({
event
.
stopPropagation
();
bindHide
();
});
var
noCheckKeys
=
[
9
,
13
,
3
8
,
40
];
var
noCheckKeys
=
[
9
,
13
,
3
7
,
39
];
$
(
this
.
nodes
.
inputNode
)
.
keydown
(
function
(
event
)
{
if
(
event
.
keyCode
==
13
)
{
...
...
@@ -144,20 +146,31 @@ var PathBar = VispaModule.extend({
}
else
if
(
event
.
keyCode
!=
38
&&
event
.
keyCode
!=
40
)
{
// clear the check timeout
window
.
clearTimeout
(
_this
.
workflow
.
checkTimeout
);
if
(
_this
.
workflow
.
autocompleteVisible
)
{
_this
.
workflow
.
autocompleteVisible
=
false
;
$
(
this
).
autocomplete
(
'
destroy
'
);
}
_this
.
destroyAutoComplete
();
}
}).
keyup
(
function
(
event
)
{
if
(
$
.
inArray
(
event
.
keyCode
,
noCheckKeys
)
<
0
)
{
_this
.
check
(
this
.
value
);
if
(
!
_this
.
workflow
.
autocompleteVisible
)
{
if
(
event
.
keyCode
!=
38
&&
event
.
keyCode
!=
40
)
{
_this
.
check
(
this
.
value
);
}
}
else
{
_this
.
check
(
this
.
value
);
}
}
});
return
this
;
},
destroyAutoComplete
:
function
()
{
try
{
$
(
this
.
nodes
.
inputNode
).
autocomplete
(
'
destroy
'
);
}
catch
(
err
){}
this
.
workflow
.
autocompleteVisible
=
false
;
return
this
;
},
setLoader
:
function
(
value
,
flag
)
{
// value:
// undefined -> empty
...
...
@@ -172,7 +185,7 @@ var PathBar = VispaModule.extend({
.
attr
(
'
src
'
,
this
.
vispa
.
urlHandler
.
static
(
'
img/maingui/loader3.gif
'
))
.
css
(
'
margin-top
'
,
5
);
}
else
if
(
value
===
false
)
{
content
=
this
.
makeFileBanner
(
'
?
'
,
false
);
content
=
this
.
makeFileBanner
(
'
?
'
);
}
else
if
(
typeof
(
value
)
==
'
string
'
)
{
content
=
this
.
makeFileBanner
(
value
,
flag
);
}
else
{
...
...
@@ -329,11 +342,17 @@ var PathBar = VispaModule.extend({
minLength
:
0
,
source
:
response
.
suggestions
,
select
:
function
(
event
)
{
_this
.
check
(
_this
.
nodes
.
inputNode
.
value
,
true
);
_this
.
check
(
_this
.
nodes
.
inputNode
.
value
);
event
.
stopPropagation
();
},
open
:
function
()
{
_this
.
workflow
.
autocompleteVisible
=
true
;
},
close
:
function
()
{
_this
.
workflow
.
autocompleteVisible
=
false
;
}
}).
autocomplete
(
'
search
'
)
;
_this
.
workflow
.
autocompleteVisible
=
true
;
}).
data
(
'
autocomplete
'
).
_renderItem
=
_this
.
_renderItem
;
$
(
_this
.
nodes
.
inputNode
).
autocomplete
(
'
search
'
)
;
}
else
{
_this
.
check
(
path
);
}
...
...
@@ -359,19 +378,65 @@ var PathBar = VispaModule.extend({
}
else
if
(
response
.
type
==
'
d
'
)
{
ext
=
'
/
'
;
}
// is there a listener?
if
(
$
.
inArray
(
ext
,
_this
.
workflow
.
fileExtensions
)
>=
0
)
{
// yes!
var
handler
=
_this
.
vispa
.
extensionManager
.
getDefaultFileHandler
(
ext
);
if
(
handler
&&
handler
.
callback
)
{
handler
.
callback
(
path
);
}
// is there a handler?
var
handlers
=
_this
.
vispa
.
extensionManager
.
getFileHandlers
(
ext
,
true
);
if
(
handlers
.
length
==
1
)
{
handlers
[
0
].
callback
(
path
);
}
else
if
(
handlers
.
length
>
1
)
{
var
names
=
[];
var
map
=
{};
$
.
each
(
handlers
,
function
(
i
,
handler
)
{
var
name
=
'
unknown
'
;
if
(
handler
.
owner
instanceof
Extension
)
{
name
=
$
.
Helpers
.
strFormat
(
'
<b>{0}</b> <i>(Extension)</i>
'
,
handler
.
owner
.
name
);
}
else
if
(
handler
.
owner
instanceof
ExtensionFactoryBase
)
{
name
=
$
.
Helpers
.
strFormat
(
'
<b>{0}</b> <i>(Factory)</i>
'
,
handler
.
owner
.
title
);
}
names
.
push
(
name
);
map
[
name
]
=
handler
;
});
_this
.
destroyAutoComplete
();
$
(
_this
.
nodes
.
inputNode
)
.
autocomplete
({
delay
:
0
,
minLength
:
0
,
source
:
function
(
request
,
response
)
{
// set names as source array
response
(
names
);
},
select
:
function
(
event
,
ui
)
{
var
name
=
ui
.
item
.
value
;
event
.
preventDefault
();
if
(
map
[
name
])
{
map
[
name
].
callback
(
path
);
}
},
focus
:
function
(
event
)
{
// don't change the value of the input
event
.
preventDefault
();
},
open
:
function
()
{
_this
.
workflow
.
autocompleteVisible
=
true
;
},
close
:
function
()
{
_this
.
workflow
.
autocompleteVisible
=
false
;
}
}).
data
(
'
autocomplete
'
).
_renderItem
=
_this
.
_renderItem
;
$
(
_this
.
nodes
.
inputNode
).
autocomplete
(
'
search
'
);
}
}
});
return
this
;
},
_renderItem
:
function
(
ul
,
item
)
{
var
regexp
=
new
RegExp
(
'
^
'
+
this
.
term
);
var
label
=
item
.
label
.
replace
(
regexp
,
$
.
Helpers
.
strFormat
(
'
<b>{0}</b>
'
,
this
.
term
));
return
$
(
'
<li>
'
)
.
append
(
$
(
'
<a>
'
).
html
(
label
))
.
appendTo
(
ul
);
},
setupTopics
:
function
()
{
var
_this
=
this
;
$
.
Topic
(
'
extenstion.added
'
).
subscribe
(
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment