This repository was archived by the owner on Apr 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-25
lines changed Expand file tree Collapse file tree 1 file changed +10
-25
lines changed Original file line number Diff line number Diff line change @@ -46,37 +46,22 @@ angular.module('angular-confirm', ['ui.bootstrap'])
4646 } ,
4747 link : function ( scope , element , attrs ) {
4848
49- function bind ( func ) {
50- element . unbind ( "click" ) . bind ( "click" , function ( ) {
51- func ( ) ;
52- } ) ;
53- }
54-
55- function bindConfirm ( ) {
56- bind ( $confirm ( { text : scope . confirm } , scope . ngClick ) ) ;
57- }
58-
59- function bindDefault ( ) {
60- bind ( function ( ) {
61- if ( scope . $$phase || scope . $root . $$phase ) {
62- scope . ngClick ( ) ;
63- } else {
64- scope . $apply ( scope . ngClick ) ;
65- }
66- } ) ;
67- }
6849
69- if ( 'confirmIf' in attrs ) {
7050 scope . $watch ( 'confirmIf' , function ( newVal ) {
7151 if ( newVal ) {
72- bindConfirm ( ) ;
52+ element . unbind ( "click" ) . bind ( "click" , function ( ) {
53+ $confirm ( { text : scope . confirm } , scope . ngClick ) ;
54+ } ) ;
7355 } else {
74- bindDefault ( ) ;
56+ element . unbind ( "click" ) . bind ( "click" , function ( ) {
57+ if ( scope . $$phase || scope . $root . $$phase ) {
58+ scope . ngClick ( ) ;
59+ } else {
60+ scope . $apply ( scope . ngClick ) ;
61+ }
62+ } ) ;
7563 }
7664 } ) ;
77- } else {
78- bindConfirm ( ) ;
79- }
8065 }
8166 }
8267} ) ;
You can’t perform that action at this time.
0 commit comments