angular-bootstrap-confirm
Advanced tools
Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "angular-bootstrap-confirm", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"homepage": "https://github.com/mattlewis92/angular-bootstrap-confirm", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -0,1 +1,4 @@ | ||
# 0.4.1 (2015-10-02) | ||
* Allow handle-focus to be set to false if set as an attribute. | ||
# 0.4.0 (2015-09-28) | ||
@@ -2,0 +5,0 @@ * Auto focus the confirm button when opening the popover. Thanks to @andreptb! |
/** | ||
* angular-bootstrap-confirm - Displays a bootstrap confirmation popover when clicking the given element. | ||
* @version v0.4.0 | ||
* @version v0.4.1 | ||
* @link https://github.com/mattlewis92/angular-bootstrap-confirm | ||
@@ -117,3 +117,4 @@ * @license MIT | ||
function applyFocus(target) { | ||
if (vm.handleFocus || vm.defaults.handleFocus) { | ||
var shouldFocus = angular.isDefined(vm.handleFocus) ? vm.handleFocus : vm.defaults.handleFocus; | ||
if (shouldFocus) { | ||
target[0].focus(); | ||
@@ -120,0 +121,0 @@ } |
/** | ||
* angular-bootstrap-confirm - Displays a bootstrap confirmation popover when clicking the given element. | ||
* @version v0.4.0 | ||
* @version v0.4.1 | ||
* @link https://github.com/mattlewis92/angular-bootstrap-confirm | ||
* @license MIT | ||
*/ | ||
!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n(require("angular"),require("angular-bootstrap"),require("angular-sanitize"));else if("function"==typeof define&&define.amd)define(["angular","angular-bootstrap","angular-sanitize"],n);else{var t="object"==typeof exports?n(require("angular"),require("angular-bootstrap"),require("angular-sanitize")):n(e.angular,e["angular-bootstrap"],e["angular-sanitize"]);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,function(e,n,t){return function(e){function n(o){if(t[o])return t[o].exports;var i=t[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";var o=t(1);t(3),t(2),e.exports=o.module("mwl.confirm",["ngSanitize","ui.bootstrap.position"]).controller("PopoverConfirmCtrl",["$scope","$element","$compile","$document","$window","$timeout","$position","confirmationPopoverDefaults",function(e,n,t,i,s,r,c,l){function a(){var e=c.positionElements(n,g,v.popoverPlacement,!0);e.top+="px",e.left+="px",g.css(e)}function u(e){(v.handleFocus||v.defaults.handleFocus)&&e[0].focus()}function p(){v.isVisible||(g.css({display:"block"}),a(),u(g.find("button")),v.isVisible=!0),v.isOpen=!0}function d(e){v.isVisible&&(g.css({display:"none"}),v.isVisible=!1,e&&u(n)),v.isOpen=!1}function f(){v.isVisible?d():p(),e.$apply()}function m(t){!v.isVisible||g[0].contains(t.target)||n[0].contains(t.target)||(d(),e.$apply())}var v=this;v.defaults=l,v.popoverPlacement=v.placement||v.defaults.placement;var b=['<div class="popover" ng-class="vm.popoverPlacement">','<div class="arrow"></div>','<h3 class="popover-title" ng-bind-html="vm.title"></h3>','<div class="popover-content">','<p ng-bind-html="vm.message"></p>','<div class="row">','<div class="col-xs-6">','<button class="btn btn-block" ng-class="\'btn-\' + (vm.confirmButtonType || vm.defaults.confirmButtonType)" ng-click="vm.onConfirm(); vm.hidePopover()" ng-bind-html="vm.confirmText || vm.defaults.confirmText"></button>',"</div>",'<div class="col-xs-6">','<button class="btn btn-block" ng-class="\'btn-\' + (vm.cancelButtonType || vm.defaults.cancelButtonType)" ng-click="vm.onCancel(); vm.hidePopover(true)" ng-bind-html="vm.cancelText || vm.defaults.cancelText"></button>',"</div>","</div>","</div>","</div>"].join("\n"),g=o.element(b);g.css("display","none"),t(g)(e),i.find("body").append(g),v.isVisible=!1,v.showPopover=p,v.hidePopover=d,v.togglePopover=f,e.$watch("vm.isOpen",function(e){r(function(){e?p():d()})}),n.bind("click",f),s.addEventListener("resize",a),i.bind("click",m),i.bind("touchend",m),e.$on("$destroy",function(){g.remove(),n.unbind("click",f),s.removeEventListener("resize",a),i.unbind("click",m),i.unbind("touchend",m)})}]).directive("mwlConfirm",function(){return{restrict:"EA",controller:"PopoverConfirmCtrl as vm",bindToController:!0,scope:{confirmText:"@",cancelText:"@",message:"@",title:"@",placement:"@",onConfirm:"&",onCancel:"&",confirmButtonType:"@",cancelButtonType:"@",isOpen:"=?",handleFocus:"="}}}).value("confirmationPopoverDefaults",{confirmText:"Confirm",cancelText:"Cancel",confirmButtonType:"success",cancelButtonType:"default",placement:"top",handleFocus:!0}).name},function(n,t){n.exports=e},function(e,t){e.exports=n},function(e,n){e.exports=t}])}); | ||
!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n(require("angular"),require("angular-bootstrap"),require("angular-sanitize"));else if("function"==typeof define&&define.amd)define(["angular","angular-bootstrap","angular-sanitize"],n);else{var o="object"==typeof exports?n(require("angular"),require("angular-bootstrap"),require("angular-sanitize")):n(e.angular,e["angular-bootstrap"],e["angular-sanitize"]);for(var t in o)("object"==typeof exports?exports:e)[t]=o[t]}}(this,function(e,n,o){return function(e){function n(t){if(o[t])return o[t].exports;var i=o[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var o={};return n.m=e,n.c=o,n.p="",n(0)}([function(e,n,o){"use strict";var t=o(1);o(3),o(2),e.exports=t.module("mwl.confirm",["ngSanitize","ui.bootstrap.position"]).controller("PopoverConfirmCtrl",["$scope","$element","$compile","$document","$window","$timeout","$position","confirmationPopoverDefaults",function(e,n,o,i,s,r,c,l){function a(){var e=c.positionElements(n,g,v.popoverPlacement,!0);e.top+="px",e.left+="px",g.css(e)}function u(e){var n=t.isDefined(v.handleFocus)?v.handleFocus:v.defaults.handleFocus;n&&e[0].focus()}function p(){v.isVisible||(g.css({display:"block"}),a(),u(g.find("button")),v.isVisible=!0),v.isOpen=!0}function d(e){v.isVisible&&(g.css({display:"none"}),v.isVisible=!1,e&&u(n)),v.isOpen=!1}function f(){v.isVisible?d():p(),e.$apply()}function m(o){!v.isVisible||g[0].contains(o.target)||n[0].contains(o.target)||(d(),e.$apply())}var v=this;v.defaults=l,v.popoverPlacement=v.placement||v.defaults.placement;var b=['<div class="popover" ng-class="vm.popoverPlacement">','<div class="arrow"></div>','<h3 class="popover-title" ng-bind-html="vm.title"></h3>','<div class="popover-content">','<p ng-bind-html="vm.message"></p>','<div class="row">','<div class="col-xs-6">','<button class="btn btn-block" ng-class="\'btn-\' + (vm.confirmButtonType || vm.defaults.confirmButtonType)" ng-click="vm.onConfirm(); vm.hidePopover()" ng-bind-html="vm.confirmText || vm.defaults.confirmText"></button>',"</div>",'<div class="col-xs-6">','<button class="btn btn-block" ng-class="\'btn-\' + (vm.cancelButtonType || vm.defaults.cancelButtonType)" ng-click="vm.onCancel(); vm.hidePopover(true)" ng-bind-html="vm.cancelText || vm.defaults.cancelText"></button>',"</div>","</div>","</div>","</div>"].join("\n"),g=t.element(b);g.css("display","none"),o(g)(e),i.find("body").append(g),v.isVisible=!1,v.showPopover=p,v.hidePopover=d,v.togglePopover=f,e.$watch("vm.isOpen",function(e){r(function(){e?p():d()})}),n.bind("click",f),s.addEventListener("resize",a),i.bind("click",m),i.bind("touchend",m),e.$on("$destroy",function(){g.remove(),n.unbind("click",f),s.removeEventListener("resize",a),i.unbind("click",m),i.unbind("touchend",m)})}]).directive("mwlConfirm",function(){return{restrict:"EA",controller:"PopoverConfirmCtrl as vm",bindToController:!0,scope:{confirmText:"@",cancelText:"@",message:"@",title:"@",placement:"@",onConfirm:"&",onCancel:"&",confirmButtonType:"@",cancelButtonType:"@",isOpen:"=?",handleFocus:"="}}}).value("confirmationPopoverDefaults",{confirmText:"Confirm",cancelText:"Cancel",confirmButtonType:"success",cancelButtonType:"default",placement:"top",handleFocus:!0}).name},function(n,o){n.exports=e},function(e,o){e.exports=n},function(e,n){e.exports=o}])}); | ||
//# sourceMappingURL=angular-bootstrap-confirm.min.js.map |
{ | ||
"name": "angular-bootstrap-confirm", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Displays a bootstrap confirmation popover when clicking the given element.", | ||
@@ -35,3 +35,3 @@ "browser": "src/angular-bootstrap-confirm.js", | ||
"ejs": "~2.3.3", | ||
"eslint": "~1.5.1", | ||
"eslint": "~1.6.0", | ||
"eslint-config-mwl": "~0.3.0", | ||
@@ -38,0 +38,0 @@ "eslint-loader": "~1.0.0", |
@@ -54,3 +54,4 @@ 'use strict'; | ||
function applyFocus(target) { | ||
if (vm.handleFocus || vm.defaults.handleFocus) { | ||
var shouldFocus = angular.isDefined(vm.handleFocus) ? vm.handleFocus : vm.defaults.handleFocus; | ||
if (shouldFocus) { | ||
target[0].focus(); | ||
@@ -57,0 +58,0 @@ } |
@@ -166,8 +166,9 @@ 'use strict'; | ||
var element, scope, $compile, $timeout; | ||
var element, scope, $compile, $timeout, $document; | ||
beforeEach(inject(function(_$compile_, $rootScope, _$timeout_) { | ||
beforeEach(inject(function(_$compile_, $rootScope, _$timeout_, _$document_) { | ||
scope = $rootScope.$new(); | ||
$compile = _$compile_; | ||
$timeout = _$timeout_; | ||
$document = _$document_; | ||
})); | ||
@@ -345,4 +346,14 @@ | ||
it('should allow the handle-focus option to be set as an attribute', function() { | ||
createPopover('<button mwl-confirm handle-focus="false">Test</button>'); | ||
var otherButton = $('<button></button>'); | ||
$('body').append(otherButton); | ||
otherButton.focus(); | ||
$(element).click(); | ||
scope.$digest(); | ||
expect(otherButton[0]).to.equal($document[0].activeElement); | ||
}); | ||
}); | ||
}); |
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
72768
954