📄 dialog.js
字号:
var Dialog={
runtime:{items:[],options:{}},
goods:function(callback,options){
Dialog.runtime.options=options;
if(options.type=='checkbox'){
fbox.open({ctl:'dialog/goods',act:'goodsList',p:['checkbox',0]},{noClose:true,width:800,height:500});
}else if(options.type=='radio'){
fbox.open({ctl:'dialog/goods',act:'goodsList',p:['radio',0]},{noClose:true,width:800,height:500});
}
Dialog.runtime.callback = callback;
},
goodsGrp:function(callback,options){
Dialog.runtime.options = options;
if(options.type == 'checkbox'){
fbox.open({ctl:'dialog/goods',act:'goodsListGrp',p:['checkbox',0]},{noClose:true,width:800,height:500});
}else if(options.type == 'radio'){
fbox.open({ctl:'dialog/goods',act:'goodsListGrp',p:['radio',0]},{noClose:true,width:800,height:500});
}
Dialog.runtime.callback = callback;
},
goodscat:function(callback,options){
Dialog.runtime.options = options;
if(options.type == 'checkbox'){
fbox.open({ctl:'dialog/goods',act:'goodsCat',p:['checkbox',0]},{noClose:true,width:800,height:500});
}else if(options.type == 'radio'){
fbox.open({ctl:'dialog/goods',act:'goodsCat',p:['radio',0]},{noClose:true,width:800,height:500});
}
Dialog.runtime.callback = callback;
},
member:function(callback,options){
Dialog.runtime.options = options;
if(options.type == 'checkbox'){
fbox.open({ctl:'dialog/member',act:'member',p:['checkbox']},{noClose:true,width:800,height:500});
}else if(options.type == 'radio'){
fbox.open({ctl:'dialog/member',act:'member',p:['radio']},{noClose:true,width:800,height:500});
}
Dialog.runtime.callback = callback;
},
emailGroup:function(callback,options){
Dialog.runtime.options = options;
if(options.type=='checkbox'){
fbox.open({ctl:'dialog/emailGroup',act:'emailGroup',p:['checkbox']},{noClose:true,width:800,height:500});
}else if(options.type=='radio'){
fbox.open({ctl:'dialog/emailGroup',act:'emailGroup',p:['radio']},{noClose:true,width:800,height:500});
}
Dialog.runtime.callback = callback;
},
files:function(callback,options){
Dialog.runtime.options = options;
fbox.open({ctl:'dialog/resource',act:'dirList',p:[Dialog.runtime.options.dirType,Dialog.runtime.options.ftype,Dialog.runtime.options.src]},{noClose:true,width:800,height:500});
Dialog.runtime.callback = callback;
},
done:function(obj){
var ipts = obj.getElementsByTagName('input');
var items=[];
var str = '';
var tmp = [];
var s = true;
var ct = 0;
for(i=0;i<ipts.length;i++){
if(ipts[i].checked){
if(ipts[i].getAttribute('item')){
obj = eval('('+ipts[i].getAttribute('item')+')');
items.push(obj);
} else if(ipts[i].name.substr(0,1) == ',') {
for (y=0; y<tmp.length; y++) {
if (tmp[y] == ipts[i].name.substr(0,tmp[y].length)) {
s = false;
break;
} else {
s = true;
}
}
if (s == true) {
str += ','+ipts[i].value;
tmp[ct] = ipts[i].name;
ct++;
}
}
}
}
if (str != '') {
str = str.substr(1);
if (Dialog.runtime.options.name == 'goods') {
X.go({ctl:'dialog/goods',act:'getGoodsByCatIds',p:[str]},{});
} else if (Dialog.runtime.options.name == 'goodscat') {
X.go({ctl:'dialog/goods',act:'getCatsByCatIds',p:[str]},{});
}
}
if(items.length > 0) {
if(Dialog.runtime.options.type == 'radio'){
Dialog.runtime.options.obj.innerHTML='';
}
Dialog.runtime.callback(items,Dialog.runtime.options);
}
fbox.close();
},
checkedAll : function(o) {
var whole = $('dialog').getElementsByTagName('input');
var catPath = o.name;
var catPathSplit = catPath.split(',');
var fatherCatPath = [];
var fatherCatPathState = {};
var tmp = '';
for (var i=1; i<catPathSplit.length-2; i++) {
tmp += ','+catPathSplit[i];
if (i%2 == 0) {
fatherCatPath[i/2-1] = tmp;
}
}
for (var i=0; i<whole.length; i++) {
if (whole[i].name) {
if (whole[i].name.substr(0,catPath.length) == catPath) {
whole[i].checked = o.checked;
}
if (!o.checked) {
for (y=0; y<fatherCatPath.length; y++) {
if (whole[i].name == fatherCatPath[y]) {
whole[i].checked = false;
}
}
}
}
}
if (o.checked) {
fatherCatPath.reverse(true);
for (y=0; y<fatherCatPath.length; y++) {
for (var i=0; i<whole.length; i++) {
if (whole[i].name != fatherCatPath[y] && whole[i].name.substr(0, fatherCatPath[y].length)==fatherCatPath[y]) {
if (fatherCatPathState[fatherCatPath[y]] == null) {
fatherCatPathState[fatherCatPath[y]] = true;
}
fatherCatPathState[fatherCatPath[y]] &= whole[i].checked;
}
}
if (fatherCatPathState[fatherCatPath[y]]==true && document.getElementsByName(fatherCatPath[y])[0]) {
document.getElementsByName(fatherCatPath[y])[0].checked = true;
}
}
}
},
extend : function(o) {
for (var o=o.nextSibling; o!=null; o=o.nextSibling){
if (o.tagName == 'INPUT') {
var obj = o;
} else if (o.tagName == 'DIV') {
var expand = o;
}
}
if (expand.style.display == 'none') {
expand. style.display = 'block';
if (obj.type == 'checkbox') {
if (obj.checked) {
X.go({ctl:'dialog/goods',act:'nextCat',p:['checkbox',obj.value,1]});
} else {
X.go({ctl:'dialog/goods',act:'nextCat',p:['checkbox',obj.value,0]});
}
} else if (obj.type == 'radio') {
X.go({ctl:'dialog/goods',act:'nextCat',p:['radio',obj.value]});
} else if (obj.type == 'hidden') {
X.go({ctl:'dialog/goods',act:'nextCat',p:['radio',obj.value,-1]});
}
} else {
expand.style.display = 'none';
}
},
selectAll : function(o) {
var v = o.checked?true:false;
for (o=o.parentNode; o.className!='body'; o=o.parentNode) {;}
var z = o.getElementsByTagName("input");
for(i=1; i<z.length; i++) {
if (z[i].type == 'checkbox') {
z[i].checked = v;
}
}
},
getElementsByName : function(name) {
var returns = document.getElementsByName(name);
if(returns.length > 0) {
return returns;
}
returns = new Array();
var e = $('dialog').getElementsByTagName('*');
for(i=0; i<e.length; i++) {
if(e[i].getAttribute('name') == name) {
returns[returns.length] = e[i];
}
}
return returns;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -