@@ -164,11 +164,25 @@ app.actions = function (params) {
164164 app . openModal ( modal ) ;
165165 return modal [ 0 ] ;
166166} ;
167- app . popover = function ( modal , target ) {
167+ app . popover = function ( modal , target , removeOnClose ) {
168+ if ( typeof removeOnClose === 'undefined' ) removeOnClose = true ;
169+ if ( typeof modal === 'string' && modal . indexOf ( '<' ) >= 0 ) {
170+ var _modal = document . createElement ( 'div' ) ;
171+ _modal . innerHTML = modal ;
172+ if ( _modal . childNodes . length > 0 ) {
173+ modal = _modal . childNodes [ 0 ] ;
174+ if ( removeOnClose ) modal . classList . add ( 'remove-on-close' ) ;
175+ $ ( 'body' ) . append ( modal ) ;
176+ }
177+ else return false ; //nothing found
178+ }
168179 modal = $ ( modal ) ;
180+ console . log ( target ) ;
169181 target = $ ( target ) ;
170182 if ( modal . length === 0 || target . length === 0 ) return false ;
171-
183+ if ( modal . find ( '.popover-angle' ) . length === 0 ) {
184+ modal . append ( '<div class="popover-angle"></div>' ) ;
185+ }
172186 modal . show ( ) ;
173187
174188 function sizePopover ( ) {
@@ -256,7 +270,18 @@ app.popover = function (modal, target) {
256270 app . openModal ( modal ) ;
257271 return modal [ 0 ] ;
258272} ;
259- app . popup = function ( modal ) {
273+ app . popup = function ( modal , removeOnClose ) {
274+ if ( typeof removeOnClose === 'undefined' ) removeOnClose = true ;
275+ if ( typeof modal === 'string' && modal . indexOf ( '<' ) >= 0 ) {
276+ var _modal = document . createElement ( 'div' ) ;
277+ _modal . innerHTML = modal ;
278+ if ( _modal . childNodes . length > 0 ) {
279+ modal = _modal . childNodes [ 0 ] ;
280+ if ( removeOnClose ) modal . classList . add ( 'remove-on-close' ) ;
281+ $ ( 'body' ) . append ( modal ) ;
282+ }
283+ else return false ; //nothing found
284+ }
260285 modal = $ ( modal ) ;
261286 if ( modal . length === 0 ) return false ;
262287 modal . show ( ) ;
@@ -294,15 +319,18 @@ app.closeModal = function (modal) {
294319 modal . trigger ( 'close' ) ;
295320 var isPopover = modal . hasClass ( 'popover' ) ;
296321 var isPopup = modal . hasClass ( 'popup' ) ;
322+ var removeOnClose = modal . hasClass ( 'remove-on-close' ) ;
297323 if ( ! isPopover ) {
298324 modal . removeClass ( 'modal-in' ) . addClass ( 'modal-out' ) . transitionEnd ( function ( e ) {
299325 modal . trigger ( 'closed' ) ;
300326 if ( ! isPopup ) modal . remove ( ) ;
301327 if ( isPopup ) modal . removeClass ( 'modal-out' ) . hide ( ) ;
328+ if ( removeOnClose ) modal . remove ( ) ;
302329 } ) ;
303330 }
304331 else {
305332 modal . removeClass ( 'modal-in modal-out' ) . trigger ( 'closed' ) . hide ( ) ;
333+ if ( removeOnClose ) modal . remove ( ) ;
306334 }
307335 return true ;
308336} ;
0 commit comments