diff options
author | Sebastian Silva <sebastian@sugarlabs.org> | 2011-11-19 14:53:59 (GMT) |
---|---|---|
committer | Sebastian Silva <sebastian@sugarlabs.org> | 2011-11-19 14:53:59 (GMT) |
commit | 577a105986c7b0752155d763fcdc4f7d68dad8bb (patch) | |
tree | f6683c90ab0a5d6b170d32081c99d9da1f498836 /app/templates/editor.html | |
parent | d37af74b9e56d30044b45913afb21a86c9ad2b79 (diff) |
Fix UI - add new file
Diffstat (limited to 'app/templates/editor.html')
-rw-r--r-- | app/templates/editor.html | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/app/templates/editor.html b/app/templates/editor.html index 73fbcf8..6ac5d83 100644 --- a/app/templates/editor.html +++ b/app/templates/editor.html @@ -9,10 +9,8 @@ <link rel="stylesheet" href="/static/css/sugar-theme/jquery-ui-1.8.16.sugar.css" /> <script src="/static/js/jquery-1.6.2.js" type="text/javascript"></script> <script src="/static/js/jquery-ui-1.8.16.sugar.min.js" type="text/javascript"></script> + <script src="/static/js/jquery.corner.js" type="text/javascript"></script> <script src="/static/js/websdk-1.js" type="text/javascript"></script> -<!-- <script src="js/jquery-plugins/json.js" type="text/javascript"></script> - <script src="js/jquery-plugins/jquery.hotkeys-0.7.8.js" type="text/javascript"></script> - <script src="js/jquery-plugins/jquery.intercept.js" type="text/javascript"></script> --> </head> <body> <script src="/static/js/ace/ace-uncompressed.js" type="text/javascript" charset="utf-8"></script> @@ -20,23 +18,27 @@ <script py:if="mode" src="/static/js/ace/mode-${mode}.js" type="text/javascript" charset="utf-8"></script> <pre id="editor">$content</pre> <div id="editor-sidebar" class="bling"> +<form id="saveform" action="/save" method="post"> <div class="file"> <img src="/static/icons/${icon}" /><br/> ${absdir}/<br/> - <strong>${basename}</strong><br/> + <strong py:if="basename!='///'">${basename}</strong> + <input py:if="basename=='///'" style="width:90%" type="text" name="basename" id="basename"/> + <br/> </div> +<span id="result" style="color:red"></span> +<br/> <hr /><br/> -<div id="result" style="color:red"></div> -<form id="saveform" action="/save" method="post"> <input type="hidden" name="filename" id="filename" value="$filename" /> <input type="hidden" name="directory" id="directory" value="$directory" /> <input type="hidden" name="content" id="content" value="ñññ" /> <!--input type="button" class="btn" value="Browse" onclick='location.href="/files/$directory"' /--> <input type="submit" value="Save file" /><br/> -<input type="button" class="btn" value="Delete file" onclick='location.href="/delete/${filename}"' /> +<input py:if="basename!='///'" type="button" value="Delete file" onclick='location.href="/delete/${filename}"' /> <!-- save a magic cookie for security here TODO --> -<input type="button" class="btn" value="Return" onclick='location.href="/help"' /> +<input type="button" value="Return" onclick='location.href="/help"' /> <!--input type="button" class="btn" value="edit wysiwyg" onclick='top.location.href=top.location.href+"&editor=wysiwyg"' /--> + </form> </div> <script> @@ -45,25 +47,42 @@ /* stop form from submitting normally */ event.preventDefault(); - + + var newfile=false; /* get some values from elements on the page: */ var form = $( this ), cont = form.find( 'input[name="content"]' ).val(), - file = form.find( 'input[name="filename"]' ).val(), dir = form.find( 'input[name="directory"]' ).val(), url = form.attr( 'action' ); + if ("${basename}"=="///") { // New file + if (form.find('input[name="basename"]').val()=="") { + $( "#result" ).empty().append( "name your file" ); + $( "#result" ).show().fadeOut(15000); + return false; + }else{ + var file = dir + "/" + form.find('input[name="basename"]').val(); + $('filename').val(file); + newfile = true; + } + } else { + var file = form.find( 'input[name="filename"]' ).val(); + } - /* Send the data using post and put the results in a div */ + /* Send the data using post and put the results to #result */ $.post( url, { content: cont, filename: file, directory: dir }, function( data ) { - // var content = $( data ).find( '#content' ); $( "#result" ).empty().append( data ); - $( "#result" ).show().fadeOut(5000); + $( "#result" ).show().fadeOut(15000); } ); + if (newfile) { + parent.frame2.location.reload(); + } }); document.ready = function() { + $('#basename').corner(); + var aceEditor = ace.edit("editor"); aceEditor.setTheme("ace/theme/twilight"); document.getElementById('editor').style.fontSize='16px'; |