LAPTOP-SB56SG4Q\86185
3 years ago
13 changed files with 651 additions and 1 deletions
Binary file not shown.
@ -1,3 +1,6 @@
|
||||
# open-JSD-8501 |
||||
|
||||
JSD-8501 文件控件功能加强 |
||||
JSD-8501 文件控件功能加强\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.third.party.jsdifab</id> |
||||
<name><![CDATA[文件控件加强版]]></name> |
||||
<active>yes</active> |
||||
<version>0.1</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2019-01-01</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[文件控件添加jpg,jpeg,png文件类型功能]]></description> |
||||
<change-notes><![CDATA[]]></change-notes> |
||||
<extra-report> |
||||
<JavaScriptFileHandler class="com.fr.plugin.third.party.jsdifab.web.ResourceJavaScriptFileHandler"/> |
||||
</extra-report> |
||||
<extra-form> |
||||
<JavaScriptFileHandler class="com.fr.plugin.third.party.jsdifab.web.ResourceJavaScriptFileHandler"/> |
||||
</extra-form> |
||||
<extra-designer> |
||||
<FormWidgetOptionProvider class="com.fr.plugin.third.party.jsdifab.parameter.CustomMultiFileWidgetOptionProvider"/> |
||||
<CellWidgetOptionProvider class="com.fr.plugin.third.party.jsdifab.cell.CustomMultiFileCellWidgetOptionProvider"/> |
||||
</extra-designer> |
||||
<function-recorder class="com.fr.plugin.third.party.jsdifab.web.ResourceJavaScriptFileHandler"/> |
||||
</plugin> |
@ -0,0 +1,30 @@
|
||||
package com.fr.plugin.third.party.jsdifab.cell; |
||||
|
||||
import com.fanruan.api.design.DesignKit; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.impl.AbstractCellWidgetOptionProvider; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.plugin.third.party.jsdifab.parameter.CustomMultiFileEditor; |
||||
|
||||
public class CustomMultiFileCellWidgetOptionProvider extends AbstractCellWidgetOptionProvider { |
||||
@Override |
||||
public Class<? extends CustomMultiFileEditor> classForWidget() { |
||||
return CustomMultiFileEditor.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BasicBeanPane<? extends Widget>> appearanceForWidget() { |
||||
return CustomMultiFileEditorPane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "com/fr/plugin/third/party/jsdifab/images/files_up.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return DesignKit.i18nText("Fine-Design_Basic_Widget_Type_File")+"++"; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,124 @@
|
||||
package com.fr.plugin.third.party.jsdifab.cell; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.gui.icombobox.DictionaryConstants; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.utils.gui.UIComponentUtils; |
||||
import com.fr.design.widget.ui.FieldEditorDefinePane; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.third.party.jsdifab.parameter.CustomMultiFileEditor; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.KeyListener; |
||||
|
||||
public class CustomMultiFileEditorPane extends FieldEditorDefinePane<CustomMultiFileEditor> { |
||||
private DictionaryComboBox acceptType; |
||||
private UICheckBox singleFileCheckBox; |
||||
private UISpinner fileSizeField; |
||||
|
||||
public CustomMultiFileEditorPane() { |
||||
this.initComponents(); |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return "file"; |
||||
} |
||||
|
||||
protected JPanel setFirstContentPane() { |
||||
JPanel var1 = new JPanel(new BorderLayout()); |
||||
this.singleFileCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Single_File_Upload")); |
||||
UIComponentUtils.setLineWrap(this.singleFileCheckBox); |
||||
this.singleFileCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
//this.acceptType = new DictionaryComboBox(DictionaryConstants.acceptTypes, DictionaryConstants.fileTypeDisplays);
|
||||
//this.acceptType.setEditable(true);
|
||||
//jpg,jpeg,png
|
||||
String[] tempAcceptTypes = ArrayUtils.addAll(DictionaryConstants.acceptTypes, new String[]{"jpg|jpeg|png"}); |
||||
String[] tempFileTypeDisplays = ArrayUtils.addAll(DictionaryConstants.fileTypeDisplays, new String[]{"jpg,jpeg,png"}); |
||||
|
||||
if (!PluginContexts.currentContext().isAvailable()) { |
||||
LogKit.error("文件控件加强版许可证过期"); |
||||
tempAcceptTypes = DictionaryConstants.acceptTypes; |
||||
tempFileTypeDisplays = DictionaryConstants.fileTypeDisplays; |
||||
} |
||||
this.acceptType = new DictionaryComboBox(tempAcceptTypes, tempFileTypeDisplays); |
||||
|
||||
this.acceptType.addKeyListener(new KeyListener() { |
||||
@Override |
||||
public void keyTyped(KeyEvent e) { |
||||
//必须加这个,否则自定义下拉框的值,会不保存
|
||||
doChangeOfAcceptType(); |
||||
} |
||||
|
||||
@Override |
||||
public void keyPressed(KeyEvent e) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void keyReleased(KeyEvent e) { |
||||
|
||||
} |
||||
}); |
||||
this.acceptType.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
//必须加这个,否则自定义下拉框的值,会不保存
|
||||
doChangeOfAcceptType(); |
||||
} |
||||
}); |
||||
|
||||
|
||||
this.fileSizeField = new UISpinner(0.0D, 2.147483647E9D, 1.0D, -1.0D); |
||||
this.fileSizeField.setPreferredSize(new Dimension(140, 20)); |
||||
JPanel var2 = new JPanel(new BorderLayout()); |
||||
UILabel var3 = new UILabel(Toolkit.i18nText("Fine-Design_Report_Utils_File_Type")); |
||||
UILabel var4 = new UILabel(Toolkit.i18nText("Fine-Design_Report_Size_Limit")); |
||||
var2.add(this.fileSizeField, "Center"); |
||||
var2.add(new UILabel(" KB"), "East"); |
||||
double var5 = -1.0D; |
||||
double var7 = -2.0D; |
||||
Component[][] var9 = new Component[][]{{this.singleFileCheckBox, null}, {var3, this.acceptType}, {var4, var2}}; |
||||
double[] var10 = new double[]{var7, var7, var7}; |
||||
double[] var11 = new double[]{var7, var5}; |
||||
int[][] var12 = new int[][]{{1, 1}, {1, 1}, {1, 1}}; |
||||
JPanel var13 = TableLayoutHelper.createGapTableLayoutPane(var9, var10, var11, var12, 25.0D, 10.0D); |
||||
var1.add(var13, "Center"); |
||||
return var1; |
||||
} |
||||
|
||||
private void doChangeOfAcceptType() { |
||||
//必须加这个,否则自定义下拉框的值,会不保存
|
||||
if (this.acceptType.getUiObserverListener() != null) { |
||||
this.acceptType.getUiObserverListener().doChange(); |
||||
} |
||||
} |
||||
|
||||
protected void populateSubFieldEditorBean(CustomMultiFileEditor var1) { |
||||
this.acceptType.setSelectedItem(var1.getAccept()); |
||||
this.singleFileCheckBox.setSelected(var1.isSingleFile()); |
||||
this.fileSizeField.setValue(var1.getMaxSize()); |
||||
} |
||||
|
||||
protected CustomMultiFileEditor updateSubFieldEditorBean() { |
||||
CustomMultiFileEditor var1 = new CustomMultiFileEditor(); |
||||
//this.acceptType.getSelectedItem() 只能获取到上一次的值
|
||||
String acceptTypeValue = this.acceptType.getEditor().getItem().toString(); |
||||
var1.setAccept(acceptTypeValue); |
||||
System.out.println("updateSubFieldEditorBean"); |
||||
System.out.println(var1.getAccept()); |
||||
var1.setSingleFile(this.singleFileCheckBox.isSelected()); |
||||
var1.setMaxSize(this.fileSizeField.getValue()); |
||||
return var1; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,35 @@
|
||||
package com.fr.plugin.third.party.jsdifab.parameter; |
||||
|
||||
import com.fr.form.ui.MultiFileEditor; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
public class CustomMultiFileEditor extends MultiFileEditor { |
||||
|
||||
@Override |
||||
public String getXType() { |
||||
//return "multifile_jsd5094" ;
|
||||
return super.getXType(); |
||||
} |
||||
|
||||
public void readXML(XMLableReader var1) { |
||||
super.readXML(var1); |
||||
|
||||
|
||||
} |
||||
|
||||
public void writeXML(XMLPrintWriter var1) { |
||||
super.writeXML(var1); |
||||
|
||||
} |
||||
|
||||
public boolean equals(Object var1) { |
||||
if (!(var1 instanceof CustomMultiFileEditor)) { |
||||
return false; |
||||
} else { |
||||
return super.equals(var1) && ComparatorUtils.equals(((CustomMultiFileEditor)var1).getAccept(), this.getAccept()) && this.getMaxLength() == ((CustomMultiFileEditor)var1).getMaxLength(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.fr.plugin.third.party.jsdifab.parameter; |
||||
|
||||
import com.fanruan.api.design.DesignKit; |
||||
import com.fr.design.fun.impl.AbstractFormWidgetOptionProvider; |
||||
|
||||
public class CustomMultiFileWidgetOptionProvider extends AbstractFormWidgetOptionProvider { |
||||
@Override |
||||
public Class<? extends CustomMultiFileEditor> classForWidget() { |
||||
return CustomMultiFileEditor.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<?> appearanceForWidget() { |
||||
return XCustomMultiFileUploader.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "com/fr/plugin/third/party/jsdifab/images/files_up.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return DesignKit.i18nText("Fine-Design_Basic_Widget_Type_File")+"++"; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,23 @@
|
||||
package com.fr.plugin.third.party.jsdifab.parameter; |
||||
|
||||
import com.fr.design.designer.creator.XMultiFileUploader; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public class XCustomMultiFileUploader extends XMultiFileUploader { |
||||
|
||||
public XCustomMultiFileUploader(CustomMultiFileEditor editor, Dimension dimension) { |
||||
super(editor, dimension); |
||||
} |
||||
|
||||
@Override |
||||
public String getIconPath() { |
||||
return "/com/fr/plugin/third/party/jsdifab/images/files_up.png"; |
||||
} |
||||
|
||||
@Override |
||||
protected String getIconName() { |
||||
return "/com/fr/plugin/third/party/jsdifab/images/files_up.png"; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,23 @@
|
||||
package com.fr.plugin.third.party.jsdifab.web; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.fun.Authorize; |
||||
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||
|
||||
@EnableMetrics |
||||
@Authorize(callSignKey = "com.fr.plugin.third.party.jsdifab") |
||||
public class ResourceJavaScriptFileHandler extends AbstractJavaScriptFileHandler { |
||||
@Override |
||||
@Focus(id = "com.fr.plugin.third.party.jsdifab", text = "plugin-jsd-ifab", source = Original.PLUGIN) |
||||
public String[] pathsForFiles() { |
||||
if (!PluginContexts.currentContext().isAvailable()) { |
||||
return new String[]{}; |
||||
} |
||||
return new String[]{ |
||||
"/com/fr/plugin/third/party/jsdifab/web/jsdifab.js" |
||||
}; |
||||
} |
||||
} |
After Width: | Height: | Size: 742 B |
@ -0,0 +1,363 @@
|
||||
;(function (a) { |
||||
FR.CustomJsd5094MultiFileEditor = FR.extend(FR.BaseEditor, { |
||||
_defaultConfig: function () { |
||||
return a.extend(FR.CustomJsd5094MultiFileEditor.superclass._defaultConfig.apply(), { |
||||
width: 120, |
||||
height: 20, |
||||
render: true, |
||||
showViewImage: true |
||||
}) |
||||
}, _init: function () { |
||||
FR.$defaultImport("/com/fr/web/core/js/noswfupload.js", "js"); |
||||
FR.$defaultImport("/com/fr/web/core/css/widget/noswfupload-icons.css", "css"); |
||||
FR.CustomJsd5094MultiFileEditor.superclass._init.apply(this, arguments); |
||||
var h = this.options; |
||||
var d = this; |
||||
this.$uploadForm = a('<form enctype="multipart/form-data"></form>').css("position", "relative").appendTo(this.element); |
||||
this.divWrap = a("<div></div>").css({ |
||||
"width": this.options.width + "px", |
||||
"height": this.options.height + "px", |
||||
"position": "relative", |
||||
"overflow": "hidden" |
||||
}).appendTo(this.$uploadForm); |
||||
this.$fileupload = a('<input type="file" name="file"/>').addClass("fr-fileupload").appendTo(this.divWrap); |
||||
if (h.maxlength !== 1) { |
||||
this.$fileupload[0].setAttribute("multiple", "multiple") |
||||
} |
||||
if (h.disabled) { |
||||
this.$fileupload[0].setAttribute("disabled", "disabled") |
||||
} |
||||
if (h.render === true) { |
||||
var e = Math.min(this.options.height, this.options.width); |
||||
var c = e > 32 ? 32 : e - 2; |
||||
var b = e > 32 ? 20 : e * 0.7; |
||||
this.$previewImage = a("<img>").attr("src", FR.servletURL + "?op=resource&resource=/com/fr/web/images/file/upload.png").appendTo(this.divWrap).addClass("fr-fileupload-image").css({ |
||||
left: this.options.width > 32 ? (this.options.width - 32) / 2 : 0, |
||||
top: this.options.height > 32 ? (this.options.height - 32) / 2 : 0, |
||||
width: c, |
||||
height: c |
||||
}); |
||||
if (h.tooltipText) { |
||||
var g = a("<span/>").addClass("fr-fileupload-tooltipspan"); |
||||
this.tooltipDiv = a("<div/>").css({ |
||||
left: c + 7 + "px", |
||||
height: c + "px" |
||||
}).append(g.text(h.tooltipText)).addClass("fr-fileupload-tooltip").appendTo(this.$uploadForm) |
||||
} |
||||
this.$preview = this.$previewImage; |
||||
if (d.options.maxlength !== 1) { |
||||
this.$previewCount = a('<div class="fr-fileupload-preview-count"/>').text(0).appendTo(this.divWrap).css({ |
||||
left: this.options.width > 32 ? (this.options.width - 32) / 2 + 22 : this.$previewImage.width() - 10, |
||||
top: this.options.height > 32 ? (this.options.height - 32) / 2 + 8 : 0, |
||||
width: b, |
||||
height: b, |
||||
"border-radius": b, |
||||
"font-size": b * 0.6 |
||||
}) |
||||
} |
||||
} else { |
||||
this.$preview = this.element |
||||
} |
||||
if (this.options.write) { |
||||
a(".fr-fileupload", d.element).css({ |
||||
"right": 0, |
||||
"font-size": d.element.height() < 100 ? "100px" : d.element.height() + "px", |
||||
"width": this.options.width, |
||||
"height": this.options.height |
||||
}) |
||||
} |
||||
this.wrap = noswfupload.wrap((this.$fileupload)[0], h.maxSize, h.maxlength, this.options.width, this.options.height); |
||||
var f = this.wrap; |
||||
f.onerror = function () { |
||||
noswfupload.text(this.dom.info, "WARNING: Unable to upload " + this.file.fileName) |
||||
}; |
||||
f.onloadstart = function (i, j) { |
||||
this.show(0, 0); |
||||
noswfupload.text(this.dom.info, "Preparing for upload ... ") |
||||
}; |
||||
f.onprogress = function (i, j) { |
||||
this.show((this.sent + i.loaded) * 100 / this.total, i.loaded * 100 / i.total); |
||||
noswfupload.text(this.dom.info, FR.i18nText("Fine-Engine_Basic_File_Uping_File") + ": " + this.file.fileName); |
||||
if (this.file.fileSize !== -1) { |
||||
if (i.simulation) { |
||||
noswfupload.text(this.dom.info, FR.i18nText("Fine-Engine_Basic_File_Uping_File") + ": " + this.file.fileName, FR.i18nText("Fine-Engine_Basic_File_All_File_Uploaded") + noswfupload.size(this.sent + i.loaded)) |
||||
} else { |
||||
noswfupload.text(this.dom.info, FR.i18nText("Fine-Engine_Basic_File_Uping_File") + ": " + this.file.fileName, FR.i18nText("Fine-Engine_Basic_File_Uploaded_File") + ": " + noswfupload.size(i.loaded), FR.i18nText("Fine-Engine_Basic_File_All_File_Uploaded") + noswfupload.size(this.sent + i.loaded)) |
||||
} |
||||
} else { |
||||
noswfupload.text(this.dom.info, "Uploading: " + this.file.fileName, "Sent: " + (this.sent / 100) + " out of " + (this.total / 100)) |
||||
} |
||||
}; |
||||
f.onerror = function () { |
||||
noswfupload.text(this.dom.info, "WARNING: Unable to upload " + this.file.fileName) |
||||
}; |
||||
f.onload = function (k, m) { |
||||
var l = this; |
||||
noswfupload.text(this.dom.info, "Upload complete"); |
||||
setTimeout(function () { |
||||
l.clean(); |
||||
l.hide(); |
||||
noswfupload.text(l.dom.info, ""); |
||||
d.fireEvent(FR.Events.AFTEREDIT) |
||||
}, 1000); |
||||
var j = ""; |
||||
_.each(d.wrap.attach_array, function (n) { |
||||
if (n.errorCode === 21300002) { |
||||
j += n.filename + " : " + FR.i18nText("Fine-Engine_Report_File_File_Too_Big") + f.maxSize + "KB; " |
||||
} else { |
||||
if (n.errorCode === 21300003) { |
||||
var o = f.fileType ? (FR.i18nText("Fine-Dec_Invalid_File_Type_To_Upload") + f.fileType) : FR.i18nText("Fine-Engine_Generic_Invalid_File_Type_Security"); |
||||
j += n.filename + o + "; " |
||||
} |
||||
} |
||||
}); |
||||
if (j) { |
||||
FR.Msg.toast(j) |
||||
} |
||||
var i = _.filter(d.wrap.attach_array, function (n) { |
||||
return n.errorCode === undefined |
||||
}); |
||||
if (_.isEmpty(i)) { |
||||
d.wrap.attach_array = []; |
||||
return |
||||
} |
||||
d.showViewList(); |
||||
d.fireEvent(FR.Events.CALLBACK, d.wrap.attach_array[0]) |
||||
}; |
||||
f.url = this.options.url ? this.options.url : FR.servletURL + "?op=fr_attach&cmd=ah_upload"; |
||||
f.url += this.options.sessionID ? "&sessionID=" + this.options.sessionID : ""; |
||||
f.url += ((window.FS && window.FS.serverID) ? "&serverID=" + window.FS.serverID : ""); |
||||
f.fileType = h.accept; |
||||
f.attach_array = []; |
||||
f.attach_names = []; |
||||
f.attachNum = 0; |
||||
this._dealValueWithEvents(h.value) |
||||
}, _dealValueWithEvents: function (b) { |
||||
if (FR.equals(b, this.wrap.attach_array) || (this.wrap.attach_array.length === 1 && FR.equals(this.wrap.attach_array[0], b))) { |
||||
return |
||||
} |
||||
if ((a.isArray(b) && b.length > 0 && b[0].attach_id) || (b && b.attach_id)) { |
||||
var e = a.isArray(b) ? b : [b]; |
||||
this.wrap.attach_array = []; |
||||
for (var c = 0; c < e.length; c++) { |
||||
this.wrap.attach_array.push(e[c]); |
||||
var d = {}; |
||||
this.wrap.files.push(d) |
||||
} |
||||
this.showViewList(); |
||||
this.wrap.files.length = 0 |
||||
} |
||||
if (b == "") { |
||||
this.reset() |
||||
} |
||||
}, createListItem: function (d, e) { |
||||
if (d.errorCode) { |
||||
return null |
||||
} |
||||
var c = this; |
||||
var b = a("<li></li>"); |
||||
var f; |
||||
b.append(f = (a("<a class='fr-fileupload-progressCancel' href='#'> </a>")).click(function (g) { |
||||
c.removeAttach(d, b); |
||||
g.stopEvent() |
||||
}).hide()).append(a("<span class='fr-fileupload-fileNameItem'>" + c.wrap.attach_names[e] + " " + FR.__fileSizeFormat__(d.fileSize) + "</span>").bind("click", function () { |
||||
var g = d.attach_id; |
||||
window.open(FR.servletURL + "?op=fr_attach&cmd=ah_download&id=" + g) |
||||
}).mouseover(function () { |
||||
a(this).css({color: "blue"}) |
||||
}).mouseout(function () { |
||||
a(this).css({color: ""}) |
||||
})).addClass("fr-fileupload-listitem").mouseover(function () { |
||||
f.show(); |
||||
a(this).css({"background-color": "#9FC5F8"}) |
||||
}).mouseout(function () { |
||||
f.hide(); |
||||
a(this).css({"background-color": ""}) |
||||
}); |
||||
c.wrap.attachNum++; |
||||
if (c.wrap.maxlength !== 1) { |
||||
c.$previewCount.text(c.wrap.attachNum) |
||||
} |
||||
return b |
||||
}, showViewList: function () { |
||||
var s = this; |
||||
var h; |
||||
var t; |
||||
if (!s.options.hideFileList) { |
||||
var r = a("ul", s.element); |
||||
if (r.length === 0) { |
||||
var l = a("<div class='fr-fileupload-popview'/>").appendTo(s.element).css({ |
||||
marginTop: 18 - s.options.height / 2, |
||||
marginLeft: s.options.width / 2 + 18 |
||||
}); |
||||
h = a("<div class='fr-fileupload-popview-list'/>").appendTo(l); |
||||
t = a("<ul/>").addClass("fr-fileupload-list").appendTo(h) |
||||
} else { |
||||
h = r.parent(); |
||||
t = r |
||||
} |
||||
} |
||||
var d = s.wrap; |
||||
this.imageURL = null; |
||||
if (s.options.maxlength === 1) { |
||||
var g = this.options; |
||||
var q = d.attach_array[0]; |
||||
this.removeBackground(); |
||||
if (q.attach_type == "image") { |
||||
s.$tempPreview = a("<td></td>").appendTo(this.divWrap).css({ |
||||
left: s.element.outerWidth(true) - s.element.width(), |
||||
width: g.width, |
||||
height: g.height, |
||||
top: 0, |
||||
position: "absolute" |
||||
}); |
||||
FR.lastTarget = s.$tempPreview; |
||||
var f = a(s.$tempPreview); |
||||
f.css("background", ""); |
||||
var c = FR.servletURL + "?op=fr_attach&cmd=ah_image&id=" + q.attach_id; |
||||
f.css("background", "url(" + c + ") 0 0 no-repeat transparent"); |
||||
this.imageURL = c; |
||||
f.css("cursor", "default").unbind("click", b) |
||||
} |
||||
d.attach_names[0] = q.filename; |
||||
if (t) { |
||||
t.children().remove(); |
||||
t.append(this.createListItem(q, 0)) |
||||
} |
||||
} |
||||
if (s.options.maxlength !== 1) { |
||||
for (var p = d.attach_array.length - 1, k = 0; k < d.files.length; p--, k++) { |
||||
d.attach_names[p] = d.attach_array[p].filename; |
||||
var e = 0; |
||||
for (var n = 0; |
||||
n < d.attach_array.length - d.files.length; n++) { |
||||
if (d.attach_names[p] === d.attach_array[n].filename) { |
||||
e++ |
||||
} |
||||
} |
||||
if (e > 0) { |
||||
d.attach_names[p] = FR.lengthenFileName(d.attach_array[p].filename, "(" + e + ")") |
||||
} |
||||
t && t.append(this.createListItem(d.attach_array[p], p)) |
||||
} |
||||
} |
||||
s.wrap.attach_array = _.filter(s.wrap.attach_array, function (i) { |
||||
return i.errorCode === undefined |
||||
}); |
||||
if (FR.Browser.isIE() && h) { |
||||
if (h.height() > 160) { |
||||
h.height(160); |
||||
if (t.width() + 18 > h.width()) { |
||||
h.width(t.width() + 18) |
||||
} |
||||
} |
||||
} |
||||
|
||||
function b(i) { |
||||
window.open(FR.servletURL + "?op=fr_attach&cmd=ah_download&id=" + i.data); |
||||
i.stopPropagation() |
||||
} |
||||
}, removeAttach: function (e, c) { |
||||
var b = e.attach_id; |
||||
var d = this; |
||||
var f = this.wrap; |
||||
FR.ajax({ |
||||
url: FR.servletURL + "?op=fr_attach&cmd=ah_release", data: {id: b}, complete: function (h, g) { |
||||
if (g == "success") { |
||||
if (c) { |
||||
c.remove() |
||||
} |
||||
d.imageURL = null; |
||||
for (var i = 0; i < f.attach_array.length; i++) { |
||||
if (f.attach_array[i].attach_id == b) { |
||||
if (d.wrap.maxlength !== 1) { |
||||
f.attachNum--; |
||||
d.$previewCount.text(d.wrap.attachNum); |
||||
if (f.attachNum === 0) { |
||||
a(".fr-fileupload-popview", d.element).remove() |
||||
} |
||||
} |
||||
f.attach_array.removeWeakEqual(f.attach_array[i]); |
||||
break |
||||
} |
||||
} |
||||
if (d.wrap.maxlength === 1) { |
||||
a(".fr-fileupload-popview", d.element).remove(); |
||||
d.removeBackground() |
||||
} |
||||
d.fireEvent(FR.Events.CALLBACK) |
||||
} |
||||
} |
||||
}) |
||||
}, resetBackground: function (c) { |
||||
var b = c || this.imageURL; |
||||
this.removeBackground(); |
||||
if (this.options.tdCell) { |
||||
this.options.tdCell.css("background", "url(" + b + "&height=" + this.options.tdCell.height() + ") 0 0 no-repeat transparent") |
||||
} |
||||
}, removeBackground: function () { |
||||
if (this.options.tdCell) { |
||||
this.options.tdCell.css("background-image", "") |
||||
} |
||||
var b = this.divWrap.children().eq(2); |
||||
b.css("background-image", ""); |
||||
b.remove() |
||||
}, startEditing: function () { |
||||
if (this.options.tdCell) { |
||||
a(".attach-download-div,.fr-fileupload-download-all", a(this.options.tdCell)).hide() |
||||
} |
||||
this.$preview.show(); |
||||
if (this.options.disabled) { |
||||
this.$preview.unbind("click") |
||||
} |
||||
if (FR.Browser.isIE() && !a.support.boxModel && this.options.write) { |
||||
a(".x-editor").addClass("none-border") |
||||
} |
||||
FR.CustomJsd5094MultiFileEditor.superclass.startEditing.apply(this, arguments) |
||||
}, stopEditing: function () { |
||||
if (this.options.tdCell) { |
||||
var c = a(".attach-download-div,.fr-fileupload-download-all", a(this.options.tdCell)); |
||||
c.show() |
||||
} |
||||
if (FR.Browser.isIE() && !a.support.boxModel && this.options.write) { |
||||
a(".x-editor").removeClass("none-border") |
||||
} |
||||
if (this.imageURL != null) { |
||||
var b = this; |
||||
setTimeout(function () { |
||||
b.resetBackground() |
||||
}, 200) |
||||
} |
||||
}, getValue: function () { |
||||
if (!this.wrap.attach_array) { |
||||
return "" |
||||
} |
||||
if (this.options.maxlength === 1 && this.wrap.attach_array[0] && this.wrap.attach_array[0].attach_type == "image") { |
||||
return this.wrap.attach_array[0] |
||||
} |
||||
return this.wrap.attach_array.length === 0 ? "" : this.wrap.attach_array |
||||
}, setEnable: function (b) { |
||||
FR.CustomJsd5094MultiFileEditor.superclass.setEnable.apply(this, arguments); |
||||
if (this.$fileupload && this.$fileupload[0]) { |
||||
if (b) { |
||||
this.$fileupload[0].removeAttribute("disabled") |
||||
} else { |
||||
this.$fileupload[0].setAttribute("disabled", "disabled") |
||||
} |
||||
} |
||||
}, isShowViewImage: function () { |
||||
return this.options.showViewImage && this.options.maxlength === 1 |
||||
}, reset: function () { |
||||
this.wrap.attach_array = []; |
||||
this.wrap.attach_names = []; |
||||
this.wrap.attachNum = 0; |
||||
if (this.options.tdCell) { |
||||
a(".attach-download-div", a(this.options.tdCell)).remove() |
||||
} |
||||
a(".fr-fileupload-popview", this.element).remove(); |
||||
this.removeBackground() |
||||
} |
||||
}); |
||||
a.shortcut("multifile_jsd5094", FR.CustomJsd5094MultiFileEditor) |
||||
} |
||||
)(jQuery); |
Binary file not shown.
Loading…
Reference in new issue