Skip to content

Commit 14b3db0

Browse files
committed
overhaul rename interface
1 parent d0dfddd commit 14b3db0

7 files changed

Lines changed: 99 additions & 115 deletions

File tree

css/style.css

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ body, html{
242242
border: none;
243243
outline: none;
244244
width: 100%;
245-
height: calc(100% - 102px);
245+
height: calc(100% - 56px);
246246
position: absolute;
247247
background-color: white;
248248
overflow: auto;
@@ -334,22 +334,22 @@ body, html{
334334

335335
.tab-tab h4{
336336
margin: 0px;
337-
font-size: 12px;
338-
width: 83px;
339-
overflow: hidden;
340-
word-break: break-all;
341-
text-overflow: ellipsis;
342-
float: left;
343-
word-wrap: break-word;
344-
overflow: hidden;
345-
height: 17px;
346-
font-family: 'Roboto';
347-
color: white;
348-
padding-top: 7px;
349-
padding-left: 5px;
350-
font-weight: 300;
351-
position: relative;
352-
margin-left: 14px;
337+
font-size: 12px;
338+
width: 83px;
339+
overflow: hidden;
340+
word-break: break-all;
341+
text-overflow: ellipsis;
342+
float: left;
343+
word-wrap: break-word;
344+
overflow: hidden;
345+
height: 17px;
346+
font-family: 'Roboto';
347+
color: white;
348+
padding-top: 7px;
349+
padding-left: 5px;
350+
font-weight: 300;
351+
position: relative;
352+
margin-left: 14px;
353353
}
354354
.tab-tab h6{
355355
margin: 0;
@@ -453,18 +453,21 @@ body, html{
453453
margin: 0;
454454
}
455455
.tab-right{
456-
position: relative;
457-
color: #F4E5E5;
458-
padding: 8px;
459-
background-color: transparent;
460-
text-align: center;
461-
font-family: 'Roboto-Thin';
462-
z-index: 11;
463-
font-size: 17px;
464-
padding-right: 12px;
465-
padding-left: 12px;
466-
float: right;
467-
overflow: visible;
456+
position: relative;
457+
color: #F4E5E5;
458+
padding: 0px;
459+
background-color: transparent;
460+
text-align: center;
461+
font-family: 'Roboto-Thin';
462+
z-index: 11;
463+
font-size: 17px;
464+
float: right;
465+
overflow: visible;
466+
}
467+
.tab-right > i{
468+
padding: 8px;
469+
padding-left: 12px;
470+
padding-right: 12px;
468471
}
469472

470473
#navigate{
@@ -495,7 +498,7 @@ body, html{
495498
background-color: white;
496499
margin-top: 0px;
497500
border: none;
498-
height: calc(100% - 84px);
501+
height: calc(100% - 42px);
499502
}
500503

501504
.terminal > * {
@@ -653,7 +656,7 @@ FILE BROWSING TREE
653656

654657
.tree-tree{
655658
overflow: auto;
656-
height: calc(100% - 86px);
659+
height: calc(100% - 34px);
657660
}
658661
.tree ul{
659662
list-style-type: none;

index.html

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@
4040

4141
<div id="side" style="display:none">
4242
<div id="side-inner">
43-
<div class="side-head flex-center" style="height:42px">
44-
<div class="InputAddOn" id="rename-div">
45-
<input id="title" value="code your cloud" placeholder="Title" class="InputAddOn-field" readonly="" onchange="ok_rename()"/>
46-
<button class="InputAddOn-item" id="rename-toggle" onclick="toggle_rename_show()" style="display:none"><i class="zmdi zmdi-edit"></i></button>
47-
</div>
48-
</div>
49-
5043
<div class="side-head" id="navigate" style="border-bottom: solid thin #424242">
5144
<div class="active" id="nav_tree" onclick="nav_tree()"><i class="zmdi zmdi-folder-outline"></i></div>
5245
<div id="nav_preview" onclick="nav_preview()"><i class="zmdi zmdi-eye"></i></div>
@@ -183,7 +176,8 @@ <h6>
183176
<div class="tab-right">
184177
<i class="zmdi zmdi-more-vert" onclick="$('#more-popup').toggle()"></i>
185178

186-
<div style="display:none" id="more-popup" class="popup">
179+
<div style="display:none" id="more-popup" class="popup">
180+
<span onclick="manager.currentRename()"><i class="zmdi zmdi-edit"></i> Rename</span>
187181
<span onclick="manager.trash(current_file)"><i class="zmdi zmdi-delete"></i> Delete</span>
188182
<span onclick="picker.share(current_file)" class="share-button"><i class="zmdi zmdi-account-add"></i> Share</span>
189183
<span onclick="picker.saveAs()"><i class="zmdi zmdi-floppy"></i>Save As</span>
@@ -362,20 +356,23 @@ <h4>Would you be ok with ads on this site?</h4>
362356
TODO: copy + paste + cut
363357
-->
364358
<div id="context" class="popup context-menu">
359+
<span onclick="" class="context-menu__item">
360+
<a class="context-menu__link" onclick="context.rename()"><i class="zmdi zmdi-edit"></i> Rename</a>
361+
</span>
365362
<span onclick="" class="context-menu__item">
366-
<a class="context-menu__link" onclick="context.trash()"><i class="zmdi zmdi-delete"></i>Delete</a>
363+
<a class="context-menu__link" onclick="context.trash()"><i class="zmdi zmdi-delete"></i> Delete</a>
367364
</span>
368365
<span onclick="" class="context-menu__item">
369-
<a class="context-menu__link" onclick="context.save()"><i class="zmdi zmdi-floppy"></i>Save</a>
366+
<a class="context-menu__link" onclick="context.save()"><i class="zmdi zmdi-floppy"></i> Save</a>
370367
</span>
371368
<span onclick="" class="context-menu__item share-button">
372-
<a class="context-menu__link" onclick="context.share()"><i class="zmdi zmdi-account-add"></i>Share</a>
369+
<a class="context-menu__link" onclick="context.share()"><i class="zmdi zmdi-account-add"></i> Share</a>
373370
</span>
374371
<span onclick="" class="context-menu__item">
375-
<a class="context-menu__link" onclick="context.download()"><i class="zmdi zmdi-download"></i>Download</a>
372+
<a class="context-menu__link" onclick="context.download()"><i class="zmdi zmdi-download"></i> Download</a>
376373
</span>
377374
<span onclick="" class="context-menu__item">
378-
<a class="context-menu__link" onclick="context.close()"><i class="zmdi zmdi-close"></i>Close</a>
375+
<a class="context-menu__link" onclick="context.close()"><i class="zmdi zmdi-close"></i> Close</a>
379376
</span>
380377
</div>
381378

@@ -389,10 +386,7 @@ <h4>Would you be ok with ads on this site?</h4>
389386
<link rel="stylesheet" href="lib/codemirror/addon/hint/show-hint.css" >
390387
<link rel="stylesheet" href="lib/codemirror/addon/tern/tern.css" >
391388
<script src="lib/codemirror/addon/comment/comment.js" ></script>
392-
393-
<script src="lib/codemirror/addon/comment/comment.js"></script>
394389
<script src="lib/codemirror/addon/dialog/dialog.js"></script>
395-
<link rel="stylesheet" href="lib/codemirror/addon/dialog/dialog.css">
396390

397391
<script src="lib/codemirror/addon/edit/closebrackets.js"></script>
398392
<script src="lib/codemirror/addon/edit/closetag.js"></script>
@@ -430,6 +424,7 @@ <h4>Would you be ok with ads on this site?</h4>
430424
<link rel="stylesheet" href="lib/codemirror/addon/tern/tern.css">
431425

432426
<script src="lib/codemirror/addon/search/match-highlighter.js"></script>
427+
<script src="lib/codemirror/addon/scroll/annotatescrollbar.js"></script>
433428
<script src="lib/codemirror/addon/search/matchesonscrollbar.js"></script>
434429
<script src="lib/codemirror/addon/search/search.js"></script>
435430
<script src="lib/codemirror/addon/search/searchcursor.js"></script>

js/context.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ context.close = function(){
2424
manager.removeTab($(context.taskItemInContext).attr("data-fileid"));
2525
}
2626

27+
context.rename = function(){
28+
var current_title = $(context.taskItemInContext).parent().parent().find("h4").text();
29+
var current_title = $(context.taskItemInContext).parent().parent().find("h4").text();
30+
manager.rename(current_title, $(context.taskItemInContext).attr("data-fileid"));
31+
}
32+
2733
/*BACKBONE*/
2834

2935
context.clickInsideElement = function(e, className) {

js/editor.js

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,48 @@ manager.trash = function(id){
1616
}
1717
}
1818
}
19+
manager.renameId = null;
20+
manager.rename = function(current_title, id){
21+
manager.renameId = id;
22+
editor().openDialog('Rename: <input type="text" style="width: 10em" class="CodeMirror-search-field" value="'+current_title+'"/>', function(new_title){
23+
manager.setFileTitle(manager.renameId, new_title);
24+
if(cloud_use === "drive"){
25+
sendData({
26+
type: "title",
27+
title: new_title
28+
}, manager.renameId);
29+
}
30+
else if(cloud_use === "sky"){
31+
sky.renameFile(manager.renameId, new_title);
32+
}
33+
}, {});
34+
}
35+
manager.currentRename = function(){
36+
manager.rename(title(), current_file);
37+
}
38+
manager.setFileTitle = function(id, title){
39+
editors[getIndex(id)].title = title;
40+
$(".tab-tab[data-fileid='"+id+"']").find("h4").html(title);
41+
manager.checkMode(id, title);
42+
var index = getIndex(id);
43+
var ext = manager.extension(title.toLowerCase());
44+
if(images.isImage(ext)){
45+
editors[index].image = true;
46+
47+
//TODO: work on this
48+
49+
if(current_file === id){
50+
images.init(id); //display it as an image
51+
}
52+
}
53+
54+
//change the title in the tree view
55+
var inner_html = $("[data-tree-li='"+id+"'] span").html().split(">");
56+
inner_html[2] = title;
57+
$("[data-tree-li='"+id+"'] span").html(inner_html.join(">"));
58+
$(".tab-tab[data-fileid='"+id+"'] > i").replaceWith(tree.getIconByTitle(title));
59+
$(".tab-tab[data-fileid='"+id+"']").attr("data-icon", tree.getClassFromIcon(tree.getIconByTitle(title)));
60+
}
1961

2062
manager.save = function(id){
2163
if(id !== "welcome"){
@@ -100,27 +142,9 @@ manager.openTab = function(id){
100142
catch(e){
101143
//otherwise, a file isn't open
102144
//set everything to the default
103-
$("#title").val("Code Your Cloud");
104-
$("#rename-toggle").css("display","none");
105-
$("#rename_input").val("");
106145
}
107146

108147
var index = getIndex(id);
109-
if(editors[index].welcome){
110-
//default
111-
$("#title").val("Code Your Cloud");
112-
$("#rename-toggle").css("display","none");
113-
$("#title").css("border-top-right-radius","6px").css("border-bottom-right-radius","6px");
114-
//switch #title to readonly
115-
hide_top_rename();
116-
}
117-
else{
118-
//a file
119-
$("#title").val(editors[index].title);
120-
$("#rename-toggle").css("display","inline-block");
121-
$("#title").css("border-top-right-radius","0px").css("border-bottom-right-radius","0px");
122-
}
123-
124148
if(editors[index].image){
125149
//TODO: fix this
126150
images.init(id);

js/picker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ picker.saveDest = "";
132132

133133
picker.saveAs = function(){
134134
if(cloud_use === "drive"){
135-
$("#file-name").val($("#title").val());
135+
$("#file-name").val(title());
136136
$('#saveas-overlay').velocity('transition.slideDownIn');
137137
}
138138
else if(cloud_use === "sky"){
139-
$("#file-name").val($("#title").val());
139+
$("#file-name").val(title());
140140
$('#saveas-overlay').velocity('transition.slideDownIn');
141141
}
142142
};

js/realtime.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ var _init = false;
1313
function loadDrive(){
1414
drive.load();
1515
}
16-
17-
1816
function loadSky(){
1917
sky.load();
2018
}
21-
2219
function init(){
2320
if(_init === false){
2421
_init = true;
@@ -109,20 +106,3 @@ function new_file(){
109106
sky.insertNewFile(sky.upload_location, (new Date()).getTime()+".txt", "");
110107
}
111108
}
112-
113-
/**
114-
* RENAMING
115-
* renames the file
116-
**/
117-
function ok_rename(){
118-
setFileTitle(current_file, $("#title").val());
119-
if(cloud_use === "drive"){
120-
sendData({
121-
type: "title",
122-
title: $("#title").val()
123-
}, current_file);
124-
}
125-
else if(cloud_use === "sky"){
126-
sky.renameFile(current_file, $("#title").val());
127-
}
128-
}

js/tabs.js

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ function editor(){
1111
}
1212
}
1313
}
14+
function title(){
15+
return editors[getIndex(current_file)].title;
16+
}
1417
function add_editor(e, id, welcome){
1518
var to_push = {
1619
editor: e, //the editor instance itself
@@ -57,32 +60,6 @@ function setIgnore(id, ignore){
5760
}
5861
}
5962
}
60-
function setFileTitle(id, title){
61-
editors[getIndex(id)].title = title;
62-
$(".tab-tab[data-fileid='"+id+"']").find("h4").html(title);
63-
manager.checkMode(id, title);
64-
var index = getIndex(id);
65-
if(current_file === id){ //if this is the file being show, you should change the title input
66-
$("#title").val(editors[index].title);
67-
}
68-
var ext = manager.extension(title.toLowerCase());
69-
if(images.isImage(ext)){
70-
editors[index].image = true;
71-
72-
//TODO: work on this
73-
74-
if(current_file === id){
75-
images.init(id); //display it as an image
76-
}
77-
}
78-
79-
//change the title in the tree view
80-
var inner_html = $("[data-tree-li='"+id+"'] span").html().split(">");
81-
inner_html[2] = title;
82-
$("[data-tree-li='"+id+"'] span").html(inner_html.join(">"));
83-
$(".tab-tab[data-fileid='"+id+"'] > i").replaceWith(tree.getIconByTitle(title));
84-
$(".tab-tab[data-fileid='"+id+"']").attr("data-icon", tree.getClassFromIcon(tree.getIconByTitle(title)));
85-
}
8663

8764
/**
8865
* COMMUNICATIONS
@@ -92,7 +69,6 @@ function setFileTitle(id, title){
9269
window.addEventListener("message", receiveMessage, false);
9370
function receiveMessage(event){
9471
if(event.data !== "!_{h:''}"){
95-
9672
var json = JSON.parse(event.data);
9773
if(typeof json.s === 'undefined'){ //this makes sure that only the intended messages are getting in. There are some "background" ones
9874
var id = json.currentfile;
@@ -102,7 +78,7 @@ function receiveMessage(event){
10278
hide_loading_spinner();
10379
}
10480
else if(json.type === "title"){ //sets the title
105-
setFileTitle(id, json.title);
81+
manager.setFileTitle(id, json.title);
10682
}
10783
else if(json.type === "insert_text"){ //text has been inserted
10884
setIgnore(id, true); //ignore the second one (realtime problems)

0 commit comments

Comments
 (0)