zoukankan      html  css  js  c++  java
  • 页面查看模式下,将元素转为文本展示

    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','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;
                 }
            }
    }
  • 相关阅读:
    14.3.2.1 Transaction Isolation Levels 事务隔离级别
    ReentrantLock可重入锁
    Lock与synchronized 的区别
    synchronized 与 Lock
    This usually indicates a missing no-arg constructor or that the editor's class name was mistyped in
    Oracle dump 分析secondary key
    java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener
    Oracle 验证IOT表数据存储在主键里
    Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for U
    Oracle heap 表的主键 dump 分析
  • 原文地址:https://www.cnblogs.com/fxfly/p/4636063.html
Copyright © 2011-2022 走看看