diff --git a/.jshintrc b/.jshintrc
index 1cc7b688..d21b03ef 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -1,5 +1,5 @@
{
- "strict": true,
+ "globalstrict": true,
"curly": true,
"eqeqeq": true,
"immed": true,
diff --git a/Gruntfile.js b/Gruntfile.js
index f2a6c74e..c3d4b146 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -15,6 +15,10 @@ module.exports = function(grunt) {
out: 'build/<%= pkg.name %>.css',
outMin: 'tmp/<%= pkg.name %>.min.css'
},
+ html: {
+ src: ['templates/tags-input.html', 'templates/auto-complete.html'],
+ out: 'tmp/templates.js'
+ },
zip: {
unminified: 'build/<%= pkg.name %>.zip',
minified: 'build/<%= pkg.name %>.min.zip'
@@ -45,6 +49,23 @@ module.exports = function(grunt) {
build: ['build/'],
tmp: ['tmp/']
},
+ // Compiles the HTML templates into a Javascript file
+ ngtemplates: {
+ 'tags-input': {
+ files: {
+ '<%= files.html.out %>': ['<%= files.html.src %>']
+ },
+ options: {
+ url: function(url) {
+ return 'ngTagsInput/' + url.replace('templates/', '');
+ },
+ htmlmin: {
+ collapseWhitespace: true,
+ removeRedundantAttributes: true
+ }
+ }
+ }
+ },
// Concatenates all source files into one JS file and one CSS file
concat: {
js: {
@@ -52,15 +73,14 @@ module.exports = function(grunt) {
banner: '(function() {\n\'use strict\';\n\n',
footer: '\n}());',
process: function(src) {
- // Remove all (function() {'use strict'; and }()) from the code and
+ // Remove all 'use strict'; from the code and
// replaces all double blank lines with one
- return src.replace(/\(function\(\) \{\n'use strict';\n\s*/g, '')
- .replace(/\n\}\(\)\);/g, '')
+ return src.replace(/'use strict';\n/g, '')
.replace(/\n\n\s*\n/g, '\n\n');
}
},
files: {
- '<%= files.js.out %>': ['<%= files.js.src %>']
+ '<%= files.js.out %>': ['<%= files.js.src %>', '<%= files.html.out %>']
}
},
css: {
@@ -140,6 +160,7 @@ module.exports = function(grunt) {
'jshint',
'karma',
'clean',
+ 'ngtemplates',
'concat',
'ngAnnotate',
'uglify',
diff --git a/build/ng-tags-input.js b/build/ng-tags-input.js
index d97f933b..82045878 100644
--- a/build/ng-tags-input.js
+++ b/build/ng-tags-input.js
@@ -68,23 +68,7 @@ angular.module('tags-input').directive('tagsInput', ["$timeout","$document","con
},
replace: false,
transclude: true,
- template: '
',
+ templateUrl: 'ngTagsInput/tags-input.html',
controller: ["$scope","$attrs","$element", function($scope, $attrs, $element) {
var events = new SimplePubSub(),
shouldRemoveLastTag;
@@ -356,15 +340,7 @@ angular.module('tags-input').directive('autoComplete', ["$document","$timeout","
restrict: 'E',
require: '?^tagsInput',
scope: { source: '&' },
- template: '',
+ templateUrl: 'ngTagsInput/auto-complete.html',
link: function(scope, element, attrs, tagsInputCtrl) {
var hotkeys = [KEYS.enter, KEYS.tab, KEYS.escape, KEYS.up, KEYS.down],
suggestionList, tagsInput, highlight;
@@ -474,6 +450,7 @@ angular.module('tags-input').directive('autoComplete', ["$document","$timeout","
}
};
}]);
+(function() {
/**
* @ngdoc directive
@@ -490,6 +467,9 @@ angular.module('tags-input').directive('transcludeAppend', function() {
};
});
+}());
+(function() {
+
/**
* @ngdoc service
* @name tagsInput.service:configuration
@@ -516,5 +496,18 @@ angular.module('tags-input').service('configuration', ["$interpolate", function(
};
}]);
+}());
+
+angular.module('tags-input').run(['$templateCache', function($templateCache) {
+
+ $templateCache.put('ngTagsInput/tags-input.html',
+ ""
+ );
+
+ $templateCache.put('ngTagsInput/auto-complete.html',
+ ""
+ );
+
+}]);
}());
\ No newline at end of file
diff --git a/build/ng-tags-input.min.zip b/build/ng-tags-input.min.zip
index ea009b44..d4d8b298 100644
Binary files a/build/ng-tags-input.min.zip and b/build/ng-tags-input.min.zip differ
diff --git a/build/ng-tags-input.zip b/build/ng-tags-input.zip
index ae14e629..a7dc5eb7 100644
Binary files a/build/ng-tags-input.zip and b/build/ng-tags-input.zip differ
diff --git a/karma.conf.js b/karma.conf.js
index 245d5a42..aa3c71d1 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -21,9 +21,19 @@ module.exports = function(config) {
'src/tags-input.js',
'src/auto-complete.js',
'src/transclude-append.js',
- 'src/configuration.js'
+ 'src/configuration.js',
+ 'templates/*.html'
],
+ preprocessors: {
+ 'templates/*.html': ['ng-html2js']
+ },
+
+ ngHtml2JsPreprocessor: {
+ stripPrefix: 'templates/',
+ prependPrefix: 'ngTagsInput/',
+ moduleName: 'tags-input'
+ },
// list of files to exclude
exclude: [
diff --git a/package.json b/package.json
index efc5af73..9337a139 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,9 @@
"grunt-contrib-clean": "=0.5.0",
"grunt-contrib-concat": "=0.3.0",
"grunt-ng-annotate": "=0.0.4",
+ "grunt-angular-templates": "=0.5.0",
"grunt-karma": "=0.6.2",
+ "karma-ng-html2js-preprocessor": "=0.1.0",
"load-grunt-tasks": "=0.2.0"
}
}
diff --git a/src/auto-complete.js b/src/auto-complete.js
index 991989c3..111f0fec 100644
--- a/src/auto-complete.js
+++ b/src/auto-complete.js
@@ -1,4 +1,3 @@
-(function() {
'use strict';
/**
@@ -93,15 +92,7 @@ angular.module('tags-input').directive('autoComplete', function($document, $time
restrict: 'E',
require: '?^tagsInput',
scope: { source: '&' },
- template: '',
+ templateUrl: 'ngTagsInput/auto-complete.html',
link: function(scope, element, attrs, tagsInputCtrl) {
var hotkeys = [KEYS.enter, KEYS.tab, KEYS.escape, KEYS.up, KEYS.down],
suggestionList, tagsInput, highlight;
@@ -210,6 +201,4 @@ angular.module('tags-input').directive('autoComplete', function($document, $time
});
}
};
-});
-
-}());
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/src/keycodes.js b/src/keycodes.js
index 09d7d9f8..18748376 100644
--- a/src/keycodes.js
+++ b/src/keycodes.js
@@ -7,4 +7,4 @@ var KEYS = {
up: 38,
down: 40,
comma: 188
-};
+};
\ No newline at end of file
diff --git a/src/tags-input.js b/src/tags-input.js
index cc32cf3b..b22dd1c5 100644
--- a/src/tags-input.js
+++ b/src/tags-input.js
@@ -1,4 +1,3 @@
-(function() {
'use strict';
angular.module('tags-input', []);
@@ -57,23 +56,7 @@ angular.module('tags-input').directive('tagsInput', function($timeout, $document
},
replace: false,
transclude: true,
- template: '',
+ templateUrl: 'ngTagsInput/tags-input.html',
controller: function($scope, $attrs, $element) {
var events = new SimplePubSub(),
shouldRemoveLastTag;
@@ -251,6 +234,4 @@ angular.module('tags-input').directive('tagsInput', function($timeout, $document
});
}
};
-});
-
-}());
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/templates/auto-complete.html b/templates/auto-complete.html
new file mode 100644
index 00000000..de2cb598
--- /dev/null
+++ b/templates/auto-complete.html
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/templates/tags-input.html b/templates/tags-input.html
new file mode 100644
index 00000000..bd44ba4f
--- /dev/null
+++ b/templates/tags-input.html
@@ -0,0 +1,17 @@
+
\ No newline at end of file
diff --git a/test/auto-complete.spec.js b/test/auto-complete.spec.js
index 21fc1fa2..8a11cdfb 100644
--- a/test/auto-complete.spec.js
+++ b/test/auto-complete.spec.js
@@ -1,4 +1,3 @@
-(function() {
'use strict';
describe('autocomplete-directive', function() {
@@ -37,8 +36,9 @@ describe('autocomplete-directive', function() {
};
parent = $compile('')($scope);
- parentCtrl = parent.controller('tagsInput');
+ $scope.$digest();
+ parentCtrl = parent.controller('tagsInput');
spyOn(parentCtrl, 'registerAutocomplete').andReturn(tagsInput);
options = jQuery.makeArray(arguments).join(' ');
@@ -726,5 +726,3 @@ describe('autocomplete-directive', function() {
});
});
});
-
-})();
diff --git a/test/tags-input.spec.js b/test/tags-input.spec.js
index f99bb648..c9246a76 100644
--- a/test/tags-input.spec.js
+++ b/test/tags-input.spec.js
@@ -1,4 +1,3 @@
-(function() {
'use strict';
describe('tags-input-directive', function() {
@@ -21,8 +20,8 @@ describe('tags-input-directive', function() {
var template = '';
element = $compile(template)($scope);
- isolateScope = element.isolateScope();
$scope.$digest();
+ isolateScope = element.isolateScope();
}
function getTags() {
@@ -965,6 +964,4 @@ describe('tags-input-directive', function() {
expect(autocompleteObj.getTags()).toEqual(['a', 'b', 'c']);
});
});
-});
-
-}());
+});
\ No newline at end of file
diff --git a/test/transclude-append.spec.js b/test/transclude-append.spec.js
index 48b3b22b..439739cb 100644
--- a/test/transclude-append.spec.js
+++ b/test/transclude-append.spec.js
@@ -1,4 +1,3 @@
-(function() {
'use strict';
describe('transclude-append-directive', function () {
@@ -55,7 +54,4 @@ describe('transclude-append-directive', function () {
var content = $.map(element.find('p'), function(e) { return $(e).html(); });
expect(content).toEqual(['existing content', 'transcluded content']);
});
-});
-
-
-}());
+});
\ No newline at end of file