Просмотр исходного кода

Added directive element for the new checkboxes

Torkel Ödegaard 11 лет назад
Родитель
Сommit
4997068a0d
2 измененных файлов с 11 добавлено и 14 удалено
  1. 9 4
      src/app/directives/tip.js
  2. 2 10
      src/app/partials/share-panel.html

+ 9 - 4
src/app/directives/tip.js

@@ -20,13 +20,18 @@ function (angular, kbn) {
 
   angular
     .module('grafana.directives')
-    .directive('tip', function($compile) {
+    .directive('editorOptBool', function($compile) {
       return {
         restrict: 'E',
         link: function(scope, elem, attrs) {
-          var _t = '<i class="grafana-tip icon-'+(attrs.icon||'question-sign')+'" bs-tooltip="\''+
-            kbn.addslashes(elem.text())+'\'"></i>';
-          elem.replaceWith($compile(angular.element(_t))(scope));
+          var template = '<div class="editor-option text-center">' +
+                         ' <label for="' + attrs.name + '" class="small">' +
+                           attrs.text + '</label>' +
+                          '<input id="' + attrs.name + '" type="checkbox" ' +
+                          '       ng-model="' + attrs.model + '"' +
+                          '       ng-checked="' + attrs.model + '"></input>' +
+                          ' <label for="' + attrs.name + '" class="cr1"></label>';
+          elem.replaceWith($compile(angular.element(template))(scope));
         }
       };
     });

+ 2 - 10
src/app/partials/share-panel.html

@@ -16,16 +16,8 @@
 
 	<div class="modal-body">
 		<div class="editor-row">
-			<div class="editor-option text-center">
-				<label for="currentTime" class="small">Current time range</label>
-				<input id="currentTime" type="checkbox" ng-model="forCurrent" ng-checked="forCurrent"></input>
-				<label for="currentTime" class="cr1"></label>
-			</div>
-			<div class="editor-option text-center">
-				<label for="toPanel" class="small">To fullscreen panel</label>
-				<input id="toPanel" type="checkbox" ng-model="toPanel" ng-checked="toPanel"></input>
-				<label for="toPanel" class="cr1"></label>
-			</div>
+			<editor-opt-bool name="currentTime" text="Current time range" model="forCurrent"></editor-opt-bool>
+			<editor-opt-bool name="toPanel" text="To this panel only" model="toPanel"></editor-opt-bool>
 		</div>
 
 		<div class="editor-row" style="margin-top: 20px;">