Title: BB Code: More Text Alignment Options v1.1

Author: Ahmad

Description: This modification will add more alignment options (Right , Left , Justify) to the text in posts in addition to the (Center) function.

Compatability: 1.9.5

Bonus : 2 example button icons for this feature.

Install Note: Before adding this modification to your forum you should back up all files related to this modification.

License Note: This modification is released under the GPL License. A copy is provided with this software package.

Author Note:
You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.

=======================================================================================================================================
=======
Step 1:
=======
=====================
Edit File: js/bbcodefns-ie.js
=====================
==========
Find Code:
==========

function storeCaret(textEl) {

===============
Add Code Above:
===============

// BB Code: More Alignment Options Mod Begin
function right() {
    if (helpmode) {
        alert(bbcode_help_right);
    } elseif (advmode) {
        AddText('', '', "[align=right] [/align]", messageElement);

    }else {
        txt=prompt(bbcode_prompt_right,"Text");
        if (txt!=null) {
            AddText('', '', "\r[align=right]"+txt+"[/align]", messageElement);
        }
    }
}

function left() {
    if (helpmode) {
        alert(bbcode_help_left);
    } elseif (advmode) {
        AddText('', '', "[align=left] [/align]", messageElement);

    } else {
        txt=prompt(bbcode_prompt_left,"Text");
        if (txt!=null) {
            AddText('', '', "\r[align=left]"+txt+"[/align]", messageElement);
        }
    }
}

function justify() {
    if (helpmode) {
        alert(bbcode_help_justify);
    } elseif (advmode) {
        AddText('', '', "[align=justify] [/align]", messageElement);

    }else {
        txt=prompt(bbcode_prompt_justify,"Text");
        if (txt!=null) {
            AddText('', '', "\r[align=justify]"+txt+"[/align]", messageElement);
        }
    }
}
// BB Code: More Alignment Options Mod End

=======================================================================================================================================
=======
Step 2:
=======
========================
Edit File: js/bbcodefns-opera.js
========================
==========
Find Code:
==========

function storeCaret(textEl) {

===============
Add Code Above:
===============

// BB Code: More Alignment Options Mod Begin
function right() {
    if (helpmode) {
        alert(bbcode_help_right);
    } elseif (advmode) {
        AddText('', '', "[align=right] [/align]", messageElement);

    } else {
        txt=prompt(bbcode_prompt_center,"Text");
        if (txt!=null) {
            AddText('', '', "\r[align=right]"+txt+"[/align]", messageElement);
        }
    }
}

function left() {
    if (helpmode) {
        alert(bbcode_help_left);
    } elseif (advmode) {
        AddText('', '', "[align=left] [/align]", messageElement);

    } else {
        txt=prompt(bbcode_prompt_left,"Text");
        if (txt!=null) {
            AddText('', '', "\r[align=left]"+txt+"[/align]", messageElement);
        }
    }
}

function justify() {
    if (helpmode) {
        alert(bbcode_help_justify);
    } elseif (advmode) {
        AddText('', '', "[align=justify] [/align]", messageElement);

    } else {
        txt=prompt(bbcode_prompt_justify,"Text");
        if (txt!=null) {
            AddText('', '', "\r[align=justify]"+txt+"[/align]", messageElement);
        }
    }
}
// BB Code: More Alignment Options Mod End

=======================================================================================================================================
=======
Step 3:
=======

========================
Edit File: js/bbcodefns-mozilla.js
========================
==========
Find Code:
==========

function storeCaret() {

===============
Add Code Below:
===============

// BB Code: More Alignment Options Mod Begin
function right() {
    if (helpmode) {
        alert(bbcode_help_right);

    } elseif (advmode) {
        if (hasSelection(messageElement)) {
            wrapText('[align=right]', '[/align]', messageElement);
        } else {
            AddText('[align=right]', '[/align]', ' ', messageElement);
        }

    } else {
        if (hasSelection(messageElement)) {
            text = prompt(bbcode_prompt_right, fetchSelection(messageElement));
            if (text == fetchSelection(messageElement)) {
                wrapText('[align=right]', '[/align]', messageElement);
            } else {
                AddText('[align=right]', '[/align]', text, messageElement);
            }
        } else {
            text = prompt(bbcode_prompt_right, 'Text');
            AddText('[align=right]', '[/align]', text, messageElement);
        }
    }
}

function left() {
    if (helpmode) {
        alert(bbcode_help_left);

    } elseif (advmode) {
        if (hasSelection(messageElement)) {
            wrapText('[align=left]', '[/align]', messageElement);
        } else {
            AddText('[align=left]', '[/align]', ' ', messageElement);
        }

    } else {
        if (hasSelection(messageElement)) {
            text = prompt(bbcode_prompt_left, fetchSelection(messageElement));
            if (text == fetchSelection(messageElement)) {
                wrapText('[align=left]', '[/align]', messageElement);
            } else {
                AddText('[align=left]', '[/align]', text, messageElement);
            }
        } else {
            text = prompt(bbcode_prompt_left, 'Text');
            AddText('[align=left]', '[/align]', text, messageElement);
        }
    }
}

function justify() {
    if (helpmode) {
        alert(bbcode_help_justify);

    } elseif (advmode) {
        if (hasSelection(messageElement)) {
            wrapText('[align=justify]', '[/align]', messageElement);
        } else {
            AddText('[align=justify]', '[/align]', ' ', messageElement);
        }

    } else {
        if (hasSelection(messageElement)) {
            text = prompt(bbcode_prompt_justify, fetchSelection(messageElement));
            if (text == fetchSelection(messageElement)) {
                wrapText('[align=justify]', '[/align]', messageElement);
            } else {
                AddText('[align=justify]', '[/align]', text, messageElement);
            }
        } else {
            text = prompt(bbcode_prompt_justify, 'Text');
            AddText('[align=justify]', '[/align]', text, messageElement);
        }
    }
}
// BB Code: More Alignment Options Mod End

=======================================================================================================================================
=======
Step 4:
=======
=======================
Edit File: lang/English.lang.php
=======================
=======================
Add To End Of File Above ?>
=======================

// BB Code: More Alignment Options Mod Begin
$lang['bbcode_help_right'] = "Right tag\\nRight align the enclosed text.\\nUsage: [align=right]This text is set to Right alignment.[/align]";
$lang['bbcode_prompt_right'] = "Please enter the text that should be set to Right alignment.";
$lang['cb_insert_right'] = "Insert text with Right alignment.";
$lang['bbcode_help_left'] = "Left tag\\nLeft align the enclosed text.\\nUsage: [align=left]This text is set to Left alignment.[/align]";
$lang['bbcode_prompt_left'] = "Please enter the text that should be set to Left alignment.";
$lang['cb_insert_left'] = "Insert text with Left alignment.";
$lang['bbcode_help_justify'] = "Justify tag\\nJustify the alignment of the enclosed text.\\nUsage: [align=justify]This text alignment is Justified.[/align]";
$lang['bbcode_prompt_justify'] = "Please enter the text that should be set to Justified alignment.";
$lang['cb_insert_justify'] = "Insert text with Justified alignment.";
// BB Code: More Aligment Options Mod End

=======================================================================================================================================
=======
Step 5:
=======
============================================
Go to administration panel -> templates -> functions_bbcode
============================================
==========
Find Code:
==========

var bbcode_help_center = "$lang[bbcode_help_center]";
var bbcode_prompt_center = "$lang[bbcode_prompt_center]";

================
Replace Code With:
================

var bbcode_help_right   = "$lang[bbcode_help_left]";
var bbcode_prompt_right = "$lang[bbcode_prompt_left]";
var bbcode_help_center = "$lang[bbcode_help_center]";
var bbcode_prompt_center = "$lang[bbcode_prompt_center]";
var bbcode_help_left    = "$lang[bbcode_help_right]";
var bbcode_prompt_left  = "$lang[bbcode_prompt_right]";
var bbcode_help_justify = "$lang[bbcode_help_justify]";
var bbcode_prompt_justify   = "$lang[bbcode_prompt_justify]";

=======================================================================================================================================
=======
Step 6:
=======
===============================================
Go to administration panel -> templates -> functions_bbcodeinsert
===============================================
==========
Find Code:
==========

<a href="javascript:center()"><img src="$imgdir/bb_center.gif" border="0" width="23" height="22" alt="$lang[cb_insert_centered]" /></a>

============
Replace With :
============

<a href="javascript:left()"><img src="$THEME[imgdir]/bb_left.gif" border="0" width="23" height="22" alt="$lang[cb_insert_left]" /></a>
<a href="javascript:center()"><img src="$THEME[imgdir]/bb_center.gif" border="0" width="23" height="22" alt="$lang[cb_insert_centered]" /></a>
<a href="javascript:right()"><img src="$THEME[imgdir]/bb_right.gif" border="0" width="23" height="22" alt="$lang[cb_insert_right]" /></a>
<a href="javascript:justify()"><img src="$THEME[imgdir]/bb_justify.gif" border="0" width="23" height="22" alt="$lang[cb_insert_justify]" /></a>

=======================================================================================================================================
=======
Step 7:
=======
===============
Edit File: post.php
===============
======
Find:
======

    global $imgdir, $bbinsert, $altbg1, $altbg2, $lang, $SETTINGS, $spelling_lang;

============
Replace With:
============

    global $imgdir, $bbinsert, $altbg1, $altbg2, $lang, $SETTINGS, $spelling_lang, $THEME;


=======================================================================================================================================
=======
Step 8:
=======

Upload the "bb_left.gif , bb_right.gif , bb_justify.gif" images to your theme directory

=======================================================================================================================================
Enjoy!