/**
* @description 快捷键设计器对象
*/
function FastkeyDesigner(){
UDeisgner.call(this);
this.designerRelationMgr = null;
this.mediator = null;
this.create = createFastkey; //创建单元
this.loadXml = loadFastkey; //加载单元
this.preview = previewFastkey; //预览单元
this.toXml = toFastkeyXml; //获取单元XML描述
this.destory = destoryFastkey; //删除单元(原)
this.del = deleteFastkey; //删除单元(新)
this.setVersion = setFastkeyVersion;//另存版本
this.resize = resizeFastkey;
}
FastkeyDesigner.prototype.ibusToolbar = null; //当前快捷工具栏设计器的dhtmlXToolbarObject对象
FastkeyDesigner.prototype.ibusFastkey = null; //当前快捷键设计器的dhtmlXToolbarObject对象
FastkeyDesigner.prototype.toolbarEntity = null; //当前快捷键设计器的dhtmlXToolbarObject实体Entity对象
FastkeyDesigner.prototype.dhxWins = null; //当前快捷键设计器的dhtmlXWindows对象
FastkeyDesigner.prototype.fastkeyEntity = null;
FastkeyDesigner.prototype.appid = null; //应用ID
/**
* @description 将快捷键实体转换为XML描述
*/
function toFastkeyXml(){
var fastkeyEntityXml = null;
if (this.fastkeyEntity != null) {
if (this.toolbarEntity != null) {
this.fastkeyEntity.toolEntityArray = this.toolbarEntity.toolEntityArray;
}
fastkeyEntityXml=this.fastkeyEntity.getFastkeyEntityXml();
}
return fastkeyEntityXml;
}
/**
* @description 预览快捷键
* @param el 单元定义的Element
* @param containerObj 布局容器对象
* @param targetId 目标Id
* @param layoutType 布局类型,"MAIN_LAYOUT"为主界面布局
* @param applicationId 应用Id
* @param currentMode "USER_MODE"为用户模式,"NORMAL_MODE"为预览模式
*/
function previewFastkey(el, containerObj, targetId,layoutType,applicationId, currentMode){
this.appid = applicationId;
// alert(serializeXml(el));
var fastkeyEntity = new FastkeyEntity();
fastkeyEntity.loadFastkeyEntity(el);
this.toolbarEntity = new ToolBarEntity();
this.toolbarEntity.toolEntityArray = fastkeyEntity.toolEntityArray;
var fastkeyUnitDiv = createFastkeyUnitDiv(fastkeyEntity,targetId,"preview");
// alert(fastkeyUnitDiv.innerHTML);
if (layoutType=="MAIN_LAYOUT") {
containerObj.attachObject(fastkeyUnitDiv);
}else{
containerObj.cells(targetId).attachObject(fastkeyUnitDiv);
containerObj.setTabActive(targetId);
}
this.ibusToolbar = new dhtmlXToolbarObject("toolbar"+targetId);
this.ibusToolbar.setSkin('dhx_ibusblue');
this.ibusToolbar.setIconsPath(path+"/jsp/developcenter/unitdesigner/fastkey/imgs/ibus/system/");
this.ibusFastkey = new dhtmlXToolbarObject("fastkey"+targetId);
this.ibusFastkey.setSkin('dhx_ibusblue');
this.ibusFastkey.setIconsPath(path+"/jsp/developcenter/unitdesigner/fastkey/imgs/ibus/system/");
viewFastkey(this.ibusFastkey, fastkeyEntity.menusArray);
viewFastToolbar(this.ibusToolbar, fastkeyEntity.toolEntityArray);
var mediator = this.mediator;
//定义事件
this.ibusFastkey.attachEvent("onClick", function(id){
var resourceURL = "";
var tempArray=fastkeyEntity.menusArray;
for(var i=0; i<tempArray.length; i++){
var fmEntity=tempArray[i];
if(id==fmEntity.id){
resourceURL=fmEntity.targer;
break;
}
}
// alert("mediator="+mediator);
// alert("resourceURL="+resourceURL);
//点击菜单项,链接到资源地址或装配的页面
linkURL(mediator, resourceURL, id, currentMode,"4");
});
//定义事件
this.ibusToolbar.attachEvent("onClick", function(id){
var jscode="";
var tempArray=fastkeyEntity.toolEntityArray;
for(var i=0; i<tempArray.length; i++){
var toolEntity=tempArray[i];
if(id==toolEntity.tool_code){
jscode=toolEntity.tool_js;
break;
}
}
jscode=revertString(jscode);
eval(jscode);
});
}
/**
* @description 布局单元调整高度/宽度时会调用此方法
*
* @param targetId 当前填充单元的ID
* @param height 当前填充单元高度
* @param width 当前填充单元宽度
* @author fuxl
* @date 2011-09-19
* @return 无
*/
function resizeFastkey(targetId,height,width){
}
/**
* @description 加载快捷键
* @param el 快捷键元素
* @param containerObj layout容器
* @param targetId 布局区域的ID
*/
function loadFastkey(el, containerObj, targetId,layoutType,applicationId){
this.appid = applicationId;
this.fastkeyEntity = new FastkeyEntity();
this.fastkeyEntity.loadFastkeyEntity(el);
this.toolbarEntity = new ToolBarEntity();
this.toolbarEntity.toolEntityArray = this.fastkeyEntity.toolEntityArray;
var fastkeyUnitDiv = createFastkeyUnitDiv(this.fastkeyEntity,targetId,"load");
if (layoutType=="MAIN_LAYOUT") {
containerObj.attachObject(fastkeyUnitDiv);
}else{
containerObj.cells(targetId).attachObject(fastkeyUnitDiv);
containerObj.setTabActive(targetId);
}
this.ibusToolbar = new dhtmlXToolbarObject("toolbar"+targetId);
this.ibusToolbar.setSkin('dhx_ibusblue');
this.ibusToolbar.setIconsPath(path+"/jsp/developcenter/unitdesigner/fastkey/imgs/ibus/system/");
this.ibusFastkey = new dhtmlXToolbarObject("fastkey"+targetId);
this.ibusFastkey.setSkin('dhx_ibusblue');
this.ibusFastkey.setIconsPath(path+"/jsp/developcenter/unitdesigner/fastkey/imgs/ibus/system/");
this.ibusFastkey.setAlign(this.fastkeyEntity.menus_align);
this.ibusToolbar.setAlign(this.fastkeyEntity.sysbutton_align);
viewFastkey(this.ibusFastkey, this.fastkeyEntity.menusArray);
viewFastToolbar(this.ibusToolbar, this.fastkeyEntity.toolEntityArray);
}
/**
* @description 删除快捷键单元
*/
function destoryFastkey(){
return true;
}
/**
* 另存图片单元版本
*/
function setFastkeyVersion(version) {
//alert("sa="+version);
this.fastkeyEntity.version = version;
}
/**
* @description 删除快捷键单元
* @param targetId 布局区域的ID
*/
function deleteFastkey(targetId){
var targetDIV=document.getElementById(targetId);
targetDIV.parentNode.removeChild(targetDIV);
return true;
}
/**
* @description 创建一个单元对象
* @param containerObj layout容器
* @param targetId 布局区域的ID
*/
function createFastkey(containerObj, targetId,layoutType,applicationId){
this.appid = applicationId;
this.fastkeyEntity = new FastkeyEntity();
this.fastkeyEntity.id = targetId;
this.toolbarEntity = new ToolBarEntity();
var fastkeyUnitDiv = createFastkeyUnitDiv(this.fastkeyEntity,targetId,"create");
// alert(fastkeyUnitDiv.innerHTML);
if (layoutType=="MAIN_LAYOUT") {
containerObj.attachObject(fastkeyUnitDiv);
}else{
containerObj.cells(targetId).attachObject(fastkeyUnitDiv);
containerObj.setTabActive(targetId);
}
this.ibusToolbar = new dhtmlXToolbarObject("toolbar"+targetId);
this.ibusToolbar.setSkin('dhx_ibusblue');
this.ibusToolbar.setIconsPath(path+"/jsp/developcenter/unitdesigner/fastkey/imgs/ibus/system/");
this.ibusFastkey = new dhtmlXToolbarObject("fastkey"+targetId);
this.ibusFastkey.setSkin('dhx_ibusblue');
this.ibusFastkey.setIconsPath(path+"/jsp/developcenter/unitdesigner/fastkey/imgs/ibus/system/");
}
/**
* @description 创建快捷键单元容器
* @param targetId layoutCell的ID
* @return 返回动态创建出来的DIV
*/
function createFastkeyUnitDiv(fastkeyEntity,targetId,fastkeyState){
var UnitDiv = document.createElement('div');
UnitDiv.style.width = "100%";
UnitDiv.style.height = "30px";
UnitDiv.style.background ="#D5E8FF";
UnitDiv.setAttribute("id",targetId);
var tab = document.createElement('table');
var tbody = document.createElement('tbody');
var tr = document.createElement('tr');
var fastkeytd = document.createElement('td');
var fastkeyDiv = document.createElement('div');
var toolbartd = document.createElement('td');
var toolbarDiv = document.createElement('div');
tr.style.border = "0";
fastkeytd.style.border = "0";
toolbartd.style.border = "0";
tab.style.width = "100%";
tab.style.height = "30px";
// tab.boder = "0";
// tab.cellpadding = "0";
// tab.cellspacing = "0";
// fastkeytd.style.width = "100%";
// fastkeytd.style.height = "30px";
// toolbartd.style.width = "100%";
// toolbartd.style.height = "30px";
fastkeyDiv.style.width = "100%";
fastkeyDiv.style.height = "30px";
// fastkeyDiv.style.background ="#FF0000";
fastkeyDiv.setAttribute("id","fastkey"+targetId);
fastkeytd.setAttribute("id","td_fastkey"+targetId);
fastkeytd.style.width = fastkeyEntity.menus_per;
fastkeytd.appendChild(fastkeyDiv);
tr.appendChild(fastkeytd);
toolbarDiv.style.width = "100%";
toolbarDiv.style.height = "30px";
// toolbarDiv.style.background ="#B3C9FE";
toolbarDiv.setAttribute("id","toolbar"+targetId);
toolbartd.setAttribute("id","td_toolbar"+targetId);
toolbartd.style.width = fastkeyEntity.sysbutton_per;
toolbartd.appendChild(toolbarDiv);
tr.appendChild(toolbartd);
tbody.appendChild(tr);
tab.appendChild(tbody);
UnitDiv.appendChild(tab);
if(fastkeyState != "preview"){
UnitDiv.onmouseup = function(e){
//弹出快捷键右键菜单
if(!e)e = window.event;
if(e.button == 2){
cancleEventUp(e);//阻止事件冒泡
return true;
}
};
fastkeyDiv.onmouseup = function(e){
//弹出快捷键右键菜单
if(!e)e = window.event;
if(e.button == 2){
createFastkeyMenu(targetId);
cancleEventUp(e);//阻止事件冒泡
return true;
}
};
toolbarDiv.onmouseup = function(e){
//弹出快捷工具栏右键菜单
if(!e)e = window.event;
if(e.button == 2){
createFastToolBarRMenu(targetId);
cancleEventUp(e);//阻止事件冒泡
return true;
}
};
}
// alert("UnitDiv:"+UnitDiv.innerHTML);
return UnitDiv;
}
/**
* @description 快捷键事件区右键菜单
* @param e 事件源
* @param targetId 容器Id
* @return dhtmlXMenuObject对象
*/
function createFastkeyMenu(targetId){
var fastkeyRMenu = new dhtmlXMenuObject();
fastkeyRMenu.setSkin('dhx_ibusblue');
fastkeyRMenu.setIconsPath(path+"/jsp/developcenter/unitdesigner/fastkey/imgs/dhtmlx/dhtmlxMenu/imgs/");
fastkeyRMenu.renderAsContextMenu();
fastkeyRMenu.addContextZone("fastkey"+targetId);
//注册点击事件
fastkeyRMenu.attachEvent("onClick", function(itemId){
if(itemId =='setting') {//设置属性
var dhxWins = getSelfDesigner(targetId).dhxWins;
if(dhxWins == null){
dhxWins = new dhtmlXWindows();
dhxWins.setSkin('dhx_ibusblue');
dhxWins.attachViewportTo("winVP"+targetId);
dhxWins.setImagePath(path+"/jsp/developcenter/unitdesigner/grid/imgs/dhtmlx/dhxWindows/");
getSelfDesigner(targetId).dhxWins = dhxWins;
}
//设置弹出窗口的XY坐标
if(dhxWins.isWindow("setparam"))return;
var w1 = dhxWins.createWindow("setparam", 390, 100, 380, 180);
dhxWins.window('setparam').setModal(true);
w1.setText("设置快捷键单元属性");
w1.button("minmax1").hide();
w1.button("park").hide();
w1.denyResize();
w1.attachURL(path+'/jsp/developcenter/unitdesigner/fastkey/fastkey_set_param.jsp?targetId='+targetId);
}else if(itemId =='managetool') {//管理工具
var dhxWins = getSelfDesigner(targetId).dhxWins;
if(dhxWins == null){
dhxWins = new dhtmlXWindows();
dhxWins.setSkin('dhx_ibusblue');
dhxWins.attachViewportTo("winVP"+targetId);
dhxWins.setImagePath(path+"/jsp/developcenter/unitdesigner/grid/imgs/dhtmlx/dhxWindows/");
getSelfDesigner(targetId).dhxWins = dhxWins;
}
//设置弹出窗口的XY坐标
if(dhxWins.isWindow("fastkey"))return;
var w1 = dhxWins.createWindow("fastkey", 390, 50, 500, 400);
dhxWins.window('fastkey').setModal(true);
w1.setText("管理工具");
w1.button("minmax1").hide();
w1.button("park").hide();
w1.denyResize();
w1.attachURL(path+'/jsp/developcenter/unitdesigner/fastkey/fastkey_tool_manage.jsp?targetId='+targetId);
}else if(itemId =='delete') {//删除
if(confirm("确定要删除快捷键单元吗?")){
getSelfDesigner(targetId).del(targetId);
getSelfDesigner(targetId).mediator.deleteUnit(targetId);
}
}
});
//设置右键菜单选项
var fastkeyRMenuXml ="<?xml version=\"1.0\"?> " +
"<menu> "+
"<item id=\"setting\" text=\"设置属性\" img=\"workshop.gif\" />" +
"<item id=\"managetool\" text=\"管理工具\" img=\"manage.gif\" />" +
"<item id=\"delete\" text=\"删除单元\" img=\"close.gif\" />" +
"</menu>";
fastkeyRMenu.clearAll();
fastkeyRMenu.loadXMLString(fastkeyRMenuXml);
return fastkeyRMenu;
}
/**
* @description 工具栏右键菜单
* @param e 事件源
* @param targetId 容器Id
* @return dhtmlXMenuObject对象
*/
function createFastToolBarRMenu(targetId){
var toolBarRMenu = new dhtmlXMenuObject();
toolBarRMenu.setSkin('dhx_ibusblue');
toolBarRMenu.setIconsPath(path+"/jsp/developcenter/unitdesigner/toolbar/imgs/dhtmlx/dhtmlxMenu/imgs/");
toolBarRMenu.renderAsContextMenu();
toolBarRMenu.addContextZone("toolbar"+targetId);
//注册点击事件
toolBarRMenu.attachEvent("onClick", function(itemId){
if(itemId =='setting') {//设置属性
var dhxWins = getSelfDesigner(targetId).dhxWins;
if(dhxWins == null){
dhxWins = new dhtmlXWindows();
dhxWins.setSkin('dhx_ibusblue');
dhxWins.attachViewportTo("winVP"+targetId);
dhxWins.setImagePath(path+"/jsp/developcenter/unitdesigner/grid/imgs/dhtmlx/dhxWindows/");
getSelfDesigner(targetId).dhxWins = dhxWins;
}
//设置弹出窗口的XY坐标
if(dhxWins.isWindow("setparam"))return;
var w1 = dhxWins.createWindow("setparam", 390, 100, 380, 180);
dhxWins.window('setparam').setModal(true);
w1.setText("设置快捷键单元属性");
w1.button("minmax1").hide();
w1.button("park").hide();
w1.denyResize();
w1.attachURL(path+'/jsp/developcenter/unitdesigner/fastkey/fastkey_set_param.jsp?targetId='+targetId);
}else if(itemId =='managetool') {//管理工具
var dhxWins = getSelfDesigner(targetId).dhxWins;
if(dhxWins == null){
dhxWins = new dhtmlXWindows();
dhxWins.setSkin('dhx_ibusblue');
dhxWins.attachViewportTo("winVP"+targetId);
dhxWins.setImagePath(path+"/jsp/developcenter/unitdesigner/grid/imgs/dhtmlx/dhxWindows/");
getSelfDesigner(targetId).dhxWins = dhxWins;
}
//设置弹出窗口的XY坐标
if(dhxWins.isWindow("toolbar"))return;
var w1 = dhxWins.createWindow("toolbar", 390, 50, 500, 400);
dhxWins.window('toolbar').setModal(true);
w1.setText("管理工具");
w1.button("minmax1").hide();
w1.button("park").hide();
w1.denyResize();
w1.attachURL(path+'/jsp/developcenter/unitdesigner/toolbar/toolbar_tool_manage.jsp?targetId='+targetId);
}else if(itemId =='delete') {//删除
if(confirm("确定要删除快捷键单元吗?")){
getSelfDesigner(targetId).del(targetId);
getSelfDesigner(targetId).mediator.deleteUnit(targetId);
}
}
});
//设置右键菜单选项
var toolBarRMenuXml ="<?xml version=\"1.0\"?> " +
"<menu> "+
"<item id=\"setting\" text=\"设置属性\" img=\"workshop.gif\" />" +
"<item id=\"managetool\" text=\"管理工具\" img=\"manage.gif\" />" +
"<item id=\"delete\" text=\"删除单元\" img=\"close.gif\" />" +
"</menu>";
toolBarRMenu.clearAll();
toolBarRMenu.loadXMLString(toolBarRMenuXml);
return toolBarRMenu;
}
function viewFastkey(fastkeyObj, toolEntityArray){
if(fastkeyObj==null || toolEntityArray==null || toolEntityArray.lenght==0){
return false;
}
for(var i=0; i<toolEntityArray.length; i++){
var MenuEntity=toolEntityArray[i];
fastkeyObj.addButton(MenuEntity.id, i, MenuEntity.name, "toolimg02.gif", "toolimg02.gif");
}
}
function viewFastToolbar(toolbarObj, toolEntityArray){
if(toolbarObj==null || toolEntityArray==null || toolEntityArray.lenght==0){
return false;
}
for(var i=0; i<toolEntityArray.length; i++){
var toolEntity=toolEntityArray[i];
var tool_type=toolEntity.tool_type;
if(tool_type=="text"){
var text=toolEntity.tool_name;
if(toolEntity.tool_img!=""){
text="<img src=\""+path+"/jsp/developcenter/unitdesigner/toolbar/imgs/ibus/system/"+toolEntity.tool_img+"\" width=\"15\" height=\"15\" />"+text;
}
if(toolEntity.tool_href!=""){
text="<a href=\""+toolEntity.tool_href+"\" target=\""+toolEntity.tool_target+"\">"+text+"</a>";
}
toolbarObj.addText(toolEntity.tool_code,i, "");
toolbarObj.setItemText(toolEntity.tool_code, text);
}else if(tool_type=="button"){
toolbarObj.addButton(toolEntity.tool_code, i, toolEntity.tool_name, toolEntity.tool_img, toolEntity.tool_img);
}else if(tool_type=="textinput"){
toolbarObj.addInput(toolEntity.tool_code, i, toolEntity.tool_value, toolEntity.tool_width);
}else if(tool_type=="pswinput"){
toolbarObj.addInput(toolEntity.tool_code, i, toolEntity.tool_value, toolEntity.tool_width);
}else if(tool_type=="info"){
//???????????
}else if(tool_type=="separator"){
toolbarObj.addSeparator(toolEntity.tool_code, i);
}
}
}
fastkey_ designer.js
最新推荐文章于 2021-11-15 16:46:45 发布