[demo-1] Select Expand BBCodes MOD
 
 
Post new topic   Reply to topic   printer-friendly view    phpMiX.org Forum Index -> phpBB MODs -> Select Expand BBCodes
View previous topic :: View next topic  
Author Message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Sep 24, 2004 11:47 am    Post subject: [demo-1] Select Expand BBCodes MOD Reply with quote

Select Expand BBCodes MOD - DEMO

markus_petrux wrote:
Quote:
MOD Title: Select Expand BBCodes MOD

MOD Version: 1.0.0 Beta

MOD Description: This MOD is a DHTML add-on for the Code and Quote BBCodes. It adds a couple of commands next to the BBCode block title. First one, allows you to Select its contents for easier copy/paste actions. Second one, allows you to Expand or Contract the BBCode block. It has been coded to degrade correctly even if the browser does not support the required features (please, read author notes for further information).

MOD Add-ons: It also comes with a MOD script to install this MOD for the PHP Syntax Highlighter BBCode.

Credits: Inspired by Daz's fi_divexpand control, but somehow improved (please, read author notes for further information).

Code:
_SXBB.prototype.resize = function(cmd)
{
   var o = this.getObj(this.id);
   if( !o ) return;
   var x = this.getObj(this.id+'x');
   if( !x ) return;

   // First, deal with user's request...
   if( cmd == this.T['expand'] )
   {
      this.size = o.scrollHeight + 5;
      o.style.height = this.size + 'px';
      x.innerHTML = this.genCmd('resize', this.T['contract']);
   }
   else
   {
      this.size = this.min;
      o.style.height = this.size + 'px';
      x.innerHTML = this.genCmd('resize', this.T['expand']);
   }
   // If necessary, adjust height of outer blocks...
   if( o.parentNode ) for( o = o.parentNode; o.parentNode; o = o.parentNode )
   {
      if( o.tagName && o.tagName == 'DIV' && o.id && o.id.indexOf('SXBB') == 0 )
         SXBB[o.id].resize(this.T['expand']);
   }
   return false;
}

PHP:
<?php

//+MOD: Select Expand BBcodes MOD
    
global $phpbb_root_path;
    
$u_sxbb_jslib $phpbb_root_path 'templates/select_expand_bbcodes.js';

    
// Replacing BBCode variables, but also adding CR to preserve HTML comment delimiters for JS code.
    
$expand_ary1 = array('<!--''//-->''{L_SELECT}''{L_EXPAND}''{L_CONTRACT}''{U_SXBB_JSLIB}');
    
$expand_ary2 = array("\r<!--\r""\r//-->\r"$lang['Select'], $lang['Expand'], $lang['Contract'], $u_sxbb_jslib);
    
$expand_ary3 = array('<!--''//-->');
    
$expand_ary4 = array("\r<!--\r""\r//-->\r");

    
$bbcode_tpl['quote_open'] = str_replace($expand_ary1$expand_ary2$bbcode_tpl['quote_open']);
    
$bbcode_tpl['quote_username_open'] = str_replace($expand_ary1$expand_ary2$bbcode_tpl['quote_username_open']);
    
$bbcode_tpl['code_open'] = str_replace($expand_ary1$expand_ary2$bbcode_tpl['code_open']);

    
$bbcode_tpl['quote_close'] = str_replace($expand_ary3$expand_ary4$bbcode_tpl['quote_close']);
    
$bbcode_tpl['code_close'] = str_replace($expand_ary3$expand_ary4$bbcode_tpl['code_close']);
//-MOD: Select Expand BBcodes MOD

?>


Another demo:
http://forums.phpmix.org/viewtopic.php?p=1165#1165

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    phpMiX.org Forum Index -> phpBB MODs -> Select Expand BBCodes All times are GMT + 1 Hour
 
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum