Home
+ · sNews Development
+++ · [mod] Text Direction Update

[mod] Text Direction Update

posted in sNews Development | on 22.04.2008. 12:20

rtl
just a small JS addon i use, for changing elements direction on the fly this is an upgrade to the one i posted for 1.5 can change direction for any element #id.

can be added in index.php within the head tags, or added to the JS function in snews.php



ADD the JS PART // TOGGLE DIRECTION FOR ELEMENTS ID //
function dircng(drc) {
var dr = document.getElementById(drc);
var dc = dr.style.direction;
if(dc=='ltr') {
dr.style.direction = 'rtl';
} else if (dc=='rtl') {
dr.style.direction = 'ltr';
} else if (dc=='') {
dr.style.direction = 'ltr';
} }
//#######################//

 

   <?php

    
# OPTIONAL USE:
    # for snews text editor:
    # in snews.php
    # find function form_articles

    # Code:
    
    
echo html_input('textarea''text''txt'$frm_textl('text'), '''''''''''2''100''''''');
    echo 
'<p>';


    
# ADD after the opening P tag
    # Code:
    
echo html_input('button''dirt''''DIR''''button''onclick="dircng('txt')"''''''''''''''''');

?>  

 

can change other elements by adding:

	onclick="dircng('ELEMENT #ID')" 
         to any toggler element you want 
         ( P, H1-6 span, div, etc...)

 

 

e.g: use in index.php
toggler element - add style="cursor: pointer;" onclick="dircng('mydiv')"
- >    will change the content direction for Div with id=mydiv
target div - add id=mydiv