(function(window, $) { /* 获得当前文件路径 */ var js=document.scripts; var path = js[js.length - 1].src.substring(0, js[js.length - 1].src.lastindexof("/") + 1); $.fn.recruit = function(options) { var _this = this; var iframe = null; var loading = null; /* 参数 */ var defaults = { cansubmit: true }; var opts = jquery.extend(defaults,options); /* 遍历每个指定元素 */ this.each(function(i) { $(this).unbind().on('click', function() { var _this = this; createloading(); var iframe1 = createiframe(); $(iframe1).load(function() { $(iframe1)[0].contentwindow.id = $(_this).attr('recruit'); $(iframe1)[0].contentwindow.submit_url = opts.url; $(iframe1)[0].contentwindow.code = opts.code; $(iframe1)[0].contentwindow.cansubmit = opts.cansubmit = null ? true : opts.cansubmit; $(iframe1)[0].contentwindow.slidein(); }); }); }); /* 创建加载动画 */ function createloading() { $("[upload-box-close]").click(); if (!iframe) { loading = document.createelement('div'); $(loading) .html('') .css({ 'position': 'fixed', 'left': '50%', 'top': '50%', 'z-index': '99999', 'transform': 'translatez(0)', 'width': '400px', 'height': '300px', 'margin-left': '-200px', 'margin-top': '-150px' }) .appendto('body'); } } /* 销毁加载动画 */ function destroyloading() { if(loading) { $(loading).remove(); loading = null; } } window.destroyloading = destroyloading; /* 创建iframe */ function createiframe() { if (!iframe) { iframe = document.createelement('iframe'); $(iframe).css({ 'position': 'fixed', 'top': '0', 'left': '0', 'z-index': '99999', 'transform': 'translatez(0)', 'width': '100%', 'height': '100%', 'background': 'transparent' }) .attr('frameborder', '0') .attr('allowtransparency', 'true') .attr('id', 'recruit_iframe') .attr('src', path + 'recruit.html?1') .attr('scrolling', 'no') .appendto('body'); /*$('html, body').css({ 'overflow': 'hidden' });*/ return iframe; } else { return iframe; } } /* 销毁iframe */ function destroyiframe() { if (iframe) { $(iframe).remove(); iframe = null; /*$('html, body').css({ 'overflow': 'visible' });*/ } } window.destroyiframe = destroyiframe; } })(window, jquery);