1/** 2 * Kendo UI compatibility shim -- maps $.fn.kendoWindow to jQuery UI Dialog 3 * and $.fn.kendoTooltip to jQuery UI Tooltip. 4 * 5 * This file replaces the 4.6 MB kendo.all.min.js head-blocking load. 6 * Must load after jQuery (in HEAD); jQuery UI Dialog/Tooltip must be loaded 7 * before any kendoWindow()/kendoTooltip() call is actually invoked (they load 8 * in the footer, before ajaxCart.min.js). 9 */ 10(function ($) { 11 12 // Kendo position string -> jQuery UI {my, at} object 13 var positionMap = { 14 'top': { my: 'center bottom-5', at: 'center top' }, 15 'bottom': { my: 'center top+5', at: 'center bottom' }, 16 'left': { my: 'right-5 center', at: 'left center' }, 17 'right': { my: 'left+5 center', at: 'right center' } 18 }; 19 20 // -- kendoWindow -> jQuery UI Dialog ------------------------------------- 21 22 $.fn.kendoWindow = function (options) { 23 var $el = this.first(); 24 options = options || {}; 25 26 $el.dialog({ 27 autoOpen: false, 28 modal: false, // overlay managed manually via .k-overlay below 29 draggable: options.draggable !== false, 30 resizable: options.resizable !== false, 31 title: options.title || ' ', 32 width: options.width || 'auto', 33 zIndex: 1070, 34 close: function (event, ui) { 35 // Always clean up the manually-injected overlay, regardless of 36 // whether closed via the x button or instance.close() 37 $('.k-overlay').remove(); 38 if (options.close) options.close.call(this, event, ui); 39 } 40 }); 41 42 var $wrapper = $el.closest('.ui-dialog'); 43 44 var instance = { 45 // ajaxCart does: instance.wrapper.addClass("ajaxCart [errorWindow]") 46 wrapper: $wrapper, 47 element: $el, 48 49 open: function () { 50 // Inject .k-overlay so ajaxCart's $(document).on("click", ".k-overlay", ...) fires 51 if (!$('.k-overlay').length) { 52 $('<div class="k-overlay"></div>').appendTo('body'); 53 } 54 $el.dialog('open'); 55 return instance; 56 }, 57 58 close: function () { 59 $el.dialog('close'); 60 // .k-overlay removal is handled by the dialog's close event above 61 return instance; 62 }, 63 64 // jQuery UI Dialog centers automatically; no-op for chaining 65 center: function () { 66 return instance; 67 }, 68 69 // Sets dialog body HTML (used by ajaxCart to inject AJAX-loaded content) 70 content: function (html) { 71 $el.html(html); 72 return instance; 73 }, 74 75 title: function (val) { 76 if (val !== undefined) { 77 $el.dialog('option', 'title', val); 78 return instance; 79 } 80 return $el.dialog('option', 'title'); 81 }, 82 83 setOptions: function (opts) { 84 $el.dialog('option', opts); 85 return instance; 86 }, 87 88 destroy: function () { 89 $el.dialog('destroy'); 90 $('.k-overlay').remove(); 91 } 92 }; 93 94 // Store instance so ajaxCart can retrieve it via .data('kendoWindow') 95 $el.data('kendoWindow', instance); 96 97 return this; 98 }; 99 100 // -- kendoTooltip -> jQuery UI Tooltip ----------------------------------- 101 102 $.fn.kendoTooltip = function (options) { 103 options = options || {}; 104 105 var jqOptions = { 106 position: positionMap[options.position] || positionMap['top'] 107 }; 108 109 if (options.filter) { 110 jqOptions.items = options.filter; 111 } 112 113 if (options.content) { 114 jqOptions.content = options.content; 115 } 116 117 // Map Kendo 'show' callback -> jQuery UI 'open' event. 118 // Passes synthetic e.sender.popup.element -> ui.tooltip so callers that 119 // do e.sender.popup.element.addClass('...') continue to work. 120 if (options.show) { 121 var kendoShow = options.show; 122 jqOptions.open = function (event, ui) { 123 kendoShow.call(this, { 124 sender: { popup: { element: ui.tooltip } } 125 }); 126 }; 127 } 128 129 return this.tooltip(jqOptions); 130 }; 131 132})(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.