Browse Source

refactor: moved array join directive to typecrtipt

Torkel Ödegaard 10 years ago
parent
commit
812e4c7cd4

+ 1 - 1
public/app/core/core.ts

@@ -1,5 +1,5 @@
 
 
-export * from './directives/cool_dir'
+export * from './directives/array_join'
 export * from './routes/module_loader'
 export * from './routes/module_loader'
 export * from './filters/filters'
 export * from './filters/filters'
 
 

+ 32 - 0
public/app/core/directives/array_join.ts

@@ -0,0 +1,32 @@
+///<reference path="../../headers/common.d.ts" />
+
+import angular = require('angular');
+import _ = require('lodash');
+
+export function ArrayJoin()
+{
+  return {
+    restrict: 'A',
+    require: 'ngModel',
+    link: function(scope, element, attr, ngModel) {
+
+      function split_array(text) {
+        return (text || '').split(',');
+      }
+
+      function join_array(text) {
+        if(_.isArray(text)) {
+          return (text || '').join(',');
+        } else {
+          return text;
+        }
+      }
+
+      ngModel.$parsers.push(split_array);
+      ngModel.$formatters.push(join_array);
+    }
+  };
+}
+
+angular.module('grafana.directives').directive('arrayJoin', ArrayJoin);
+

+ 0 - 7
public/app/core/directives/cool_dir.ts

@@ -1,7 +0,0 @@
-
-export class CoolDir {
-  getName() : string {
-    return "CoolDir";
-  }
-}
-

+ 0 - 1
public/app/directives/all.js

@@ -1,5 +1,4 @@
 define([
 define([
-  './arrayJoin',
   './dashUpload',
   './dashUpload',
   './grafanaSimplePanel',
   './grafanaSimplePanel',
   './dashEditLink',
   './dashEditLink',

+ 0 - 35
public/app/directives/arrayJoin.js

@@ -1,35 +0,0 @@
-define([
-  'angular',
-  'app',
-  'lodash'
-],
-function (angular, app, _) {
-  'use strict';
-
-  angular
-    .module('grafana.directives')
-    .directive('arrayJoin', function() {
-      return {
-        restrict: 'A',
-        require: 'ngModel',
-        link: function(scope, element, attr, ngModel) {
-
-          function split_array(text) {
-            return (text || '').split(',');
-          }
-
-          function join_array(text) {
-            if(_.isArray(text)) {
-              return (text || '').join(',');
-            } else {
-              return text;
-            }
-          }
-
-          ngModel.$parsers.push(split_array);
-          ngModel.$formatters.push(join_array);
-        }
-      };
-    });
-
-});