From f7039e43f6ffa4a373ea03c35bc0eb96460b6420 Mon Sep 17 00:00:00 2001 From: melvisdev Date: Wed, 17 Jun 2015 12:16:01 -0400 Subject: [PATCH] refactoring --- .gitignore | 0 .travis.yml | 0 Gruntfile.js | 0 README.md | 0 bower.json | 0 dist/ngCart.js | 312 +++++++++++++++++---------------- dist/ngCart.min.js | 2 +- karma.conf.js | 0 package.json | 2 +- src/ngCart.directives.js | 0 src/ngCart.directives_test.js | 0 src/ngCart.fulfilment.js | 0 src/ngCart.js | 0 src/ngCart_test.js | 0 template/ngCart/addtocart.html | 2 +- template/ngCart/cart.html | 2 +- template/ngCart/checkout.html | 0 template/ngCart/summary.html | 0 template/troggle.html | 5 + 19 files changed, 174 insertions(+), 151 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .travis.yml mode change 100644 => 100755 Gruntfile.js mode change 100644 => 100755 README.md mode change 100644 => 100755 bower.json mode change 100644 => 100755 dist/ngCart.js mode change 100644 => 100755 karma.conf.js mode change 100644 => 100755 package.json mode change 100644 => 100755 src/ngCart.directives.js mode change 100644 => 100755 src/ngCart.directives_test.js mode change 100644 => 100755 src/ngCart.fulfilment.js mode change 100644 => 100755 src/ngCart.js mode change 100644 => 100755 src/ngCart_test.js mode change 100644 => 100755 template/ngCart/addtocart.html mode change 100644 => 100755 template/ngCart/cart.html mode change 100644 => 100755 template/ngCart/checkout.html mode change 100644 => 100755 template/ngCart/summary.html create mode 100755 template/troggle.html diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 diff --git a/Gruntfile.js b/Gruntfile.js old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/bower.json b/bower.json old mode 100644 new mode 100755 diff --git a/dist/ngCart.js b/dist/ngCart.js old mode 100644 new mode 100755 index 98d1f65..fcc91c0 --- a/dist/ngCart.js +++ b/dist/ngCart.js @@ -38,15 +38,16 @@ angular.module('ngCart', ['ngCart.directives']) }; }; - this.addItem = function (id, name, price, quantity, data) { + this.addItem = function (id, name, price, quantity, maxqty, data) { var inCart = this.getItemById(id); if (typeof inCart === 'object'){ //Update quantity of an item if it's already in the cart inCart.setQuantity(quantity, false); + inCart.setMaxQuantity(maxqty); } else { - var newItem = new ngCartItem(id, name, price, quantity, data); + var newItem = new ngCartItem(id, name, price, quantity, maxqty, data); this.$cart.items.push(newItem); $rootScope.$broadcast('ngCart:itemAdded', newItem); } @@ -180,7 +181,7 @@ angular.module('ngCart', ['ngCart.directives']) _self.$cart.tax = storedCart.tax; angular.forEach(storedCart.items, function (item) { - _self.$cart.items.push(new ngCartItem(item._id, item._name, item._price, item._quantity, item._data)); + _self.$cart.items.push(new ngCartItem(item._id, item._name, item._price, item._quantity, item._maxqty, item._data)); }); this.$save(); }; @@ -193,11 +194,12 @@ angular.module('ngCart', ['ngCart.directives']) .factory('ngCartItem', ['$rootScope', '$log', function ($rootScope, $log) { - var item = function (id, name, price, quantity, data) { + var item = function (id, name, price, quantity, maxqty, data) { this.setId(id); this.setName(name); this.setPrice(price); this.setQuantity(quantity); + this.setMaxQuantity(maxqty); this.setData(data); }; @@ -261,10 +263,24 @@ angular.module('ngCart', ['ngCart.directives']) }; + item.prototype.setMaxQuantity = function(maxqty){ + this._maxqty = maxqty; + }; + item.prototype.getQuantity = function(){ return this._quantity; }; + item.prototype.getMaxQuantity = function(){ + return this._maxqty; + }; + + item.prototype.getIsMaxQuantity = function(){ + //console.log(this._maxqty+' '+this._quantity); + //console.log(this._maxqty); + return this._maxqty <= this._quantity; + }; + item.prototype.setData = function(data){ if (data) this._data = data; }; @@ -326,146 +342,148 @@ angular.module('ngCart', ['ngCart.directives']) }]) .value('version', '0.0.3-rc.1'); -;'use strict'; - - -angular.module('ngCart.directives', ['ngCart.fulfilment']) - - .controller('CartController',['$scope', 'ngCart', function($scope, ngCart) { - $scope.ngCart = ngCart; - }]) - - .directive('ngcartAddtocart', ['ngCart', function(ngCart){ - return { - restrict : 'E', - controller : 'CartController', - scope: { - id:'@', - name:'@', - quantity:'@', - quantityMax:'@', - price:'@', - data:'=' - }, - transclude: true, - templateUrl: 'template/ngCart/addtocart.html', - link:function(scope, element, attrs){ - scope.attrs = attrs; - scope.inCart = function(){ - return ngCart.getItemById(attrs.id); - }; - - if (scope.inCart()){ - scope.q = ngCart.getItemById(attrs.id).getQuantity(); - } else { - scope.q = parseInt(scope.quantity); - } - - scope.qtyOpt = []; - for (var i = 1; i <= scope.quantityMax; i++) { - scope.qtyOpt.push(i); - } - - } - - }; - }]) - - .directive('ngcartCart', [function(){ - return { - restrict : 'E', - controller : 'CartController', - scope: {}, - templateUrl: 'template/ngCart/cart.html', - link:function(scope, element, attrs){ - - } - }; - }]) - - .directive('ngcartSummary', [function(){ - return { - restrict : 'E', - controller : 'CartController', - scope: {}, - transclude: true, - templateUrl: 'template/ngCart/summary.html' - }; - }]) - - .directive('ngcartCheckout', [function(){ - return { - restrict : 'E', - controller : ('CartController', ['$scope', 'ngCart', 'fulfilmentProvider', function($scope, ngCart, fulfilmentProvider) { - $scope.ngCart = ngCart; - - $scope.checkout = function () { - fulfilmentProvider.setService($scope.service); - fulfilmentProvider.setSettings($scope.settings); - var promise = fulfilmentProvider.checkout(); - console.log(promise); - } - }]), - scope: { - service:'@', - settings:'=' - }, - transclude: true, - templateUrl: 'template/ngCart/checkout.html' - }; - }]);; -angular.module('ngCart.fulfilment', []) - .service('fulfilmentProvider', ['$injector', function($injector){ - - this._obj = { - service : undefined, - settings : undefined - }; - - this.setService = function(service){ - this._obj.service = service; - }; - - this.setSettings = function(settings){ - this._obj.settings = settings; - }; - - this.checkout = function(){ - var provider = $injector.get('ngCart.fulfilment.' + this._obj.service); - return provider.checkout(this._obj.settings); - - } - - }]) - - -.service('ngCart.fulfilment.log', ['$q', '$log', 'ngCart', function($q, $log, ngCart){ - - this.checkout = function(){ - - var deferred = $q.defer(); - - $log.info(ngCart.toObject()); - deferred.resolve({ - cart:ngCart.toObject() - }); - - return deferred.promise; - - } - - }]) - -.service('ngCart.fulfilment.http', ['$http', 'ngCart', function($http, ngCart){ - - this.checkout = function(settings){ - return $http.post(settings.url, - {data:ngCart.toObject()}) - } - }]) - - -.service('ngCart.fulfilment.paypal', ['$http', 'ngCart', function($http, ngCart){ - - -}]); +;'use strict'; + + +angular.module('ngCart.directives', ['ngCart.fulfilment']) + + .controller('CartController',['$scope', 'ngCart', function($scope, ngCart) { + $scope.ngCart = ngCart; + }]) + + .directive('ngcartAddtocart', ['ngCart', function(ngCart){ + return { + restrict : 'E', + controller : 'CartController', + scope: { + id:'@', + name:'@', + quantity:'@', + quantityMax:'@', + price:'@', + data:'=' + }, + transclude: true, + templateUrl: 'template/ngCart/addtocart.html', + link:function(scope, element, attrs){ + scope.attrs = attrs; + scope.inCart = function(){ + return ngCart.getItemById(attrs.id); + }; + + if (scope.inCart()){ + // scope.q = ngCart.getItemById(attrs.id).getQuantity(); + scope.q = parseInt(scope.quantity); + } else { + scope.q = parseInt(scope.quantity); + } + + scope.qtyOpt = []; + + for (var i = 1; i <= scope.quantityMax; i++) { + scope.qtyOpt.push(i); + } + + } + + }; + }]) + + .directive('ngcartCart', [function(){ + return { + restrict : 'E', + controller : 'CartController', + scope: {}, + templateUrl: 'template/ngCart/cart.html', + link:function(scope, element, attrs){ + + } + }; + }]) + + .directive('ngcartSummary', [function(){ + return { + restrict : 'E', + controller : 'CartController', + scope: {}, + transclude: true, + templateUrl: 'template/ngCart/summary.html' + }; + }]) + + .directive('ngcartCheckout', [function(){ + return { + restrict : 'E', + controller : ('CartController', ['$scope', 'ngCart', 'fulfilmentProvider', function($scope, ngCart, fulfilmentProvider) { + $scope.ngCart = ngCart; + + $scope.checkout = function () { + fulfilmentProvider.setService($scope.service); + fulfilmentProvider.setSettings($scope.settings); + var promise = fulfilmentProvider.checkout(); + console.log(promise); + } + }]), + scope: { + service:'@', + settings:'=' + }, + transclude: true, + templateUrl: 'template/ngCart/checkout.html' + }; + }]);; +angular.module('ngCart.fulfilment', []) + .service('fulfilmentProvider', ['$injector', function($injector){ + + this._obj = { + service : undefined, + settings : undefined + }; + + this.setService = function(service){ + this._obj.service = service; + }; + + this.setSettings = function(settings){ + this._obj.settings = settings; + }; + + this.checkout = function(){ + var provider = $injector.get('ngCart.fulfilment.' + this._obj.service); + return provider.checkout(this._obj.settings); + + } + + }]) + + +.service('ngCart.fulfilment.log', ['$q', '$log', 'ngCart', function($q, $log, ngCart){ + + this.checkout = function(){ + + var deferred = $q.defer(); + + $log.info(ngCart.toObject()); + deferred.resolve({ + cart:ngCart.toObject() + }); + + return deferred.promise; + + } + + }]) + +.service('ngCart.fulfilment.http', ['$http', 'ngCart', function($http, ngCart){ + + this.checkout = function(settings){ + return $http.post(settings.url, + {data:ngCart.toObject()}) + } + }]) + + +.service('ngCart.fulfilment.paypal', ['$http', 'ngCart', function($http, ngCart){ + + +}]); diff --git a/dist/ngCart.min.js b/dist/ngCart.min.js index 3db3bc9..892ac96 100644 --- a/dist/ngCart.min.js +++ b/dist/ngCart.min.js @@ -1,2 +1,2 @@ /*! ngCart v0.0.3-rc.1 */ - "use strict";angular.module("ngCart",["ngCart.directives"]).config([function(){}]).provider("$ngCart",function(){this.$get=function(){}}).run(["$rootScope","ngCart","ngCartItem","store",function(a,b,c,d){a.$on("ngCart:change",function(){b.$save()}),angular.isObject(d.get("cart"))?b.$restore(d.get("cart")):b.init()}]).service("ngCart",["$rootScope","ngCartItem","store",function(a,b,c){this.init=function(){this.$cart={shipping:null,taxRate:null,tax:null,items:[]}},this.addItem=function(c,d,e,f,g){var h=this.getItemById(c);if("object"==typeof h)h.setQuantity(f,!1);else{var i=new b(c,d,e,f,g);this.$cart.items.push(i),a.$broadcast("ngCart:itemAdded",i)}a.$broadcast("ngCart:change",{})},this.getItemById=function(a){var b=this.getCart().items,c=!1;return angular.forEach(b,function(b){b.getId()===a&&(c=b)}),c},this.setShipping=function(a){return this.$cart.shipping=a,this.getShipping()},this.getShipping=function(){return 0==this.getCart().items.length?0:this.getCart().shipping},this.setTaxRate=function(a){return this.$cart.taxRate=+parseFloat(a).toFixed(2),this.getTaxRate()},this.getTaxRate=function(){return this.$cart.taxRate},this.getTax=function(){return+parseFloat(this.getSubTotal()/100*this.getCart().taxRate).toFixed(2)},this.setCart=function(a){return this.$cart=a,this.getCart()},this.getCart=function(){return this.$cart},this.getItems=function(){return this.getCart().items},this.getTotalItems=function(){var a=0,b=this.getItems();return angular.forEach(b,function(b){a+=b.getQuantity()}),a},this.getTotalUniqueItems=function(){return this.getCart().items.length},this.getSubTotal=function(){var a=0;return angular.forEach(this.getCart().items,function(b){a+=b.getTotal()}),+parseFloat(a).toFixed(2)},this.totalCost=function(){return+parseFloat(this.getSubTotal()+this.getShipping()+this.getTax()).toFixed(2)},this.removeItem=function(b){this.$cart.items.splice(b,1),a.$broadcast("ngCart:itemRemoved",{}),a.$broadcast("ngCart:change",{})},this.removeItemById=function(b){var c=this.getCart();angular.forEach(c.items,function(a,d){a.getId()===b&&c.items.splice(d,1)}),this.setCart(c),a.$broadcast("ngCart:itemRemoved",{}),a.$broadcast("ngCart:change",{})},this.empty=function(){a.$broadcast("ngCart:change",{}),this.$cart.items=[],localStorage.removeItem("cart")},this.toObject=function(){if(0===this.getItems().length)return!1;var a=[];return angular.forEach(this.getItems(),function(b){a.push(b.toObject())}),{shipping:this.getShipping(),tax:this.getTax(),taxRate:this.getTaxRate(),subTotal:this.getSubTotal(),totalCost:this.totalCost(),items:a}},this.$restore=function(a){var c=this;c.init(),c.$cart.shipping=a.shipping,c.$cart.tax=a.tax,angular.forEach(a.items,function(a){c.$cart.items.push(new b(a._id,a._name,a._price,a._quantity,a._data))}),this.$save()},this.$save=function(){return c.set("cart",JSON.stringify(this.getCart()))}}]).factory("ngCartItem",["$rootScope","$log",function(a,b){var c=function(a,b,c,d,e){this.setId(a),this.setName(b),this.setPrice(c),this.setQuantity(d),this.setData(e)};return c.prototype.setId=function(a){a?this._id=a:b.error("An ID must be provided")},c.prototype.getId=function(){return this._id},c.prototype.setName=function(a){a?this._name=a:b.error("A name must be provided")},c.prototype.getName=function(){return this._name},c.prototype.setPrice=function(a){var c=parseFloat(a);c?0>=c?b.error("A price must be over 0"):this._price=c:b.error("A price must be provided")},c.prototype.getPrice=function(){return this._price},c.prototype.setQuantity=function(c,d){var e=parseInt(c);e%1===0?(d===!0?this._quantity+=e:this._quantity=e,this._quantity<1&&(this._quantity=1)):(this._quantity=1,b.info("Quantity must be an integer and was defaulted to 1")),a.$broadcast("ngCart:change",{})},c.prototype.getQuantity=function(){return this._quantity},c.prototype.setData=function(a){a&&(this._data=a)},c.prototype.getData=function(){return this._data?this._data:void b.info("This item has no data")},c.prototype.getTotal=function(){return+parseFloat(this.getQuantity()*this.getPrice()).toFixed(2)},c.prototype.toObject=function(){return{id:this.getId(),name:this.getName(),price:this.getPrice(),quantity:this.getQuantity(),data:this.getData(),total:this.getTotal()}},c}]).service("store",["$window",function(a){return{get:function(b){if(a.localStorage[b]){var c=angular.fromJson(a.localStorage[b]);return JSON.parse(c)}return!1},set:function(b,c){return void 0===c?a.localStorage.removeItem(b):a.localStorage[b]=angular.toJson(c),a.localStorage[b]}}}]).controller("CartController",["$scope","ngCart",function(a,b){a.ngCart=b}]).value("version","0.0.3-rc.1"),angular.module("ngCart.directives",["ngCart.fulfilment"]).controller("CartController",["$scope","ngCart",function(a,b){a.ngCart=b}]).directive("ngcartAddtocart",["ngCart",function(a){return{restrict:"E",controller:"CartController",scope:{id:"@",name:"@",quantity:"@",quantityMax:"@",price:"@",data:"="},transclude:!0,templateUrl:"template/ngCart/addtocart.html",link:function(b,c,d){b.attrs=d,b.inCart=function(){return a.getItemById(d.id)},b.q=b.inCart()?a.getItemById(d.id).getQuantity():parseInt(b.quantity),b.qtyOpt=[];for(var e=1;e<=b.quantityMax;e++)b.qtyOpt.push(e)}}}]).directive("ngcartCart",[function(){return{restrict:"E",controller:"CartController",scope:{},templateUrl:"template/ngCart/cart.html",link:function(){}}}]).directive("ngcartSummary",[function(){return{restrict:"E",controller:"CartController",scope:{},transclude:!0,templateUrl:"template/ngCart/summary.html"}}]).directive("ngcartCheckout",[function(){return{restrict:"E",controller:["$scope","ngCart","fulfilmentProvider",function(a,b,c){a.ngCart=b,a.checkout=function(){c.setService(a.service),c.setSettings(a.settings);var b=c.checkout();console.log(b)}}],scope:{service:"@",settings:"="},transclude:!0,templateUrl:"template/ngCart/checkout.html"}}]),angular.module("ngCart.fulfilment",[]).service("fulfilmentProvider",["$injector",function(a){this._obj={service:void 0,settings:void 0},this.setService=function(a){this._obj.service=a},this.setSettings=function(a){this._obj.settings=a},this.checkout=function(){var b=a.get("ngCart.fulfilment."+this._obj.service);return b.checkout(this._obj.settings)}}]).service("ngCart.fulfilment.log",["$q","$log","ngCart",function(a,b,c){this.checkout=function(){var d=a.defer();return b.info(c.toObject()),d.resolve({cart:c.toObject()}),d.promise}}]).service("ngCart.fulfilment.http",["$http","ngCart",function(a,b){this.checkout=function(c){return a.post(c.url,{data:b.toObject()})}}]).service("ngCart.fulfilment.paypal",["$http","ngCart",function(){}]); \ No newline at end of file + "use strict";angular.module("ngCart",["ngCart.directives"]).config([function(){}]).provider("$ngCart",function(){this.$get=function(){}}).run(["$rootScope","ngCart","ngCartItem","store",function(a,b,c,d){a.$on("ngCart:change",function(){b.$save()}),angular.isObject(d.get("cart"))?b.$restore(d.get("cart")):b.init()}]).service("ngCart",["$rootScope","ngCartItem","store",function(a,b,c){this.init=function(){this.$cart={shipping:null,taxRate:null,tax:null,items:[]}},this.addItem=function(c,d,e,f,g,h){var i=this.getItemById(c);if("object"==typeof i)i.setQuantity(f,!1),i.setMaxQuantity(g);else{var j=new b(c,d,e,f,g,h);this.$cart.items.push(j),a.$broadcast("ngCart:itemAdded",j)}a.$broadcast("ngCart:change",{})},this.getItemById=function(a){var b=this.getCart().items,c=!1;return angular.forEach(b,function(b){b.getId()===a&&(c=b)}),c},this.setShipping=function(a){return this.$cart.shipping=a,this.getShipping()},this.getShipping=function(){return 0==this.getCart().items.length?0:this.getCart().shipping},this.setTaxRate=function(a){return this.$cart.taxRate=+parseFloat(a).toFixed(2),this.getTaxRate()},this.getTaxRate=function(){return this.$cart.taxRate},this.getTax=function(){return+parseFloat(this.getSubTotal()/100*this.getCart().taxRate).toFixed(2)},this.setCart=function(a){return this.$cart=a,this.getCart()},this.getCart=function(){return this.$cart},this.getItems=function(){return this.getCart().items},this.getTotalItems=function(){var a=0,b=this.getItems();return angular.forEach(b,function(b){a+=b.getQuantity()}),a},this.getTotalUniqueItems=function(){return this.getCart().items.length},this.getSubTotal=function(){var a=0;return angular.forEach(this.getCart().items,function(b){a+=b.getTotal()}),+parseFloat(a).toFixed(2)},this.totalCost=function(){return+parseFloat(this.getSubTotal()+this.getShipping()+this.getTax()).toFixed(2)},this.removeItem=function(b){this.$cart.items.splice(b,1),a.$broadcast("ngCart:itemRemoved",{}),a.$broadcast("ngCart:change",{})},this.removeItemById=function(b){var c=this.getCart();angular.forEach(c.items,function(a,d){a.getId()===b&&c.items.splice(d,1)}),this.setCart(c),a.$broadcast("ngCart:itemRemoved",{}),a.$broadcast("ngCart:change",{})},this.empty=function(){a.$broadcast("ngCart:change",{}),this.$cart.items=[],localStorage.removeItem("cart")},this.toObject=function(){if(0===this.getItems().length)return!1;var a=[];return angular.forEach(this.getItems(),function(b){a.push(b.toObject())}),{shipping:this.getShipping(),tax:this.getTax(),taxRate:this.getTaxRate(),subTotal:this.getSubTotal(),totalCost:this.totalCost(),items:a}},this.$restore=function(a){var c=this;c.init(),c.$cart.shipping=a.shipping,c.$cart.tax=a.tax,angular.forEach(a.items,function(a){c.$cart.items.push(new b(a._id,a._name,a._price,a._quantity,a._maxqty,a._data))}),this.$save()},this.$save=function(){return c.set("cart",JSON.stringify(this.getCart()))}}]).factory("ngCartItem",["$rootScope","$log",function(a,b){var c=function(a,b,c,d,e,f){this.setId(a),this.setName(b),this.setPrice(c),this.setQuantity(d),this.setMaxQuantity(e),this.setData(f)};return c.prototype.setId=function(a){a?this._id=a:b.error("An ID must be provided")},c.prototype.getId=function(){return this._id},c.prototype.setName=function(a){a?this._name=a:b.error("A name must be provided")},c.prototype.getName=function(){return this._name},c.prototype.setPrice=function(a){var c=parseFloat(a);c?0>=c?b.error("A price must be over 0"):this._price=c:b.error("A price must be provided")},c.prototype.getPrice=function(){return this._price},c.prototype.setQuantity=function(c,d){var e=parseInt(c);e%1===0?(d===!0?this._quantity+=e:this._quantity=e,this._quantity<1&&(this._quantity=1)):(this._quantity=1,b.info("Quantity must be an integer and was defaulted to 1")),a.$broadcast("ngCart:change",{})},c.prototype.setMaxQuantity=function(a){this._maxqty=a},c.prototype.getQuantity=function(){return this._quantity},c.prototype.getMaxQuantity=function(){return this._maxqty},c.prototype.getIsMaxQuantity=function(){return this._maxqty<=this._quantity},c.prototype.setData=function(a){a&&(this._data=a)},c.prototype.getData=function(){return this._data?this._data:void b.info("This item has no data")},c.prototype.getTotal=function(){return+parseFloat(this.getQuantity()*this.getPrice()).toFixed(2)},c.prototype.toObject=function(){return{id:this.getId(),name:this.getName(),price:this.getPrice(),quantity:this.getQuantity(),data:this.getData(),total:this.getTotal()}},c}]).service("store",["$window",function(a){return{get:function(b){if(a.localStorage[b]){var c=angular.fromJson(a.localStorage[b]);return JSON.parse(c)}return!1},set:function(b,c){return void 0===c?a.localStorage.removeItem(b):a.localStorage[b]=angular.toJson(c),a.localStorage[b]}}}]).controller("CartController",["$scope","ngCart",function(a,b){a.ngCart=b}]).value("version","0.0.3-rc.1"),angular.module("ngCart.directives",["ngCart.fulfilment"]).controller("CartController",["$scope","ngCart",function(a,b){a.ngCart=b}]).directive("ngcartAddtocart",["ngCart",function(a){return{restrict:"E",controller:"CartController",scope:{id:"@",name:"@",quantity:"@",quantityMax:"@",price:"@",data:"="},transclude:!0,templateUrl:"template/ngCart/addtocart.html",link:function(b,c,d){b.attrs=d,b.inCart=function(){return a.getItemById(d.id)},b.inCart()?b.q=parseInt(b.quantity):b.q=parseInt(b.quantity),b.qtyOpt=[];for(var e=1;e<=b.quantityMax;e++)b.qtyOpt.push(e)}}}]).directive("ngcartCart",[function(){return{restrict:"E",controller:"CartController",scope:{},templateUrl:"template/ngCart/cart.html",link:function(a,b,c){}}}]).directive("ngcartSummary",[function(){return{restrict:"E",controller:"CartController",scope:{},transclude:!0,templateUrl:"template/ngCart/summary.html"}}]).directive("ngcartCheckout",[function(){return{restrict:"E",controller:["$scope","ngCart","fulfilmentProvider",function(a,b,c){a.ngCart=b,a.checkout=function(){c.setService(a.service),c.setSettings(a.settings);var b=c.checkout();console.log(b)}}],scope:{service:"@",settings:"="},transclude:!0,templateUrl:"template/ngCart/checkout.html"}}]),angular.module("ngCart.fulfilment",[]).service("fulfilmentProvider",["$injector",function(a){this._obj={service:void 0,settings:void 0},this.setService=function(a){this._obj.service=a},this.setSettings=function(a){this._obj.settings=a},this.checkout=function(){var b=a.get("ngCart.fulfilment."+this._obj.service);return b.checkout(this._obj.settings)}}]).service("ngCart.fulfilment.log",["$q","$log","ngCart",function(a,b,c){this.checkout=function(){var d=a.defer();return b.info(c.toObject()),d.resolve({cart:c.toObject()}),d.promise}}]).service("ngCart.fulfilment.http",["$http","ngCart",function(a,b){this.checkout=function(c){return a.post(c.url,{data:b.toObject()})}}]).service("ngCart.fulfilment.paypal",["$http","ngCart",function(a,b){}]); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js old mode 100644 new mode 100755 diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 1be308c..590e177 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "devDependencies": { "grunt-contrib-concat": "~0.4.0", - "grunt-contrib-uglify": "~0.2.2", + "grunt-contrib-uglify": "~0.9.1", "grunt-contrib-copy": "~0.5.0", "grunt-contrib-watch": "~0.6.1", "protractor": "~0.20.1", diff --git a/src/ngCart.directives.js b/src/ngCart.directives.js old mode 100644 new mode 100755 diff --git a/src/ngCart.directives_test.js b/src/ngCart.directives_test.js old mode 100644 new mode 100755 diff --git a/src/ngCart.fulfilment.js b/src/ngCart.fulfilment.js old mode 100644 new mode 100755 diff --git a/src/ngCart.js b/src/ngCart.js old mode 100644 new mode 100755 diff --git a/src/ngCart_test.js b/src/ngCart_test.js old mode 100644 new mode 100755 diff --git a/template/ngCart/addtocart.html b/template/ngCart/addtocart.html old mode 100644 new mode 100755 index ebf00db..903f829 --- a/template/ngCart/addtocart.html +++ b/template/ngCart/addtocart.html @@ -9,7 +9,7 @@ ng-options=" v for v in qtyOpt"> diff --git a/template/ngCart/cart.html b/template/ngCart/cart.html old mode 100644 new mode 100755 index 4b1d6a0..dacd852 --- a/template/ngCart/cart.html +++ b/template/ngCart/cart.html @@ -47,7 +47,7 @@    {{ item.getQuantity() | number }}   - + {{ item.getPrice() | currency}} {{ item.getTotal() | currency }} diff --git a/template/ngCart/checkout.html b/template/ngCart/checkout.html old mode 100644 new mode 100755 diff --git a/template/ngCart/summary.html b/template/ngCart/summary.html old mode 100644 new mode 100755 diff --git a/template/troggle.html b/template/troggle.html new file mode 100755 index 0000000..26b0e19 --- /dev/null +++ b/template/troggle.html @@ -0,0 +1,5 @@ + +
+ +
+
\ No newline at end of file