mirror of https://github.com/gogits/gogs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
12 KiB
1 line
12 KiB
9 years ago
|
"use strict";function initCommentPreviewTab(t){var e=t.find(".tabular.menu");e.find(".item").tab(),e.find('.item[data-tab="'+e.data("preview")+'"]').click(function(){var i=$(this);$.post(i.data("url"),{_csrf:csrf,mode:"gfm",context:i.data("context"),text:t.find('.tab.segment[data-tab="'+e.data("write")+'"] textarea').val()},function(i){var a=t.find('.tab.segment[data-tab="'+e.data("preview")+'"]');a.html(i),emojify.run(a[0])})}),buttonsClickOnEnter()}function initCommentForm(){function t(t,e,i){$.post(t,{_csrf:csrf,action:e,id:i})}function e(e,i){var a=$(e+" .menu"),n=$(".ui"+e+".list"),o="update"==a.data("action");a.find(".item:not(.no-select)").click(function(){switch($(this).parent().find(".item").each(function(){$(this).removeClass("selected active")}),$(this).addClass("selected active"),o&&t(a.data("update-url"),"",$(this).data("id")),i){case"#milestone_id":n.find(".selected").html('<a class="item" href='+$(this).data("href")+">"+$(this).text()+"</a>");break;case"#assignee_id":n.find(".selected").html('<a class="item" href='+$(this).data("href")+'><img class="ui avatar image" src='+$(this).data("avatar")+">"+$(this).text()+"</a>")}$(".ui"+e+".list .no-select").addClass("hide"),$(i).val($(this).data("id"))}),a.find(".no-select.item").click(function(){$(this).parent().find(".item:not(.no-select)").each(function(){$(this).removeClass("selected active")}),o&&t(a.data("update-url"),"",""),n.find(".selected").html(""),n.find(".no-select").removeClass("hide"),$(i).val("")})}if(0!=$(".comment.form").length){initCommentPreviewTab($(".comment.form"));var i=$(".ui.labels.list"),a=i.find(".no-select"),n=$(".select-label .menu"),o="update"==n.data("action");n.find(".item:not(.no-select)").click(function(){$(this).hasClass("checked")?($(this).removeClass("checked"),$(this).find(".octicon").removeClass("octicon-check"),o&&t(n.data("update-url"),"detach",$(this).data("id"))):($(this).addClass("checked"),$(this).find(".octicon").addClass("octicon-check"),o&&t(n.data("update-url"),"attach",$(this).data("id")));var e="";return $(this).parent().find(".item").each(function(){$(this).hasClass("checked")?(e+=$(this).data("id")+",",$($(this).data("id-selector")).removeClass("hide")):$($(this).data("id-selector")).addClass("hide")}),0==e.length?a.removeClass("hide"):a.addClass("hide"),$($(this).parent().data("id")).val(e),!1}),n.find(".no-select.item").click(function(){o&&t(n.data("update-url"),"clear",""),$(this).parent().find(".item").each(function(){$(this).removeClass("checked"),$(this).find(".octicon").removeClass("octicon-check")}),i.find(".item").each(function(){$(this).addClass("hide")}),a.removeClass("hide"),$($(this).parent().data("id")).val("")}),e(".select-milestone","#milestone_id"),e(".select-assignee","#assignee_id")}}function initInstall(){0!=$(".install").length&&($("#db_type").change(function(){var t="data/gogs.db",e="data/gogs_tidb",i=$(this).val();if("SQLite3"===i||"TiDB"===i)return $("#sql_settings").hide(),$("#pgsql_settings").hide(),$("#sqlite_settings").show(),void("SQLite3"===i&&$("#db_path").val()==e?$("#db_path").val(t):"TiDB"===i&&$("#db_path").val()==t&&$("#db_path").val(e));var a="127.0.0.1:3306",n="127.0.0.1:5432";$("#sqlite_settings").hide(),$("#sql_settings").show(),"PostgreSQL"===i?($("#pgsql_settings").show(),$("#db_host").val()==a&&$("#db_host").val(n)):($("#pgsql_settings").hide(),$("#db_host").val()==n&&$("#db_host").val(a))}),$("#offline-mode input").change(function(){$(this).is(":checked")&&$("#disable-gravatar").checkbox("check")}),$("#disable-registration input").change(function(){$(this).is(":checked")&&$("#enable-captcha").checkbox("uncheck")}),$("#enable-captcha input").change(function(){$(this).is(":checked")&&$("#disable-registration").checkbox("uncheck")}))}function initRepository(){if(0!=$(".repository").length){if($(".repository.settings.options").length>0&&$("#repo_name").keyup(function(){var t=$("#repo-name-change-prompt");$(this).val().toString().toLowerCase()!=$(this).data("repo-name").toString().toLowerCase()?t.show():t.hide()}),$(".repository.labels").length>0){var t=$(".new-label.seg
|