Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MINI-ADDON] Direction switcher  (Read 1507 times)

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
[MINI-ADDON] Direction switcher
« on: April 18, 2008, 07:08:13 pm »

hey all  :D

just a small JS addon i use,
for changing elements direction on the fly  ;D

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

1)  ADD the JS PART
Code: [Select]
<?php // <-- no need to copy tag //

// 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'; }
}
//#######################//

?>


OPTIONAL USE:
for snews text editor:
in snews.php
find function form_articles
Code: [Select]
<?php

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

?>

ADD after the opening P tag
Code: [Select]
<?php // <-- no need to copy tags //

        
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
Code: [Select]
<p onclick="dircng('mydiv')" style="cursor: pointer;">toggler element</p>
<div id="mydiv">
will change the content direction for Div with id=mydiv .....
</div>

 ;D
« Last Edit: April 26, 2008, 06:03:18 pm by mosh »
Logged