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
e2a36f22
Commit
e2a36f22
authored
Jul 16, 2015
by
Fabian-Andree Heidemann
Browse files
Bookmarks:
- remove .done() - small typos and prettify
parent
e5c1f5d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
vispa/extensions/file/static/js/base/bookmark.js
View file @
e2a36f22
define
([
"
jquery
"
,
"
jclass
"
],
function
(
$
,
JClass
)
{
define
([
"
jquery
"
,
"
jclass
"
],
function
(
$
,
JClass
)
{
var
BookmarkContainer
=
JClass
.
_extend
({
init
:
function
(
PathBar
)
{
init
:
function
(
PathBar
)
{
var
self
=
this
;
self
.
FileBase
=
PathBar
.
FileBase
;
self
.
instance
=
self
.
FileBase
.
instance
;
...
...
@@ -56,17 +56,17 @@ define(["jquery", "jclass"], function($, JClass) {
self
.
directives
=
{
"
bookmark
"
:
{
"
title
"
:
function
(
params
)
{
"
title
"
:
function
(
params
)
{
return
self
.
paths
[
params
.
index
];
}
},
"
bookmark-name
"
:
{
"
text
"
:
function
()
{
"
text
"
:
function
()
{
return
this
.
value
;
}
},
"
bookmark-glyphicon
"
:
{
"
class
"
:
function
(
params
)
{
"
class
"
:
function
(
params
)
{
return
"
bookmark-glyphicon-symbol glyphicon glyphicon-
"
+
self
.
symbols
[
params
.
index
];
}
}
...
...
@@ -76,7 +76,7 @@ define(["jquery", "jclass"], function($, JClass) {
self
.
_setupDone
=
false
;
},
setup
:
function
(
node
)
{
setup
:
function
(
node
)
{
if
(
this
.
_setupDone
)
{
return
;
}
...
...
@@ -84,7 +84,7 @@ define(["jquery", "jclass"], function($, JClass) {
var
self
=
this
;
self
.
container
=
node
;
vispa
.
socket
.
on
(
"
workspace.ini_modified
"
,
function
(
data
)
{
vispa
.
socket
.
on
(
"
workspace.ini_modified
"
,
function
(
data
)
{
if
(
data
.
workspaceId
==
self
.
instance
.
getWorkspaceId
()
&&
self
.
_workspaceiniMtime
!=
data
.
mtime
)
{
self
.
_workspaceiniMtime
=
data
.
mtime
;
...
...
@@ -94,14 +94,14 @@ define(["jquery", "jclass"], function($, JClass) {
this
.
setContent
();
},
setContent
:
function
()
{
setContent
:
function
()
{
var
self
=
this
;
// get names from workspaceini
this
.
instance
.
GET
(
"
/ajax/fs/getworkspaceini
"
,
{
request
:
JSON
.
stringify
({
Bookmarks
:
[
"
names
"
,
"
paths
"
,
"
symbols
"
]
})
},
function
(
err
,
data
)
{
},
function
(
err
,
data
)
{
if
(
err
)
{
self
.
names
=
[];
self
.
paths
=
[];
...
...
@@ -144,54 +144,54 @@ define(["jquery", "jclass"], function($, JClass) {
});
},
setupClicks
:
function
()
{
setupClicks
:
function
()
{
var
self
=
this
;
var
clicktype
=
vispa
.
device
.
hasTouch
?
"
tap
"
:
"
click
"
;
// button click
var
node
=
$
(
"
.bookmark-button
"
,
self
.
container
);
node
.
off
();
node
.
on
(
clicktype
,
function
(
event
)
{
node
.
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
self
.
addBookmark
();
});
// bookmark clicks
$
.
each
(
$
(
"
.bookmark
"
,
self
.
container
),
function
(
index
,
node
)
{
$
.
each
(
$
(
"
.bookmark
"
,
self
.
container
),
function
(
index
,
node
)
{
// click on bookmark self
$
(
node
).
off
();
$
(
node
).
on
(
clicktype
,
function
()
{
$
(
node
).
on
(
clicktype
,
function
()
{
$
(
"
input
"
,
self
.
container
).
blur
();
self
.
FileBase
.
instance
.
setState
(
"
path
"
,
self
.
paths
[
index
]);
self
.
FileBase
.
updateView
();
});
// click on remove glyph
$
(
"
.bookmark-glyphicon-remove
"
,
node
).
off
();
$
(
"
.bookmark-glyphicon-remove
"
,
node
).
on
(
clicktype
,
function
(
event
)
{
$
(
"
.bookmark-glyphicon-remove
"
,
node
).
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
self
.
removeBookmark
(
index
);
});
// click on edit glyph
$
(
"
.bookmark-glyphicon-edit
"
,
node
).
off
();
$
(
"
.bookmark-glyphicon-edit
"
,
node
).
on
(
clicktype
,
function
(
event
)
{
$
(
"
.bookmark-glyphicon-edit
"
,
node
).
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
self
.
editBookmark
(
index
);
});
});
},
setupSortability
:
function
()
{
setupSortability
:
function
()
{
var
self
=
this
;
$
(
"
.bookmarks
"
,
self
.
container
).
sortable
({
cursor
:
"
move
"
,
delay
:
150
,
disabled
:
false
,
start
:
function
(
event
,
ui
)
{
start
:
function
(
event
,
ui
)
{
ui
.
item
.
startPos
=
ui
.
item
.
index
();
// suppress click event
$
(
$
(
"
.bookmark
"
,
self
.
container
)[
ui
.
item
.
startPos
]).
off
();
// finish inline renameing
$
(
"
.input-bookmarkname
"
,
self
.
container
).
blur
();
},
stop
:
function
(
event
,
ui
)
{
stop
:
function
(
event
,
ui
)
{
// prevent further sorting
$
(
"
.bookmarks
"
,
self
.
container
).
sortable
({
"
disabled
"
:
true
...
...
@@ -209,8 +209,8 @@ define(["jquery", "jclass"], function($, JClass) {
self
.
symbols
.
splice
(
index
,
1
);
self
.
symbols
.
splice
(
newindex
,
0
,
symbol
);
// set new data to ini
self
.
saveBookmarks
(
).
done
(
function
(
res
)
{
if
(
!
res
.
success
)
{
self
.
saveBookmarks
(
function
(
err
)
{
if
(
err
)
{
self
.
instance
.
alert
(
"
Couldn't save new bookmark positions.
"
);
self
.
names
.
splice
(
newindex
,
1
);
self
.
names
.
splice
(
index
,
0
,
name
);
...
...
@@ -225,8 +225,8 @@ define(["jquery", "jclass"], function($, JClass) {
});
},
saveBookmarks
:
function
(
)
{
return
this
.
instance
.
POST
(
"
/ajax/fs/setworkspaceini
"
,
{
saveBookmarks
:
function
(
callback
)
{
this
.
instance
.
POST
(
"
/ajax/fs/setworkspaceini
"
,
{
request
:
JSON
.
stringify
({
Bookmarks
:
{
names
:
this
.
names
.
join
(
"
:
"
),
...
...
@@ -234,10 +234,10 @@ define(["jquery", "jclass"], function($, JClass) {
symbols
:
this
.
symbols
.
join
(
"
:
"
)
}
})
});
}
,
(
callback
||
Function
)()
);
},
addBookmark
:
function
()
{
addBookmark
:
function
()
{
var
self
=
this
;
// add data
this
.
symbols
[
this
.
symbols
.
length
]
=
"
bookmark
"
;
...
...
@@ -248,8 +248,8 @@ define(["jquery", "jclass"], function($, JClass) {
this
.
names
[
this
.
names
.
length
-
1
]
=
"
New bookmark
"
;
}
// set new data to ini and update view
this
.
saveBookmarks
(
).
done
(
function
(
res
)
{
if
(
!
res
.
success
)
{
this
.
saveBookmarks
(
function
(
err
)
{
if
(
err
)
{
self
.
instance
.
alert
(
"
Couldn't add bookmark.
"
);
self
.
names
.
splice
(
self
.
names
.
length
-
1
,
1
);
self
.
paths
.
splice
(
self
.
paths
.
length
-
1
,
1
);
...
...
@@ -260,7 +260,7 @@ define(["jquery", "jclass"], function($, JClass) {
});
},
removeBookmark
:
function
(
index
)
{
removeBookmark
:
function
(
index
)
{
// delete entry in arrays
var
self
=
this
;
var
name
=
this
.
names
[
index
];
...
...
@@ -268,14 +268,14 @@ define(["jquery", "jclass"], function($, JClass) {
var
symbol
=
this
.
symbols
[
index
];
this
.
instance
.
confirm
(
"
Do you want to delete bookmark
\"
"
+
name
+
"
\"
?
"
,
function
(
confirmed
)
{
function
(
confirmed
)
{
if
(
confirmed
)
{
self
.
names
.
splice
(
index
,
1
);
self
.
paths
.
splice
(
index
,
1
);
self
.
symbols
.
splice
(
index
,
1
);
// set new data to ini and update view
self
.
saveBookmarks
(
).
done
(
function
(
res
)
{
if
(
!
res
.
success
)
{
self
.
saveBookmarks
(
function
(
err
)
{
if
(
err
)
{
self
.
instance
.
alert
(
"
Couldn't remove bookmark.
"
);
self
.
names
.
splice
(
index
,
0
,
name
);
self
.
paths
.
splice
(
index
,
0
,
path
);
...
...
@@ -289,7 +289,7 @@ define(["jquery", "jclass"], function($, JClass) {
);
},
editBookmark
:
function
(
index
)
{
editBookmark
:
function
(
index
)
{
var
self
=
this
;
var
bookmark
=
$
(
$
(
"
.bookmark
"
,
self
.
container
)[
index
]);
...
...
@@ -309,24 +309,24 @@ define(["jquery", "jclass"], function($, JClass) {
// when clicking in input filed, do not open folder or file
var
clicktype
=
vispa
.
device
.
hasTouch
?
"
tap
"
:
"
click
"
;
replaceWith
.
on
(
clicktype
,
function
(
event
)
{
replaceWith
.
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
});
// disable link and edit glyph
bookmark
.
off
();
bookmark
.
on
(
clicktype
,
function
(
event
)
{
bookmark
.
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
replaceWith
.
blur
();
});
$
(
"
.bookmark-glyphicon-edit
"
,
bookmark
).
off
();
$
(
"
.bookmark-glyphicon-edit
"
,
bookmark
).
on
(
clicktype
,
function
(
event
)
{
$
(
"
.bookmark-glyphicon-edit
"
,
bookmark
).
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
});
//symbol glyph
bookmarkSymbol
.
toggleClass
(
"
bookmark-glyphicon-symbol-editable
"
,
true
);
bookmarkSymbol
.
toggleClass
(
"
bookmark-glyphicon-symbol
"
,
false
);
bookmarkSymbol
.
prop
(
"
title
"
,
"
Edit symbol
"
);
bookmarkSymbol
.
on
(
clicktype
,
function
(
event
)
{
bookmarkSymbol
.
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
this
.
blur
();
self
.
editSymbol
(
index
);
...
...
@@ -334,7 +334,7 @@ define(["jquery", "jclass"], function($, JClass) {
// rename on blur
replaceWith
.
blur
(
function
(
event
)
{
replaceWith
.
blur
(
function
(
event
)
{
event
.
preventDefault
();
//check for ascii
var
ascii
=
/^
[
-~
]
+$/
;
...
...
@@ -354,8 +354,8 @@ define(["jquery", "jclass"], function($, JClass) {
self
.
names
[
index
]
=
String
(
replaceWith
.
val
());
// write new data to ini and update view (if newname != oldname)
if
(
self
.
names
[
index
]
!==
oldname
)
{
self
.
saveBookmarks
(
).
done
(
function
(
res
)
{
if
(
!
res
.
success
)
{
self
.
saveBookmarks
(
function
(
err
)
{
if
(
err
)
{
self
.
instance
.
alert
(
"
Couldn't rename bookmark.
"
);
self
.
names
[
index
]
=
oldname
;
self
.
saveBookmarks
();
...
...
@@ -371,7 +371,7 @@ define(["jquery", "jclass"], function($, JClass) {
self
.
setContent
();
});
// rename when pressing enter
replaceWith
.
keypress
(
function
(
event
)
{
replaceWith
.
keypress
(
function
(
event
)
{
if
(
event
.
which
==
13
)
{
event
.
preventDefault
();
this
.
blur
();
...
...
@@ -379,11 +379,11 @@ define(["jquery", "jclass"], function($, JClass) {
});
},
editSymbol
:
function
(
index
)
{
editSymbol
:
function
(
index
)
{
var
self
=
this
;
$
(
"
.input-bookmarkname
"
,
self
.
container
).
blur
();
self
.
instance
.
getTemplate
(
"
html/bookmarkSymbolDialog.html
"
,
function
(
err
,
tmpl
)
{
self
.
instance
.
getTemplate
(
"
html/bookmarkSymbolDialog.html
"
,
function
(
err
,
tmpl
)
{
var
body
=
$
(
tmpl
).
children
().
first
();
var
footer
=
$
(
tmpl
).
children
().
last
();
var
dialog
=
null
;
...
...
@@ -392,12 +392,12 @@ define(["jquery", "jclass"], function($, JClass) {
// render body
body
.
render
(
self
.
allowedSymbols
,
{
"
button
"
:
{
"
title
"
:
function
()
{
"
title
"
:
function
()
{
return
this
.
value
;
}
},
"
symbol
"
:
{
"
class
"
:
function
()
{
"
class
"
:
function
()
{
return
"
glyphicon glyphicon-
"
+
this
.
value
;
}
}
...
...
@@ -405,7 +405,7 @@ define(["jquery", "jclass"], function($, JClass) {
$
(
"
.glyphicon-
"
+
self
.
symbols
[
index
],
body
).
parent
()
.
toggleClass
(
"
btn-primary btn-default
"
);
// clicks
body
.
children
().
on
(
clicktype
,
function
(
event
)
{
body
.
children
().
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
$
(
"
.btn-primary
"
,
body
).
toggleClass
(
"
btn-primary btn-default
"
);
$
(
event
.
currentTarget
).
toggleClass
(
"
btn-primary btn-default
"
);
...
...
@@ -413,18 +413,18 @@ define(["jquery", "jclass"], function($, JClass) {
// footer clicks
// just close for cancel
$
(
"
#cancel
"
,
footer
).
on
(
clicktype
,
function
(
event
)
{
$
(
"
#cancel
"
,
footer
).
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
dialog
.
close
();
});
// save new symbol for save
$
(
"
#save
"
,
footer
).
on
(
clicktype
,
function
(
event
)
{
$
(
"
#save
"
,
footer
).
on
(
clicktype
,
function
(
event
)
{
event
.
stopPropagation
();
var
oldsymbol
=
self
.
symbols
[
index
];
self
.
symbols
[
index
]
=
$
(
"
.btn-primary
"
,
body
).
children
().
first
().
prop
(
"
class
"
).
slice
(
20
);
self
.
saveBookmarks
(
).
done
(
function
(
res
)
{
if
(
!
res
.
success
)
{
self
.
instance
.
alert
(
"
Couldn't
rename bookmark
.
"
);
self
.
saveBookmarks
(
function
(
err
)
{
if
(
err
)
{
self
.
instance
.
alert
(
"
Couldn't
change symbol
.
"
);
self
.
symbols
[
index
]
=
oldsymbol
;
self
.
saveBookmarks
();
}
...
...
@@ -438,10 +438,10 @@ define(["jquery", "jclass"], function($, JClass) {
"
header
"
:
"
Edit symbol of bookmark
\"
"
+
self
.
names
[
index
]
+
"
\"
"
,
"
body
"
:
body
,
"
footer
"
:
footer
,
beforeClose
:
function
(
cb
)
{
beforeClose
:
function
(
cb
)
{
cb
();
},
onRender
:
function
()
{
onRender
:
function
()
{
dialog
=
this
;
}
});
...
...
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