@@ -30,7 +30,7 @@ var jconfirm, Jconfirm;
30
30
$ ( this ) . each ( function ( ) {
31
31
var $this = $ ( this ) ;
32
32
if ( $this . attr ( 'jc-attached' ) ) {
33
- console . warn ( 'jConfirm has already binded to this element ' , $this [ 0 ] ) ;
33
+ console . warn ( 'jConfirm has already been attached to this element ' , $this [ 0 ] ) ;
34
34
return ;
35
35
}
36
36
@@ -165,6 +165,10 @@ var jconfirm, Jconfirm;
165
165
jconfirm . lastFocused = $ ( 'body' ) . find ( ':focus' ) ;
166
166
167
167
this . _id = Math . round ( Math . random ( ) * 99999 ) ;
168
+ /**
169
+ * contentParsed maintains the contents for $content, before it is put in DOM
170
+ */
171
+ this . contentParsed = $ ( document . createElement ( 'div' ) ) ;
168
172
169
173
if ( ! this . lazyOpen ) {
170
174
setTimeout ( function ( ) {
@@ -267,7 +271,7 @@ var jconfirm, Jconfirm;
267
271
that . onContentReady ( ) ;
268
272
} , 50 ) ;
269
273
else {
270
- that . setContent ( ) ;
274
+ // that.setContent();
271
275
that . _updateContentMaxHeight ( ) ;
272
276
that . setTitle ( ) ;
273
277
that . setIcon ( ) ;
@@ -376,8 +380,6 @@ var jconfirm, Jconfirm;
376
380
} ,
377
381
_updateContentMaxHeight : function ( ) {
378
382
var height = $ ( window ) . height ( ) - ( this . $jconfirmBox . outerHeight ( ) - this . $contentPane . outerHeight ( ) ) - ( this . offsetTop + this . offsetBottom ) ;
379
- // console.log($(window).height(), this.$jconfirmBox.outerHeight() - this.$contentPane.outerHeight());
380
-
381
383
this . $contentPane . css ( {
382
384
'max-height' : height + 'px'
383
385
} ) ;
@@ -655,8 +657,8 @@ var jconfirm, Jconfirm;
655
657
. css ( 'display' , that . buttons [ key ] . isHidden ? 'none' : '' )
656
658
. click ( function ( e ) {
657
659
e . preventDefault ( ) ;
658
- var res = that . buttons [ key ] . action . apply ( that , that . buttons [ key ] ) ;
659
- that . onAction . apply ( that , key , that . buttons [ key ] ) ;
660
+ var res = that . buttons [ key ] . action . apply ( that , [ that . buttons [ key ] ] ) ;
661
+ that . onAction . apply ( that , [ key , that . buttons [ key ] ] ) ;
660
662
that . _stopCountDown ( ) ;
661
663
if ( typeof res === 'undefined' || res )
662
664
that . close ( ) ;
@@ -798,28 +800,28 @@ var jconfirm, Jconfirm;
798
800
this . $titleContainer . show ( ) ;
799
801
}
800
802
} ,
801
- setContentPrepend : function ( string , force ) {
802
- this . contentParsed = string + this . contentParsed ;
803
- if ( this . isAjaxLoading && ! force )
803
+ setContentPrepend : function ( content , force ) {
804
+ if ( ! content )
804
805
return ;
805
806
806
- this . $content . prepend ( string ) ;
807
+ this . contentParsed . prepend ( content ) ;
807
808
} ,
808
- setContentAppend : function ( string , force ) {
809
- this . contentParsed = this . contentParsed + string ;
810
- if ( this . isAjaxLoading && ! force )
809
+ setContentAppend : function ( content ) {
810
+ if ( ! content )
811
811
return ;
812
812
813
- this . $content . append ( string ) ;
813
+ this . contentParsed . append ( content ) ;
814
814
} ,
815
- setContent : function ( string , force ) {
816
- force = force || false ;
815
+ setContent : function ( content , force ) {
816
+ force = ! ! force ;
817
817
var that = this ;
818
- this . contentParsed = ( typeof string == 'undefined' ) ? this . contentParsed : string ;
818
+ if ( content )
819
+ this . contentParsed . html ( '' ) . append ( content ) ;
819
820
if ( this . isAjaxLoading && ! force )
820
821
return ;
821
822
822
- this . $content . html ( this . contentParsed ) ;
823
+ this . $content . html ( '' ) ;
824
+ this . $content . append ( this . contentParsed ) ;
823
825
setTimeout ( function ( ) {
824
826
that . $body . find ( 'input[autofocus]:visible:first' ) . focus ( ) ;
825
827
} , 100 ) ;
@@ -877,7 +879,7 @@ var jconfirm, Jconfirm;
877
879
this . isAjaxLoading = true ;
878
880
var u = this . content . substring ( 4 , this . content . length ) ;
879
881
$ . get ( u ) . done ( function ( html ) {
880
- that . contentParsed = html ;
882
+ that . contentParsed . html ( html ) ;
881
883
} ) . always ( function ( data , status , xhr ) {
882
884
that . ajaxResponse = {
883
885
data : data ,
@@ -894,8 +896,8 @@ var jconfirm, Jconfirm;
894
896
this . content = e ;
895
897
896
898
if ( ! this . isAjax ) {
897
- this . contentParsed = this . content ;
898
- this . setContent ( this . contentParsed ) ;
899
+ this . contentParsed . html ( this . content ) ;
900
+ this . setContent ( ) ;
899
901
that . _contentReady . resolve ( ) ;
900
902
}
901
903
} ,
@@ -1118,16 +1120,11 @@ var jconfirm, Jconfirm;
1118
1120
return false ;
1119
1121
}
1120
1122
1121
- // console.log(el);
1122
- // console.log(jconfirm.lastClicked);
1123
-
1124
1123
if ( ! el )
1125
1124
return false ;
1126
1125
1127
1126
var offset = el . offset ( ) ;
1128
- // console.log(offset.top, offset.left);
1129
1127
1130
- // originate from center of the clicked element
1131
1128
var iTop = el . outerHeight ( ) / 2 ;
1132
1129
var iLeft = el . outerWidth ( ) / 2 ;
1133
1130
@@ -1237,6 +1234,9 @@ var jconfirm, Jconfirm;
1237
1234
dragWindowGap : 15 ,
1238
1235
dragWindowBorder : true ,
1239
1236
animateFromElement : true ,
1237
+ /**
1238
+ * @deprecated
1239
+ */
1240
1240
alignMiddle : true ,
1241
1241
smoothContent : true ,
1242
1242
content : 'Are you sure to continue?' ,
0 commit comments