function(tools, othis){
    var iframeDOM = this.document
    ,CHECK = 'layedit-tool-active'
    ,container = getContainer(Range(iframeDOM))
    ,item = function(type){
      return tools.find('.layedit-tool-'+type)
    }

    if(othis){
      othis[othis.hasClass(CHECK) ? 'removeClass' : 'addClass'](CHECK);
    }
    
    tools.find('>i').removeClass(CHECK);
    item('unlink').addClass(ABLED);

    $(container).parents().each(function(){
      var tagName = this.tagName.toLowerCase()
      ,textAlign = this.style.textAlign;

      //文字
      if(tagName === 'b' || tagName === 'strong'){
        item('b').addClass(CHECK)
      }
      if(tagName === 'i' || tagName === 'em'){
        item('i').addClass(CHECK)
      }
      if(tagName === 'u'){
        item('u').addClass(CHECK)
      }
      if(tagName === 'strike'){
        item('d').addClass(CHECK)
      }
      
      //对齐
      if(tagName === 'p'){
        if(textAlign === 'center'){
          item('center').addClass(CHECK);
        } else if(textAlign === 'right'){
          item('right').addClass(CHECK);
        } else {
          item('left').addClass(CHECK);
        }
      }
      
      //超链接
      if(tagName === 'a'){
        item('link').addClass(CHECK);
        item('unlink').removeClass(ABLED);
      }
    });
  }
function(tools, othis){
    var iframeDOM = this.document
    ,CHECK = 'layedit-tool-active'
    ,container = getContainer(Range(iframeDOM))
    ,item = function(type){
      return tools.find('.layedit-tool-'+type)
    }

    if(othis){
      othis[othis.hasClass(CHECK) ? 'removeClass' : 'addClass'](CHECK);
    }
    
    tools.find('>i').removeClass(CHECK);
    item('unlink').addClass(ABLED);

    $(container).parents().each(function(){
      var tagName = this.tagName.toLowerCase()
      ,textAlign = this.style.textAlign;

      
      if(tagName === 'b' || tagName === 'strong'){
        item('b').addClass(CHECK)
      }
      if(tagName === 'i' || tagName === 'em'){
        item('i').addClass(CHECK)
      }
      if(tagName === 'u'){
        item('u').addClass(CHECK)
      }
      if(tagName === 'strike'){
        item('d').addClass(CHECK)
      }
      
      
      if(tagName === 'p'){
        if(textAlign === 'center'){
          item('center').addClass(CHECK);
        } else if(textAlign === 'right'){
          item('right').addClass(CHECK);
        } else {
          item('left').addClass(CHECK);
        }
      }
      
      
      if(tagName === 'a'){
        item('link').addClass(CHECK);
        item('unlink').removeClass(ABLED);
      }
    });
  }
function ( tools , othis ) { var iframeDOM = this . document , CHECK = 'layedit-tool-active' , container = getContainer ( Range ( iframeDOM ) ) , item = function ( type ) { return tools . find ( '.layedit-tool-' + type ) } if ( othis ) { othis [ othis . hasClass ( CHECK ) ? 'removeClass' : 'addClass' ] ( CHECK ) ; } tools . find ( '>i' ) . removeClass ( CHECK ) ; item ( 'unlink' ) . addClass ( ABLED ) ; $ ( container ) . parents ( ) . each ( function ( ) { var tagName = this . tagName . toLowerCase ( ) , textAlign = this . style . textAlign ; //文字 if ( tagName === 'b' || tagName === 'strong' ) { item ( 'b' ) . addClass ( CHECK ) } if ( tagName === 'i' || tagName === 'em' ) { item ( 'i' ) . addClass ( CHECK ) } if ( tagName === 'u' ) { item ( 'u' ) . addClass ( CHECK ) } if ( tagName === 'strike' ) { item ( 'd' ) . addClass ( CHECK ) } //对齐 if ( tagName === 'p' ) { if ( textAlign === 'center' ) { item ( 'center' ) . addClass ( CHECK ) ; } else if ( textAlign === 'right' ) { item ( 'right' ) . addClass ( CHECK ) ; } else { item ( 'left' ) . addClass ( CHECK ) ; } } //超链接 if ( tagName === 'a' ) { item ( 'link' ) . addClass ( CHECK ) ; item ( 'unlink' ) . removeClass ( ABLED ) ; } } ) ; }
iframe初始化
iframe初始化