From 5acc948562547b393ba1e89b012e7421143c6dd8 Mon Sep 17 00:00:00 2001
From: Unknwon <joe2010xtmf@163.com>
Date: Thu, 14 Aug 2014 14:12:21 +0800
Subject: Page: `/org/:orgname/settings`

---
 public/ng/css/gogs.css            |  6 +++
 public/ng/js/gogs.js              | 80 ++++++++++++++++++++++++---------------
 public/ng/less/gogs/settings.less |  1 +
 3 files changed, 56 insertions(+), 31 deletions(-)

(limited to 'public')

diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css
index e69e4b66..93a5d2f8 100644
--- a/public/ng/css/gogs.css
+++ b/public/ng/css/gogs.css
@@ -1348,26 +1348,32 @@ The register and sign-in page style
 .setting-content {
   margin-left: 32px;
 }
+#org-setting-form,
 #repo-setting-form,
 #user-profile-form {
   background-color: #FFF;
   padding: 30px 0;
 }
+#org-setting-form textarea,
 #repo-setting-form textarea,
 #user-profile-form textarea {
   margin-left: 4px;
   height: 100px;
 }
+#org-setting-form label,
 #repo-setting-form label,
 #user-profile-form label,
+#org-setting-form .form-label,
 #repo-setting-form .form-label,
 #user-profile-form .form-label {
   width: 240px;
 }
+#org-setting-form .ipt,
 #repo-setting-form .ipt,
 #user-profile-form .ipt {
   width: 360px;
 }
+#org-setting-form .field,
 #repo-setting-form .field,
 #user-profile-form .field {
   margin-bottom: 24px;
diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js
index 473997e9..ad8df997 100644
--- a/public/ng/js/gogs.js
+++ b/public/ng/js/gogs.js
@@ -225,6 +225,30 @@ function initCore() {
     Gogs.renderCodeView();
 }
 
+function initUserSetting() {
+    // Confirmation of change username in user profile page.
+    $('#user-profile-form').submit(function (e) {
+        var $username = $('#username');
+        if (($username.data('uname') != $username.val()) && !confirm('Username has been changed, do you want to continue?')) {
+            e.preventDefault();
+            return true;
+        }
+    });
+
+    // Show add SSH key panel.
+    $('#ssh-add').click(function () {
+        $('#user-ssh-add-form').removeClass("hide");
+    });
+
+    // Confirmation of delete account.
+    $('#delete-account-button').click(function (e) {
+        if (!confirm('This account is going to be deleted, do you want to continue?')) {
+            e.preventDefault();
+            return true;
+        }
+    });
+}
+
 function initRepoCreate() {
     // Owner switch menu click.
     $('#repo-create-owner-list').on('click', 'li', function () {
@@ -286,21 +310,43 @@ function initRepoSetting() {
     });
 }
 
+function initOrgSetting() {
+    // Options.
+    // Confirmation of changing organization name.
+    $('#org-setting-form').submit(function (e) {
+        var $orgname = $('#orgname');
+        if (($orgname.data('orgname') != $orgname.val()) && !confirm('Organization name has been changed, do you want to continue?')) {
+            e.preventDefault();
+            return true;
+        }
+    });
+    // Confirmation of delete organization.
+    $('#delete-org-button').click(function (e) {
+        if (!confirm('This organization is going to be deleted, do you want to continue?')) {
+            e.preventDefault();
+            return true;
+        }
+    });
+}
+
 $(document).ready(function () {
     initCore();
+    if ($('#user-profile-setting').length) {
+        initUserSetting();
+    }
     if ($('#repo-create-form').length || $('#repo-migrate-form').length) {
         initRepoCreate();
     }
     if ($('#repo-setting').length) {
         initRepoSetting();
     }
+    if ($('#org-setting').length) {
+        initOrgSetting();
+    }
 
     Tabs('#dashboard-sidebar-menu');
 
     homepage();
-    settingsProfile();
-    settingsSSHKeys();
-    settingsDelete();
 
     // Fix language drop-down menu height.
     var l = $('#footer-lang li').length;
@@ -328,32 +374,4 @@ function homepage() {
         }
         $('#promo-form').attr('action', '/user/sign_up');
     });
-}
-
-function settingsProfile() {
-    // Confirmation of change username in user profile page.
-    $('#user-profile-form').submit(function (e) {
-        var $username = $('#username');
-        if (($username.data('uname') != $username.val()) && !confirm('Username has been changed, do you want to continue?')) {
-            e.preventDefault();
-            return true;
-        }
-    });
-}
-
-function settingsSSHKeys() {
-    // Show add SSH key panel.
-    $('#ssh-add').click(function () {
-        $('#user-ssh-add-form').removeClass("hide");
-    });
-}
-
-function settingsDelete() {
-    // Confirmation of delete account.
-    $('#delete-account-button').click(function (e) {
-        if (!confirm('This account is going to deleted, do you want to continue?')) {
-            e.preventDefault();
-            return true;
-        }
-    });
 }
\ No newline at end of file
diff --git a/public/ng/less/gogs/settings.less b/public/ng/less/gogs/settings.less
index 1a492b03..ad50e4ff 100644
--- a/public/ng/less/gogs/settings.less
+++ b/public/ng/less/gogs/settings.less
@@ -31,6 +31,7 @@
   margin-left: 32px;
 }
 
+#org-setting-form,
 #repo-setting-form,
 #user-profile-form {
     background-color: #FFF;
-- 
cgit v1.2.3