Skip to content

Commit

Permalink
Merge branch 'master' of github.com:geisslercom/ngCart
Browse files Browse the repository at this point in the history
  • Loading branch information
webben-de committed Jan 23, 2016
2 parents a81788c + ba59efa commit d76c827
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 177 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/
*/node_modules/
bower_components/
*/bower_components/
!dist
tmp
.DS_Store
.idea
Expand Down
352 changes: 176 additions & 176 deletions dist/ngCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,179 +330,179 @@ angular.module('ngCart', ['ngCart.directives'])
}])

.value('version', '1.0.0');
;'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: function(element, attrs) {
if ( typeof attrs.templateUrl == 'undefined' ) {
return 'template/ngCart/addtocart.html';
} else {
return attrs.templateUrl;
}
},
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: function(element, attrs) {
if ( typeof attrs.templateUrl == 'undefined' ) {
return 'template/ngCart/cart.html';
} else {
return attrs.templateUrl;
}
},
link:function(scope, element, attrs){

}
};
}])

.directive('ngcartSummary', [function(){
return {
restrict : 'E',
controller : 'CartController',
scope: {},
transclude: true,
templateUrl: function(element, attrs) {
if ( typeof attrs.templateUrl == 'undefined' ) {
return 'template/ngCart/summary.html';
} else {
return attrs.templateUrl;
}
}
};
}])

.directive('ngcartCheckout', [function(){
return {
restrict : 'E',
controller : ('CartController', ['$rootScope', '$scope', 'ngCart', 'fulfilmentProvider', function($rootScope, $scope, ngCart, fulfilmentProvider) {
$scope.ngCart = ngCart;

$scope.checkout = function () {
fulfilmentProvider.setService($scope.service);
fulfilmentProvider.setSettings($scope.settings);
fulfilmentProvider.checkout()
.success(function (data, status, headers, config) {
$rootScope.$broadcast('ngCart:checkout_succeeded', data);
})
.error(function (data, status, headers, config) {
$rootScope.$broadcast('ngCart:checkout_failed', {
statusCode: status,
error: data
});
});
}
}]),
scope: {
service:'@',
settings:'='
},
transclude: true,
templateUrl: function(element, attrs) {
if ( typeof attrs.templateUrl == 'undefined' ) {
return 'template/ngCart/checkout.html';
} else {
return attrs.templateUrl;
}
}
};
}]);
;
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(), options: settings.options});
}
}])


.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: function(element, attrs) {
if ( typeof attrs.templateUrl == 'undefined' ) {
return 'template/ngCart/addtocart.html';
} else {
return attrs.templateUrl;
}
},
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: function(element, attrs) {
if ( typeof attrs.templateUrl == 'undefined' ) {
return 'template/ngCart/cart.html';
} else {
return attrs.templateUrl;
}
},
link:function(scope, element, attrs){

}
};
}])

.directive('ngcartSummary', [function(){
return {
restrict : 'E',
controller : 'CartController',
scope: {},
transclude: true,
templateUrl: function(element, attrs) {
if ( typeof attrs.templateUrl == 'undefined' ) {
return 'template/ngCart/summary.html';
} else {
return attrs.templateUrl;
}
}
};
}])

.directive('ngcartCheckout', [function(){
return {
restrict : 'E',
controller : ('CartController', ['$rootScope', '$scope', 'ngCart', 'fulfilmentProvider', function($rootScope, $scope, ngCart, fulfilmentProvider) {
$scope.ngCart = ngCart;

$scope.checkout = function () {
fulfilmentProvider.setService($scope.service);
fulfilmentProvider.setSettings($scope.settings);
fulfilmentProvider.checkout()
.success(function (data, status, headers, config) {
$rootScope.$broadcast('ngCart:checkout_succeeded', data);
})
.error(function (data, status, headers, config) {
$rootScope.$broadcast('ngCart:checkout_failed', {
statusCode: status,
error: data
});
});
}
}]),
scope: {
service:'@',
settings:'='
},
transclude: true,
templateUrl: function(element, attrs) {
if ( typeof attrs.templateUrl == 'undefined' ) {
return 'template/ngCart/checkout.html';
} else {
return attrs.templateUrl;
}
}
};
}]);
;
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(), options: settings.options});
}
}])


.service('ngCart.fulfilment.paypal', ['$http', 'ngCart', function($http, ngCart){


}]);
2 changes: 1 addition & 1 deletion src/ngCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
angular.module('ngCart', ['ngCart.directives'])

.config([function () {

2
}])

.provider('$ngCart', function () {
Expand Down

0 comments on commit d76c827

Please sign in to comment.