1(function ($) { 2 $.fn.ecwd_popup = function (opt) { 3 //default params 4 var default_options = { 5 button: '', 6 title: 'Event Details', 7 body_id: '', 8 body_class: '', 9 container_class: '', 10 fillhtml: false, 11 only_open: false, 12 get_ajax_data: function (el) { 13 }, 14 popup_close: function () { 15 }, 16 after_popup_show: function (el) { 17 }, 18 get_el_class: function (el) { 19 } 20 }; 21 22 for (var key in default_options) { 23 if (opt[key] == undefined) { 24 opt[key] = default_options[key]; 25 } 26 } 27 var params = opt; 28 var el = $(this); 29 30 el.hide(); 31 params.button.on('click', function (e) { 32 e.preventDefault(); 33 34 var data = params.get_ajax_data($(this)); 35 if (data) { 36 if (params.fillhtml) { 37 data.html = params.fillhtml.val(); 38 } 39 jQuery.post(ecwd.ajaxurl, data, function (response) { 40 if (response != 0) { 41 open_popup(response); 42 show_gmap(); 43 } 44 }); 45 } else if (params.fillhtml.length > 0 && params.fillhtml) { 46 open_popup(params.fillhtml.val()); 47 } else { 48 open_popup(el.html()); 49 } 50 el.on('click', '.ecwd_close_popup', function () { 51 el.hide(); 52 jQuery('body').removeClass("body-ecwd_open_popup"); 53 params.popup_close(el); 54 }); 55 $(document).keyup(function (e) { 56 if (e.keyCode == 27) { // escape key maps to keycode `27` 57 el.hide(); 58 jQuery('body').removeClass("body-ecwd_open_popup"); 59 params.popup_close(el); 60 } 61 }); 62 63 }); 64 65 function open_popup(html) { 66 if (params.only_open == false) { 67 add_popup(html); 68 } 69 jQuery('body').addClass("body-ecwd_open_popup"); 70 el.show(); 71 params.after_popup_show(el); 72 el.addClass('ecwd_popup_el'); 73 } 74 75 function add_popup(html) { 76 77 var head = get_popup_head(); 78 var body = get_popup_body(html); 79 80 var popup_html = 81 "<div class='ecwd_popup_back ecwd_open_popup'>" + 82 "<div class='ecwd_popup_container " + params.container_
82class + "'>" + 83 head + body + 84 "</div>" + 85 "</div>"; 86 el.html(popup_html); 87 } 88 89 function get_popup_head() { 90 var popup_head = 91 "<div class='ecwd_popup_head'>" + 92 "<div class='ecwd_popup_title'><h4>" + params.title + "</h4></div>" + 93 "<div class='ecwd_close_popup'><i class='fa fa-times'></i></div>" + 94 "</div>"; 95 return popup_head; 96 } 97 98 function get_popup_body(html) { 99 var body_id = (params.body_id != '') ? "id='" + params.body_id + "'" : ""; 100 var popup_body = "<div " + body_id + " class='ecwd_popup_body " + params.body_class + "'>" + html + "</div>"; 101 return popup_body; 102 } 103 104 105 function show_gmap() { 106 var interval = setInterval(function () { 107 var el = $('.ecwd_popup_container').find('.ecwd-show-map .ecwd_markers'); 108 if (el.html() != "") { 109 ecwd_js_init_call.showMap(); 110 clearInterval(interval); 111 } 112 }, 100); 113 } 114 115 $.fn.ecwd_popup.params = default_options; 116 }; 117}(jQuery)); 118
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.