diff --git a/public/config.codekit b/public/config.codekit index 5faa5569f..fa0fae58a 100644 --- a/public/config.codekit +++ b/public/config.codekit @@ -221,6 +221,26 @@ "strictMath": 0, "strictUnits": 0 }, + "\/less\/_editor.less": { + "allowInsecureImports": 0, + "createSourceMap": 0, + "disableJavascript": 0, + "fileType": 1, + "ieCompatibility": 1, + "ignore": 1, + "ignoreWasSetByUser": 0, + "inputAbbreviatedPath": "\/less\/_editor.less", + "outputAbbreviatedPath": "\/css\/_editor.css", + "outputPathIsOutsideProject": 0, + "outputPathIsSetByUser": 0, + "outputStyle": 0, + "relativeURLS": 0, + "shouldRunAutoprefixer": 0, + "shouldRunBless": 0, + "strictImports": 0, + "strictMath": 0, + "strictUnits": 0 + }, "\/less\/_emojify.less": { "allowInsecureImports": 0, "createSourceMap": 0, diff --git a/public/css/gogs.css b/public/css/gogs.css index 7df337732..0bf68b1ba 100644 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -1376,10 +1376,6 @@ footer .ui.language .menu { .repository.file.editor .tabular.menu .octicon { margin-right: 5px; } -.repository.file.editor .CodeMirror.cm-s-default { - border-radius: 3px; - padding: 0 !important; -} .repository.file.editor .commit-form-wrapper { padding-left: 64px; } @@ -2500,6 +2496,16 @@ footer .ui.language .menu { tab-size: 16 !important; -moz-tab-size: 16 !important; } +.CodeMirror { + font: 14px Consolas, "Liberation Mono", Menlo, Courier, monospace; +} +.CodeMirror.cm-s-default { + border-radius: 3px; + padding: 0 !important; +} +.CodeMirror .cm-comment { + background: inherit !important; +} .organization { padding-top: 15px; padding-bottom: 80px; diff --git a/public/js/gogs.js b/public/js/gogs.js index 8204149fc..c87baa48a 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -15,10 +15,10 @@ function initCommentPreviewTab($form) { "text": $form.find('.tab.segment[data-tab="' + $tabMenu.data('write') + '"] textarea').val() }, function (data) { - var $previewSegment = $form.find('.tab.segment[data-tab="' + $tabMenu.data('preview') + '"]'); - $previewSegment.html(data); - emojify.run($previewSegment[0]); - $('pre code', $previewSegment[0]).each(function (i, block) { + var $previewPanel = $form.find('.tab.segment[data-tab="' + $tabMenu.data('preview') + '"]'); + $previewPanel.html(data); + emojify.run($previewPanel[0]); + $('pre code', $previewPanel[0]).each(function (i, block) { hljs.highlightBlock(block); }); } @@ -45,10 +45,10 @@ function initEditPreviewTab($form) { "text": $form.find('.tab.segment[data-tab="' + $tabMenu.data('write') + '"] textarea').val() }, function (data) { - var $previewSegment = $form.find('.tab.segment[data-tab="' + $tabMenu.data('preview') + '"]'); - $previewSegment.html(data); - emojify.run($previewSegment[0]); - $('pre code', $previewSegment[0]).each(function (i, block) { + var $previewPanel = $form.find('.tab.segment[data-tab="' + $tabMenu.data('preview') + '"]'); + $previewPanel.html(data); + emojify.run($previewPanel[0]); + $('pre code', $previewPanel[0]).each(function (i, block) { hljs.highlightBlock(block); }); } @@ -68,9 +68,9 @@ function initEditDiffTab($form) { "content": $form.find('.tab.segment[data-tab="' + $tabMenu.data('write') + '"] textarea').val() }, function (data) { - var $diffPreviewSegment = $form.find('.tab.segment[data-tab="' + $tabMenu.data('diff') + '"]'); - $diffPreviewSegment.html(data); - emojify.run($diffPreviewSegment[0]); + var $diffPreviewPanel = $form.find('.tab.segment[data-tab="' + $tabMenu.data('diff') + '"]'); + $diffPreviewPanel.html(data); + emojify.run($diffPreviewPanel[0]); } ); }); @@ -96,9 +96,9 @@ function initCommentForm() { // Labels var $list = $('.ui.labels.list'); - var $no_select = $list.find('.no-select'); - var $label_menu = $('.select-label .menu'); - var has_label_update_action = $label_menu.data('action') == 'update'; + var $noSelect = $list.find('.no-select'); + var $labelMenu = $('.select-label .menu'); + var hasLabelUpdateAction = $labelMenu.data('action') == 'update'; function updateIssueMeta(url, action, id) { $.post(url, { @@ -108,41 +108,41 @@ function initCommentForm() { }); } - $label_menu.find('.item:not(.no-select)').click(function () { + $labelMenu.find('.item:not(.no-select)').click(function () { if ($(this).hasClass('checked')) { $(this).removeClass('checked'); $(this).find('.octicon').removeClass('octicon-check'); - if (has_label_update_action) { - updateIssueMeta($label_menu.data('update-url'), "detach", $(this).data('id')); + if (hasLabelUpdateAction) { + updateIssueMeta($labelMenu.data('update-url'), "detach", $(this).data('id')); } } else { $(this).addClass('checked'); $(this).find('.octicon').addClass('octicon-check'); - if (has_label_update_action) { - updateIssueMeta($label_menu.data('update-url'), "attach", $(this).data('id')); + if (hasLabelUpdateAction) { + updateIssueMeta($labelMenu.data('update-url'), "attach", $(this).data('id')); } } - var label_ids = ""; + var labelIds = ""; $(this).parent().find('.item').each(function () { if ($(this).hasClass('checked')) { - label_ids += $(this).data('id') + ","; + labelIds += $(this).data('id') + ","; $($(this).data('id-selector')).removeClass('hide'); } else { $($(this).data('id-selector')).addClass('hide'); } }); - if (label_ids.length == 0) { - $no_select.removeClass('hide'); + if (labelIds.length == 0) { + $noSelect.removeClass('hide'); } else { - $no_select.addClass('hide'); + $noSelect.addClass('hide'); } - $($(this).parent().data('id')).val(label_ids); + $($(this).parent().data('id')).val(labelIds); return false; }); - $label_menu.find('.no-select.item').click(function () { - if (has_label_update_action) { - updateIssueMeta($label_menu.data('update-url'), "clear", ''); + $labelMenu.find('.no-select.item').click(function () { + if (hasLabelUpdateAction) { + updateIssueMeta($labelMenu.data('update-url'), "clear", ''); } $(this).parent().find('.item').each(function () { @@ -153,14 +153,14 @@ function initCommentForm() { $list.find('.item').each(function () { $(this).addClass('hide'); }); - $no_select.removeClass('hide'); + $noSelect.removeClass('hide'); $($(this).parent().data('id')).val(''); }); function selectItem(select_id, input_id) { var $menu = $(select_id + ' .menu'); var $list = $('.ui' + select_id + '.list'); - var has_update_action = $menu.data('action') == 'update'; + var hasUpdateAction = $menu.data('action') == 'update'; $menu.find('.item:not(.no-select)').click(function () { $(this).parent().find('.item').each(function () { @@ -168,7 +168,7 @@ function initCommentForm() { }); $(this).addClass('selected active'); - if (has_update_action) { + if (hasUpdateAction) { updateIssueMeta($menu.data('update-url'), '', $(this).data('id')); } switch (input_id) { @@ -189,7 +189,7 @@ function initCommentForm() { $(this).removeClass('selected active') }); - if (has_update_action) { + if (hasUpdateAction) { updateIssueMeta($menu.data('update-url'), '', ''); } @@ -211,37 +211,37 @@ function initInstall() { // Database type change detection. $("#db_type").change(function () { - var sqlite_default = 'data/gogs.db'; - var tidb_default = 'data/gogs_tidb'; + var sqliteDefault = 'data/gogs.db'; + var tidbDefault = 'data/gogs_tidb'; - var db_type = $(this).val(); - if (db_type === "SQLite3" || db_type === "TiDB") { + var dbType = $(this).val(); + if (dbType === "SQLite3" || dbType === "TiDB") { $('#sql_settings').hide(); $('#pgsql_settings').hide(); $('#sqlite_settings').show(); - if (db_type === "SQLite3" && $('#db_path').val() == tidb_default) { - $('#db_path').val(sqlite_default); - } else if (db_type === "TiDB" && $('#db_path').val() == sqlite_default) { - $('#db_path').val(tidb_default); + if (dbType === "SQLite3" && $('#db_path').val() == tidbDefault) { + $('#db_path').val(sqliteDefault); + } else if (dbType === "TiDB" && $('#db_path').val() == sqliteDefault) { + $('#db_path').val(tidbDefault); } return; } - var mysql_default = '127.0.0.1:3306'; - var postgres_default = '127.0.0.1:5432'; + var mysqlDefault = '127.0.0.1:3306'; + var postgresDefault = '127.0.0.1:5432'; $('#sqlite_settings').hide(); $('#sql_settings').show(); - if (db_type === "PostgreSQL") { + if (dbType === "PostgreSQL") { $('#pgsql_settings').show(); - if ($('#db_host').val() == mysql_default) { - $('#db_host').val(postgres_default); + if ($('#db_host').val() == mysqlDefault) { + $('#db_host').val(postgresDefault); } } else { $('#pgsql_settings').hide(); - if ($('#db_host').val() == postgres_default) { - $('#db_host').val(mysql_default); + if ($('#db_host').val() == postgresDefault) { + $('#db_host').val(mysqlDefault); } } }); @@ -317,11 +317,11 @@ function initRepository() { // Options if ($('.repository.settings.options').length > 0) { $('#repo_name').keyup(function () { - var $prompt_span = $('#repo-name-change-prompt'); + var $prompt = $('#repo-name-change-prompt'); if ($(this).val().toString().toLowerCase() != $(this).data('repo-name').toString().toLowerCase()) { - $prompt_span.show(); + $prompt.show(); } else { - $prompt_span.hide(); + $prompt.hide(); } }); @@ -345,12 +345,12 @@ function initRepository() { // Labels if ($('.repository.labels').length > 0) { // Create label - var $new_label_panel = $('.new-label.segment'); + var $newLabelPanel = $('.new-label.segment'); $('.new-label.button').click(function () { - $new_label_panel.show(); + $newLabelPanel.show(); }); $('.new-label.segment .cancel').click(function () { - $new_label_panel.hide(); + $newLabelPanel.hide(); }); $('.color-picker').each(function () { @@ -400,32 +400,32 @@ function initRepository() { // Issues if ($('.repository.view.issue').length > 0) { // Edit issue title - var $issue_title = $('#issue-title'); - var $edit_input = $('#edit-title-input input'); + var $issueTitle = $('#issue-title'); + var $editInput = $('#edit-title-input input'); var editTitleToggle = function () { - $issue_title.toggle(); + $issueTitle.toggle(); $('.not-in-edit').toggle(); $('#edit-title-input').toggle(); $('.in-edit').toggle(); - $edit_input.focus(); + $editInput.focus(); return false; }; $('#edit-title').click(editTitleToggle); $('#cancel-edit-title').click(editTitleToggle); $('#save-edit-title').click(editTitleToggle).click(function () { - if ($edit_input.val().length == 0 || - $edit_input.val() == $issue_title.text()) { - $edit_input.val($issue_title.text()); + if ($editInput.val().length == 0 || + $editInput.val() == $issueTitle.text()) { + $editInput.val($issueTitle.text()); return false; } $.post($(this).data('update-url'), { "_csrf": csrf, - "title": $edit_input.val() + "title": $editInput.val() }, function (data) { - $edit_input.val(data.title); - $issue_title.text(data.title); + $editInput.val(data.title); + $issueTitle.text(data.title); }); return false; }); @@ -433,48 +433,48 @@ function initRepository() { // Edit issue or comment content $('.edit-content').click(function () { var $segment = $(this).parent().parent().parent().next(); - var $edit_content_zone = $segment.find('.edit-content-zone'); - var $render_content = $segment.find('.render-content'); - var $raw_content = $segment.find('.raw-content'); + var $editContentZone = $segment.find('.edit-content-zone'); + var $renderContent = $segment.find('.render-content'); + var $rawContent = $segment.find('.raw-content'); var $textarea; // Setup new form - if ($edit_content_zone.html().length == 0) { - $edit_content_zone.html($('#edit-content-form').html()); + if ($editContentZone.html().length == 0) { + $editContentZone.html($('#edit-content-form').html()); $textarea = $segment.find('textarea'); // Give new write/preview data-tab name to distinguish from others - var $edit_content_form = $edit_content_zone.find('.ui.comment.form'); - var $tabular_menu = $edit_content_form.find('.tabular.menu'); - $tabular_menu.attr('data-write', $edit_content_zone.data('write')); - $tabular_menu.attr('data-preview', $edit_content_zone.data('preview')); - $tabular_menu.find('.write.item').attr('data-tab', $edit_content_zone.data('write')); - $tabular_menu.find('.preview.item').attr('data-tab', $edit_content_zone.data('preview')); - $edit_content_form.find('.write.segment').attr('data-tab', $edit_content_zone.data('write')); - $edit_content_form.find('.preview.segment').attr('data-tab', $edit_content_zone.data('preview')); - - initCommentPreviewTab($edit_content_form); - - $edit_content_zone.find('.cancel.button').click(function () { - $render_content.show(); - $edit_content_zone.hide(); + var $editContentForm = $editContentZone.find('.ui.comment.form'); + var $tabMenu = $editContentForm.find('.tabular.menu'); + $tabMenu.attr('data-write', $editContentZone.data('write')); + $tabMenu.attr('data-preview', $editContentZone.data('preview')); + $tabMenu.find('.write.item').attr('data-tab', $editContentZone.data('write')); + $tabMenu.find('.preview.item').attr('data-tab', $editContentZone.data('preview')); + $editContentForm.find('.write.segment').attr('data-tab', $editContentZone.data('write')); + $editContentForm.find('.preview.segment').attr('data-tab', $editContentZone.data('preview')); + + initCommentPreviewTab($editContentForm); + + $editContentZone.find('.cancel.button').click(function () { + $renderContent.show(); + $editContentZone.hide(); }); - $edit_content_zone.find('.save.button').click(function () { - $render_content.show(); - $edit_content_zone.hide(); + $editContentZone.find('.save.button').click(function () { + $renderContent.show(); + $editContentZone.hide(); - $.post($edit_content_zone.data('update-url'), { + $.post($editContentZone.data('update-url'), { "_csrf": csrf, "content": $textarea.val(), - "context": $edit_content_zone.data('context') + "context": $editContentZone.data('context') }, function (data) { if (data.length == 0) { - $render_content.html($('#no-content').html()); + $renderContent.html($('#no-content').html()); } else { - $render_content.html(data.content); - emojify.run($render_content[0]); - $('pre code', $render_content[0]).each(function (i, block) { + $renderContent.html(data.content); + emojify.run($renderContent[0]); + $('pre code', $renderContent[0]).each(function (i, block) { hljs.highlightBlock(block); }); } @@ -485,10 +485,10 @@ function initRepository() { } // Show write/preview tab and copy raw content as needed - $edit_content_zone.show(); - $render_content.hide(); + $editContentZone.show(); + $renderContent.hide(); if ($textarea.val().length == 0) { - $textarea.val($raw_content.text()); + $textarea.val($rawContent.text()); } $textarea.focus(); return false; @@ -508,16 +508,16 @@ function initRepository() { }); // Change status - var $status_btn = $('#status-button'); + var $statusButton = $('#status-button'); $('#edit_area').keyup(function () { if ($(this).val().length == 0) { - $status_btn.text($status_btn.data('status')) + $statusButton.text($statusButton.data('status')) } else { - $status_btn.text($status_btn.data('status-and-comment')) + $statusButton.text($statusButton.data('status-and-comment')) } }); - $status_btn.click(function () { - $('#status').val($status_btn.data('status-val')); + $statusButton.click(function () { + $('#status').val($statusButton.data('status-val')); $('#comment-form').submit(); }); } @@ -564,7 +564,7 @@ function initRepository() { function initRepositoryCollaboration() { console.log('initRepositoryCollaboration'); -// Change collaborator access mode + // Change collaborator access mode $('.access-mode.menu .item').click(function () { var $menu = $(this).parent(); $.post($menu.data('url'), { @@ -576,19 +576,19 @@ function initRepositoryCollaboration() { } function initWikiForm() { - var $edit_area = $('.repository.wiki textarea#edit_area'); - if ($edit_area.length > 0) { + var $editArea = $('.repository.wiki textarea#edit_area'); + if ($editArea.length > 0) { new SimpleMDE({ autoDownloadFontAwesome: false, - element: $edit_area[0], + element: $editArea[0], forceSync: true, previewRender: function (plainText, preview) { // Async method setTimeout(function () { // FIXME: still send render request when return back to edit mode - $.post($edit_area.data('url'), { + $.post($editArea.data('url'), { "_csrf": csrf, "mode": "gfm", - "context": $edit_area.data('context'), + "context": $editArea.data('context'), "text": plainText }, function (data) { @@ -617,31 +617,13 @@ function initWikiForm() { } function initIssueForm() { - var $edit_area = $('.repository.issue textarea.edit_area'); - if ($edit_area.length > 0) { - $edit_area.each(function (i, edit_area) { + var $editArea = $('.repository.issue textarea.edit_area'); + if ($editArea.length > 0) { + $editArea.each(function (i, edit_area) { new SimpleMDE({ autoDownloadFontAwesome: false, element: edit_area[0], forceSync: true, - previewRender: function (plainText, preview) { // Async method - setTimeout(function () { - // FIXME: still send render request when return back to edit mode - $.post($edit_area.data('url'), { - "_csrf": csrf, - "mode": "gfm", - "context": $edit_area.data('context'), - "text": plainText - }, - function (data) { - preview.innerHTML = '