angular-bootstrap-confirm
Advanced tools
Comparing version 2.1.0 to 2.2.0
{ | ||
"name": "angular-bootstrap-confirm", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"homepage": "https://github.com/mattlewis92/angular-bootstrap-confirm", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -0,1 +1,11 @@ | ||
<a name="2.2.0"></a> | ||
# [2.2.0](https://github.com/mattlewis92/angular-bootstrap-confirm/compare/2.1.0...v2.2.0) (2016-06-08) | ||
### Features | ||
* **isOpen:** warn the user when attempting to assign the value to a boolean value ([3243b8f](https://github.com/mattlewis92/angular-bootstrap-confirm/commit/3243b8f)), closes [#24](https://github.com/mattlewis92/angular-bootstrap-confirm/issues/24) | ||
<a name="2.1.0"></a> | ||
@@ -2,0 +12,0 @@ # [2.1.0](https://github.com/mattlewis92/angular-bootstrap-confirm/compare/2.0.0...v2.1.0) (2016-05-06) |
/** | ||
* angular-bootstrap-confirm - Displays a bootstrap confirmation popover when clicking the given element. | ||
* @version v2.1.0 | ||
* @version v2.2.0 | ||
* @link https://github.com/mattlewis92/angular-bootstrap-confirm | ||
@@ -82,4 +82,4 @@ * @license MIT | ||
.controller('PopoverConfirmCtrl', ["$scope", "$rootScope", "$element", "$attrs", "$compile", "$document", "$window", "$timeout", "$injector", "$templateRequest", "$parse", "confirmationPopoverDefaults", function($scope, $rootScope, $element, $attrs, $compile, $document, $window, $timeout, | ||
$injector, $templateRequest, $parse, confirmationPopoverDefaults) { | ||
.controller('PopoverConfirmCtrl', ["$scope", "$rootScope", "$element", "$attrs", "$compile", "$document", "$window", "$timeout", "$injector", "$templateRequest", "$parse", "$log", "confirmationPopoverDefaults", function($scope, $rootScope, $element, $attrs, $compile, $document, $window, $timeout, | ||
$injector, $templateRequest, $parse, $log, confirmationPopoverDefaults) { | ||
var vm = this; | ||
@@ -94,5 +94,10 @@ vm.defaults = confirmationPopoverDefaults; | ||
function assignOuterScopeValue(scopeName, value) { | ||
function assignOuterScopeValue(attributeName, value) { | ||
var scopeName = $attrs[attributeName]; | ||
if (angular.isDefined(scopeName)) { | ||
$parse(scopeName).assign($scope, value); | ||
if ($parse(scopeName).assign) { | ||
$parse(scopeName).assign($scope, value); | ||
} else { | ||
$log.warn('Could not set value of ' + attributeName + ' to ' + value + '. This is normally because the value is not a variable.'); | ||
} | ||
} | ||
@@ -139,3 +144,3 @@ } | ||
vm.isVisible = true; | ||
assignOuterScopeValue($attrs.isOpen, true); | ||
assignOuterScopeValue('isOpen', true); | ||
} | ||
@@ -148,3 +153,3 @@ } | ||
vm.isVisible = false; | ||
assignOuterScopeValue($attrs.isOpen, false); | ||
assignOuterScopeValue('isOpen', false); | ||
} | ||
@@ -151,0 +156,0 @@ } |
/** | ||
* angular-bootstrap-confirm - Displays a bootstrap confirmation popover when clicking the given element. | ||
* @version v2.1.0 | ||
* @version v2.2.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","confirmationPopoverDefaults",function(n,t,e,i,s,r,a,c,l,u,p,f){function m(t,e){o.isDefined(t)&&p(t).assign(n,e)}function d(t,e){return o.isDefined(t)?p(t)(n):e}function v(){var n=y.positionElements(e,x.popover,i.placement||x.defaults.placement,!0);n.top+="px",n.left+="px",x.popover.css(n)}function b(){var n=i.focusButton||x.defaults.focusButton;if(n){var t=n+"-button";x.popover[0].getElementsByClassName(t)[0].focus()}}function $(){x.isVisible||d(i.isDisabled,!1)||(x.popover.css({display:"block"}),v(),b(),x.isVisible=!0,m(i.isOpen,!0))}function g(){x.isVisible&&(x.popover.css({display:"none"}),x.isVisible=!1,m(i.isOpen,!1))}function h(){x.isVisible?g():$(),n.$apply()}function C(t){!x.isVisible||x.popover[0].contains(t.target)||e[0].contains(t.target)||(g(),n.$apply())}var x=this;x.defaults=f,x.$attrs=i;var B=l.has("$uibPosition")?"$uibPosition":"$position",y=l.get(B),T=i.templateUrl||f.templateUrl,P=t.$new(!0);P.vm=x,u(T).then(function(n){x.popover=o.element(n),x.popover.css("display","none"),s(x.popover)(P),r.find("body").append(x.popover)}),x.isVisible=!1,x.showPopover=$,x.hidePopover=g,x.togglePopover=h,x.onConfirm=function(){d(i.onConfirm)},x.onCancel=function(){d(i.onCancel)},n.$watch(i.isOpen,function(n){c(function(){n?$():g()})}),e.bind("click",h),a.addEventListener("resize",v),r.bind("click",C),r.bind("touchend",C),n.$on("$destroy",function(){x.popover.remove(),e.unbind("click",h),a.removeEventListener("resize",v),r.unbind("click",C),r.unbind("touchend",C),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 class="popover" ng-class="vm.$attrs.placement || vm.defaults.placement">\n <div class="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,f,m){function d(t,e){var s=i[t];o.isDefined(s)&&(p(s).assign?p(s).assign(n,e):f.warn("Could not set value of "+t+" to "+e+". This is normally because the value is not a variable."))}function v(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 g(){var n=i.focusButton||B.defaults.focusButton;if(n){var t=n+"-button";B.popover[0].getElementsByClassName(t)[0].focus()}}function $(){B.isVisible||v(i.isDisabled,!1)||(B.popover.css({display:"block"}),b(),g(),B.isVisible=!0,d("isOpen",!0))}function h(){B.isVisible&&(B.popover.css({display:"none"}),B.isVisible=!1,d("isOpen",!1))}function C(){B.isVisible?h():$(),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=m,B.$attrs=i;var y=c.has("$uibPosition")?"$uibPosition":"$position",T=c.get(y),P=i.templateUrl||m.templateUrl,w=t.$new(!0);w.vm=B,u(P).then(function(n){B.popover=o.element(n),B.popover.css("display","none"),s(B.popover)(w),r.find("body").append(B.popover)}),B.isVisible=!1,B.showPopover=$,B.hidePopover=h,B.togglePopover=C,B.onConfirm=function(){v(i.onConfirm)},B.onCancel=function(){v(i.onCancel)},n.$watch(i.isOpen,function(n){l(function(){n?$():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),w.$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 class="popover" ng-class="vm.$attrs.placement || vm.defaults.placement">\n <div class="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.1.0", | ||
"version": "2.2.0", | ||
"description": "Displays a bootstrap confirmation popover when clicking the given element.", | ||
@@ -41,5 +41,5 @@ "browser": "dist/angular-bootstrap-confirm.js", | ||
"conventional-changelog": "~1.1.0", | ||
"conventional-changelog-cli": "~1.1.1", | ||
"conventional-changelog-cli": "~1.2.0", | ||
"cz-conventional-changelog": "~1.1.5", | ||
"eslint": "~2.9.0", | ||
"eslint": "~2.11.1", | ||
"eslint-config-mwl": "~0.4.0", | ||
@@ -60,3 +60,3 @@ "eslint-loader": "~1.3.0", | ||
"karma-webpack": "~1.7.0", | ||
"mocha": "~2.4.5", | ||
"mocha": "~2.5.3", | ||
"ng-annotate-loader": "~0.1.0", | ||
@@ -63,0 +63,0 @@ "open": "0.0.5", |
@@ -26,2 +26,4 @@ # Angular bootstrap confirm | ||
[Angular2 version](https://github.com/mattlewis92/angular2-bootstrap-confirm) | ||
## Installation | ||
@@ -28,0 +30,0 @@ |
@@ -21,3 +21,3 @@ 'use strict'; | ||
.controller('PopoverConfirmCtrl', function($scope, $rootScope, $element, $attrs, $compile, $document, $window, $timeout, | ||
$injector, $templateRequest, $parse, confirmationPopoverDefaults) { | ||
$injector, $templateRequest, $parse, $log, confirmationPopoverDefaults) { | ||
var vm = this; | ||
@@ -32,5 +32,10 @@ vm.defaults = confirmationPopoverDefaults; | ||
function assignOuterScopeValue(scopeName, value) { | ||
function assignOuterScopeValue(attributeName, value) { | ||
var scopeName = $attrs[attributeName]; | ||
if (angular.isDefined(scopeName)) { | ||
$parse(scopeName).assign($scope, value); | ||
if ($parse(scopeName).assign) { | ||
$parse(scopeName).assign($scope, value); | ||
} else { | ||
$log.warn('Could not set value of ' + attributeName + ' to ' + value + '. This is normally because the value is not a variable.'); | ||
} | ||
} | ||
@@ -77,3 +82,3 @@ } | ||
vm.isVisible = true; | ||
assignOuterScopeValue($attrs.isOpen, true); | ||
assignOuterScopeValue('isOpen', true); | ||
} | ||
@@ -86,3 +91,3 @@ } | ||
vm.isVisible = false; | ||
assignOuterScopeValue($attrs.isOpen, false); | ||
assignOuterScopeValue('isOpen', false); | ||
} | ||
@@ -89,0 +94,0 @@ } |
@@ -167,5 +167,5 @@ 'use strict'; | ||
var element, scope, $compile, $timeout, $document, confirmationPopoverDefaults; | ||
var element, scope, $compile, $timeout, $document, confirmationPopoverDefaults, $log; | ||
beforeEach(inject(function(_$compile_, $rootScope, _$timeout_, _$document_, _confirmationPopoverDefaults_) { | ||
beforeEach(inject(function(_$compile_, $rootScope, _$timeout_, _$document_, _confirmationPopoverDefaults_, _$log_) { | ||
scope = $rootScope.$new(); | ||
@@ -176,2 +176,3 @@ $compile = _$compile_; | ||
confirmationPopoverDefaults = _confirmationPopoverDefaults_; | ||
$log = _$log_; | ||
})); | ||
@@ -354,2 +355,11 @@ | ||
it('should not a helpful warning when not set to a variable', function() { | ||
sinon.spy($log, 'warn'); | ||
createPopover('<button mwl-confirm is-open="false">Test</button>'); | ||
expect(function() { | ||
$(element).click(); | ||
}).not.to.throw(); | ||
expect($log.warn).to.have.been.calledOnce; | ||
}); | ||
}); | ||
@@ -356,0 +366,0 @@ |
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
92509
1080
185