1function pop_up(options) { 2 var default_options = { 3 html: false, 4 title: "Message Title", 5 content: 6 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.", 7 type: "", 8 buttons: { 9 ok: { 10 title: "OK", 11 callback: function () { 12 hide_popup(); 13 }, 14 }, 15 cancel: { 16 title: "Cancel", 17 callback: hide_popup, 18 }, 19 order: { 20 title: "Order now", 21 callback: function () {}, 22 }, 23 }, 24 }; 25 26 const fullUrlPath = window.location.pathname; 27 const parts = fullUrlPath.split("/"); 28 const locale = parts[1]; 29 30 options = $.extend(true, default_options, options || {}); 31 32 var popup_wrapper = $('<div id="popup_wrapper"/>').appendTo("body").addClass(options.type), 33 popup_bgr = $('<div id="popup_bgr"/>').appendTo("body").hide().click(hide_popup); 34 35 var public_methods = { hide_popup: hide_popup }; 36 37 popup_wrapper 38 .draggable({ 39 handle: "h2", 40 containment: "document", 41 }) 42 .delegate("a", "click", function () { 43 if ( 44 options.buttons[$(this).data("button-type")] && 45 options.buttons[$(this).data("button-type")].callback 46 ) { 47 options.buttons[$(this).data("button-type")].callback.call(public_methods, this); 48 } 49 }); 50 51 if (options.html) { 52 popup_wrapper.html(options.html); 53 } else { 54 var title = $("<h2/>").appendTo(popup_wrapper).html(options.title), 55 container = $("<div/>").insertAfter(title); 56 $("<p />").appendTo(container).html(options.content); 57 if (options.buttons) { 58 var button_holder = $("<p/>").addClass("selectors").appendTo(container); 59 options.buttons.ok && 60 $('<a data-button-type="ok" href="javascript:;" />') 61 .addClass("krono-btn krono-btn--smaller krono-btn--main") 62 .attr("title", options.buttons.ok.title) 63 .text(options.buttons.ok.title) 64 .appendTo(button_holder); 65 options.buttons.order && 66 $('<a data-button-type="order" />') 67 .addClass("krono-btn krono-btn--smaller krono-btn--main") 68 .attr("href", `/${locale}/order-samples`) 69 .attr("title", options.buttons.order.title) 70 .text(options.buttons.order.title) 71 .appendTo(button_holder); 72 73 options.buttons.cancel && 74 $('<a data-button-type="cancel" href="javascript:;" />') 75 .addClass("krono-btn krono-btn--smaller krono-btn--main") 76 .attr("title", options.buttons.cancel.title) 77 .text(options.buttons.cancel.title) 78 .appendTo(button_holder); 79 } 80 } 81 82 var esc = function (e) { 83 if (e.which == 27) { 84 // 27 is 'Esc' in the keyboard 85 hide_popup(); // function close popup 86 } 87 }; 88 89 popup_bgr.show(); 90 popup_wrapper.fadeIn(400, function () { 91 $("body").bind("keyup", esc); 92 }); 93 94 function hide_popup() { 95 popup_wrapper.fadeOut("normal", function () { 96 popup_wrapper.remove(); 97 popup_bgr.remove(); 98 $("body").unbind("keyup", esc); 99 }); 100 } 101}
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.