Skip to content

Commit

Permalink
Merge branch 'feature/browserify'
Browse files Browse the repository at this point in the history
  • Loading branch information
pc035860 committed Feb 3, 2015
2 parents 9264c82 + dcf5c95 commit 2c4faf0
Show file tree
Hide file tree
Showing 13 changed files with 1,270 additions and 42 deletions.
10 changes: 10 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"curly": true,
"multistr": true,
"expr": true,
"boss": true,
"undef": true,
"predef": [
"require", "define", "escape", "module"
]
}
48 changes: 31 additions & 17 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
module.exports = function(grunt) {
grunt.initConfig({
modulename: 'hljs',
builddir: 'build',
pkg: grunt.file.readJSON('package.json'),
meta: {
banner:
'/*! <%= pkg.name %>\n' +
'version: <%= pkg.version %>\n' +
'build date: <%= grunt.template.today("yyyy-mm-dd") %>\n' +
'author: <%= pkg.author %>\n' +
'<%= pkg.repository.url %> */'
},
jshint: {
options: {
curly: true,
multistr: true,
expr: true,
boss: true,
undef: true
},
beforeuglify: ['<%= pkg.name %>.js'],
gruntfile: ['Gruntfile.js']
},
uglify: {
concat: {
options: {
banner: '<%= meta.banner %>\n\n'+
'/* commonjs package manager support (eg componentjs) */\n'+
'if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){\n'+
' module.exports = \'<%= modulename %>\';\n'+
'}\n\n'+
'(function (window, angular, undefined) {\n',
footer: '})(window, window.angular);'
},
build: {
src: '<%= pkg.name %>.js',
dest: '<%= pkg.name %>.min.js'
},
dest: '<%= builddir %>/<%= pkg.name %>.js'
}
},
uglify: {
options: {
mangle: true,
compress: true,
banner:
'/*! <%= pkg.name %>\n' +
'version: <%= pkg.version %>\n' +
'build date: <%= grunt.template.today("yyyy-mm-dd") %>\n' +
'author: <%= pkg.author %>\n' +
'<%= pkg.repository.url %> */\n'
banner: '<%= meta.banner %>\n'
},
build: {
src: '<%= builddir %>/<%= pkg.name %>.js',
dest: '<%= builddir %>/<%= pkg.name %>.min.js'
}
},
watch: {
Expand Down Expand Up @@ -53,7 +66,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.registerTask('default', ['jshint:beforeuglify', 'uglify']);
grunt.registerTask('default', ['jshint:beforeuglify', 'concat:build', 'uglify:build']);
};

42 changes: 22 additions & 20 deletions angular-highlightjs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/*global angular*/
(function (module) {

var dirHljs, dirLanguageFactory, dirSourceFactory, dirIncludeFactory;

function shouldHighlightStatics(attrs) {
var should = true;
Expand All @@ -15,12 +12,13 @@ function shouldHighlightStatics(attrs) {
return should;
}

module

var ngModule = angular.module('hljs', []);

/**
* hljsService service
*/
.provider('hljsService', function () {
ngModule.provider('hljsService', function () {
var _hljsOptions = {};

return {
Expand All @@ -35,21 +33,21 @@ module
return $window.hljs;
}]
};
})
});

/**
* hljsCache service
*/
.factory('hljsCache', [
ngModule.factory('hljsCache', [
'$cacheFactory',
function ($cacheFactory) {
return $cacheFactory('hljsCache');
}])
}]);

/**
* HljsCtrl controller
*/
.controller('HljsCtrl', [
ngModule.controller('HljsCtrl', [
'hljsCache', 'hljsService',
function HljsCtrl (hljsCache, hljsService) {
var ctrl = this;
Expand Down Expand Up @@ -133,10 +131,13 @@ function HljsCtrl (hljsCache, hljsService) {
};
}]);


var hljsDir, languageDirFactory, sourceDirFactory, includeDirFactory;

/**
* hljs directive
*/
dirHljs = ['$compile', '$parse', function ($compile, $parse) {
hljsDir = ['$compile', '$parse', function ($compile, $parse) {
return {
restrict: 'EA',
controller: 'HljsCtrl',
Expand Down Expand Up @@ -205,7 +206,7 @@ dirHljs = ['$compile', '$parse', function ($compile, $parse) {
/**
* language directive
*/
dirLanguageFactory = function (dirName) {
languageDirFactory = function (dirName) {
return [function () {
return {
require: '?hljs',
Expand All @@ -227,7 +228,7 @@ dirLanguageFactory = function (dirName) {
/**
* source directive
*/
dirSourceFactory = function (dirName) {
sourceDirFactory = function (dirName) {
return ['$compile', '$parse', function ($compile, $parse) {
return {
require: '?hljs',
Expand Down Expand Up @@ -267,7 +268,7 @@ dirSourceFactory = function (dirName) {
/**
* include directive
*/
dirIncludeFactory = function (dirName) {
includeDirFactory = function (dirName) {
return [
'$http', '$templateCache', '$q', '$compile', '$parse',
function ($http, $templateCache, $q, $compile, $parse) {
Expand Down Expand Up @@ -356,10 +357,11 @@ dirIncludeFactory = function (dirName) {
}];
};

module
.directive('hljs', dirHljs)
.directive('language', dirLanguageFactory('language'))
.directive('source', dirSourceFactory('source'))
.directive('include', dirIncludeFactory('include'));

})(angular.module('hljs', []));
/**
* Add directives
*/
ngModule
.directive('hljs', hljsDir)
.directive('language', languageDirFactory('language'))
.directive('source', sourceDirFactory('source'))
.directive('include', includeDirFactory('include'));
Loading

0 comments on commit 2c4faf0

Please sign in to comment.