1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

VBB 真牛!

本帖由 不学无术2005-11-01 发布。版面名称:源码讨论

  1. 不学无术

    不学无术 Ulysses 的元神

    注册:
    2005-08-31
    帖子:
    16,714
    赞:
    39
    找到了。

    PHP:
    // #############################################################################
    // vB_AJAX_TitleEdit
    // #############################################################################

    /**
    * Class to handle thread title editing with XML-HTTP
    *
    * @param    object    The <td> containing the title element
    */
    function vB_AJAX_TitleEdit(obj)
    {
        
    this.obj obj;
        
    this.threadid this.obj.id.substr(this.obj.id.lastIndexOf('_') + 1);
        
    this.linkobj fetch_object('thread_title_' this.threadid);
        
    this.container this.linkobj.parentNode;
        
    this.editobj null;
        
    this.xml_sender null;

        
    this.origtitle '';
        
    this.editstate false;
        
        
    // =============================================================================
        // vB_AJAX_TitleEdit methods

        /**
        * Function to initialize the editor for a thread title
        */
        
    this.edit = function()
        {
            if (
    this.editstate == false)
            {
                
    // create the new editor input box properties...
                
    this.inputobj document.createElement('input');
                
    this.inputobj.type 'text';
                
    this.inputobj.size 50;
                
    this.inputobj.maxLength 85;
                
    this.inputobj.style.width Math.max(this.linkobj.offsetWidth250) + 'px';
                
    this.inputobj.className 'bginput';
                
    this.inputobj.value PHP.unhtmlspecialchars(this.linkobj.innerHTML);
                
    this.inputobj.title this.inputobj.value;

                
    // ... and event handlers
                
    this.inputobj.onblur vB_AJAX_ThreadList_Events.prototype.titleinput_onblur;
                
    this.inputobj.onkeypress vB_AJAX_ThreadList_Events.prototype.titleinput_onkeypress;

                
    // insert the editor box and select it
                
    this.editobj this.container.insertBefore(this.inputobjthis.linkobj);
                
    this.editobj.select();

                
    // store the original text
                
    this.origtitle this.linkobj.innerHTML;

                
    // hide the link object
                
    this.linkobj.style.display 'none';

                
    // declare that we are in an editing state
                
    this.editstate true;
            }
        }

        
    /**
        * Function to restore a thread title in the editing state
        */
        
    this.restore = function()
        {
            if (
    this.editstate == true)
            {
                
    // do we actually need to save?
                
    if (this.editobj.value != this.origtitle)
                {
                    
    this.linkobj.innerHTML PHP.htmlspecialchars(this.editobj.value);
                    
    this.save(this.editobj.value);
                }
                else
                {
                    
    // set the new contents for the link
                    
    this.linkobj.innerHTML this.editobj.value;
                }

                
    // remove the editor box
                
    this.container.removeChild(this.editobj);

                
    // un-hide the link
                
    this.linkobj.style.display '';

                
    // declare that we are in a normal state
                
    this.editstate false;
                
    this.obj null;
            }
        }

        
    /**
        * Function to save an edited thread title
        *
        * @param    string    Edited title text
        *
        * @return    string    Validated title text
        */
        
    this.save = function(titletext)
        {
            
    this.xml_sender = new vB_AJAX_Handler(true);
            
    this.xml_sender.onreadystatechange(this.onreadystatechange);
            
    this.xml_sender.send('ajax.php''do=updatethreadtitle&t=' this.threadid '&title=' PHP.urlencode(titletext));
        }

        var 
    me this;

        
    /**
        * OnReadyStateChange callback. Uses a closure to keep state.
        * Remember to use me instead of this inside this function!
        */
        
    this.onreadystatechange = function()
        {
            if (
    me.xml_sender.handler.readyState == && me.xml_sender.handler.status == 200 && me.xml_sender.handler.responseText)
            {
                
    me.linkobj.innerHTML me.xml_sender.handler.responseText;
                
                if (
    is_ie)
                {
                    
    me.xml_sender.handler.abort();
                }
                
                
    vB_ThreadTitle_Editor.obj null;
            }
        }

        
    // start the editor
        
    this.edit();
    }
     
    #21 不学无术, 2005-11-01
    最后编辑: 2005-11-01
  2. jcking

    jcking Well-Known Member

    注册:
    2005-08-30
    帖子:
    22,282
    赞:
    70
    恭喜你找到了。
     
  3. yeshou

    yeshou New Member

    注册:
    2005-09-06
    帖子:
    7,067
    赞:
    34
    不高亮 看不懂
     
  4. 不学无术

    不学无术 Ulysses 的元神

    注册:
    2005-08-31
    帖子:
    16,714
    赞:
    39
    BSU。像你这样灌水,这论坛没办法管理了。
     
  5. jcking

    jcking Well-Known Member

    注册:
    2005-08-30
    帖子:
    22,282
    赞:
    70
    :( :( 为什么总是说我灌水.不说别人的,我不活了.
     
  6. 不学无术

    不学无术 Ulysses 的元神

    注册:
    2005-08-31
    帖子:
    16,714
    赞:
    39
    看不懂拉到,不过看思路和我的一样。

    只是 vB 中都写成类了,我还不会:(
     
  7. yeshou

    yeshou New Member

    注册:
    2005-09-06
    帖子:
    7,067
    赞:
    34
    现在看懂了

     
  8. 木偶

    木偶 New Member

    注册:
    2005-09-11
    帖子:
    264
    赞:
    0
    这个测试不了~~~
     
  9. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    啊哦,挺麻烦的