From c9d2374425ffef136d396288022b2db66f0e9a8d Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Tue, 4 Jun 2013 15:11:43 -0700 Subject: [PATCH] Finish integration of text editor --- app.rb | 1 - views/dashboard.slim | 4 ++-- views/site_files/text_editor.slim | 30 +++++++++++++++++++----------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app.rb b/app.rb index cd828040..d0add425 100644 --- a/app.rb +++ b/app.rb @@ -150,7 +150,6 @@ end get '/site_files/text_editor/:filename' do |filename| @file_url = "http://#{current_site.username}.neocities.org/#{filename}" - slim :'site_files/text_editor' end diff --git a/views/dashboard.slim b/views/dashboard.slim index 29101621..111152a8 100644 --- a/views/dashboard.slim +++ b/views/dashboard.slim @@ -31,10 +31,10 @@ javascript: a href="http://#{current_site.username}.neocities.org/#{file.filename}" target="_blank" View
span i class="icon-edit"    - a href="#" Edit with visual editor not implemented yet.. ETA one week
+ a href="/site_files/text_editor/#{file.filename}" Edit with text editor
span i class="icon-edit"    - a href="/site_files/text_editor/#{file.filename}" Edit with text editor not implemented yet.. ETA one day
+ span Edit with visual editor (not implemented yet.. coming soon)
span i class="icon-trash"    a href="#" onclick="confirmFileDelete('#{file.filename}')" Delete diff --git a/views/site_files/text_editor.slim b/views/site_files/text_editor.slim index f7657e2b..03e0e1ec 100644 --- a/views/site_files/text_editor.slim +++ b/views/site_files/text_editor.slim @@ -7,11 +7,6 @@ css: left: 0; } -.row - .span6.offset3 - div id="editorUpdates" class="alert alert-success hidden" - button type="button" class="close" onclick="$('#editorUpdates').addClass('hidden');" × - span .row .span6 font style="font-size: 27pt" Editing #{params[:filename]} @@ -59,12 +54,16 @@ css: .row.text-center style="margin-top: 10px" .span4 - a.btn.btn-large.btn-warning href="" Finish Without Saving + a.btn.btn-large.btn-warning href="/dashboard"   Finish Without Saving .span4 - a.btn.btn-large.btn-success href="#" onclick="saveTextFile()" Save Changes + a.btn.btn-large.btn-success href="#" onclick="saveTextFile(false)"   Save Changes .span4 - a.btn.btn-large.btn-info href="" Save and Finish + a.btn.btn-large.btn-info href="#" onclick="saveTextFile(true);"   Save and Finish +.row style="margin-top: 20px" + .span6.offset3.text-center + div id="editorUpdates" class="alert alert-success hidden" + span script src="http://rawgithub.com/ajaxorg/ace-builds/master/src-noconflict/ace.js" type="text/javascript" charset="utf-8" javascript: @@ -73,8 +72,8 @@ javascript: editor.setTheme($('#theme').val()); } - function saveTextFile() { - /* + function saveTextFile(quit) { + /* $.post('/site_files/save/#{params[:filename]}', editor.getValue(), function(resp) { if(resp == 'ok') { $('#editorUpdates span').text('Your file has been saved.'); @@ -91,11 +90,20 @@ javascript: type: 'POST', success: function(response){ if(response == 'ok') { - $('#editorUpdates span').text('Your file has been saved.'); + if(quit === true) { + window.location = '/dashboard'; + } + $('#editorUpdates span').html('  Your file has been saved.'); + setTimeout(function() { + $('#editorUpdates').fadeOut(); //.addClass('hidden'); + }, 2000); + } else { $('#editorUpdates span').text(response); } + $('#editorUpdates').fadeIn(); $('#editorUpdates').removeClass('hidden'); + } }); }