From 887941baad9186fa6cc3b106071781c47fea57cc Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 19 Aug 2015 02:49:37 +0000 Subject: [PATCH] improved usability of some code views a bit --- codepot/src/codepot/controllers/code.php | 2 +- .../codepot/language/english/common_lang.php | 2 + .../language/indonesian/common_lang.php | 2 + .../codepot/language/korean/common_lang.php | 2 + codepot/src/codepot/views/code_edit.php | 38 +++++++++---- codepot/src/codepot/views/code_folder.php | 55 ++++++++----------- codepot/src/codepot/views/code_revision.php | 45 +++++++-------- 7 files changed, 79 insertions(+), 67 deletions(-) diff --git a/codepot/src/codepot/controllers/code.php b/codepot/src/codepot/controllers/code.php index e118b2c2..df2f992b 100644 --- a/codepot/src/codepot/controllers/code.php +++ b/codepot/src/codepot/controllers/code.php @@ -102,7 +102,7 @@ class Code extends Controller if (count($import_files) > 0 && $this->subversion->importFiles ($projectid, $path, $login['id'], $post_new_message, $import_files, $this->upload) === FALSE) { - $popup_error_message = '
' . htmlspecialchars($this->subversion->import_files_errmsg) . '
'; + $popup_error_message = $this->subversion->import_files_errmsg; } else { diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index c33fadc4..3df4bd1f 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -31,6 +31,7 @@ $lang['Download'] = 'Download'; $lang['Edit'] = 'Edit'; $lang['Enstyle'] = 'Enstyle'; $lang['Error'] = 'Error'; +$lang['Failure'] = 'Failure'; $lang['File'] = 'File'; $lang['Files'] = 'Files'; $lang['Filter'] = 'Filter'; @@ -96,6 +97,7 @@ $lang['Size'] = 'Size'; $lang['Source'] = 'Source'; $lang['Status'] = 'Status'; $lang['Summary'] = 'Summary'; +$lang['Success'] = 'Success'; $lang['System'] = 'System'; $lang['Tag'] = 'Tag'; $lang['Text'] = 'Text'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index b6cc329a..a2137628 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -31,6 +31,7 @@ $lang['Download'] = 'Download'; $lang['Edit'] = 'Rubah'; $lang['Enstyle'] = 'Enstyle'; $lang['Error'] = 'Error'; +$lang['Failure'] = 'Failure'; $lang['File'] = 'File'; $lang['Files'] = 'File'; $lang['Filter'] = 'Filter'; @@ -94,6 +95,7 @@ $lang['Sites'] = 'Sites'; $lang['Size'] = 'Ukuran'; $lang['Source'] = 'Sumber'; $lang['Status'] = 'Status'; +$lang['Success'] = 'Success'; $lang['Summary'] = 'Rangkuman'; $lang['System'] = 'Sistem'; $lang['Tag'] = 'Label'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index 53afeb41..f5bc4f6a 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -31,6 +31,7 @@ $lang['Download'] = '내려받음'; $lang['Edit'] = '수정'; $lang['Enstyle'] = '모양새내기'; $lang['Error'] = '오류'; +$lang['Failure'] = '실패'; $lang['File'] = '파일'; $lang['Files'] = '파일'; $lang['Filter'] = '필터'; @@ -95,6 +96,7 @@ $lang['Sites'] = '사이트'; $lang['Size'] = '크기'; $lang['Status'] = '상태'; $lang['Source'] = '소스'; +$lang['Success'] = '성공'; $lang['Summary'] = '요약'; $lang['System'] = '시스템'; $lang['Tag'] = '태그'; diff --git a/codepot/src/codepot/views/code_edit.php b/codepot/src/codepot/views/code_edit.php index 61a13bad..97cd48dc 100644 --- a/codepot/src/codepot/views/code_edit.php +++ b/codepot/src/codepot/views/code_edit.php @@ -54,8 +54,10 @@ function show_alert (outputMsg, titleMsg) { $("#code_edit_mainarea_alert").html(outputMsg).dialog({ title: titleMsg, - resizable: false, + resizable: true, modal: true, + width: 'auto', + height: 'auto', buttons: { "OK": function () { $(this).dialog("close"); @@ -68,6 +70,7 @@ var ace_modes = null; var editor_changed = false; var save_button = null; var return_button = null; +var saving_in_progress = false; function set_editor_changed (changed) { @@ -145,27 +148,31 @@ $(function () { editor.getSession().setMode ($(this).val()); }); - - $("#code_edit_mainarea_save_form").dialog ({ + $('#code_edit_mainarea_save_form').dialog ({ title: 'lang->line('Save')?>', autoOpen: false, modal: true, width: '60%', buttons: { 'lang->line('OK')?>': function () { + if (saving_in_progress) return; + var save_message = $("#code_edit_mainarea_save_message").val(); if (save_message == '') return false; editor.setReadOnly (true); save_button.button ("disable"); + saving_in_progress = true; $.ajax({ method: "POST", dataType: "json", url: codepot_merge_path('', 'id}/{$hex_headpath}"; ?>'), data: { "message": save_message, "text": editor.getValue() }, - success: function(json) { - + success: function(json, textStatus, jqXHR) { + saving_in_progress = false; + $('#code_edit_mainarea_save_form').dialog('enable'); + $('#code_edit_mainarea_save_form').dialog('close'); if (json.status == "ok") { set_editor_changed (false); @@ -173,30 +180,39 @@ $(function () { // once the existing document is saved, arrange to return // to the the head revision regardless of the original revision. return_button.attr ('href', base_return_anchor); - show_alert ('Saved', ''); + show_alert ('Saved', "lang->line('Success')?>"); } else { - show_alert ('Not saved - ' + codepot_htmlspecialchars(json.status), ''); + show_alert ('
' + codepot_htmlspecialchars(json.status) + '
', "lang->line('Error')?>"); save_button.button ("enable"); } editor.setReadOnly (false); }, - error: function(data) { - show_alert ('Not saved', ''); + error: function(jqXHR, textStatus, errorThrown) { + saving_in_progress = false; + $('#code_edit_mainarea_save_form').dialog('enable'); + $('#code_edit_mainarea_save_form').dialog('close'); + show_alert ('Not saved - ' + errorThrown, "lang->line('Error')?>"); editor.setReadOnly (false); save_button.button ("enable"); } }); - $(this).dialog('close'); + + $('#code_edit_mainarea_save_form').dialog('disable'); }, 'lang->line('Cancel')?>': function () { + if (saving_in_progress) return; $(this).dialog('close'); } }, - close: function() { } + + beforeClose: function() { + // if saving is in progress, prevent dialog closing + return !saving_in_progress; + } }); diff --git a/codepot/src/codepot/views/code_folder.php b/codepot/src/codepot/views/code_folder.php index fe3cd8cb..9ad21135 100644 --- a/codepot/src/codepot/views/code_folder.php +++ b/codepot/src/codepot/views/code_folder.php @@ -57,11 +57,12 @@ function show_alert (outputMsg, titleMsg) { - $("#code_folder_mainarea_alert").html(outputMsg).dialog({ + $('#code_folder_mainarea_alert').html(outputMsg).dialog({ title: titleMsg, resizable: true, modal: true, - width: 500, + width: 'auto', + height: 'auto', buttons: { "OK": function () { $(this).dialog("close"); @@ -198,7 +199,7 @@ function render_readme() } var new_item_no = 0; -var import_in_progress = 0; +var import_in_progress = false; function get_new_item_html(no, type, name) { @@ -220,25 +221,26 @@ $(function () { title: 'lang->line('New');?>', resizable: true, autoOpen: false, - width: 500, + width: 'auto', + height: 'auto', modal: true, buttons: { 'More': function () { - if (import_in_progress > 0) return; + if (import_in_progress) return; ++new_item_no; $('#code_folder_mainarea_new_file_form_item_list').append (get_new_item_html(new_item_no, 'file', 'file')); $('#code_folder_mainarea_new_dir_form_item_list').append (get_new_item_html(new_item_no, 'text', 'dir')); }, 'lang->line('OK')?>': function () { - if (import_in_progress > 0) return; + if (import_in_progress) return; $('#code_folder_mainarea_new_item_count').val (new_item_no + 1); if (!!window.FormData) { // FormData is supported - import_in_progress = 1; + import_in_progress = true; var form_data = new FormData(); @@ -265,17 +267,22 @@ $(function () { cache: false, success: function (data, textStatus, jqXHR) { - import_in_progress = 0; + import_in_progress = false; $('#code_folder_mainarea_new_form_div').dialog('enable'); $('#code_folder_mainarea_new_form_div').dialog('close'); if (data == 'ok') + { + // refresh the page to the head revision $(location).attr ('href', codepot_merge_path('', 'id}/{$hex_headpath}"; ?>')); + } else - show_alert ('
' + codepot_htmlspecialchars(data) + '
', ''); + { + show_alert ('
' + codepot_htmlspecialchars(data) + '
', "lang->line('Error')?>"); + } }, error: function (jqXHR, textStatus, errorThrown) { - import_in_progress = 0; + import_in_progress = false; $('#code_folder_mainarea_new_form_div').dialog('enable'); $('#code_folder_mainarea_new_form_div').dialog('close'); show_alert ('Failed - ' + errorThrown, "lang->line('Error')?>"); @@ -290,12 +297,16 @@ $(function () { }, 'lang->line('Cancel')?>': function () { - if (import_in_progress > 0) return; + if (import_in_progress) return; $('#code_folder_mainarea_new_form_div').dialog('close'); } }, - clsoe: function() {} + + beforeClose: function() { + // if importing is in progress, prevent dialog closing + return !import_in_progress; + } } ); @@ -395,20 +406,8 @@ $(function () { render_readme (); - 0): ?> - $("#code_folder_popup_error_div").dialog( { - title: 'lang->line('Error')?>', - width: 'auto', - height: 'auto', - modal: true, - autoOpen: true, - buttons: { - "lang->line('OK')?>": function() { - $( this ).dialog( "close" ); - } - } - }); + show_alert (' . htmlspecialchars($popup_error_message) . ''); ?>, "lang->line('Error')?>"); }); @@ -872,12 +871,6 @@ $this->load->view ( - 0): ?> -
- -
- - diff --git a/codepot/src/codepot/views/code_revision.php b/codepot/src/codepot/views/code_revision.php index 2781d740..c3a37ffd 100644 --- a/codepot/src/codepot/views/code_revision.php +++ b/codepot/src/codepot/views/code_revision.php @@ -23,6 +23,22 @@ @@ -560,6 +560,8 @@ $history = $file['history']; +
+ @@ -640,11 +642,6 @@ $history = $file['history']; - 0): ?> -
- -
-