1;(function ( $ ) { 2 $.br_popup_list = []; 3 $.fn.br_popup = function( options ) { 4 if (this.length > 1){ 5 this.each(function() { $(this).br_popup(options) }); 6 return this; 7 } 8 this.open_popup = function () { 9 var popup_data = this.data('br_popup_data'); 10 if( ! popup_data.opened ) { 11 this.reset_option(); 12 this.create_popup(); 13 this.add_content(); 14 this.add_events(); 15 this.show_popup(); 16 } 17 }; 18 this.reset_option = function () { 19 var popup_data = {timer_interval: undefined, close_delay: undefined, can_close_popup: true, opened:false, can_close_popup_count:0}; 20 this.data('br_popup_data', popup_data); 21 jQuery(this).trigger('br_popup-after_reset_option', this); 22 }; 23 this.create_popup = function() { 24 jQuery(this).trigger('br_popup-before_create_popup', this); 25 var settings = this.data('br_popup_settings'); 26 27 $popup_html = '<div id="br_popup" class="br_popup animated'+this.builder.popup_class(settings)+'" style="'+this.builder.popup_style(settings)+'">'; 28 $popup_html += '<div class="br_popup_wrapper'+this.builder.popup_wrapper_class(settings)+'" style="'+this.builder.popup_wrapper_style(settings)+'">'; 29 $popup_html += '<div class="animated popup_animation'+this.builder.popup_animation_class(settings)+'">'; 30 31 $popup_html += this.builder.close_button(settings); 32 $popup_html += this.builder.close_delay(settings); 33 $popup_html += this.builder.header_title(settings); 34 35 $popup_html += '<div class="br_popup_inner">'; 36 if ( 37 ( settings.yes_no_buttons.show == true 38 && settings.yes_no_buttons.custom == false 39 || settings.print_button == true 40 ) 41 && settings.yes_no_buttons.location == 'content' 42 ) { 43 $popup_html += '<div class="br_popup_buttons">'; 44 $popup_html += this.builder.buttons(settings); 45 $popup_html += '</div>'; 46 } 47 $popup_html += '</div>'; 48 49 if ( 50 ( settings.yes_no_buttons.show == true 51 && settings.yes_no_buttons.custom == false 52 || settings.print_button == true 53 ) 54 && settings.yes_no_buttons.location == 'popup' 55 ) { 56 $popup_html += '<div class="br_popup_buttons">'; 57 $popup_html += this.builder.buttons(settings); 58 $popup_html += '</div>'; 59 } 60 61 $popup_html += '</div></div>'; 62
63 if ( settings.no_overlay == false ) { 64 $popup_html += '<div class="br_popup_overlay"></div>'; 65 } 66 67 $popup_html += '</div>'; 68 $popup_html = $($popup_html); 69 $popup_html.appendTo('body'); 70 $popup_html.data('br_popup_main', this); 71 this.data('br_popup_object', $popup_html); 72 jQuery(this).trigger('br_popup-after_create_popup', this); 73 }; 74 this.builder = { 75 popup_class: function(settings) { 76 var text = ''; 77 if ( settings.theme != 'default' && settings.theme != '' ) { 78 text += ' ' + settings.theme; 79 } 80 return text; 81 }, 82 popup_style: function(settings) {return '';}, 83 popup_wrapper_class: function(settings) {return '';}, 84 popup_wrapper_style: function(settings) { 85 var text = ''; 86 if ( settings.width ) { 87 text += 'width: '+settings.width+';'; 88 } 89 if ( settings.height ) { 90 text += 'height: '+settings.height+';'; 91 } 92 return text; 93 }, 94 popup_animation_class: function(settings) { 95 var text = ''; 96 if ( settings.yes_no_buttons.show == true 97 && settings.yes_no_buttons.custom == false 98 && settings.yes_no_buttons.location == 'popup' 99 || settings.print_button == true 100 ) { 101 text += ' with_yes_no_buttons'; 102 } 103 text += ' yes_no_buttons_'+settings.yes_no_buttons.align; 104 if ( settings.title && settings.title != '' ) { 105 text += ' with_header'; 106 } 107 if ( settings.print_button == true ) { 108 text += ' with_print_button'; 109 } 110 return text; 111 }, 112 close_button: function(settings) { 113 var text = ''; 114 if ( settings.no_x_button == false ) { 115 text += '<a href="#" class="br_popup_close">Ã</a>'; 116 } 117 return text; 118 }, 119 close_delay: function(settings) { 120 var text = ''; 121 if ( settings.close_delay * 1 > 0 ) { 122 var close_delay_text = '%s second(s) before close'; 123 if( settings.close_delay_text && (typeof(sett
123ings.close_delay_text) === 'string' || settings.close_delay_text instanceof String) ) { 124 close_delay_text = settings.close_delay_text; 125 } 126 close_delay_text = close_delay_text.replace('%s', '<span>' + ( settings.close_delay * 1 ) + '</span>'); 127 text += '<span class="counters after_close">'+close_delay_text+'</span>'; 128 } 129 return text; 130 }, 131 header_title: function(settings) { 132 var text = ''; 133 if ( settings.title && settings.title != '' ) { 134 text += '<div class="br_popup_header popup_header_' + settings.header_align + '">' + settings.title + '</div>'; 135 } 136 return text; 137 }, 138 buttons: function(settings) { 139 var text = ''; 140 if ( settings.yes_no_buttons.show == true && settings.yes_no_buttons.custom == false ) { 141 text += '<a href="' + settings.yes_no_buttons.yes_text + '" ' 142 + 'class="br_yes_button ' + settings.yes_no_buttons.yes_classes + '">' 143 + settings.yes_no_buttons.yes_text 144 + '</a>'; 145 text += '<a href="' + settings.yes_no_buttons.no_text + '" ' 146 + 'class="br_no_button ' +settings.yes_no_buttons.no_classes + '">' 147 + settings.yes_no_buttons.no_text 148 + '</a>'; 149 } 150 if ( settings.print_button == true ) { 151 text += '<a href="Print" class="print_button">'+settings.print_button_text+'</a>'; 152 } 153 return text; 154 } 155 }; 156 this.add_content = function() { 157 var settings = this.data('br_popup_settings'); 158 if( settings.content ) { 159 this.data('br_popup_object').find('.br_popup_inner').prepend( settings.content ); 160 } else { 161 this.data('br_popup_object').find('.br_popup_inner').prepend( this.html() ); 162 } 163 jQuery(this).trigger('br_popup-after_add_content', this); 164 }; 165 this.add_events = function() { 166 var settings = this.data('br_popup_settings'); 167 var $this = this; 168 if ( settings.close_with.includes('overlay') ) { 169 $(this.data('br_popup_object')).on("click", ".br_popup_overlay", function (event){ 170 event.preventDefault(); 171 $this.hide_popup(); 172 }); 173 } 174 175 if ( settings.close_with.includes('x_button') ) { 176 $(this.data('br_popup_object')).on("click", ".br_popup_close", function (event){ 177 event.preventDefault(); 178 $this.hide_popup(); 179 }); 180 } 181 182 if ( settings.close_with.includes('esc_button') ) { 183 $(document).on("keydown", function (event){ 184 if ( event.keyCode === 27 ) { 185 $this.hide_popup(); 186 } 187 }); 188 } 189 190 if ( settings.yes_no_buttons.show == true && settings.yes_no_buttons.custom == false ) { 191 $(this.data('br_popup_object')).on("click", settings.yes_no_buttons.yes_button, function (event){ 192 event.preventDefault(); 193 var popup_data = $this.data('br_popup_data'); 194 if( popup_data.can_close_popup == false ) { 195 return; 196 } 197 if ( settings.close_with.includes('yes_button') ) { 198 $this.hide_popup(); 199 } 200 201 jQuery($this).trigger('br_popup-yes_button', $this); 202 if ( typeof settings.yes_no_buttons.yes_func === 'function' ) { 203 settings.yes_no_buttons.yes_func(); 204 } else if( settings.yes_no_buttons.yes_func) { 205 try { 206 eval(settings.yes_no_buttons.yes_func); 207 } catch( error ) { 208 console.log('Incorrect function settings.yes_no_buttons.yes_func'); 209 } 210 } 211 }); 212 } 213 214 if ( settings.yes_no_buttons.show == true && settings.yes_no_buttons.custom == false ) { 215 $(this.data('br_popup_object')).on("click", settings.yes_no_buttons.no_button, function (event){ 216 event.preventDefault(); 217 var popup_data = $this.data('br_popup_data'); 218 if ( settings.close_with.includes('no_button') ) { 219 $this.enable_close(); 220 $this.hide_popup(); 221 } 222 if( popup_data.can_close_popup == false ) { 223 return; 224 } 225 226 jQuery($this).trigger('br_popup-no_button', $this); 227 if ( typeof settings.yes_no_buttons.no_func === 'function' ) { 228 settings.yes_no_buttons.no_func(); 229 } else if( settings.yes_no_buttons.no_func) { 230 try { 231 eval(settings.yes_no_buttons.no_func); 232 } catch( error ) { 233 console.log('Incorrect function settings.yes_no_buttons.no_func'); 234 } 235 } 236 }); 237 } 238 239 if ( settings.print_button == true ) { 240 $(this.data('br_popup_object')).on("click", '.print_button', function (event){ 241 event.preventDefault(); 242 $this.print(); 243 }); 244 } 245 jQuery(this).trigger('br_popup-after_add_events', this); 246 }; 247 this.show_popup = function() { 248 var settings = this.data('br_popup_settings'); 249 var popup_data = this.data('br_popup_data'); 250 if ( this.data('br_popup_object') && this.data('br_popup_object').is(':hidden') ) { 251 var $this = this; 252 popup_data.opened = true; 253 254 $('body').addClass('br_popup_opened'); 255 256 if ( settings.hide_body_scroll ) { 257 $('body').addClass('hide_scroll'); 258 } 259 260 this.data('br_popup_object').css({display:'block'}); 261 this.animateCss(this.data('br_popup_object'), 'fadeIn'); 262 this.animateCss(this.data('br_popup_object').find('.popup_animation'), 'fadeInDown'); 263 popup_data = this.set_close_delay(popup_data); 264 this.data('br_popup_data', popup_data); 265 jQuery(this).trigger('br_popup-show_popup', this); 266 } 267 }; 268 this.set_close_delay = function (popup_data, close_delay_sec) { 269 var settings = this.data('br_popup_settings'); 270 var $this = this; 271 if( typeof(popup_data) == 'undefined' || ! popup_data ) { 272 popup_data = this.data('br_popup_data'); 273 } 274 if( typeof(close_delay_sec) == 'undefined' || ! close_delay_sec ) { 275 close_delay_sec = settings.close_delay; 276 } 277 if ( close_delay_sec * 1 > 0 ) { 278 this.data('br_popup_object').addClass('counting'); 279 this.disable_close(); 280 281 popup_data.close_delay = close_delay_sec * 1 - 1; 282 popup_data.timer_interval = setInterval(function (){ 283 if ( popup_data.close_delay <= 0 ) { 284 $this.enable_close(); 285 clearInterval(popup_data.timer_interval); 286 $this.data('br_popup_object').removeClass('counting'); 287 } else { 288 $this.data('br_popup_object').find('.counters span').text(popup_data.close_delay); 289 } 290 popup_data.close_delay--; 291 $this.data('br_popup_data', popup_data); 292 }, 1000); 293 } 294 this.data('br_popup_data', popup_data); 295 return popup_data; 296 } 297 this.disable_close = function (popup_data) { 298 if( typeof(popup_data) == 'undefined' || ! popup_data ) { 299 popup_data = this.data('br_popup_data'); 300 } 301 popup_data.can_close_popup = false;
302 popup_data.can_close_popup_count = popup_data.can_close_popup_count*1 + 1; 303 this.data('br_popup_object').addClass('cannot_be_closed'); 304 this.data('br_popup_data', popup_data); 305 return popup_data; 306 } 307 this.enable_close = function (popup_data) { 308 if( typeof(popup_data) == 'undefined' || ! popup_data ) { 309 popup_data = this.data('br_popup_data'); 310 } 311 popup_data.can_close_popup_count = popup_data.can_close_popup_count*1 - 1; 312 if( popup_data.can_close_popup_count <= 0 ) { 313 popup_data.can_close_popup_count = 0; 314 popup_data.can_close_popup = true; 315 this.data('br_popup_object').removeClass('cannot_be_closed'); 316 } 317 this.data('br_popup_data', popup_data); 318 return popup_data; 319 } 320 this.hide_popup = function () { 321 var $this = this; 322 var popup_data = this.data('br_popup_data'); 323 if ( popup_data.can_close_popup == true && this.data('br_popup_object').hasClass('br_popup') && this.data('br_popup_object').is(':visible') ) { 324 var $this = this; 325 326 jQuery(this).trigger('br_popup-hide_popup', this); 327 clearInterval(popup_data.timer_interval); 328 this.animateCss(this.data('br_popup_object').find('.popup_animation'), 'fadeOutUp'); 329 this.animateCss(this.data('br_popup_object'), 'fadeOut', function (){ 330 $this.data('br_popup_object').remove(); 331 popup_data.opened = false; 332 popup_data.can_close_popup = true; 333 $('body').removeClass('br_popup_opened hide_scroll'); 334 $this.data('br_popup_data', popup_data); 335 }); 336 } 337 }; 338 this.animateCss = function (element, animationName, callback) { 339 element = $(element); 340 element.addClass('animated').addClass(animationName); 341 342 function handleAnimationEnd() { 343 element.removeClass('animated').removeClass(animationName); 344 element.off('animationend', handleAnimationEnd); 345 346 if ( typeof callback === 'function' ) callback() 347 } 348 349 element.on('animationend', handleAnimationEnd); 350 setTimeout(function() { 351 element.trigger('animationend'); 352 }, 1500); 353 }; 354 this.print = function() { 355 $('body').addClass('print'); 356 window.print(); 357 $('body').removeClass('print'); 358 }; 359 360 var settings = this.data('br_popup_settings'); 361 if ( settings ) { 362 settings = $.extend( true, settings, options ); 363 } else { 364 this.reset_option(); 365 $.br_popup_list.push(this); 366 settings = $.extend( true, { 367 title: '', // title for popup header 368 content: '', // html from this element will be duplicated to the popup 369 height: '', // popup height ( with px or %) 370 width: '', // popup weight ( with px or %) 371 no_overlay: false, // don't use overlay 372 no_x_button: false, // don't show x button 373 header_align: 'left', // align header text 374 yes_no_buttons: { // yes and no buttons to catch the action from user 375 custom: false, // show own buttons or use default 376 show: false, // show buttons 377 yes_button: '.br_yes_button', // class or id for the yes button. Don't change it unless custom is true 378 no_button: '.br_no_button', // class or id for the no button. Don't change it unless custom is true 379 yes_func: '', // your function to run when yes is clicked 380 no_func: '', // your function to run when no is clicked 381 yes_text: 'Accept', // text shown on yes button
382 no_text: 'Decline', // text shown on no button 383 yes_classes:'', // text shown on yes button 384 no_classes: '', // text shown on no button 385 location: 'popup', // where to show buttons: 'content' - under the content, 'popup' - bottom of popup 386 align: 'right' // align text: 'right', 'left', 'center' 387 }, 388 print_button: false, // show print button for popup 389 print_button_text: 'Print', // print button text 390 close_with: [ 391 'overlay', // popup will be closed if catch click on overlay 392 'x_button', // popup will be closed if catch click on x button 393 'yes_button', // popup will be closed if catch click on yes overlay 394 'no_button', // popup will be closed if catch click on no overlay 395 'esc_button' // popup will be closed if catch esc mouse down 396 ], 397 close_delay: 0, // don't allow popup close for X seconds 398 effects: { // effects list is here - https://github.com/daneden/animate.css 399 open: { // when popup is opening 400 effect: 'fadeInDown' 401 }, 402 close: { // when popup is closing 403 effect: 'fadeOutUp' 404 } 405 }, 406 theme: "default", // default, sweet-alert, simple-shadow 407 themes_folder_url: "./themes/", // url where themes are located if you want popup to load theme 408 hide_body_scroll: false // if true body will get overflow hidden on popup opened 409 }, options ); 410 settings = $.extend( true, settings, $(this).data()); 411 } 412 this.data('br_popup_settings', settings); 413 return this; 414 } 415 416}( jQuery ));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.