浏览代码

Use ng-options instead of options element in FixedProfile.

FelisCatus 8 年之前
父节点
当前提交
788bfe7d4e
共有 2 个文件被更改,包括 19 次插入8 次删除
  1. 17 1
      omega-web/src/omega/controllers/fixed_profile.coffee
  2. 2 7
      omega-web/src/partials/profile_fixed.jade

+ 17 - 1
omega-web/src/omega/controllers/fixed_profile.coffee

@@ -1,4 +1,5 @@
-angular.module('omega').controller 'FixedProfileCtrl', ($scope, $modal) ->
+angular.module('omega').controller 'FixedProfileCtrl', ($scope, $modal,
+  trFilter) ->
   $scope.urlSchemes = ['', 'http', 'https', 'ftp']
   $scope.urlSchemeDefault = 'fallbackProxy'
   proxyProperties =
@@ -20,6 +21,21 @@ angular.module('omega').controller 'FixedProfileCtrl', ($scope, $modal) ->
 
   $scope.showAdvanced = false
 
+  $scope.optionsForScheme = {}
+  for scheme in $scope.urlSchemes
+    defaultLabel =
+      if scheme
+        trFilter('options_protocol_useDefault')
+      else
+        trFilter('options_protocol_direct')
+    $scope.optionsForScheme[scheme] = [
+      {label: defaultLabel, value: undefined},
+      {label: 'HTTP', value: 'http'},
+      {label: 'HTTPS', value: 'https'},
+      {label: 'SOCKS4', value: 'socks4'},
+      {label: 'SOCKS5', value: 'socks5'},
+    ]
+
   $scope.proxyEditors = {}
 
   $scope.authSupported = {"http": true, "https": true}

+ 2 - 7
omega-web/src/partials/profile_fixed.jade

@@ -14,13 +14,8 @@ div(ng-controller='FixedProfileCtrl')
           tr(ng-repeat='scheme in urlSchemes' ng-show='scheme == "" || showAdvanced')
             td {{schemeDisp[scheme] || ('options_scheme_default' | tr)}}
             td
-              select.form-control(ng-model='proxyEditors[scheme].scheme')
-                option(value='')
-                  | {{(scheme ? 'options_protocol_useDefault' : 'options_protocol_direct') | tr}}
-                option(value='http') HTTP
-                option(value='https') HTTPS
-                option(value='socks4') SOCKS4
-                option(value='socks5') SOCKS5
+              select.form-control(ng-model='proxyEditors[scheme].scheme'
+                ng-options='opt.value as opt.label for opt in optionsForScheme[scheme]')
             td(ng-if='proxyEditors[scheme].scheme')
               input.form-control(type='text' ng-model='proxyEditors[scheme].host' required)
             td(ng-if='!proxyEditors[scheme].scheme')