-pg电子官方网址入口

/******************************************************************************* * kindeditor - wysiwyg html editor for internet * pg电子平台网站 copyright (c) 2006-2011 kindsoft.net * * @author roddy * @site http://www.kindsoft.net/ * @licence http://www.kindsoft.net/license.php *******************************************************************************/ kindeditor.plugin('image', function(k) { var self = this, name = 'image', allowimageupload = k.undef(self.allowimageupload, true), allowimageremote = k.undef(self.allowimageremote, true), formatuploadurl = k.undef(self.formatuploadurl, true), allowfilemanager = k.undef(self.allowfilemanager, false), uploadjson = k.undef(self.uploadjson, self.basepath 'php/upload_json.php'), imagetabindex = k.undef(self.imagetabindex, 0), imgpath = self.pluginspath 'image/images/', extraparams = k.undef(self.extrafileuploadparams, {}), filepostname = k.undef(self.filepostname, 'imgfile'), filldescafteruploadimage = k.undef(self.filldescafteruploadimage, false), lang = self.lang(name '.'); self.plugin.imagedialog = function(options) { var imageurl = options.imageurl, imagewidth = k.undef(options.imagewidth, ''), imageheight = k.undef(options.imageheight, ''), imagetitle = k.undef(options.imagetitle, ''), imagealign = k.undef(options.imagealign, ''), showremote = k.undef(options.showremote, true), showlocal = k.undef(options.showlocal, true), tabindex = k.undef(options.tabindex, 0), clickfn = options.clickfn; var target = 'kindeditor_upload_iframe_' new date().gettime(); var hiddenelements = []; for(var k in extraparams){ hiddenelements.push(''); } var html = [ '
', //tabs '
', //remote image - start '', //remote image - end //local upload - start '', //local upload - end '
' ].join(''); var dialogwidth = showlocal || allowfilemanager ? 450 : 400, dialogheight = showlocal && showremote ? 300 : 250; var dialog = self.createdialog({ name : name, width : dialogwidth, height : dialogheight, title : self.lang(name), body : html, yesbtn : { name : self.lang('yes'), click : function(e) { // bugfix: http://code.google.com/p/kindeditor/issues/detail?id=319 if (dialog.isloading) { return; } // insert local image if (showlocal && showremote && tabs && tabs.selectedindex === 1 || !showremote) { if (uploadbutton.filebox.val() == '') { alert(self.lang('pleaseselectfile')); return; } dialog.showloading(self.lang('uploadloading')); uploadbutton.submit(); localurlbox.val(''); return; } // insert remote image var url = k.trim(urlbox.val()), width = widthbox.val(), height = heightbox.val(), title = titlebox.val(), align = ''; alignbox.each(function() { if (this.checked) { align = this.value; return false; } }); if (url == 'http://' || k.invalid) { alert(self.lang('invalidurl')); urlbox[0].focus(); return; } if (!/^\d*$/.test(width)) { alert(self.lang('invalidwidth')); widthbox[0].focus(); return; } if (!/^\d*$/.test(height)) { alert(self.lang('invalidheight')); heightbox[0].focus(); return; } clickfn.call(self, url, title, width, height, 0, align); } }, beforeremove : function() { viewserverbtn.unbind(); widthbox.unbind(); heightbox.unbind(); refreshbtn.unbind(); } }), div = dialog.div; var urlbox = k('[name="url"]', div), localurlbox = k('[name="localurl"]', div), viewserverbtn = k('[name="viewserver"]', div), widthbox = k('.tab1 [name="width"]', div), heightbox = k('.tab1 [name="height"]', div), refreshbtn = k('.ke-refresh-btn', div), titlebox = k('.tab1 [name="title"]', div), alignbox = k('.tab1 [name="align"]', div); var tabs; if (showremote && showlocal) { tabs = k.tabs({ src : k('.tabs', div), afterselect : function(i) {} }); tabs.add({ title : lang.remoteimage, panel : k('.tab1', div) }); tabs.add({ title : lang.localimage, panel : k('.tab2', div) }); tabs.select(tabindex); } else if (showremote) { k('.tab1', div).show(); } else if (showlocal) { k('.tab2', div).show(); } var uploadbutton = k.uploadbutton({ button : k('.ke-upload-button', div)[0], fieldname : filepostname, form : k('.ke-form', div), target : target, width: 60, afterupload : function(data) { dialog.hideloading(); if (data.error === 0) { var url = data.url; if (formatuploadurl) { url = k.format; } if (self.afterupload) { self.afterupload.call(self, url, data, name); } if (!filldescafteruploadimage) { clickfn.call(self, url, data.title, data.width, data.height, data.border, data.align); } else { k(".ke-dialog-row #remoteurl", div).val(url); k(".ke-tabs-li", div)[0].click(); k(".ke-refresh-btn", div).click(); } } else { alert(data.message); } }, aftererror : function(html) { dialog.hideloading(); self.errordialog(html); } }); uploadbutton.filebox.change(function(e) { localurlbox.val(uploadbutton.filebox.val()); }); if (allowfilemanager) { viewserverbtn.click(function(e) { self.loadplugin('filemanager', function() { self.plugin.filemanagerdialog({ viewtype : 'view', dirname : 'image', clickfn : function(url, title) { if (self.dialogs.length > 1) { k('[name="url"]', div).val(url); if (self.afterselectfile) { self.afterselectfile.call(self, url); } self.hidedialog(); } } }); }); }); } else { viewserverbtn.hide(); } var originalwidth = 0, originalheight = 0; function setsize(width, height) { widthbox.val(width); heightbox.val(height); originalwidth = width; originalheight = height; } refreshbtn.click(function(e) { var tempimg = k('', document).css({ position : 'absolute', visibility : 'hidden', top : 0, left : '-1000px' }); tempimg.bind('load', function() { setsize(tempimg.width(), tempimg.height()); tempimg.remove(); }); k(document.body).append(tempimg); }); widthbox.change(function(e) { if (originalwidth > 0) { heightbox.val(math.round(originalheight / originalwidth * parseint(this.value, 10))); } }); heightbox.change(function(e) { if (originalheight > 0) { widthbox.val(math.round(originalwidth / originalheight * parseint(this.value, 10))); } }); urlbox.val(options.imageurl); setsize(options.imagewidth, options.imageheight); titlebox.val(options.imagetitle); alignbox.each(function() { if (this.value === options.imagealign) { this.checked = true; return false; } }); if (showremote && tabindex === 0) { urlbox[0].focus(); urlbox[0].select(); } return dialog; }; self.plugin.image = { edit : function() { var img = self.plugin.getselectedimage(); self.plugin.imagedialog({ imageurl : img ? img.attr('data-ke-src') : 'http://', imagewidth : img ? img.width() : '', imageheight : img ? img.height() : '', imagetitle : img ? img.attr('title') : '', imagealign : img ? img.attr('align') : '', showremote : allowimageremote, showlocal : allowimageupload, tabindex: img ? 0 : imagetabindex, clickfn : function(url, title, width, height, border, align) { if (img) { img.attr('src', url); img.attr('data-ke-src', url); img.attr('width', width); img.attr('height', height); img.attr('title', title); img.attr('align', align); img.attr('alt', title); } else { self.exec('insertimage', url, title, width, height, border, align); } // bugfix: [firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hidedialog settimeout(function() { self.hidedialog().focus(); }, 0); } }); }, 'delete' : function() { var target = self.plugin.getselectedimage(); if (target.parent().name == 'a') { target = target.parent(); } target.remove(); // [ie] 删除图片后立即点击图片按钮出错 self.addbookmark(); } }; self.clicktoolbar(name, self.plugin.image.edit); });
网站地图