angular-bootstrap-confirm
Advanced tools
Comparing version 2.3.0 to 2.4.0
{ | ||
"name": "angular-bootstrap-confirm", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"homepage": "https://github.com/mattlewis92/angular-bootstrap-confirm", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -0,1 +1,11 @@ | ||
<a name="2.4.0"></a> | ||
# [2.4.0](https://github.com/mattlewis92/angular-bootstrap-confirm/compare/2.3.0...v2.4.0) (2016-09-25) | ||
### Features | ||
* **customTemplate:** allow passing local values to the confirm and cancel outputs ([b3e650c](https://github.com/mattlewis92/angular-bootstrap-confirm/commit/b3e650c)) | ||
<a name="2.3.0"></a> | ||
@@ -2,0 +12,0 @@ # [2.3.0](https://github.com/mattlewis92/angular-bootstrap-confirm/compare/2.2.0...v2.3.0) (2016-06-15) |
/** | ||
* angular-bootstrap-confirm - Displays a bootstrap confirmation popover when clicking the given element. | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @link https://github.com/mattlewis92/angular-bootstrap-confirm | ||
@@ -104,5 +104,5 @@ * @license MIT | ||
function evaluateOuterScopeValue(scopeName, defaultValue) { | ||
function evaluateOuterScopeValue(scopeName, defaultValue, locals) { | ||
if (angular.isDefined(scopeName)) { | ||
return $parse(scopeName)($scope); | ||
return $parse(scopeName)($scope, locals); | ||
} else { | ||
@@ -175,8 +175,8 @@ return defaultValue; | ||
vm.onConfirm = function() { | ||
evaluateOuterScopeValue($attrs.onConfirm); | ||
vm.onConfirm = function(callbackLocals) { | ||
evaluateOuterScopeValue($attrs.onConfirm, null, callbackLocals); | ||
}; | ||
vm.onCancel = function() { | ||
evaluateOuterScopeValue($attrs.onCancel); | ||
vm.onCancel = function(callbackLocals) { | ||
evaluateOuterScopeValue($attrs.onCancel, null, callbackLocals); | ||
}; | ||
@@ -183,0 +183,0 @@ |
/** | ||
* angular-bootstrap-confirm - Displays a bootstrap confirmation popover when clicking the given element. | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @link https://github.com/mattlewis92/angular-bootstrap-confirm | ||
* @license MIT | ||
*/ | ||
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("angular"),require("angular-sanitize")):"function"==typeof define&&define.amd?define(["angular","angular-sanitize"],t):"object"==typeof exports?exports.angularBootstrapConfirmModuleName=t(require("angular"),require("angular-sanitize")):n.angularBootstrapConfirmModuleName=t(n.angular,n["angular-sanitize"])}(this,function(n,t){return function(n){function t(o){if(e[o])return e[o].exports;var i=e[o]={exports:{},id:o,loaded:!1};return n[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){"use strict";var o=e(1),i=e(2);e(3),e(1);var s="angular-bootstrap-confirm.html";n.exports=o.module("mwl.confirm",["ngSanitize","ui.bootstrap.position"]).run(["$templateCache",function(n){n.put(s,i)}]).controller("PopoverConfirmCtrl",["$scope","$rootScope","$element","$attrs","$compile","$document","$window","$timeout","$injector","$templateRequest","$parse","$log","confirmationPopoverDefaults",function(n,t,e,i,s,r,a,l,c,u,p,m,f){function v(t,e){var s=i[t];o.isDefined(s)&&(p(s).assign?p(s).assign(n,e):m.warn("Could not set value of "+t+" to "+e+". This is normally because the value is not a variable."))}function d(t,e){return o.isDefined(t)?p(t)(n):e}function b(){var n=T.positionElements(e,B.popover,i.placement||B.defaults.placement,!0);n.top+="px",n.left+="px",B.popover.css(n)}function $(){var n=i.focusButton||B.defaults.focusButton;if(n){var t=n+"-button";B.popover[0].getElementsByClassName(t)[0].focus()}}function g(){B.isVisible||d(i.isDisabled,!1)||(B.popover.css({display:"block"}),b(),$(),B.isVisible=!0,v("isOpen",!0))}function h(){B.isVisible&&(B.popover.css({display:"none"}),B.isVisible=!1,v("isOpen",!1))}function C(){B.isVisible?h():g(),n.$apply()}function x(t){!B.isVisible||B.popover[0].contains(t.target)||e[0].contains(t.target)||(h(),n.$apply())}var B=this;B.defaults=f,B.$attrs=i;var y=c.has("$uibPosition")?"$uibPosition":"$position",T=c.get(y),w=i.templateUrl||f.templateUrl,P=t.$new(!0);P.vm=B,u(w).then(function(n){B.popover=o.element(n),B.popover.css("display","none"),s(B.popover)(P),r.find("body").append(B.popover)}),B.isVisible=!1,B.showPopover=g,B.hidePopover=h,B.togglePopover=C,B.onConfirm=function(){d(i.onConfirm)},B.onCancel=function(){d(i.onCancel)},n.$watch(i.isOpen,function(n){l(function(){n?g():h()})}),e.bind("click",C),a.addEventListener("resize",b),r.bind("click",x),r.bind("touchend",x),n.$on("$destroy",function(){B.popover.remove(),e.unbind("click",C),a.removeEventListener("resize",b),r.unbind("click",x),r.unbind("touchend",x),P.$destroy()})}]).directive("mwlConfirm",function(){return{restrict:"A",controller:"PopoverConfirmCtrl"}}).value("confirmationPopoverDefaults",{confirmText:"Confirm",cancelText:"Cancel",confirmButtonType:"success",cancelButtonType:"default",placement:"top",focusButton:null,templateUrl:s,hideConfirmButton:!1,hideCancelButton:!1}).name},function(t,e){t.exports=n},function(n,t){n.exports='<div\n class="popover"\n ng-class="[vm.$attrs.placement || vm.defaults.placement, \'popover-\' + (vm.$attrs.placement || vm.defaults.placement), vm.$attrs.popoverClass || vm.defaults.popoverClass]">\n <div class="popover-arrow arrow"></div>\n <h3 class="popover-title" ng-bind-html="vm.$attrs.title"></h3>\n <div class="popover-content">\n <p ng-bind-html="vm.$attrs.message"></p>\n <div class="row">\n <div\n class="col-xs-6"\n ng-if="!vm.$attrs.hideConfirmButton && !vm.defaults.hideConfirmButton"\n ng-class="{\'col-xs-offset-3\': vm.$attrs.hideCancelButton || vm.defaults.hideCancelButton}">\n <button\n class="btn btn-block confirm-button"\n ng-class="\'btn-\' + (vm.$attrs.confirmButtonType || vm.defaults.confirmButtonType)"\n ng-click="vm.onConfirm(); vm.hidePopover()"\n ng-bind-html="vm.$attrs.confirmText || vm.defaults.confirmText">\n </button>\n </div>\n <div\n class="col-xs-6"\n ng-if="!vm.$attrs.hideCancelButton && !vm.defaults.hideCancelButton"\n ng-class="{\'col-xs-offset-3\': vm.$attrs.hideConfirmButton || vm.defaults.hideConfirmButton}">\n <button\n class="btn btn-block cancel-button"\n ng-class="\'btn-\' + (vm.$attrs.cancelButtonType || vm.defaults.cancelButtonType)"\n ng-click="vm.onCancel(); vm.hidePopover()"\n ng-bind-html="vm.$attrs.cancelText || vm.defaults.cancelText">\n </button>\n </div>\n </div>\n </div>\n</div>\n'},function(n,e){n.exports=t}])}); | ||
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("angular"),require("angular-sanitize")):"function"==typeof define&&define.amd?define(["angular","angular-sanitize"],t):"object"==typeof exports?exports.angularBootstrapConfirmModuleName=t(require("angular"),require("angular-sanitize")):n.angularBootstrapConfirmModuleName=t(n.angular,n["angular-sanitize"])}(this,function(n,t){return function(n){function t(o){if(e[o])return e[o].exports;var i=e[o]={exports:{},id:o,loaded:!1};return n[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){"use strict";var o=e(1),i=e(2);e(3),e(1);var s="angular-bootstrap-confirm.html";n.exports=o.module("mwl.confirm",["ngSanitize","ui.bootstrap.position"]).run(["$templateCache",function(n){n.put(s,i)}]).controller("PopoverConfirmCtrl",["$scope","$rootScope","$element","$attrs","$compile","$document","$window","$timeout","$injector","$templateRequest","$parse","$log","confirmationPopoverDefaults",function(n,t,e,i,s,r,a,l,c,u,p,m,f){function v(t,e){var s=i[t];o.isDefined(s)&&(p(s).assign?p(s).assign(n,e):m.warn("Could not set value of "+t+" to "+e+". This is normally because the value is not a variable."))}function d(t,e,i){return o.isDefined(t)?p(t)(n,i):e}function b(){var n=T.positionElements(e,B.popover,i.placement||B.defaults.placement,!0);n.top+="px",n.left+="px",B.popover.css(n)}function $(){var n=i.focusButton||B.defaults.focusButton;if(n){var t=n+"-button";B.popover[0].getElementsByClassName(t)[0].focus()}}function g(){B.isVisible||d(i.isDisabled,!1)||(B.popover.css({display:"block"}),b(),$(),B.isVisible=!0,v("isOpen",!0))}function h(){B.isVisible&&(B.popover.css({display:"none"}),B.isVisible=!1,v("isOpen",!1))}function C(){B.isVisible?h():g(),n.$apply()}function x(t){!B.isVisible||B.popover[0].contains(t.target)||e[0].contains(t.target)||(h(),n.$apply())}var B=this;B.defaults=f,B.$attrs=i;var y=c.has("$uibPosition")?"$uibPosition":"$position",T=c.get(y),w=i.templateUrl||f.templateUrl,P=t.$new(!0);P.vm=B,u(w).then(function(n){B.popover=o.element(n),B.popover.css("display","none"),s(B.popover)(P),r.find("body").append(B.popover)}),B.isVisible=!1,B.showPopover=g,B.hidePopover=h,B.togglePopover=C,B.onConfirm=function(n){d(i.onConfirm,null,n)},B.onCancel=function(n){d(i.onCancel,null,n)},n.$watch(i.isOpen,function(n){l(function(){n?g():h()})}),e.bind("click",C),a.addEventListener("resize",b),r.bind("click",x),r.bind("touchend",x),n.$on("$destroy",function(){B.popover.remove(),e.unbind("click",C),a.removeEventListener("resize",b),r.unbind("click",x),r.unbind("touchend",x),P.$destroy()})}]).directive("mwlConfirm",function(){return{restrict:"A",controller:"PopoverConfirmCtrl"}}).value("confirmationPopoverDefaults",{confirmText:"Confirm",cancelText:"Cancel",confirmButtonType:"success",cancelButtonType:"default",placement:"top",focusButton:null,templateUrl:s,hideConfirmButton:!1,hideCancelButton:!1}).name},function(t,e){t.exports=n},function(n,t){n.exports='<div\n class="popover"\n ng-class="[vm.$attrs.placement || vm.defaults.placement, \'popover-\' + (vm.$attrs.placement || vm.defaults.placement), vm.$attrs.popoverClass || vm.defaults.popoverClass]">\n <div class="popover-arrow arrow"></div>\n <h3 class="popover-title" ng-bind-html="vm.$attrs.title"></h3>\n <div class="popover-content">\n <p ng-bind-html="vm.$attrs.message"></p>\n <div class="row">\n <div\n class="col-xs-6"\n ng-if="!vm.$attrs.hideConfirmButton && !vm.defaults.hideConfirmButton"\n ng-class="{\'col-xs-offset-3\': vm.$attrs.hideCancelButton || vm.defaults.hideCancelButton}">\n <button\n class="btn btn-block confirm-button"\n ng-class="\'btn-\' + (vm.$attrs.confirmButtonType || vm.defaults.confirmButtonType)"\n ng-click="vm.onConfirm(); vm.hidePopover()"\n ng-bind-html="vm.$attrs.confirmText || vm.defaults.confirmText">\n </button>\n </div>\n <div\n class="col-xs-6"\n ng-if="!vm.$attrs.hideCancelButton && !vm.defaults.hideCancelButton"\n ng-class="{\'col-xs-offset-3\': vm.$attrs.hideConfirmButton || vm.defaults.hideConfirmButton}">\n <button\n class="btn btn-block cancel-button"\n ng-class="\'btn-\' + (vm.$attrs.cancelButtonType || vm.defaults.cancelButtonType)"\n ng-click="vm.onCancel(); vm.hidePopover()"\n ng-bind-html="vm.$attrs.cancelText || vm.defaults.cancelText">\n </button>\n </div>\n </div>\n </div>\n</div>\n'},function(n,e){n.exports=t}])}); | ||
//# sourceMappingURL=angular-bootstrap-confirm.min.js.map |
{ | ||
"name": "angular-bootstrap-confirm", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "Displays a bootstrap confirmation popover when clicking the given element.", | ||
@@ -42,20 +42,20 @@ "browser": "dist/angular-bootstrap-confirm.js", | ||
"conventional-changelog-cli": "~1.2.0", | ||
"cz-conventional-changelog": "~1.1.5", | ||
"eslint": "~2.12.0", | ||
"eslint-config-mwl": "~0.4.0", | ||
"eslint-loader": "~1.3.0", | ||
"eslint-plugin-angular": "~1.1.1", | ||
"ghooks": "~1.2.1", | ||
"istanbul-instrumenter-loader": "~0.2.0", | ||
"jquery": "~3.0.0", | ||
"karma": "~0.13.9", | ||
"karma-chai-plugins": "~0.7.0", | ||
"karma-chrome-launcher": "~1.0.1", | ||
"karma-coverage": "~1.0.0", | ||
"cz-conventional-changelog": "~1.2.0", | ||
"eslint": "~3.6.0", | ||
"eslint-config-mwl": "~0.5.0", | ||
"eslint-loader": "~1.5.0", | ||
"eslint-plugin-angular": "~1.4.1", | ||
"ghooks": "~1.3.2", | ||
"istanbul-instrumenter-loader": "~1.0.0", | ||
"jquery": "~3.1.1", | ||
"karma": "~1.3.0", | ||
"karma-chai-plugins": "~0.8.0", | ||
"karma-chrome-launcher": "~2.0.0", | ||
"karma-coverage": "~1.1.1", | ||
"karma-coveralls": "~1.1.0", | ||
"karma-mocha": "~1.0.1", | ||
"karma-mocha": "~1.1.1", | ||
"karma-phantomjs-launcher": "~1.0.0", | ||
"karma-sourcemap-loader": "~0.3.5", | ||
"karma-webpack": "~1.7.0", | ||
"mocha": "~2.5.3", | ||
"karma-webpack": "~1.8.0", | ||
"mocha": "~3.0.2", | ||
"ng-annotate-loader": "~0.1.0", | ||
@@ -66,5 +66,5 @@ "open": "0.0.5", | ||
"uglify-loader": "~1.3.0", | ||
"validate-commit-msg": "~2.6.1", | ||
"validate-commit-msg": "~2.8.0", | ||
"webpack": "~1.13.0", | ||
"webpack-dev-server": "~1.14.0" | ||
"webpack-dev-server": "~1.16.1" | ||
}, | ||
@@ -71,0 +71,0 @@ "peerDependencies": { |
@@ -6,3 +6,3 @@ # Angular bootstrap confirm | ||
[![Bower version](https://badge.fury.io/bo/angular-bootstrap-confirm.svg)](http://badge.fury.io/bo/angular-bootstrap-confirm) | ||
[![devDependency Status](https://david-dm.org/mattlewis92/angular-bootstrap-confirm/dev-status.svg)](https://david-dm.org/mattlewis92/angular-bootstrap-confirm#info=devDependencies) | ||
[![devDependency Status](https://david-dm.org/mattlewis92/angular-bootstrap-confirm/dev-status.svg)](https://david-dm.org/mattlewis92/angular-bootstrap-confirm?type=dev) | ||
[![Codacy Badge](https://www.codacy.com/project/badge/f00fe7fdcfa04a38a31750bec12e142d)](https://www.codacy.com/app/matt-lewis-private/angular-bootstrap-confirm) | ||
@@ -9,0 +9,0 @@ [![GitHub issues](https://img.shields.io/github/issues/mattlewis92/angular-bootstrap-confirm.svg)](https://github.com/mattlewis92/angular-bootstrap-confirm/issues) |
@@ -42,5 +42,5 @@ 'use strict'; | ||
function evaluateOuterScopeValue(scopeName, defaultValue) { | ||
function evaluateOuterScopeValue(scopeName, defaultValue, locals) { | ||
if (angular.isDefined(scopeName)) { | ||
return $parse(scopeName)($scope); | ||
return $parse(scopeName)($scope, locals); | ||
} else { | ||
@@ -113,8 +113,8 @@ return defaultValue; | ||
vm.onConfirm = function() { | ||
evaluateOuterScopeValue($attrs.onConfirm); | ||
vm.onConfirm = function(callbackLocals) { | ||
evaluateOuterScopeValue($attrs.onConfirm, null, callbackLocals); | ||
}; | ||
vm.onCancel = function() { | ||
evaluateOuterScopeValue($attrs.onCancel); | ||
vm.onCancel = function(callbackLocals) { | ||
evaluateOuterScopeValue($attrs.onCancel, null, callbackLocals); | ||
}; | ||
@@ -121,0 +121,0 @@ |
@@ -167,5 +167,5 @@ 'use strict'; | ||
var element, scope, $compile, $timeout, $document, confirmationPopoverDefaults, $log; | ||
var element, scope, $compile, $timeout, $document, confirmationPopoverDefaults, $log, $templateCache; | ||
beforeEach(inject(function(_$compile_, $rootScope, _$timeout_, _$document_, _confirmationPopoverDefaults_, _$log_) { | ||
beforeEach(inject(function(_$compile_, $rootScope, _$timeout_, _$document_, _confirmationPopoverDefaults_, _$log_, _$templateCache_) { | ||
scope = $rootScope.$new(); | ||
@@ -177,2 +177,3 @@ $compile = _$compile_; | ||
$log = _$log_; | ||
$templateCache = _$templateCache_; | ||
})); | ||
@@ -408,3 +409,3 @@ | ||
it('should allow the popover default template url to be changed', inject(function($templateCache) { | ||
it('should allow the popover default template url to be changed', function() { | ||
var customTemplateUrl = 'my-custom-popover.html'; | ||
@@ -418,5 +419,5 @@ var customTemplate = '<div class="popover">Custom</div>'; | ||
confirmationPopoverDefaults.templateUrl = originalUrl; | ||
})); | ||
}); | ||
it('should allow a per instance template url to be set', inject(function($templateCache) { | ||
it('should allow a per instance template url to be set', function() { | ||
var customTemplateUrl = 'my-custom-popover.html'; | ||
@@ -427,3 +428,3 @@ var customTemplate = '<div class="popover">Instance template</div>'; | ||
expect(popover.html()).to.equal('Instance template'); | ||
})); | ||
}); | ||
@@ -462,4 +463,25 @@ it('should hide the confirm button', function() { | ||
it('should allow a custom values to be passed to the confirm handler if using a custom template', function() { | ||
$templateCache.put('customTemplate.html', | ||
'<div class="popover" ng-class="vm.$attrs.placement || vm.defaults.placement">' + | ||
'<input type="text" ng-model="vm.defaults.hack.confirmText" class="confirm-text">' + | ||
'<button class="confirm-button" ng-click="vm.onConfirm({confirmText: vm.defaults.hack.confirmText}); vm.hidePopover()">Confirm</button>' + | ||
'</div>' | ||
); | ||
scope.onConfirm = sinon.spy(); | ||
var popover = createPopover( | ||
'<button mwl-confirm template-url="customTemplate.html" on-confirm="onConfirm(confirmText)">Test</button>' | ||
); | ||
$(element).click(); | ||
scope.$apply(); | ||
// hack to set input value, as there doesn't seem to be an easy way to fill the text value otherwise | ||
confirmationPopoverDefaults.hack = {confirmText: 'foo'}; | ||
scope.$apply(); | ||
$(popover).find('.confirm-button').click(); | ||
scope.$apply(); | ||
expect(scope.onConfirm).to.have.been.calledWith('foo'); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96011
1106