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
aa652340
Commit
aa652340
authored
Jun 14, 2015
by
ThorbenQuast
Browse files
editor: save file specific preview paths in cookies
parent
b01b115d
Changes
2
Hide whitespace changes
Inline
Side-by-side
vispa/extensions/codeeditor/static/js/prefs.js
View file @
aa652340
...
...
@@ -104,7 +104,7 @@ define(function() {
},
cookies
:
{
description
:
"
Allow the web-browser to store the last executed command.
"
,
description
:
"
Allow the web-browser to store the last executed command
s and preview paths of each file
.
"
,
type
:
"
boolean
"
,
value
:
true
},
...
...
vispa/extensions/codeeditor/static/js/preview.js
View file @
aa652340
...
...
@@ -24,22 +24,36 @@ define(["jquery", "emitter"], function($, Emitter) {
this
.
previewData
=
[];
this
.
cookie
=
null
;
this
.
thumbnailSize
=
null
;
this
.
view
.
on
(
"
stateChange
"
,
function
(
key
)
{
switch
(
key
)
{
case
"
path
"
:
var
path
=
this
.
getState
(
"
path
"
);
if
(
path
&&
!
this
.
getState
(
"
previewPath
"
))
{
var
path
=
self
.
view
.
getState
(
"
path
"
);
if
(
path
&&
!
self
.
view
.
getState
(
"
previewPath
"
))
{
var
cookie
=
$
.
cookie
(
"
VISPA-preview-path
"
);
if
(
cookie
&&
self
.
view
.
getPreference
(
"
cookies
"
))
{
cookie
=
JSON
.
parse
(
cookie
);
var
key
=
self
.
view
.
getState
(
"
path
"
);
key
=
key
?
key
.
split
(
"
/
"
).
pop
()
:
"
UNTITLED
"
;
if
(
cookie
[
key
])
{
self
.
setPath
(
cookie
[
key
],
false
);
return
;
}
}
self
.
setPath
(
path
,
true
);
}
break
;
case
"
previewPath
"
:
var
previewPath
=
this
.
getState
(
"
previewPath
"
);
if
(
previewPath
)
{
if
(
self
.
pathInput
)
if
(
self
.
pathInput
)
{
self
.
pathInput
.
val
(
previewPath
);
self
.
pathToCookie
(
previewPath
);
}
self
.
previewChanged
=
true
;
self
.
refresh
();
}
...
...
@@ -50,7 +64,6 @@ define(["jquery", "emitter"], function($, Emitter) {
setup
:
function
(
node
)
{
var
self
=
this
;
var
rightBottomNode
=
node
.
find
(
"
.codeeditor-right-bottom
"
);
this
.
zoomBtn
=
$
(
"
#zoom
"
,
rightBottomNode
);
...
...
@@ -89,9 +102,6 @@ define(["jquery", "emitter"], function($, Emitter) {
this
.
thumbnailSize
=
this
.
giveThumbnailSize
();
if
(
this
.
editor
.
path
)
this
.
setPath
(
this
.
editor
.
path
,
true
);
// load the preview template
this
.
view
.
getTemplate
(
"
html/preview.html
"
,
function
(
err
,
tmpl
)
{
self
.
previewTmpl
=
tmpl
;
...
...
@@ -156,7 +166,7 @@ define(["jquery", "emitter"], function($, Emitter) {
self
.
previewUpdating
=
false
;
return
;
}
var
files
=
$
.
grep
(
res
.
filelist
,
function
(
file
)
{
return
file
.
type
==
"
f
"
&&
~
self
.
allowedExtensions
.
indexOf
(
file
.
name
.
split
(
"
.
"
).
pop
().
toLowerCase
());
});
...
...
@@ -278,6 +288,21 @@ define(["jquery", "emitter"], function($, Emitter) {
return
size
;
},
pathToCookie
:
function
(
previewPath
)
{
if
(
!
this
.
view
.
getPreference
(
"
cookies
"
))
return
;
var
cookie
=
$
.
cookie
(
"
VISPA-preview-path
"
);
if
(
cookie
)
cookie
=
JSON
.
parse
(
cookie
);
else
cookie
=
{};
var
key
=
this
.
view
.
getState
(
"
path
"
);
key
=
key
?
key
.
split
(
"
/
"
).
pop
()
:
"
UNTITLED
"
;
cookie
[
key
]
=
previewPath
;
$
.
cookie
(
"
VISPA-preview-path
"
,
JSON
.
stringify
(
cookie
),
{
expires
:
7
});
}
});
return
CodeEditorPreview
;
...
...
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