function view(type) {
var dmt,bar;
indexOfExpend();
if (type == 1) {
dmt = $(document);
bar = $(parent.document);
} else {
dmt = $(document);
bar = $(document);
}
//查看模式
this.init = function() {
if($(bar).find("#doctype").val() == '1' || $(bar).find("#statusidx").val() == '2'
|| $(bar).find("#statusidx").val() == '4'||$(bar).find("#statusidx").val() == '5'){
this.textSet();
this.checkBoxSet();
this.buttonSet();
this.textAreaSet();
this.radioSet();
this.selectSet();
this.aSet();
this.imgSet();
//单元格空白后移除
this.hideBoxSet();
}
}
this.textSet = function() {
var tmp = "";
$(dmt).find(":text").each(function() {
tmp = $(this).val();
$(this).replaceWith("<u>" + tmp + "</u>");
});
}
this.checkBoxSet = function() {
var len = $(dmt).find(".noremv").length;
//判断是否是需要全部展示选中或没选中项
if(len>0)
$(dmt).find(".noremv").find("input[type='checkbox']").each(function() {
if ($(this).attr("checked")) {
$(this).replaceWith("☑");
} else {
$(this).replaceWith("☐");
}
});
else//否则只显示选中项
$(dmt).find("input[type='checkbox']").each(function() {
if ($(this).attr("checked")) {
$(this).replaceWith("");
} else {
//不显示其余的
$(this).parents("li").replaceWith("");
$(this).attr("disabled","disabled");
}
});
}
this.buttonSet = function() {
if (type == 1) {
$(dmt).find("input[type='button']:not(.ex)").each(function() {
$(this).replaceWith("");
});
} else {
$(dmt).find("input[type='button']:not(.ex)").each(function() {
$(this).replaceWith("");
});
}
}
this.textAreaSet = function() {
var tmp = "";
$(dmt).find("textarea").each(function() {
//判断是否为空
if($(this).attr("class")==null){
$(this).attr("readOnly",true);
return;
}
if($(this).attr("class").indexOf("nov")==-1){
tmp = $(this).val();
$(this).replaceWith(tmp);
}
});
}
this.radioSet = function() {
$(dmt).find("input[type='radio']").each(function() {
if ($(this).is(":checked")) {
$(this).remove();
} else {
//$(this).replaceWith("○");
//不显示其余的
$(this).parents("li").remove();
}
});
}
this.selectSet = function() {
var tmp = "";
$(dmt).find("select").each(function() {
if($(this).attr("class")!="noremv"){
tmp = $(this).find("option:selected").text();
$(this).replaceWith("<u>" + tmp + "</u>");
}
});
}
this.aSet = function() {
$(dmt).find("a").each(function() {
//判断是否为空
if($(this).attr("class")==null){
return;
}
//设置不需要展示的超链接
if ($(this).attr("class").indexOf("nov")!=-1) {
$(this).replaceWith("");
}
//将超链接的文本由[修改]改为[查看]
if ($(this).attr("class").indexOf("nov_")!=-1) {
$(this).text("查看");
}
});
$(dmt).find("a:contains('删除')").hide();
}
this.imgSet = function(){
$(dmt).find("img").each(function(){
if ($(this).attr("class") == 'nov') {
$(this).replaceWith("");
}
});
}
this.hideBoxSet = function(){
$(dmt).find(".hidebox").each(function(){
$(this).attr('style','width:0px;');
});
}
}
/**
* indexOf
*/
function indexOfExpend(){
if(typeof Array.indexOf !== 'function' ){
Array.prototype.indexOf = function(args){
var index = -1;
for(var i=0,l=this.length; i<l; i++){
if(this[i] === args){
index = i;
break;
}
}
return index;
}
}
}