mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Merge kyledrake changes
This commit is contained in:
commit
d56beab370
1 changed files with 35 additions and 5 deletions
|
@ -74,19 +74,19 @@
|
|||
<div class="row">
|
||||
<div class="col col-33">
|
||||
<div class="txt-Center">
|
||||
<a class="btn-Action" href="/dashboard"><i class="fa fa-remove"></i> Finish Without Saving</a>
|
||||
<a class="btn-Action" href="/dashboard"><i class="fa fa-remove"></i> Exit Without Saving</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col col-33">
|
||||
<div class="txt-Center">
|
||||
<a class="btn-Action" href="#" onclick="saveTextFile(false); return false"><i class="fa fa-save"></i> Save Changes</a>
|
||||
<a id="saveButton" class="btn-Action" href="#" onclick="saveTextFile(false); return false" style="opacity: 0.5"><i class="fa fa-save"></i> Save Changes</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col col-33">
|
||||
<div class="txt-Center">
|
||||
<a class="btn-Action" href="#" onclick="saveTextFile(true); return false"><i class="fa fa-save"></i> Save and Finish</a>
|
||||
<a id="saveAndExitButton" class="btn-Action" href="#" onclick="saveTextFile(true); return false" style="opacity: 0.5"><i class="fa fa-save"></i> Save and Exit</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -103,6 +103,8 @@
|
|||
<script src="/js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script>
|
||||
var unsavedChanges = false
|
||||
|
||||
function setTheme(name) {
|
||||
var editorTheme = $('#theme option:selected')
|
||||
editor.setTheme(editorTheme.val())
|
||||
|
@ -119,6 +121,8 @@
|
|||
<% end %>
|
||||
|
||||
function saveTextFile(quit) {
|
||||
if(unsavedChanges == false)
|
||||
return
|
||||
$.ajax({
|
||||
url: '/site_files/save/<%= @filename %>?csrf_token=<%= csrf_token %>',
|
||||
data: editor.getValue(),
|
||||
|
@ -130,10 +134,12 @@
|
|||
},
|
||||
success: function(response){
|
||||
if(response == 'ok') {
|
||||
unsavedChanges = false
|
||||
if(quit === true) {
|
||||
window.location = '/dashboard';
|
||||
window.location = '/dashboard'
|
||||
} else {
|
||||
$('#editorUpdates span').html('<i class="icon-save icon-2x"></i> <span style="font-size: 14pt">Your file has been saved.</span>');
|
||||
$('#editorUpdates span').html('<i class="icon-save icon-2x"></i> <span style="font-size: 14pt">Your file has been saved.</span>')
|
||||
$('a#saveButton,a#saveAndExitButton').css('opacity', 0.5)
|
||||
setTimeout(function() {
|
||||
$('#editorUpdates').fadeOut(); //.addClass('hidden');
|
||||
}, 2000)
|
||||
|
@ -162,6 +168,30 @@
|
|||
editor.setOptions({
|
||||
maxLines: Infinity
|
||||
})
|
||||
|
||||
editor.on('change', function(obj) {
|
||||
$('a#saveButton,a#saveAndExitButton').css('opacity', 1)
|
||||
unsavedChanges = true
|
||||
})
|
||||
})
|
||||
|
||||
$(window).keypress(function(event) {
|
||||
if(event.ctrlKey == true && event.key == 's') {
|
||||
saveTextFile(false)
|
||||
event.preventDefault()
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
window.onbeforeunload = function() {
|
||||
if(unsavedChanges == true)
|
||||
return "You have unsaved changes!"
|
||||
}
|
||||
|
||||
$('a#saveButton,a#saveAndExitButton').click(function() {
|
||||
if(!unsavedChanges)
|
||||
return false
|
||||
return true
|
||||
})
|
||||
|
||||
</script>
|
Loading…
Add table
Reference in a new issue