Hướng dẫn thêm nút chọn "select all" cho code, php, html vbb 4.1.x

  • Thread starter Thread starter AdminAdmin is verified member.
  • Start date Start date
Admin

AdminAdmin is verified member.

Well-Known Member
Staff member
Administrator
Mods template này cho phép bạn bổ xung vào BB Code CODE/HTML/PHP chức năng lựa chọn tất cả nội dung nằm trong những BB Code ấy bằng một nút bấm.

Bước 1: Chèn javascript vào template headinclude

- AdminCP -> Styles & Templates -> Style Manager -> Edit Templates ->headinclude
- Copy nội dung js sau vào cuối cùng của template headinclude :

HTML:
<script type="text/javascript">

    function selectAll(a)    {        var e  = a.parentNode.parentNode.getElementsByTagName('code')[0];        if  (window.getSelection)        {            var s = window.getSelection();            if  (s.setBaseAndExtent)            {                s.setBaseAndExtent(e, 0, e, e.innerText.length -  1);            }            else            {                var r = document.createRange();                r.selectNodeContents(e);                s.removeAllRanges();                s.addRange(r);            }        }        else if (document.getSelection)        {            var s = document.getSelection();            var r = document.createRange();            r.selectNodeContents(e);            s.removeAllRanges();            s.addRange(r);        }        else if  (document.selection)        {            var r = document.body.createTextRange();            r.moveToElementText(e);            r.select();        }    } 
</script>


Bước 2:
Thay thế toàn bộ các Temp sau đây:

... -> Edit Templates -> BB Code Layout Templates -> bbcode_code

HTML:
<div class="bbcode_container">
    <div class="bbcode_description">{vb:rawphrase code}::&nbsp;<input type="button" value="{vb:rawphrase   select_code}" onclick="selectAll(this); return false;"></div>
    <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']">style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>><code>{vb:raw code}</code></pre>
</div>

... -> Edit Templates -> BB Code Layout Templates -> bbcode_html

HTML:
<div class="bbcode_container">
    <div class="bbcode_description">{vb:rawphrase html_code}::&nbsp;<input type="button"  value="{vb:rawphrase select_code}" onclick="selectAll(this); return  false;"></div>
    <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:<vb:if condition="$blockheight<=$vboptions['codemaxlines']">{vb:math {vb:math {vb:raw blockheight}+2}}*{vb:stylevar mid_fontSize}}<vb:else />{vb:math {vb:math {vb:raw blockheight}+1}*{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>><code>{vb:raw code}</code></pre>
</div>

... -> Edit Templates -> BB Code Layout Templates -> bbcode_php

HTML:
<div class="bbcode_container">
    <div class="bbcode_description">{vb:rawphrase php_code}::&nbsp;<input type="button"  value="{vb:rawphrase select_code}" onclick="selectAll(this); return  false;"></div>
    <div class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']">style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>><code>{vb:raw code}</code></div>
</div>

Bước 3: Tạo thêm phrase : dễ dàng trong việc Việt hoá, và chuyên nghiệp hơn.

AdminCP -> Languages & Phrases -> Phrase Manager -> [Add New Phrase]
Phrase Type : GLOBAL
Product : vBulletin
Varname : select_code
Text : select all
Vietnamese (VI) Translation : Chọn tất cả

Save lại, và thưởng thức nào :tz46:
 
Em làm cho 4.1.0 không chạy anh coi lại cám ơn nhiều nhe
 

Facebook Comments

Similar threads

Admin
Replies
0
Views
1K
AdminAdmin is verified member.
Admin
Admin
Replies
1
Views
1K
Xohoso62
X
Admin
Replies
0
Views
1K
AdminAdmin is verified member.
Admin
Admin
Replies
5
Views
1K
VnSlo
V
Della007
Replies
0
Views
2K
Della007
Della007
Admin
Replies
0
Views
1K
AdminAdmin is verified member.
Admin
Admin
Replies
0
Views
845
AdminAdmin is verified member.
Admin
N
Replies
3
Views
724
AdminAdmin is verified member.
Admin
Tjeuphong
Replies
17
Views
2K
AdminAdmin is verified member.
Admin
Admin
Replies
0
Views
2K
AdminAdmin is verified member.
Admin
Back
Top