diff --git a/angular-highlightjs.min.js b/angular-highlightjs.min.js index 3eaaf14..b4684cc 100644 --- a/angular-highlightjs.min.js +++ b/angular-highlightjs.min.js @@ -1,6 +1,6 @@ -/*! angular-highlightjs -version: 0.2.7 -build date: 2014-04-09 -author: Robin Fan -https://github.com/pc035860/angular-highlightjs.git */ -angular.module("hljs",[]).provider("hljsService",function(){var a={};return{setOptions:function(b){angular.extend(a,b)},getOptions:function(){return angular.copy(a)},$get:["$window",function(b){return(b.hljs.configure||angular.noop)(a),b.hljs}]}}).factory("hljsCache",["$cacheFactory",function(a){return a("hljsCache")}]).controller("HljsCtrl",["hljsCache","hljsService",function(a,b){var c=this,d=null,e=null,f=null,g=null;c.init=function(a){d=a},c.setLanguage=function(a){e=a,f&&c.highlight(f)},c.highlightCallback=function(a){g=a},c.highlight=function(h){if(d){var i,j;f=h,e?(j=c._cacheKey(e,f),i=a.get(j),i||(i=b.highlight(e,b.fixMarkup(f),!0),a.put(j,i))):(j=c._cacheKey(f),i=a.get(j),i||(i=b.highlightAuto(b.fixMarkup(f)),a.put(j,i))),d.html(i.value),d.addClass(i.language),null!==g&&angular.isFunction(g)&&g()}},c.clear=function(){d&&(f=null,d.text(""))},c.release=function(){d=null},c._cacheKey=function(){var a=Array.prototype.slice.call(arguments),b="!angular-highlightjs!";return a.join(b)}}]).directive("hljs",[function(){return{restrict:"EA",controller:"HljsCtrl",compile:function(a){var b=a[0].innerHTML.replace(/^(\r\n|\r|\n)/m,"");return a.html('
'),function(a,c,d,e){e.init(c.find("code")),d.onhighlight&&e.highlightCallback(function(){a.$eval(d.onhighlight)}),b&&e.highlight(b),a.$on("$destroy",function(){e.release()})}}}}]).directive("language",[function(){return{require:"hljs",restrict:"A",link:function(a,b,c,d){c.$observe("language",function(a){angular.isDefined(a)&&d.setLanguage(a)})}}}]).directive("source",[function(){return{require:"hljs",restrict:"A",link:function(a,b,c,d){a.$watch(c.source,function(a){a?d.highlight(a):d.clear()})}}}]).directive("include",["$http","$templateCache","$q",function(a,b,c){return{require:"hljs",restrict:"A",compile:function(d,e){var f=e.include;return function(d,e,g,h){var i=0;d.$watch(f,function(d){var e=++i;if(d&&angular.isString(d)){var f,g;f=b.get(d),f||(g=c.defer(),a.get(d,{cache:b,transformResponse:function(a){return a}}).success(function(a){e===i&&g.resolve(a)}).error(function(){e===i&&h.clear(),g.resolve()}),f=g.promise),c.when(f).then(function(a){a&&(angular.isArray(a)?a=a[1]:angular.isObject(a)&&(a=a.data),a=a.replace(/^(\r\n|\r|\n)/m,""),h.highlight(a))})}else h.clear()})}}}}]); \ No newline at end of file +/*! angular-highlightjs +version: 0.3.0 +build date: 2014-05-24 +author: Robin Fan +https://github.com/pc035860/angular-highlightjs.git */ +angular.module("hljs",[]).provider("hljsService",function(){var a={};return{setOptions:function(b){angular.extend(a,b)},getOptions:function(){return angular.copy(a)},$get:["$window",function(b){return(b.hljs.configure||angular.noop)(a),b.hljs}]}}).factory("hljsCache",["$cacheFactory",function(a){return a("hljsCache")}]).controller("HljsCtrl",["hljsCache","hljsService",function(a,b){var c=this,d=null,e=null,f=null,g=null;c.init=function(a){d=a},c.setLanguage=function(a){e=a,f&&c.highlight(f)},c.highlightCallback=function(a){g=a},c.highlight=function(h){if(d){var i,j;f=h,e?(j=c._cacheKey(e,f),i=a.get(j),i||(i=b.highlight(e,b.fixMarkup(f),!0),a.put(j,i))):(j=c._cacheKey(f),i=a.get(j),i||(i=b.highlightAuto(b.fixMarkup(f)),a.put(j,i))),d.html(i.value),d.addClass(i.language),null!==g&&angular.isFunction(g)&&g()}},c.clear=function(){d&&(f=null,d.text(""))},c.release=function(){d=null},c._cacheKey=function(){var a=Array.prototype.slice.call(arguments),b="!angular-highlightjs!";return a.join(b)}}]).directive("hljs",["$compile","$parse",function(a,b){return{restrict:"EA",controller:"HljsCtrl",compile:function(c){var d=c[0].innerHTML.replace(/^(\r\n|\r|\n)/m,"");return c.html('
'),function(c,e,f,g){var h;angular.isDefined(f.compile)&&(h=b(f.compile)),g.init(e.find("code")),f.onhighlight&&g.highlightCallback(function(){c.$eval(f.onhighlight)}),d&&(g.highlight(d),h&&h(c)&&a(e.find("code").contents())(c)),c.$on("$destroy",function(){g.release()})}}}}]).directive("language",[function(){return{require:"hljs",restrict:"A",link:function(a,b,c,d){c.$observe("language",function(a){angular.isDefined(a)&&d.setLanguage(a)})}}}]).directive("source",["$compile","$parse",function(a,b){return{require:"hljs",restrict:"A",link:function(c,d,e,f){var g;angular.isDefined(e.compile)&&(g=b(e.compile)),c.$watch(e.source,function(b){b?(f.highlight(b),g&&g(c)&&a(d.find("code").contents())(c)):f.clear()})}}}]).directive("include",["$http","$templateCache","$q","$compile","$parse",function(a,b,c,d,e){return{require:"hljs",restrict:"A",compile:function(f,g){var h=g.include;return function(f,g,i,j){var k,l=0;angular.isDefined(i.compile)&&(k=e(i.compile)),f.$watch(h,function(e){var h=++l;if(e&&angular.isString(e)){var i,m;i=b.get(e),i||(m=c.defer(),a.get(e,{cache:b,transformResponse:function(a){return a}}).success(function(a){h===l&&m.resolve(a)}).error(function(){h===l&&j.clear(),m.resolve()}),i=m.promise),c.when(i).then(function(a){a&&(angular.isArray(a)?a=a[1]:angular.isObject(a)&&(a=a.data),a=a.replace(/^(\r\n|\r|\n)/m,""),j.highlight(a),k&&k(f)&&d(g.find("code").contents())(f))})}else j.clear()})}}}}]); \ No newline at end of file diff --git a/bower.json b/bower.json index c900f59..fa2a60a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-highlightjs", - "version": "0.2.7", + "version": "0.3.0", "description": "AngularJS directive for syntax highlighting with highlight.js.", "main": "angular-highlightjs.js", "ignore": [ diff --git a/package.json b/package.json index f645102..592376d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-highlightjs", - "version": "0.2.7", + "version": "0.3.0", "description": "AngularJS directive for syntax highlighting with highlight.js", "main": "index.js", "directories": {},