Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
chore(minification): Replaced angular.module calls
Browse files Browse the repository at this point in the history
Replaced angular.module('tags-input') calls with a shared variable so
they can be properly minified during build.

Closes #27.
  • Loading branch information
mbenford committed Dec 7, 2013
1 parent 5e2bf29 commit 503d380
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 25 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"jasmine": true,
"spyOn": true,
"require": true,
"tagsInput": true,
"KEYS": true
}
}
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ module.exports = function(grunt) {
url: function(url) {
return 'ngTagsInput/' + url.replace('templates/', '');
},
bootstrap: function(module, script) {
return 'tagsInput.run(function($templateCache) {\n' + script + '});\n';
},
htmlmin: {
collapseWhitespace: true,
removeRedundantAttributes: true
Expand Down
19 changes: 6 additions & 13 deletions build/ng-tags-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var KEYS = {
comma: 188
};

angular.module('tags-input', []);
var tagsInput = angular.module('tags-input', []);

/**
* @ngdoc directive
Expand Down Expand Up @@ -40,7 +40,7 @@ angular.module('tags-input', []);
* @param {expression} onTagAdded Expression to evaluate upon adding a new tag. The new tag is available as $tag.
* @param {expression} onTagRemoved Expression to evaluate upon removing an existing tag. The removed tag is available as $tag.
*/
angular.module('tags-input').directive('tagsInput', ["$timeout","$document","configuration", function($timeout, $document, configuration) {
tagsInput.directive('tagsInput', ["$timeout","$document","configuration", function($timeout, $document, configuration) {
function SimplePubSub() {
var events = {};

Expand Down Expand Up @@ -265,7 +265,7 @@ angular.module('tags-input').directive('tagsInput', ["$timeout","$document","con
* suggestions list.
* @param {number=} [maxResultsToShow=10] Maximum number of results to be displayed at a time.
*/
angular.module('tags-input').directive('autoComplete', ["$document","$timeout","$sce","configuration", function($document, $timeout, $sce, configuration) {
tagsInput.directive('autoComplete', ["$document","$timeout","$sce","configuration", function($document, $timeout, $sce, configuration) {
function SuggestionList(loadFn, options) {
var self = {}, debouncedLoadId, getDifference;

Expand Down Expand Up @@ -450,7 +450,6 @@ angular.module('tags-input').directive('autoComplete', ["$document","$timeout","
}
};
}]);
(function() {

/**
* @ngdoc directive
Expand All @@ -459,25 +458,22 @@ angular.module('tags-input').directive('autoComplete', ["$document","$timeout","
* @description
* Re-creates the old behavior of ng-transclude.
*/
angular.module('tags-input').directive('transcludeAppend', function() {
tagsInput.directive('transcludeAppend', function() {
return function(scope, element, attrs, ctrl, transcludeFn) {
transcludeFn(function(clone) {
element.append(clone);
});
};
});

}());
(function() {

/**
* @ngdoc service
* @name tagsInput.service:configuration
*
* @description
* Loads and initializes options from HTML attributes. Used internally for tagsInput and autoComplete directives.
*/
angular.module('tags-input').service('configuration', ["$interpolate", function($interpolate) {
tagsInput.service('configuration', ["$interpolate", function($interpolate) {
this.load = function(scope, attrs, options) {
var converters = {};
converters[String] = function(value) { return value; };
Expand All @@ -496,9 +492,7 @@ angular.module('tags-input').service('configuration', ["$interpolate", function(
};
}]);

}());

angular.module('tags-input').run(['$templateCache', function($templateCache) {
tagsInput.run(["$templateCache", function($templateCache) {

$templateCache.put('ngTagsInput/tags-input.html',
"<div class=\"ngTagsInput\" tabindex=\"-1\" ng-class=\"options.customClass\" transclude-append=\"\"><div class=\"tags\" ng-class=\"{focused: hasFocus}\"><ul><li ng-repeat=\"tag in tags\" ng-class=\"getCssClass($index)\"><span>{{tag}}</span> <button type=\"button\" ng-click=\"remove($index)\">{{options.removeTagSymbol}}</button></li></ul><input placeholder=\"{{options.placeholder}}\" size=\"{{options.placeholder.length}}\" maxlength=\"{{options.maxLength}}\" tabindex=\"{{options.tabindex}}\" ng-model=\"newTag\" ng-change=\"newTagChange()\"></div></div>"
Expand All @@ -507,7 +501,6 @@ angular.module('tags-input').run(['$templateCache', function($templateCache) {
$templateCache.put('ngTagsInput/auto-complete.html',
"<div class=\"autocomplete\" ng-show=\"suggestionList.visible\"><ul class=\"suggestions\"><li class=\"suggestion\" ng-repeat=\"item in suggestionList.items | limitTo:options.maxResultsToShow\" ng-class=\"{selected: item == suggestionList.selected}\" ng-click=\"addSuggestion()\" ng-mouseenter=\"suggestionList.select($index)\" ng-bind-html=\"highlight(item)\"></li></ul></div>"
);

}]);

}());
Binary file modified build/ng-tags-input.min.zip
Binary file not shown.
Binary file modified build/ng-tags-input.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion src/auto-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* suggestions list.
* @param {number=} [maxResultsToShow=10] Maximum number of results to be displayed at a time.
*/
angular.module('tags-input').directive('autoComplete', function($document, $timeout, $sce, configuration) {
tagsInput.directive('autoComplete', function($document, $timeout, $sce, configuration) {
function SuggestionList(loadFn, options) {
var self = {}, debouncedLoadId, getDifference;

Expand Down
5 changes: 1 addition & 4 deletions src/configuration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(function() {
'use strict';

/**
Expand All @@ -8,7 +7,7 @@
* @description
* Loads and initializes options from HTML attributes. Used internally for tagsInput and autoComplete directives.
*/
angular.module('tags-input').service('configuration', function($interpolate) {
tagsInput.service('configuration', function($interpolate) {
this.load = function(scope, attrs, options) {
var converters = {};
converters[String] = function(value) { return value; };
Expand All @@ -26,5 +25,3 @@ angular.module('tags-input').service('configuration', function($interpolate) {
});
};
});

}());
4 changes: 2 additions & 2 deletions src/tags-input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

angular.module('tags-input', []);
var tagsInput = angular.module('tags-input', []);

/**
* @ngdoc directive
Expand Down Expand Up @@ -28,7 +28,7 @@ angular.module('tags-input', []);
* @param {expression} onTagAdded Expression to evaluate upon adding a new tag. The new tag is available as $tag.
* @param {expression} onTagRemoved Expression to evaluate upon removing an existing tag. The removed tag is available as $tag.
*/
angular.module('tags-input').directive('tagsInput', function($timeout, $document, configuration) {
tagsInput.directive('tagsInput', function($timeout, $document, configuration) {
function SimplePubSub() {
var events = {};

Expand Down
7 changes: 2 additions & 5 deletions src/transclude-append.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(function() {
'use strict';

/**
Expand All @@ -8,12 +7,10 @@
* @description
* Re-creates the old behavior of ng-transclude.
*/
angular.module('tags-input').directive('transcludeAppend', function() {
tagsInput.directive('transcludeAppend', function() {
return function(scope, element, attrs, ctrl, transcludeFn) {
transcludeFn(function(clone) {
element.append(clone);
});
};
});

}());
});

0 comments on commit 503d380

Please sign in to comment.