1(function ($) { 2 var Dialog = function () { 3 if (!$('.dialog-window').length) { 4 var self = this; 5 $('body').append('<div class="dialog-window"><div>' + 6 '<div class="message"></div>' + 7 '<div class="buttons">' + 8 '<a href="#" class="ok">x</a>' + 9 '</div>' + 10 '</div></div>'); 11 12 $('.dialog-window .buttons .ok').on('click', function(e){ 13 e.preventDefault(); 14 self.close(); 15 }); 16 } 17 }; 18 19 Dialog.prototype.onClose = false; 20 21 Dialog.prototype.show = function (config) { 22 var dialogWindow = $('.dialog-window'); 23 24 if (config.title !== undefined) { 25 dialogWindow.find('.title').show().html(config.title); 26 } else { 27 dialogWindow.find('.title').hide(); 28 } 29 30 if (config.message) { 31 dialogWindow.find('.message').html(config.message); 32 } else { 33 dialogWindow.find('.message').html(''); 34 } 35 36 if (config.align !== undefined) { 37 dialogWindow.find('.message').css('text-align', config.align); 38 } else { 39 dialogWindow.find('.message').css('text-align', 'left'); 40 } 41 42 if (config.buttons !== undefined && config.buttons.length) { 43 dialogWindow.find('.buttons').show(); 44 $.each(config.buttons, function (k, v) { 45 dialogWindow.find('.buttons a.' + v).show(); 46 }); 47 } else { 48 dialogWindow.find('.buttons, .buttons a').hide(); 49 } 50 51 if (config.onClose !== undefined) { 52 this.onClose = config.onClose; 53 } else { 54 this.onClose = false; 55 } 56 57 dialogWindow.css('opacity', 0).show(); 58 if (dialogWindow.data('width') === undefined) { 59 dialogWindow.data('width', dialogWindow.children('div').outerWidth(false)); 60 } else { 61 dialogWindow.children('div').width(dialogWindow.data('width')); 62 } 63 64 if (dialogWindow.data('height') === undefined) { 65 dialogWindow.data('height', dialogWindow.children('div').outerHeight(false)); 66 } else { 67 dialogWindow.children('div').height(dialogWindow.data('height')); 68 } 69 70 console.log(dialogWindow.data('height')); 71 72 if ($(window).width() < dialogWindow.children('div').outerWidth(false)) { 73 dialogWindow.children('div').width($(window).width() - 10); 74 } 75 76 if ($(window).height() < dialogWindow.children('div').outerHeight(false)) { 77 dialogWindow.children('div').height($(window).height() - 10); 78 } 79 80 dialogWindow.css({ 81 'margin-top': '-' + dialogWindow.children('div').outerHeight(true) + 'px', 82 'margin-left': '-' + dialogWindow.children('div').outerWidth(true) + 'px', 83 'opacity': 1 84 }).hide(); 85 86 dialogWindow.fadeIn(); 87 }; 88 89 Dialog.prototype.close = function () { 90 $('.dialog-window').fadeOut(); 91 if (this.onClose !== false) { 92 this.onClose(); 93 } 94 }; 95 96 window.yar = window.yar || {}; 97 window.yar.Dialog = Dialog; 98})(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.