From efa039a0f75ff9ba9376af1cbd3d948752c074fc Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Mon, 10 Mar 2014 21:12:49 +0800
Subject: finish ssh key pages ui

---
 public/js/app.js | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

(limited to 'public/js')

diff --git a/public/js/app.js b/public/js/app.js
index 59d52109..f6e14712 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -30,7 +30,8 @@ var Gogits = {
             return;
         }
         $.each(modals, function (i, item) {
-            $(item).modal("hide");
+            var hide = $(item).data('modal');
+            $(item).modal(hide ? hide : "hide");
         });
     };
     Gogits.initTooltips = function () {
@@ -39,6 +40,30 @@ var Gogits = {
             //container: "body"
         });
     };
+    Gogits.initTabs = function () {
+        var $tabs = $('[data-toggle=tab]');
+        $tabs.tab("show");
+        $tabs.find("li:eq(" + index + ") a").tab("show");
+    }
+})(jQuery);
+
+// ajax utils
+(function ($) {
+    Gogits.ajaxDelete = function (url, data, success) {
+        data = data || {};
+        data._method = "DELETE";
+        $.ajax({
+            url: url,
+            data: data,
+            method: "POST",
+            dataType: "json",
+            success: function (json) {
+                if (success) {
+                    success(json);
+                }
+            }
+        })
+    }
 })(jQuery);
 
 
@@ -72,4 +97,18 @@ function initRegister() {
             }
         });
     });
+}
+
+function initUserSetting(){
+    $('#gogs-ssh-keys').on("click",".delete",function(){
+        var $this = $(this);
+        Gogits.ajaxDelete("",{"id":$this.data("del")},function(json){
+            if(json.ok){
+                $this.parent().remove();
+            }else{
+                alert(json.err);
+            }
+        });
+        return false;
+    });
 }
\ No newline at end of file
-- 
cgit v1.2.3