/** * @copyright Copyright (C) 2015 Cedric KEIFLIN alias ced1870 * http://www.joomlack.fr - https://www.ceikay.com * @license GNU/GPL * */ CKBox = window.CKBox || {}; (function($) { CKBox.open = function(options) { var defaults = { id: '', handler: 'iframe', // load external page or inline code : 'iframe' or 'inline' fullscreen: true, // size: {x: null, y: null}, // size of the box : {x: 800px, y: 500px} style: {padding: '0'}, // size of the box : {x: 800px, y: 500px} url: '', // url or the external content content: '', // html ID (without #) of the inline content closeText: '×', // set the text for the close button headerHtml: '', // add any code to the header footerHtml: '', // ad any code to the footer onCKBoxLoaded: function() { } //this callback is invoked when the transition effect ends } var options = $.extend(defaults, options); var modalclosebutton = options.closeText ? ''+options.closeText+'' : ''; var i = $('.ckboxmodal').length+1; // ckboxmodal = $('#ckboxmodal'+i); var boxid = options.id ? options.id : 'ckboxmodal'+i; if ($('#'+boxid).length) $('#'+boxid).remove(); if (options.handler == 'inline' && options.content && $('.ckboxmodal #' + options.content).length) { $('.ckboxmodal').each(function(j, box) { if ($(box).find('#' + options.content).length) { ckboxmodal = $(box); // $(box).show(); } }); } else { // if (! $('#ckboxmodal').length) { var styles = ''; if (options.size.x) styles += 'width:'+options.size.x+';'; if (options.size.y) styles += 'height:'+(parseInt(options.size.y)+50)+'px;'; if (! options.fullscreen) { styles += 'margin-left:-'+(parseInt(options.size.x)/2)+'px;'; styles += 'margin-top:-'+((parseInt(options.size.y)+50)/2)+'px;'; styles += 'left:50%;'; styles += 'top:' + ($(window).scrollTop() + $(window).height()/2) + 'px'; } if (styles) styles = 'style="' + styles + '"'; var modalhtml = $( '
' +'
' +'
' +'' +'
'); $(document.body).append(modalhtml); if (! $('.ckboxmodal-back').length) $(document.body).append('
'); // } ckboxmodal = $('#'+boxid); var ckboxmodalbody = ckboxmodal.find('.ckboxmodal-body'); ckboxmodalbody.empty(); ckboxmodal.find('.ckboxmodal-header').empty().append(options.headerHtml); ckboxmodal.find('.ckboxmodal-footer').empty().append(modalclosebutton).append(options.footerHtml); if (options.handler == 'inline') { if (options.content) { $('#ckboxmodalwrapper'+i).remove(); $('#' + options.content).after('
') ckboxmodalbody.append($('#' + options.content).show()); } } else { ckboxmodalbody.append('