瀏覽代碼

Changed style for logged in user and updated jQuery plugin to fit the others

Enrico Berti 13 年之前
父節點
當前提交
88dc7ef19a

+ 18 - 3
desktop/core/src/desktop/templates/common_header.mako

@@ -27,7 +27,7 @@ from desktop.lib.i18n import smart_unicode
   <meta name="author" content="">
 
   <link href="/static/ext/css/bootstrap.min.css" rel="stylesheet">
-  <link href="/static/css/jhue.css" rel="stylesheet">
+  <link href="/static/css/hue2.css" rel="stylesheet">
   <link href="/static/ext/css/fileuploader.css" rel="stylesheet">
 
   <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
@@ -55,7 +55,11 @@ from desktop.lib.i18n import smart_unicode
 
   <script type="text/javascript" charset="utf-8">
     $(document).ready(function(){
-      $(".navbar .nav-username").showUsername();
+      $("#username").jHueUsername({
+		onLoad: function(user){
+			$(".userProfile").attr("href","/useradmin/users/edit/"+user.username);
+		}
+	  });
       $("input:text[placeholder]").simplePlaceholder();
       $(".submitter").keydown(function(e){
         if (e.keyCode==13){
@@ -84,6 +88,18 @@ from desktop.lib.i18n import smart_unicode
     <div class="navbar-inner">
       <div class="container-fluid">
         <a class="brand nav-tooltip" title="About Hue" href="/about">Hue</a>
+		<div class="btn-group pull-right">
+          <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
+            <i class="icon-user"></i> <span id="username"></span>
+            <span class="caret"></span>
+          </a>
+          <ul class="dropdown-menu">
+            <li><a class="userProfile" href="#">Profile</a></li>
+            <li class="divider"></li>
+            <li><a href="/accounts/logout/">Sign Out</a></li>
+          </ul>
+        </div>
+
         <div class="nav-collapse">
           <ul class="nav">
             %for app in apps:
@@ -97,7 +113,6 @@ from desktop.lib.i18n import smart_unicode
             <li class="divider-vertical"></li>
             <li id="checkConfig"></li>
           </ul>
-          <p class="navbar-text pull-right">Logged in as <strong><span class="nav-username">&nbsp;</span></strong> - <a href="/accounts/logout/">Sign out</a></p>
         </div>
       </div>
     </div>

+ 4 - 12
desktop/core/static/css/jhue.css → desktop/core/static/css/hue2.css

@@ -1,3 +1,7 @@
+.navbar .brand {
+    color: #FFFFFF;
+}
+    
 .subnav {
     background-color: #EEEEEE;
     background-image: -moz-linear-gradient(center top , #F5F5F5 0%, #EEEEEE 100%);
@@ -120,18 +124,6 @@
     text-decoration: none;
 }
 
-.navbar .pull-right {
-	color:#e5e5e5;
-}
-
-.navbar .pull-right a {
-	font-weight:bold;
-    color:#e5e5e5;
-}
-
-.navbar .pull-right a:hover {
-    color:#ffffff;
-}
 
 h1 {
     margin-bottom:.7em;

File diff suppressed because it is too large
+ 8 - 689
desktop/core/static/ext/css/bootstrap.min.css


+ 47 - 18
desktop/core/static/js/Source/jHue/jquery.showusername.js

@@ -20,25 +20,54 @@ script: jquery.showusername.js
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
-;(function($) {
-	$.fn.showUsername = function(){
-		return this.each(function(){
-			var elem = $(this);
-			if (elem.data("user")!=null && elem.data("user")["username"]){
-				elem.text(elem.data("user")["username"]);
+;(function ($, window, document, undefined) {
+
+	var pluginName = "jHueUsername",
+	defaults = {
+		onLoad: function(){}
+	};
+
+	function Plugin(element, options) {
+		this.element = element;
+		this.options = $.extend({}, defaults, options) ;
+		this._defaults = defaults;
+		this._name = pluginName;
+		this.init();
+	}
+	
+	Plugin.prototype.setOptions = function(options) {
+		this.options = $.extend({}, defaults, options) ;
+	};
+
+	Plugin.prototype.init = function () {
+        var _this = this;
+        var elem = $(_this.element);
+        if (elem.data("user")!=null && elem.data("user")["username"]){
+            elem.text(elem.data("user")["username"]);
+        }
+        else {
+            $.post(
+                "/profile", function(user){
+                    // sets a user field value the 
+                    elem.data("user", user);
+                    elem.text(elem.data("user")["username"]);
+                    _this.options.onLoad(user);
+                }, "json").error(function(e){
+                    // we get an error when the user is not logged in
+                    elem.data("user", null);
+            });
+        }
+	};
+
+	$.fn[pluginName] = function (options) {
+		return this.each(function () {
+			if (!$.data(this, 'plugin_' + pluginName)) {
+				$.data(this, 'plugin_' + pluginName, new Plugin( this, options));
 			}
 			else {
-				$.post(
-					"/profile", function(user){
-						// sets a user field value the 
-						elem.data("user", user);
-						elem.text(elem.data("user")["username"]);
-					}, "json").error(function(e){
-						// we get an error when the user is not logged in
-						elem.data("user", null);
-				});
+				$.data(this, 'plugin_' + pluginName).setOptions(options);
 			}
 		});
-	};
-	
-})(jQuery);
+	}
+
+})(jQuery, window, document );

Some files were not shown because too many files changed in this diff