Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
69148c99
authored
Jul 23, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: store js clean up
parent
61450d0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
33 deletions
+19
-33
circle/dashboard/static/dashboard/store.js
+19
-33
No files found.
circle/dashboard/static/dashboard/store.js
View file @
69148c99
...
...
@@ -14,11 +14,16 @@ $(function() {
return
false
;
});
/* less js way, but at least works, tho redirection is bad */
/* how upload works
* - user clicks on a "fake" browse button, this triggers a click event on the file upload
* - if the file input changes it adds the name of the file to form (or number of files if multiple is enabled)
* - and finally when we click on the upload button (this event handler) it firsts ask the store api where to upload
* then changes the form's action attr before sending the form itself
*/
$
(
"#store-list-container"
).
on
(
"click"
,
'#store-upload-form button[type="submit"]'
,
function
()
{
var
current_dir
=
$
(
"#store-upload-form"
).
find
(
'[name="current_dir"]'
).
val
();
$
.
get
(
$
(
"#store-upload-form"
).
data
(
"action"
)
+
"?current_dir="
+
current_dir
,
function
(
result
)
{
$
(
'#store-upload-form button[type="submit"] i'
).
addClass
(
"
icon-spinner icon
-spin"
);
$
(
'#store-upload-form button[type="submit"] i'
).
addClass
(
"
fa-spinner fa
-spin"
);
$
(
"#store-upload-form"
).
get
(
0
).
setAttribute
(
"action"
,
result
[
'url'
]);
$
(
"#store-upload-form"
).
submit
();
});
...
...
@@ -26,7 +31,7 @@ $(function() {
return
false
;
});
/*
click on the "fake" browse button will
*/
/*
"fake" browse button
*/
$
(
"#store-list-container"
).
on
(
"click"
,
"#store-upload-browse"
,
function
()
{
$
(
'#store-upload-form input[type="file"]'
).
click
();
});
...
...
@@ -38,36 +43,17 @@ $(function() {
input
.
trigger
(
'fileselect'
,
[
numFiles
,
label
]);
});
$
(
"#store-list-container"
).
on
(
"fileselect"
,
"#store-upload-file"
,
function
(
event
,
numFiles
,
label
)
{
var
input
=
$
(
"#store-upload-filename"
);
var
log
=
numFiles
>
1
?
numFiles
+
' files selected'
:
label
;
if
(
input
.
length
)
{
input
.
val
(
log
);
}
if
(
log
)
{
$
(
'#store-upload-form button[type="submit"]'
).
prop
(
"disabled"
,
false
);
$
(
"#store-list-container"
).
on
(
"fileselect"
,
"#store-upload-file"
,
function
(
event
,
numFiles
,
label
)
{
var
input
=
$
(
"#store-upload-filename"
);
var
log
=
numFiles
>
1
?
numFiles
+
' files selected'
:
label
;
if
(
input
.
length
)
{
input
.
val
(
log
);
}
if
(
log
)
{
$
(
'#store-upload-form button[type="submit"]'
).
prop
(
"disabled"
,
false
);
}
else
{
$
(
'#store-upload-form button[type="submit"]'
).
prop
(
"disabled"
,
true
);
}
}
else
{
$
(
'#store-upload-form button[type="submit"]'
).
prop
(
"disabled"
,
true
);
}
});
/* this does not work
$('form input[type="submit"]').click(function() {
var current_dir = $("form").find('[name="current_dir"]').val();
$.get($("form").data("action") + "?current_dir=" + current_dir, function(result) {
$.ajax({
method: "POST",
url: result['url'],
data: $("form").serialize(),
success: function(re) {
console.log(re);
}
});
});
return false;
}); */
});
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