• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

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

Admin

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:
 

Facebook Comments

New posts New threads New resources

Back
Top