Add wait spinner
This commit is contained in:
parent
957e04a7f4
commit
7df10bb891
@ -87,6 +87,14 @@ body {
|
|||||||
background-position: 0 0;
|
background-position: 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-spinner {
|
||||||
|
background-image: url("../img/ajax-loader.gif");
|
||||||
|
width: 43px;
|
||||||
|
height: 11px;
|
||||||
|
background-position: 0 0;
|
||||||
|
margin: 13px 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.ui-layout-toggler-north {
|
.ui-layout-toggler-north {
|
||||||
margin-top: -3px !important;
|
margin-top: -3px !important;
|
||||||
height: 18px !important;
|
height: 18px !important;
|
||||||
|
BIN
img/ajax-loader.gif
Normal file
BIN
img/ajax-loader.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 404 B |
23
index.html
23
index.html
@ -20,7 +20,7 @@
|
|||||||
<script type="text/javascript" src="js/main.js"></script>
|
<script type="text/javascript" src="js/main.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function handleClientLoad() {
|
function handleClientLoad() {
|
||||||
window.setTimeout(gdrive.init, 1);
|
window.setTimeout(fileManager.gdriveInit, 1);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
@ -71,8 +71,9 @@
|
|||||||
data-target="#modal-remove-file-confirm"><i
|
data-target="#modal-remove-file-confirm"><i
|
||||||
class="icon-trash"></i> Remove file</a></li>
|
class="icon-trash"></i> Remove file</a></li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a class="action-upload-gdrive" href="javascript: void(0)"><i
|
<li><a class="action-upload-gdrive"
|
||||||
class="icon-gdrive"></i> Save on Google Drive</a></li>
|
href="javascript: void(0)"><i class="icon-gdrive"></i> Save
|
||||||
|
on Google Drive</a></li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a href="javascript: void(0)"
|
<li><a href="javascript: void(0)"
|
||||||
title="Modify your preferences" data-toggle="modal"
|
title="Modify your preferences" data-toggle="modal"
|
||||||
@ -81,8 +82,10 @@
|
|||||||
</ul></li>
|
</ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
|
<li><i class="file-sync-indicator icon-spinner hide"></i></li>
|
||||||
<li><a class="brand" id="file-title" href="javascript: void(0)"
|
<li><a class="brand" id="file-title" href="javascript: void(0)"
|
||||||
title="Rename the current file"><span class="file-title"></span></a></li>
|
title="Rename the current file"><span class="file-title"></span>
|
||||||
|
</a></li>
|
||||||
<li class="navbar-form"><input id="file-title-input"
|
<li class="navbar-form"><input id="file-title-input"
|
||||||
type="text" class="span3 hide" placeholder="File title" /></li>
|
type="text" class="span3 hide" placeholder="File title" /></li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -123,20 +126,18 @@
|
|||||||
<dd>
|
<dd>
|
||||||
<label class="radio"> <input type="radio"
|
<label class="radio"> <input type="radio"
|
||||||
name="radio-layout-orientation"
|
name="radio-layout-orientation"
|
||||||
id="radio-layout-orientation-horizontal">
|
id="radio-layout-orientation-horizontal"> Horizontal
|
||||||
Horizontal
|
|
||||||
</label> <label class="radio"> <input type="radio"
|
</label> <label class="radio"> <input type="radio"
|
||||||
name="radio-layout-orientation"
|
name="radio-layout-orientation"
|
||||||
id="radio-layout-orientation-vertical">
|
id="radio-layout-orientation-vertical"> Vertical
|
||||||
Vertical
|
|
||||||
</label>
|
</label>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="javascript: void(0)" class="btn action-load-settings" data-dismiss="modal">Cancel</a>
|
<a href="javascript: void(0)" class="btn action-load-settings"
|
||||||
<a href="javascript: void(0)" class="btn btn-primary action-apply-settings"
|
data-dismiss="modal">Cancel</a> <a href="javascript: void(0)"
|
||||||
data-dismiss="modal">OK</a>
|
class="btn btn-primary action-apply-settings" data-dismiss="modal">OK</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
43
js/gdrive.js
43
js/gdrive.js
@ -9,6 +9,7 @@ var gdrive = (function() {
|
|||||||
var gdrive = {};
|
var gdrive = {};
|
||||||
|
|
||||||
function askAuth(immediate, callback) {
|
function askAuth(immediate, callback) {
|
||||||
|
if (!driveEnabled) {
|
||||||
gapi.auth.authorize({ 'client_id' : CLIENT_ID, 'scope' : SCOPES,
|
gapi.auth.authorize({ 'client_id' : CLIENT_ID, 'scope' : SCOPES,
|
||||||
'immediate' : immediate }, function(authResult) {
|
'immediate' : immediate }, function(authResult) {
|
||||||
if (authResult && !authResult.error) {
|
if (authResult && !authResult.error) {
|
||||||
@ -20,16 +21,25 @@ var gdrive = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createFile(title, content, folderId, callback) {
|
function uploadFile(fileId, parentId, title, content, callback) {
|
||||||
var boundary = '-------314159265358979323846';
|
var boundary = '-------314159265358979323846';
|
||||||
var delimiter = "\r\n--" + boundary + "\r\n";
|
var delimiter = "\r\n--" + boundary + "\r\n";
|
||||||
var close_delim = "\r\n--" + boundary + "--";
|
var close_delim = "\r\n--" + boundary + "--";
|
||||||
|
|
||||||
var contentType = 'text/x-markdown';
|
var contentType = 'text/x-markdown';
|
||||||
var metadata = { title : title, mimeType : contentType };
|
var metadata = { title : title, mimeType : contentType };
|
||||||
if (folderId) {
|
if (parentId) {
|
||||||
metadata.parents = [ { kind : 'drive#fileLink', id : folderId } ];
|
// Specify the directory
|
||||||
|
metadata.parents = [ { kind : 'drive#fileLink', id : parentId } ];
|
||||||
|
}
|
||||||
|
var path = '/upload/drive/v2/files';
|
||||||
|
var method = 'POST';
|
||||||
|
if (fileId) {
|
||||||
|
// If it's an update
|
||||||
|
path += fileId;
|
||||||
|
method = 'PUT';
|
||||||
}
|
}
|
||||||
|
|
||||||
var base64Data = btoa(content);
|
var base64Data = btoa(content);
|
||||||
@ -40,8 +50,8 @@ var gdrive = (function() {
|
|||||||
+ '\r\n' + base64Data + close_delim;
|
+ '\r\n' + base64Data + close_delim;
|
||||||
|
|
||||||
var request = gapi.client.request({
|
var request = gapi.client.request({
|
||||||
'path' : '/upload/drive/v2/files',
|
'path' : path,
|
||||||
'method' : 'POST',
|
'method' : method,
|
||||||
'params' : { 'uploadType' : 'multipart', },
|
'params' : { 'uploadType' : 'multipart', },
|
||||||
'headers' : { 'Content-Type' : 'multipart/mixed; boundary="'
|
'headers' : { 'Content-Type' : 'multipart/mixed; boundary="'
|
||||||
+ boundary + '"', }, 'body' : multipartRequestBody, });
|
+ boundary + '"', }, 'body' : multipartRequestBody, });
|
||||||
@ -59,8 +69,9 @@ var gdrive = (function() {
|
|||||||
var state = JSON.parse(decodeURI((/state=(.+?)(&|$)/
|
var state = JSON.parse(decodeURI((/state=(.+?)(&|$)/
|
||||||
.exec(location.search) || [ , null ])[1]));
|
.exec(location.search) || [ , null ])[1]));
|
||||||
if (state.action == 'create') {
|
if (state.action == 'create') {
|
||||||
createFile(fileManager.currentFile, fileManager.content,
|
uploadFile(undefined, state.folderId,
|
||||||
state.folderId, function(file) {
|
fileManager.currentFile, fileManager.content, function(
|
||||||
|
file) {
|
||||||
console.log(file);
|
console.log(file);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -69,18 +80,16 @@ var gdrive = (function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
gdrive.createFile = function(title, content) {
|
gdrive.createFile = function(title, content, callback) {
|
||||||
var callback = function() {
|
askAuth(false, function() {
|
||||||
createFile(title, content, undefined, function(file) {
|
uploadFile(undefined, undefined, title, content, callback);
|
||||||
console.log(file);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if(!driveEnabled) {
|
|
||||||
askAuth(false, callback);
|
gdrive.updateFile = function(id, title, content, callback) {
|
||||||
}
|
askAuth(false, function() {
|
||||||
else {
|
uploadFile(id, undefined, title, content, callback);
|
||||||
callback();
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return gdrive;
|
return gdrive;
|
||||||
|
@ -36,10 +36,14 @@ var fileManager = (function($) {
|
|||||||
fileManager.updateFileTitleUI();
|
fileManager.updateFileTitleUI();
|
||||||
});
|
});
|
||||||
$(".action-upload-gdrive").click(function() {
|
$(".action-upload-gdrive").click(function() {
|
||||||
|
$(".file-sync-indicator").removeClass("hide");
|
||||||
var fileIndex = localStorage["file.current"];
|
var fileIndex = localStorage["file.current"];
|
||||||
var content = localStorage[fileIndex + ".content"];
|
var content = localStorage[fileIndex + ".content"];
|
||||||
var title = localStorage[fileIndex + ".title"];
|
var title = localStorage[fileIndex + ".title"];
|
||||||
gdrive.createFile(title, content);
|
gdrive.createFile(title, content, function(file) {
|
||||||
|
$(".file-sync-indicator").addClass("hide");
|
||||||
|
console.log(file);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user