Skip to content
Browse files

Remove jQuery dependency

  • Loading branch information...
1 parent d874a66 commit ced8143d682992c350bf96e04d1b181242166c7d @AlmogBaku AlmogBaku committed Nov 23, 2013
Showing with 14 additions and 9 deletions.
  1. +1 −0 .gitignore
  2. +1 −2 bower.json
  3. +5 −3 dist/angular-gettext.js
  4. +1 −1 dist/angular-gettext.min.js
  5. +1 −1 src/directive.js
  6. +5 −2 src/index.js
View
1 .gitignore
@@ -4,3 +4,4 @@
/libpeerconnection.log
/unit-results.xml
/e2e-results.xml
+/.idea
View
3 bower.json
@@ -1,6 +1,6 @@
{
"name": "angular-gettext",
- "version": "0.2.0",
+ "version": "0.2.1",
"main": "dist/angular-gettext.js",
"ignore": [
"**/.*",
@@ -12,7 +12,6 @@
"Gruntfile.coffee"
],
"dependencies": {
- "jquery": ">=1.8.0",
"angular": "~1.2.0"
},
"devDependencies": {
View
8 dist/angular-gettext.js
@@ -1,5 +1,7 @@
-if (typeof jQuery === 'undefined') {
- throw new Error('Angular-gettext depends on jQuery, be sure to include it!');
+if (!String.prototype.trim) {
+ String.prototype.trim = function () {
+ return this.replace(/^\s+|\s+$/g, '');
+ };
}
angular.module('gettext', []);
angular.module('gettext').factory('gettext', function () {
@@ -73,7 +75,7 @@ angular.module('gettext').directive('translate', [
assert(!attrs.ngSwitchWhen, 'ng-switch-when', 'translate');
var countFn = $parse(attrs.translateN);
transclude($scope, function (clone) {
- var input = $.trim(clone.html());
+ var input = clone.html().trim();
clone.removeAttr('translate');
$element.replaceWith(clone);
return $scope.$watch(function () {
View
2 dist/angular-gettext.min.js
@@ -1 +1 @@
-if("undefined"==typeof jQuery)throw new Error("Angular-gettext depends on jQuery, be sure to include it!");angular.module("gettext",[]),angular.module("gettext").factory("gettext",function(){return function(a){return a}}),angular.module("gettext").factory("gettextCatalog",["gettextPlurals",function(a){var b,c=function(a){return b.debug&&"en"!==b.currentLanguage?"[MISSING]: "+a:a};return b={debug:!1,strings:{},currentLanguage:"en",setStrings:function(a,b){var c,d;this.strings[a]||(this.strings[a]={});for(c in b)d=b[c],this.strings[a][c]="string"==typeof d?[d]:d},getStringForm:function(a,b){var c=this.strings[this.currentLanguage]||{},d=c[a]||[];return d[b]},getString:function(a){return this.getStringForm(a,0)||c(a)},getPlural:function(b,d,e){var f=a(this.currentLanguage,b);return this.getStringForm(d,f)||c(1===b?d:e)}}}]),angular.module("gettext").directive("translate",["gettextCatalog","$interpolate","$parse",function(a,b,c){return{transclude:"element",priority:499,compile:function(d,e,f){return function(d,g){var h=function(a,b,c){if(!a)throw new Error("You should add a "+b+" attribute whenever you add a "+c+" attribute.")};h(!e.translatePlural||e.translateN,"translate-n","translate-plural"),h(!e.translateN||e.translatePlural,"translate-plural","translate-n"),h(!e.ngIf,"ng-if","translate"),h(!e.ngSwitchWhen,"ng-switch-when","translate");var i=c(e.translateN);f(d,function(c){var f=$.trim(c.html());return c.removeAttr("translate"),g.replaceWith(c),d.$watch(function(){var g,h=c.html();g=e.translatePlural?a.getPlural(i(d),f,e.translatePlural):a.getString(f);var j=b(g)(d);return h!==j?c.html(j):void 0})})}}}}]),angular.module("gettext").filter("translate",["gettextCatalog","$interpolate","$parse",function(a){return function(b){return a.getString(b)}}]),angular.module("gettext").factory("gettextPlurals",function(){return function(a,b){switch(a){case"ay":case"bo":case"cgg":case"dz":case"fa":case"id":case"ja":case"jbo":case"ka":case"kk":case"km":case"ko":case"ky":case"lo":case"ms":case"my":case"sah":case"su":case"th":case"tt":case"ug":case"vi":case"wo":case"zh":return 0;case"is":return b%10!=1||b%100==11?1:0;case"jv":return 0!=b?1:0;case"mk":return 1==b||b%10==1?0:1;case"ach":case"ak":case"am":case"arn":case"br":case"fil":case"fr":case"gun":case"ln":case"mfe":case"mg":case"mi":case"oc":case"pt_BR":case"tg":case"ti":case"tr":case"uz":case"wa":case"zh":return b>1?1:0;case"lv":return b%10==1&&b%100!=11?0:0!=b?1:2;case"lt":return b%10==1&&b%100!=11?0:b%10>=2&&(10>b%100||b%100>=20)?1:2;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return b%10==1&&b%100!=11?0:b%10>=2&&4>=b%10&&(10>b%100||b%100>=20)?1:2;case"mnk":return 0==b?0:1==b?1:2;case"ro":return 1==b?0:0==b||b%100>0&&20>b%100?1:2;case"pl":return 1==b?0:b%10>=2&&4>=b%10&&(10>b%100||b%100>=20)?1:2;case"cs":case"sk":return 1==b?0:b>=2&&4>=b?1:2;case"sl":return b%100==1?1:b%100==2?2:b%100==3||b%100==4?3:0;case"mt":return 1==b?0:0==b||b%100>1&&11>b%100?1:b%100>10&&20>b%100?2:3;case"gd":return 1==b||11==b?0:2==b||12==b?1:b>2&&20>b?2:3;case"cy":return 1==b?0:2==b?1:8!=b&&11!=b?2:3;case"kw":return 1==b?0:2==b?1:3==b?2:3;case"ga":return 1==b?0:2==b?1:7>b?2:11>b?3:4;case"ar":return 0==b?0:1==b?1:2==b?2:b%100>=3&&10>=b%100?3:b%100>=11?4:5;default:return 1!=b?1:0}}});
+String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),angular.module("gettext",[]),angular.module("gettext").factory("gettext",function(){return function(a){return a}}),angular.module("gettext").factory("gettextCatalog",["gettextPlurals",function(a){var b,c=function(a){return b.debug&&"en"!==b.currentLanguage?"[MISSING]: "+a:a};return b={debug:!1,strings:{},currentLanguage:"en",setStrings:function(a,b){var c,d;this.strings[a]||(this.strings[a]={});for(c in b)d=b[c],this.strings[a][c]="string"==typeof d?[d]:d},getStringForm:function(a,b){var c=this.strings[this.currentLanguage]||{},d=c[a]||[];return d[b]},getString:function(a){return this.getStringForm(a,0)||c(a)},getPlural:function(b,d,e){var f=a(this.currentLanguage,b);return this.getStringForm(d,f)||c(1===b?d:e)}}}]),angular.module("gettext").directive("translate",["gettextCatalog","$interpolate","$parse",function(a,b,c){return{transclude:"element",priority:499,compile:function(d,e,f){return function(d,g){var h=function(a,b,c){if(!a)throw new Error("You should add a "+b+" attribute whenever you add a "+c+" attribute.")};h(!e.translatePlural||e.translateN,"translate-n","translate-plural"),h(!e.translateN||e.translatePlural,"translate-plural","translate-n"),h(!e.ngIf,"ng-if","translate"),h(!e.ngSwitchWhen,"ng-switch-when","translate");var i=c(e.translateN);f(d,function(c){var f=c.html().trim();return c.removeAttr("translate"),g.replaceWith(c),d.$watch(function(){var g,h=c.html();g=e.translatePlural?a.getPlural(i(d),f,e.translatePlural):a.getString(f);var j=b(g)(d);return h!==j?c.html(j):void 0})})}}}}]),angular.module("gettext").filter("translate",["gettextCatalog","$interpolate","$parse",function(a){return function(b){return a.getString(b)}}]),angular.module("gettext").factory("gettextPlurals",function(){return function(a,b){switch(a){case"ay":case"bo":case"cgg":case"dz":case"fa":case"id":case"ja":case"jbo":case"ka":case"kk":case"km":case"ko":case"ky":case"lo":case"ms":case"my":case"sah":case"su":case"th":case"tt":case"ug":case"vi":case"wo":case"zh":return 0;case"is":return b%10!=1||b%100==11?1:0;case"jv":return 0!=b?1:0;case"mk":return 1==b||b%10==1?0:1;case"ach":case"ak":case"am":case"arn":case"br":case"fil":case"fr":case"gun":case"ln":case"mfe":case"mg":case"mi":case"oc":case"pt_BR":case"tg":case"ti":case"tr":case"uz":case"wa":case"zh":return b>1?1:0;case"lv":return b%10==1&&b%100!=11?0:0!=b?1:2;case"lt":return b%10==1&&b%100!=11?0:b%10>=2&&(10>b%100||b%100>=20)?1:2;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return b%10==1&&b%100!=11?0:b%10>=2&&4>=b%10&&(10>b%100||b%100>=20)?1:2;case"mnk":return 0==b?0:1==b?1:2;case"ro":return 1==b?0:0==b||b%100>0&&20>b%100?1:2;case"pl":return 1==b?0:b%10>=2&&4>=b%10&&(10>b%100||b%100>=20)?1:2;case"cs":case"sk":return 1==b?0:b>=2&&4>=b?1:2;case"sl":return b%100==1?1:b%100==2?2:b%100==3||b%100==4?3:0;case"mt":return 1==b?0:0==b||b%100>1&&11>b%100?1:b%100>10&&20>b%100?2:3;case"gd":return 1==b||11==b?0:2==b||12==b?1:b>2&&20>b?2:3;case"cy":return 1==b?0:2==b?1:8!=b&&11!=b?2:3;case"kw":return 1==b?0:2==b?1:3==b?2:3;case"ga":return 1==b?0:2==b?1:7>b?2:11>b?3:4;case"ar":return 0==b?0:1==b?1:2==b?2:b%100>=3&&10>=b%100?3:b%100>=11?4:5;default:return 1!=b?1:0}}});
View
2 src/directive.js
@@ -19,7 +19,7 @@ angular.module('gettext').directive('translate', function (gettextCatalog, $inte
var countFn = $parse(attrs.translateN);
transclude($scope, function (clone) {
- var input = $.trim(clone.html());
+ var input = clone.html().trim();
clone.removeAttr('translate');
$element.replaceWith(clone);
View
7 src/index.js
@@ -1,5 +1,8 @@
-if (typeof jQuery === 'undefined') {
- throw new Error('Angular-gettext depends on jQuery, be sure to include it!');
+//Trim fallback for old browsers(instead of jQuery)
+if (!String.prototype.trim) {
+ String.prototype.trim = function () {
+ return this.replace(/^\s+|\s+$/g, '');
+ };
}
angular.module('gettext', []);

0 comments on commit ced8143

Please sign in to comment.
Something went wrong with that request. Please try again.