zoukankan      html  css  js  c++  java
  • js

    (function(){
    var bds = {
    util: {}
    };
    var c = document.getElementById('kw').parentNode;

    bds.util.getWinWidth = function(){
        return window.document.documentElement.clientWidth;
    };
    
    bds.util.setFormWidth = function(){
        var width = bds.util.getWinWidth();
        if(width < 1217)    {bds.util.setClass(c, 'ip_short', 'add')}
        else                {bds.util.setClass(c, 'ip_short', 'remove')};
    };
    
    bds.util.setClass = function(obj, class_name, set) {
        var ori_class = obj.className,
            has_class_p = -1,
            ori_class_arr = [],
            new_class = '';
    
        if(ori_class.length) ori_class_arr = ori_class.split(' ');
    
        for( i in ori_class_arr) {
            if(ori_class_arr[i] == class_name) has_class_p = i;
        }
    
        if( set == 'remove' && has_class_p >= 0) {
            ori_class_arr.splice(has_class_p, 1);
            new_class = ori_class_arr.join(' ');
            obj.className = new_class;
        } else if( set == 'add' && has_class_p < 0) {
            ori_class_arr.push(class_name);
            new_class = ori_class_arr.join(' ');
            obj.className = new_class;
        }
    }
    bds.util.setFormWidth();
    
    if (typeof document.addEventListener != "undefined") {
        window.addEventListener('resize', bds.util.setFormWidth, false);
        document.getElementById('kw').addEventListener('focus', function(){bds.util.setClass(c,'iptfocus', 'add');}, false);
        document.getElementById('kw').addEventListener('blur', function(){bds.util.setClass(c,'iptfocus', 'remove');}, false);
    } else {
        window.attachEvent('onresize', bds.util.setFormWidth, false);
        document.getElementById('kw').attachEvent('onfocus', function(){bds.util.setClass(c,'iptfocus', 'add');}, false);
        document.getElementById('kw').attachEvent('onblur', function(){bds.util.setClass(c,'iptfocus', 'remove');}, false);
    } 
    

    })();

        //</script>
  • 相关阅读:
    OAccflow集成sql
    集成备注
    CCflow与基础框架组织机构整合
    Jeecg_Jflow整合记录
    Problem opening .cshtml files
    The document cannot be opened. It has been renamed, deleted or moved.
    js中!和!!的区别及用法
    hdu 4757 Tree(可持久化字典树)
    Tomcat 学习进阶历程之Tomcat架构与核心类分析
    BZOJ 3000(Big Number-Stirling公式求n!近似值)
  • 原文地址:https://www.cnblogs.com/ITniu/p/6776325.html
Copyright © 2011-2022 走看看