Robert Marshall 9 jaren geleden
bovenliggende
commit
b1f3de3c15
3 gewijzigde bestanden met toevoegingen van 19 en 11 verwijderingen
  1. 4 11
      View/Status/index.view
  2. 14 0
      scripts/directives/equalHeightWidth.js
  3. 1 0
      template.php

+ 4 - 11
View/Status/index.view

@@ -14,13 +14,6 @@
 		margin:5px;
 	}
 }@
-@JavaScript{
-	$(function(){
-		$("button").each(function(e){
-			$(this).width($(this).height())
-		});
-	});
-}@
 @Body{
 <div ng-controller="status">
 	<div ng-if="haveUptime">
@@ -30,9 +23,9 @@
 	<div ng-if="haveSystemInfo">
 		<h3>Load</h3>
 		<div class="refreshControl">
-			<button ng-click="systemInfoRefreshInterval = systemInfoRefreshInterval - 1">-</button>
+			<button ng-click="systemInfoRefreshInterval = systemInfoRefreshInterval - 1" equal-width>-</button>
 			<input type="number" ng-model="systemInfoRefreshInterval" min="1" />
-			<button ng-click="systemInfoRefreshInterval = systemInfoRefreshInterval + 1">+</button>
+			<button ng-click="systemInfoRefreshInterval = systemInfoRefreshInterval + 1" equal-width>+</button>
 		</div>
 		<table class="alternatingRows">
 			<tr><td>1 min avg</td><td>{{load[0] * 100| number: 0}}% ({{(load[0] / 4)*100 | number: 0}}% core avg)<div class="percentageBar"><div style="width:{{(load[0] / 4) * 100}}%"></div></td></tr>
@@ -51,9 +44,9 @@
 	<div ng-if="haveProcesses">
 		<h3>Process List</h3>
 		<div class="refreshControl">
-			<button ng-click="processRefreshInterval = processRefreshInterval - 1">-</button>
+			<button ng-click="processRefreshInterval = processRefreshInterval - 1" equal-width>-</button>
 			<input type="number" ng-model="processRefreshInterval" min="1" />
-			<button ng-click="processRefreshInterval = processRefreshInterval + 1">+</button>
+			<button ng-click="processRefreshInterval = processRefreshInterval + 1" equal-width>+</button>
 		</div>
 		<table id="processTable" class="alternatingRows">
 			<tr>

+ 14 - 0
scripts/directives/equalHeightWidth.js

@@ -0,0 +1,14 @@
+app.directive("equalWidth", function() {
+	return {
+		restrict: 'A',
+		link: function(scope, element) {
+			scope.getHeight = function() {
+				return $(element).height();
+			};
+			scope.$watch(scope.getHeight, function(height) {
+				$(element).width(height);
+			});
+		}
+	}
+});
+

+ 1 - 0
template.php

@@ -1,6 +1,7 @@
 <?php
 $this->RegisterJSFile("javascript.js");
 $this->RegisterJSFile("controllers/main.js");
+$this->RegisterJSFile("directives/equalHeightWidth.js");
 
 function FormatURI(URI $uri, $base=""){
 	$image=$uri->GetImage();