AJAX Quick Edit

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Locked
down4me
Registered User
Posts: 17
Joined: Sat Aug 29, 2009 4:10 pm

Re: AJAX Quick Edit

Post by down4me »

Working fine

thank you very much

NathanFtw
Registered User
Posts: 247
Joined: Mon Jun 15, 2009 7:59 am

Re: AJAX Quick Edit

Post by NathanFtw »

It seems your new version's cancel button doesn't work, when i hit cancel it goes back to the post but it changes the content to another post and then upon refreshing the page it goes back to normal, ive un-installed the mod for now as this issue needs to be fixed, so once you fix it ill install it again.

Cheers mate.

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5449
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: AJAX Quick Edit

Post by Marc »

Hi,
bug found, fixed, and package updated.
You can find the bugfix here: http://www.m-a-styles.de/tracker.php?p=10&t=42

User avatar
spaceace
Registered User
Posts: 1933
Joined: Wed Jan 30, 2008 8:50 pm
Contact:

Re: AJAX Quick Edit

Post by spaceace »

i would just like to say that this MOD has come a long way and is working awesome. great work :D :D

edit: something that i forgot to add. if anyone is also using the MOD from Nyquist, Always Show Edit Info, and would like the edits to show after someone uses this quick edit MOD, do the following

open quickedit.php

find

Code: Select all

	$sql_ary = array(
		'post_text'         => utf8_recode($post_text, 'utf-8'),
		'bbcode_uid'		=> $uid,
		'bbcode_bitfield'   => $bitfield,
		'post_edit_time'	=> $edit_time,
		'post_edit_count'	=> $edit_count,
		'post_edit_user'	=> $edit_user,

	);
add after

Code: Select all

// <<== Nyquist's Always Show Edit Info
	if (isset($config['nyq_editinfo']) && $config['nyq_editinfo'] == 'always')
		$sql_ary = array_merge($sql_ary, array(
			'post_edit_time'	=> time(),
			'post_edit_user'	=> (int) $user->data['user_id'],
			'post_edit_count'	=> (int) $row['post_edit_count'] + 1
		));
// ==>> Nyquist's Always Show Edit Info
hope this helps someone :D

Dem0n_Hunter
Registered User
Posts: 103
Joined: Wed Aug 05, 2009 9:12 am

Re: AJAX Quick Edit

Post by Dem0n_Hunter »

Hi, I've tried to install this MOD a serveral times and it doesn't seem to work for me. When I click on the quick edit button it goes crazy idk. it becomes like this:
Image

The mods I have installed are :

Almsamim WYSIWYG phpBB3 v0.0.8
Advanced quick reply

those are the ones I think might effect it. so I was wondering if any of those 2 mod is stopping this mod to function properly? or is it just me failing at installing this.(i've only used AutoMod to install it so far. Haven't tried installing manually yet)
Edit: the image is a little too big oh well can't help it really. too lazy to resize it :P

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5449
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: AJAX Quick Edit

Post by Marc »

@spaceace: Thank you.

@Dem0n_Hunter: Seems like AutoMOD either added overall_header.html a second time or something like that. You should probably check if your edits are correct yourself.

Dem0n_Hunter
Registered User
Posts: 103
Joined: Wed Aug 05, 2009 9:12 am

Re: AJAX Quick Edit

Post by Dem0n_Hunter »

well it only happens when i click on the quick edit button. and ok i'll try checking the edits

iftitaj
Registered User
Posts: 638
Joined: Tue Jan 15, 2008 6:21 am
Location: Karachi, Pakistan

Re: AJAX Quick Edit

Post by iftitaj »

Your update mentioned here.
I cannot find exact FIND match. Please guide me.
My quickedit.php file's code:

Code: Select all

<?php
/** 
*
* @package phpBB3
* @version $Id: quickedit.php 386 2009-05-05 10:28:47Z marc1706 $
* @copyright (c) 2006 StarTrekGuide Group, (c) 2009 Marc Alexander(marc1706) www.m-a-styles.de
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('posting');

$post_id = request_var('post_id', 0);
$submit = isset($_POST['submit']) ? true : false;
$contents = utf8_normalize_nfc(request_var('contents', '', true));


if ($contents == 'cancel')
{
	$sql = 'SELECT p.*, f.*
	FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f 
	WHERE post_id = $post_id AND p.forum_id = f.forum_id";	
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	
	
	//now check to see if the user is allowed to read the post
	if (!$auth->acl_get('f_read', $row['forum_id']))
	{
		die($user->lang['USER_CANNOT_READ']);
	}
	
	$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) + (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) + (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
	$text = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);

	$template->assign_vars(array(
		'SEND_TEXT'				=> true,
		'TEXT'					=> $text,
		'EDIT_IMG' 				=> $user->img('icon_post_edit', 'EDIT_POST'),
		'DELETE_IMG'			=> $user->img('icon_post_delete', 'DELETE_POST'),
	));
}
else if ($submit)
{
	$sql = 'SELECT p.*, f.*, t.*
	FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
	WHERE p.post_id = $post_id AND p.topic_id = t.topic_id AND p.forum_id = f.forum_id";	
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	
	//first check to see if we are registered and have rights to edit something here
	if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $row['forum_id']))
	{
		$is_authed = true;
	}
	else
	{
		die($user->lang['USER_CANNOT_EDIT']);	
	}
	
	//now check to see if this forum is locked and if we aren't a mod that can edit anything
	if (($row['forum_status'] == ITEM_LOCKED || (isset($row['topic_status']) && $row['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $row['forum_id']))
	{
		die(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED');	
	}
	
	//now check to see if we can edit THIS post
	if (!$auth->acl_get('m_edit', $row['forum_id']))
	{
		if ($user->data['user_id'] != $row['poster_id'])
		{
			die($user->lang['USER_CANNOT_EDIT']);	
		}
	
		if (!($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']))
		{
			die($user->lang['CANNOT_EDIT_TIME']);	
		}
	
		if ($row['post_edit_locked'])
		{
			die($user->lang['CANNOT_EDIT_POST_LOCKED']);	
		}
	}
	
	//now check if we need to set the edit time and edit count
	if (!$auth->acl_get('m_edit', $row['forum_id']))
	{
		$edit_time = time();
		$edit_count = $row['post_edit_count'] + 1;
		$edit_user = $user->data['user_id'];
	} else {
		if(isset($row['post_edit_time']))
        {
            $edit_time = $row['post_edit_time'];
        } else {
            $edit_time = 0;
        }
        if(isset($row['post_edit_user']))
        {
            $edit_user = $row['post_edit_user'];
        } else {
            $edit_user = 0;
        }
        if(isset($row['post_edit_count']))
        {
            $edit_count = $row['post_edit_count'];
        } else {
            $edit_count = 0;
        } 
	}
	
	$post_text = utf8_normalize_nfc(request_var('contents', '', true));
	$uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage
	$allow_bbcode = $allow_urls = $allow_smilies = true;
	generate_text_for_storage($post_text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
	
	// let's try something else here in order to get the bbcode_uid and bbcode_bitfield
	$message_parser = new parse_message();
	
	$message_parser->message = $post_text;
	
	if(!isset($uid))
	{
		$uid = $message_parser->bbcode_uid;
	}
	
	if(!isset($bitfield))
	{
		$bitfield = $message_parser->bbcode_bitfield;
	}

	$sql_ary = array(
		'post_text'			=> $post_text,
		'bbcode_uid'		=> $uid,
		'bbcode_bitfield'   => $bitfield,
		'post_edit_time'	=> $edit_time,
		'post_edit_count'	=> $edit_count,
		'post_edit_user'	=> $edit_user,

	);

	$sql = 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE post_id = $post_id";	
	$db->sql_query($sql);
	
	$text = generate_text_for_display($sql_ary['post_text'], $sql_ary['bbcode_uid'], $sql_ary['bbcode_bitfield'], 7);
	
	$template->assign_vars(array(
		'SEND_TEXT'				=> true,
		'TEXT'					=> $text,
		'EDIT_IMG' 				=> $user->img('icon_post_edit', 'EDIT_POST'),
		'DELETE_IMG'			=> $user->img('icon_post_delete', 'DELETE_POST'),
	));
}
else if ($post_id)
{
	$sql = 'SELECT p.*, f.*, t.*
	FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
	WHERE p.post_id = $post_id AND p.topic_id = t.topic_id";	
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	
	// HTML, BBCode, Smilies, Images and Flash status
	$bbcode_status	= ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $row['forum_id'])) ? true : false;
	$smilies_status	= ($bbcode_status && $config['allow_smilies'] && $auth->acl_get('f_smilies', $row['forum_id'])) ? true : false;
	$img_status		= ($bbcode_status && $auth->acl_get('f_img', $row['forum_id'])) ? true : false;
	$url_status		= ($config['allow_post_links']) ? true : false;
	$flash_status	= ($bbcode_status && $auth->acl_get('f_flash', $row['forum_id']) && $config['allow_post_flash']) ? true : false;
	$quote_status	= ($auth->acl_get('f_reply', $row['forum_id'])) ? true : false;
	
	//first check to see if we are registered and have rights to edit something here
	if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $row['forum_id']))
	{
		$is_authed = true;
	}
	else
	{
		die($user->lang['USER_CANNOT_EDIT']);
	}
	
	//now check to see if this forum is locked and if we aren't a mod that can edit anything
	if (($row['forum_status'] == ITEM_LOCKED || (isset($row['topic_status']) && $row['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $row['forum_id']))
	{
		die(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED');
	}
	
	//now check to see if we can edit THIS post
	if (!$auth->acl_get('m_edit', $row['forum_id']))
	{
		if ($user->data['user_id'] != $row['poster_id'])
		{
			die($user->lang['USER_CANNOT_EDIT']);
		}
	
		if (!($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']))
		{
			die($user->lang['CANNOT_EDIT_TIME']);
		}
	
		if ($row['post_edit_locked'])
		{
			die($user->lang['CANNOT_EDIT_POST_LOCKED']);
		}
	}
	
	if(isset($row['bbcode_uid']))
	{
		decode_message($row['post_text'], $row['bbcode_uid']);
	}
	
	// Build custom bbcodes array
	display_custom_bbcodes();
	
	$template->assign_vars(array(
		'EDIT_FORM'				=> true,
		'POST_ID'				=> $post_id,
		'POST_TEXT'				=> $row['post_text'],
		'EDIT_IMG' 				=> $user->img('icon_post_edit', 'EDIT_POST'),
		'DELETE_IMG'			=> $user->img('icon_post_delete', 'DELETE_POST'),
		'S_BBCODE_IMG'			=> $img_status,
		'S_BBCODE_URL'			=> $url_status,
		'S_BBCODE_FLASH'		=> $flash_status,
		'S_BBCODE_QUOTE'		=> $quote_status,
		'S_BBCODE_ALLOWED'		=> $bbcode_status,
	));
}
else
{
	die('USER_CANNOT_EDIT');
}

$template->set_filenames(array(
	'body' => 'quickedit.html')
);
page_footer();

?>

User avatar
Berk888
Registered User
Posts: 27
Joined: Sun Sep 28, 2008 8:35 pm
Location: Kiev, Ukraine
Contact:

Re: AJAX Quick Edit

Post by Berk888 »

replace this
$sql = 'SELECT p.*, f.*
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f
WHERE post_id = $post_id AND p.forum_id = f.forum_id";
Image

NathanFtw
Registered User
Posts: 247
Joined: Mon Jun 15, 2009 7:59 am

Re: AJAX Quick Edit

Post by NathanFtw »

There seems to be a problem with the BBcodes and the advanced quick reply mod, it seems to go to the Advanced quick reply box instead of the quick edit box. Any fix for this?

dattad
Registered User
Posts: 6
Joined: Tue Jul 29, 2008 3:43 am

Re: AJAX Quick Edit

Post by dattad »

I confirm, v1.0.9 works wrong with BBcodes when Quick reply for phpBB3 is installed. 1.0.8 works fine.

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5449
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: AJAX Quick Edit

Post by Marc »

This is because Quick-Reply is using posting_buttons.html. That changes text_name to "message". AJAX Quickedit needs it to be "quickedit-textarea".
Here is a solution(haven't tested it yet, but it should work):
Open styles/*yourstyle*/template/quickedit.html
Find:

Code: Select all

var text_name = 'quickedit-textarea';
Replace with:

Code: Select all

var txt_name = 'quickedit-textarea';
Replace all instances of text_name in quickedit.html with txt_name.

dattad
Registered User
Posts: 6
Joined: Tue Jul 29, 2008 3:43 am

Re: AJAX Quick Edit

Post by dattad »

Replaced all instances of text_name (12 matches in quickedit.html), but it didn't help.

NathanFtw
Registered User
Posts: 247
Joined: Mon Jun 15, 2009 7:59 am

Re: AJAX Quick Edit

Post by NathanFtw »

Doesn't work for me either :S.

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5449
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: AJAX Quick Edit

Post by Marc »

The Quick Reply MOD also overwrites my functions. :roll:

If you have a Quick Reply MOD installed, please use this quickedit.html:
prosilver:

Code: Select all

<!-- IF EDIT_FORM -->
<!-- IF S_BBCODE_ALLOWED -->
<div id="format-buttons" style="font-family:Verdana,Helvetica,Arial,sans-serif; font-size: 1.1 em;">
<input type="button" value=" B " onclick="bbstyle2(0)" class="button2" style="width: 30px; font-size:0.85em; font-weight:bold;" title="{L_BBCODE_B_HELP}" />
<input type="button" value=" i " onclick="bbstyle2(2)" class="button2" style="width: 30px; font-size:0.85em; font-style: italic;" title="{L_BBCODE_I_HELP}" />
<input type="button" value=" u " onclick="bbstyle2(4)" class="button2" style="width: 30px; font-size:0.85em; text-decoration: underline;" title="{L_BBCODE_U_HELP}" />
<!-- IF S_BBCODE_QUOTE -->
	<input type="button" value="Quote" onclick="bbstyle2(6)" class="button2" style="width: 30px; font-size:0.85em;" title="{L_BBCODE_Q_HELP}" />
<!-- ENDIF -->
<input type="button" value="Code" onclick="bbstyle2(8)" class="button2" style="width: 30px; font-size:0.85em;" title="{L_BBCODE_C_HELP}" />
<input type="button" value="List" onclick="bbstyle2(10)" class="button2" style="width: 30px; font-size:0.85em;" title="{L_BBCODE_L_HELP}" />
<input type="button" value="List=" onclick="bbstyle2(12)" class="button2" style="width: 30px; font-size:0.85em;" title="{L_BBCODE_O_HELP}" />
<input type="button" value="[*]" onclick="bbstyle2(-1)" class="button2" style="width: 30px; font-size:0.85em;" title="{L_BBCODE_LISTITEM_HELP}" />
<!-- IF S_BBCODE_IMG -->
	<input type="button" value="Img" onclick="bbstyle2(14)" class="button2" style="width: 30px; font-size:0.85em;" title="{L_BBCODE_P_HELP}" />
<!-- ENDIF -->
<!-- IF S_LINKS_ALLOWED -->	
	<input type="button" value="URL" onclick="bbstyle2(16)" class="button2" style="width: 30px; font-size:0.85em;" title="{L_BBCODE_W_HELP}" />
<!-- ENDIF -->
<!-- IF S_BBCODE_FLASH -->
	<input type="button" value="Flash" onclick="bbstyle2(18)" class="button2" style="width: 30px; font-size:0.85em;" title="{L_BBCODE_D_HELP}" />
<!-- ENDIF -->
<select id= "addbbcode20" name="addbbcode20" onchange="bbfontstyle2('[size=' + document.getElementById('addbbcode20').options[document.getElementById('addbbcode20').selectedIndex].value + ']', '[/size]');document.getElementById('addbbcode20').selectedIndex = 2;" title="{L_BBCODE_F_HELP}">
		<option value="50">{L_FONT_TINY}</option>
		<option value="85">{L_FONT_SMALL}</option>
		<option value="100" selected="selected">{L_FONT_NORMAL}</option>
		<!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 150 -->
			<option value="150">{L_FONT_LARGE}</option>
			<!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 200 -->
				<option value="200">{L_FONT_HUGE}</option>
			<!-- ENDIF -->
		<!-- ENDIF -->
</select>
<!-- BEGIN custom_tags -->
	<input type="button" class="button2" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle2({custom_tags.BBCODE_NAME})" title="{custom_tags.BBCODE_HELPLINE}" style="width: 30px; font-size:0.85em;" />
<!-- END custom_tags -->
</div>
<!-- ENDIF -->
<div id="message-box">
	<textarea name="quickedit-textarea" id="quickedit-textarea" class="inputbox" rows="15" cols="76" onselect="storeCaret2(this);" onclick="storeCaret2(this);" onkeyup="storeCaret2(this);" onfocus="initInsertions2();" style="font-size: 1.0em;" >{POST_TEXT}</textarea><br />
</div><br />
<input class="button1" type="button" onclick="submit_changes({POST_ID});" value="{L_SUBMIT}" style="font-size:0.9em;" />
<input class="button2" type="button" onclick="cancel_changes({POST_ID});" value="{L_CANCEL}" style="font-size:0.9em;" />
<!-- ELSEIF SEND_TEXT -->
{TEXT}
<!-- ELSE -->
<script type="text/javascript">
// <![CDATA[
var http_request = getHTTPObject();
var divname = '';
var open_quick_edit = 0;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));

var baseHeight;

// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','
','
  • ','
','
  • ','
','[img]','[/img]','','','[flash=]', '[/flash]','[size=]','[/size]'<!-- BEGIN custom_tags -->, {custom_tags.BBCODE_NAME}<!-- END custom_tags -->);


function quick_edit(post_id)
{
if (open_quick_edit != 1)
{
divname = 'postdiv' + post_id;
get_text(post_id);
contents = document.getElementById('quick_edit' + post_id).style.display = 'none';
open_quick_edit = 1;
}
}

function submit_changes(post_id)
{
contents = document.getElementById('quickedit-textarea').value;
get_text(post_id, contents);
contents = document.getElementById('quick_edit' + post_id).style.display = '';
editando = '';
open_quick_edit = 0;
}

function cancel_changes(post_id)
{
contents = 'cancel';
get_text(post_id, contents);
contents = document.getElementById('quick_edit' + post_id).style.display = '';
open_quick_edit = 0;
}

function get_text(post_id, contents)
{
if (contents)
{
contents = '&contents=' + encodeURIComponent(contents) + '&submit=true';
}
else
{
contents = '';
}
param = 'post_id=' + post_id + contents;
http_request.open("POST", '{U_QUICKEDIT}', true);
http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
http_request.onreadystatechange = handle_text;
http_request.send(param);
}

function handle_text()
{
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
result = http_request.responseText;
document.getElementById(divname).innerHTML = result;
}
else
{
alert('There was a problem with the request.');
}
}
}

function getHTTPObject()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object. Consider upgrading your browser.';
}
}


/** Below are all functions regarding BBCodes and the way they are inserted into the textbox
* Please do not change anything as this might cause major problems with AJAX Quick Edit
* Functions are based on the functions in editor.js of prosilver
* bbCode control by subBlue design [ www.subBlue.com ]
* Includes unixsafe colour palette selector by SHS`
* modified by Marc Alexander to fit AJAX Quick Edit
*/



var txt_name = 'quickedit-textarea';



/**
* Fix a bug involving the TextRange object. From
* http://www.frostjedi.com/terra/scripts/ ... etBug.html
*/
function initInsertions2()
{
var textarea = document.getElementById(txt_name);

if (is_ie && typeof(baseHeight) != 'number')
{
textarea.focus();
baseHeight = document.selection.createRange().duplicate().boundingHeight;
}
}

/**
* bbstyle
*/
function bbstyle2(bbnumber, bbnumber2)
{
if (typeof(bbnumber2) == 'undefined' && bbnumber != -1)
{
bbfontstyle2(bbtags[bbnumber], bbtags[bbnumber+1]);
}
else if (typeof(bbnumber2) != 'undefined')
{
bbfontstyle2(bbnumber, bbnumber2);
}
else
{
insert_text2('[*]');
document.getElementById(txt_name).focus();
}
}

/**
* Apply bbcodes
*/
function bbfontstyle2(bbopen, bbclose)
{
theSelection = false;

var textarea = document.getElementById(txt_name);

textarea.focus();

if ((clientVer >= 4) && is_ie && is_win)
{
// Get text selection
theSelection = document.selection.createRange().text;

if (theSelection)
{
// Add tags around selection
document.selection.createRange().text = bbopen + theSelection + bbclose;
document.getElementById(txt_name).focus();
theSelection = '';
return;
}
}
else if (document.getElementById(txt_name).selectionEnd && (document.getElementById(txt_name).selectionEnd - document.getElementById(txt_name).selectionStart > 0))
{
mozWrap2(document.getElementById(txt_name), bbopen, bbclose);
document.getElementById(txt_name).focus();
theSelection = '';
return;
}

//The new position for the cursor after adding the bbcode
var caret_pos = getCaretPosition2(textarea).start;
var new_pos = caret_pos + bbopen.length;

// Open tag
insert_text2(bbopen + bbclose);

// Center the cursor when we don't have a selection
// Gecko and proper browsers
if (!isNaN(textarea.selectionStart))
{
textarea.selectionStart = new_pos;
textarea.selectionEnd = new_pos;
}
// IE
else if (document.selection)
{
var range = textarea.createTextRange();
range.move("character", new_pos);
range.select();
storeCaret2(textarea);
}

textarea.focus();
return;
}

/**
* Insert text at position
*/
function insert_text2(text, spaces, popup)
{
var textarea;

if (!popup)
{
textarea = document.getElementById(txt_name);
}
else
{
textarea = opener.document.getElementById(txt_name);
}
if (spaces)
{
text = ' ' + text + ' ';
}

if (!isNaN(textarea.selectionStart))
{
var sel_start = textarea.selectionStart;
var sel_end = textarea.selectionEnd;

mozWrap2(textarea, text, '')
textarea.selectionStart = sel_start + text.length;
textarea.selectionEnd = sel_end + text.length;
}
else if (textarea.createTextRange && textarea.caretPos)
{
if (baseHeight != textarea.caretPos.boundingHeight)
{
textarea.focus();
storeCaret2(textarea);
}

var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
}
else
{
textarea.value = textarea.value + text;
}
if (!popup)
{
textarea.focus();
}
}

/**
* From http://www.massless.org/mozedit/
*/
function mozWrap2(txtarea, open, close)
{
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop;

if (selEnd == 1 || selEnd == 2)
{
selEnd = selLength;
}

var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);

txtarea.value = s1 + open + s2 + close + s3;
txtarea.selectionStart = selEnd + open.length + close.length;
txtarea.selectionEnd = txtarea.selectionStart;
txtarea.focus();
txtarea.scrollTop = scrollTop;

return;
}

/**
* Insert at Caret position. Code from
* http://www.faqts.com/knowledge_base/vie ... 52/fid/130
*/
function storeCaret2(textEl)
{
if (textEl.createTextRange)
{
textEl.caretPos = document.selection.createRange().duplicate();
}
}

/**
* Caret Position object
*/
function caretPosition2()
{
var start = null;
var end = null;
}

/**
* Get the caret position in an textarea
*/
function getCaretPosition2(txtarea)
{
var caretPos = new caretPosition2();

// simple Gecko/Opera way
if(txtarea.selectionStart || txtarea.selectionStart == 0)
{
caretPos.start = txtarea.selectionStart;
caretPos.end = txtarea.selectionEnd;
}
// dirty and slow IE way
else if(document.selection)
{

// get current selection
var range = document.selection.createRange();

// a new selection of the whole textarea
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtarea);

// calculate selection start point by moving beginning of range_all to beginning of range
var sel_start;
for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++)
{
range_all.moveStart('character', 1);
}

txtarea.sel_start = sel_start;

// we ignore the end value for IE, this is already dirty enough and we don't need it
caretPos.start = txtarea.sel_start;
caretPos.end = txtarea.sel_start;
}

return caretPos;
}
// ]]>
</script>
<!-- ENDIF -->[/code]

subsilver2:

Code: Select all

<!-- IF EDIT_FORM -->
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr valign="middle" align="{S_CONTENT_FLOW_BEGIN}">
<td colspan="2">
<!-- IF S_BBCODE_ALLOWED -->
<input type="button" value=" B " onclick="bbstyle2(0)" class="btnbbcode" style="width: 30px; font-size:0.85em; font-weight:bold;" title="{L_BBCODE_B_HELP}" />
<input type="button" value=" i " onclick="bbstyle2(2)" class="btnbbcode" style="width: 30px; font-size:0.85em; font-style: italic;" title="{L_BBCODE_I_HELP}" />
<input type="button" value=" u " onclick="bbstyle2(4)" class="btnbbcode" style="width: 30px; font-size:0.85em; text-decoration: underline;" title="{L_BBCODE_U_HELP}" />
<!-- IF S_BBCODE_QUOTE -->
	<input type="button" value="Quote" onclick="bbstyle2(6)" class="btnbbcode" style="width: 40px; font-size:0.85em;" title="{L_BBCODE_Q_HELP}" />
<!-- ENDIF -->
<input type="button" value="Code" onclick="bbstyle2(8)" class="btnbbcode" style="width: 40px; font-size:0.85em;" title="{L_BBCODE_C_HELP}" />
<input type="button" value="List" onclick="bbstyle2(10)" class="btnbbcode" style="width: 40px; font-size:0.85em;" title="{L_BBCODE_L_HELP}" />
<input type="button" value="List=" onclick="bbstyle2(12)" class="btnbbcode" style="width: 40px; font-size:0.85em;" title="{L_BBCODE_O_HELP}" />
<input type="button" value="[*]" onclick="bbstyle2(-1)" class="btnbbcode" style="width: 40px; font-size:0.85em;" title="{L_BBCODE_LISTITEM_HELP}" />
<!-- IF S_BBCODE_IMG -->
	<input type="button" value="Img" onclick="bbstyle2(14)" class="btnbbcode" style="width: 40px; font-size:0.85em;" title="{L_BBCODE_P_HELP}" />
<!-- ENDIF -->
<!-- IF S_LINKS_ALLOWED -->	
	<input type="button" value="URL" onclick="bbstyle2(16)" class="btnbbcode" style="width: 40px; font-size:0.85em;" title="{L_BBCODE_W_HELP}" />
<!-- ENDIF -->
<!-- IF S_BBCODE_FLASH -->
	<input type="button" value="Flash" onclick="bbstyle2(18)" class="btnbbcode" style="font-size:0.85em;" title="{L_BBCODE_D_HELP}" />
<!-- ENDIF -->
<span class="genmed nowrap"><select class="gensmall" id= "addbbcode20" name="addbbcode20" onchange="bbfontstyle2('[size=' + document.getElementById('addbbcode20').options[document.getElementById('addbbcode20').selectedIndex].value + ']', '[/size]');document.getElementById('addbbcode20').selectedIndex = 2;" title="{L_BBCODE_F_HELP}">
		<option value="50">{L_FONT_TINY}</option>
		<option value="85">{L_FONT_SMALL}</option>
		<option value="100" selected="selected">{L_FONT_NORMAL}</option>
		<!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 150 -->
				<option value="150">{L_FONT_LARGE}</option>
				<!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 200 -->
					<option value="200">{L_FONT_HUGE}</option>
				<!-- ENDIF -->
		<!-- ENDIF -->
</select></span>
<!-- ENDIF -->
	</td>
</tr>
<!-- IF S_BBCODE_ALLOWED and .custom_tags -->
<tr valign="middle" align="{S_CONTENT_FLOW_BEGIN}">
<td colspan="2">
<!-- BEGIN custom_tags -->
	<input type="button" class="btnbbcode" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle2({custom_tags.BBCODE_NAME})" title="{custom_tags.BBCODE_HELPLINE}" style="font-size:0.85em;" />
<!-- END custom_tags -->
		</td>
	</tr>
<!-- ENDIF -->

<tr>
<td valign="top" style="width: 100%;"><textarea name="quickedit-textarea" id="quickedit-textarea" rows="15" cols="76" tabindex="3" onselect="storeCaret2(this);" onclick="storeCaret2(this);" onkeyup="storeCaret2(this);" onfocus="initInsertions2();" style="width: 98%; font-size: 0.9em;" >{POST_TEXT}</textarea></td>
</tr><br />
<tr>
<td>
<input class="button1" type="button" onclick="submit_changes({POST_ID});" value="{L_SUBMIT}" style="font-size:0.9em;" />
<input class="button2" type="button" onclick="cancel_changes({POST_ID});" value="{L_CANCEL}" style="font-size:0.9em;" />
</td>
</tr>
</table>
<!-- ELSEIF SEND_TEXT -->
{TEXT}
<!-- ELSE -->
<script type="text/javascript">
// <![CDATA[
var http_request = getHTTPObject();
var divname = '';
var open_quick_edit = 0;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));

var baseHeight;

// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','
','
  • ','
','
  • ','
','[img]','[/img]','','','[flash=]', '[/flash]','[size=]','[/size]'<!-- BEGIN custom_tags -->, {custom_tags.BBCODE_NAME}<!-- END custom_tags -->);


function quick_edit(post_id)
{
if (open_quick_edit != 1)
{
divname = 'postdiv' + post_id;
get_text(post_id);
contents = document.getElementById('quick_edit' + post_id).style.display = 'none';
open_quick_edit = 1;
}
}

function submit_changes(post_id)
{
contents = document.getElementById('quickedit-textarea').value;
get_text(post_id, contents);
contents = document.getElementById('quick_edit' + post_id).style.display = '';
editando = '';
open_quick_edit = 0;
}

function cancel_changes(post_id)
{
contents = 'cancel';
get_text(post_id, contents);
contents = document.getElementById('quick_edit' + post_id).style.display = '';
open_quick_edit = 0;
}

function get_text(post_id, contents)
{
if (contents)
{
contents = '&contents=' + encodeURIComponent(contents) + '&submit=true';
}
else
{
contents = '';
}
param = 'post_id=' + post_id + contents;
http_request.open("POST", '{U_QUICKEDIT}', true);
http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
http_request.onreadystatechange = handle_text;
http_request.send(param);
}

function handle_text()
{
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
result = http_request.responseText;
document.getElementById(divname).innerHTML = result;
}
else
{
alert('There was a problem with the request.');
}
}
}

function getHTTPObject()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object. Consider upgrading your browser.';
}
}


/** Below are all functions regarding BBCodes and the way they are inserted into the textbox
* Please do not change anything as this might cause major problems with AJAX Quick Edit
* Functions are based on the functions in editor.js of prosilver
* bbCode control by subBlue design [ www.subBlue.com ]
* Includes unixsafe colour palette selector by SHS`
* modified by Marc Alexander to fit AJAX Quick Edit
*/



var txt_name = 'quickedit-textarea';



/**
* Fix a bug involving the TextRange object. From
* http://www.frostjedi.com/terra/scripts/ ... etBug.html
*/
function initInsertions2()
{
var textarea = document.getElementById(txt_name);

if (is_ie && typeof(baseHeight) != 'number')
{
textarea.focus();
baseHeight = document.selection.createRange().duplicate().boundingHeight;
}
}

/**
* bbstyle
*/
function bbstyle2(bbnumber, bbnumber2)
{
if (typeof(bbnumber2) == 'undefined' && bbnumber != -1)
{
bbfontstyle2(bbtags[bbnumber], bbtags[bbnumber+1]);
}
else if (typeof(bbnumber2) != 'undefined')
{
bbfontstyle2(bbnumber, bbnumber2);
}
else
{
insert_text2('[*]');
document.getElementById(txt_name).focus();
}
}

/**
* Apply bbcodes
*/
function bbfontstyle2(bbopen, bbclose)
{
theSelection = false;

var textarea = document.getElementById(txt_name);

textarea.focus();

if ((clientVer >= 4) && is_ie && is_win)
{
// Get text selection
theSelection = document.selection.createRange().text;

if (theSelection)
{
// Add tags around selection
document.selection.createRange().text = bbopen + theSelection + bbclose;
document.getElementById(txt_name).focus();
theSelection = '';
return;
}
}
else if (document.getElementById(txt_name).selectionEnd && (document.getElementById(txt_name).selectionEnd - document.getElementById(txt_name).selectionStart > 0))
{
mozWrap2(document.getElementById(txt_name), bbopen, bbclose);
document.getElementById(txt_name).focus();
theSelection = '';
return;
}

//The new position for the cursor after adding the bbcode
var caret_pos = getCaretPosition2(textarea).start;
var new_pos = caret_pos + bbopen.length;

// Open tag
insert_text2(bbopen + bbclose);

// Center the cursor when we don't have a selection
// Gecko and proper browsers
if (!isNaN(textarea.selectionStart))
{
textarea.selectionStart = new_pos;
textarea.selectionEnd = new_pos;
}
// IE
else if (document.selection)
{
var range = textarea.createTextRange();
range.move("character", new_pos);
range.select();
storeCaret2(textarea);
}

textarea.focus();
return;
}

/**
* Insert text at position
*/
function insert_text2(text, spaces, popup)
{
var textarea;

if (!popup)
{
textarea = document.getElementById(txt_name);
}
else
{
textarea = opener.document.getElementById(txt_name);
}
if (spaces)
{
text = ' ' + text + ' ';
}

if (!isNaN(textarea.selectionStart))
{
var sel_start = textarea.selectionStart;
var sel_end = textarea.selectionEnd;

mozWrap2(textarea, text, '')
textarea.selectionStart = sel_start + text.length;
textarea.selectionEnd = sel_end + text.length;
}
else if (textarea.createTextRange && textarea.caretPos)
{
if (baseHeight != textarea.caretPos.boundingHeight)
{
textarea.focus();
storeCaret2(textarea);
}

var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
}
else
{
textarea.value = textarea.value + text;
}
if (!popup)
{
textarea.focus();
}
}

/**
* From http://www.massless.org/mozedit/
*/
function mozWrap2(txtarea, open, close)
{
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop;

if (selEnd == 1 || selEnd == 2)
{
selEnd = selLength;
}

var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);

txtarea.value = s1 + open + s2 + close + s3;
txtarea.selectionStart = selEnd + open.length + close.length;
txtarea.selectionEnd = txtarea.selectionStart;
txtarea.focus();
txtarea.scrollTop = scrollTop;

return;
}

/**
* Insert at Caret position. Code from
* http://www.faqts.com/knowledge_base/vie ... 52/fid/130
*/
function storeCaret2(textEl)
{
if (textEl.createTextRange)
{
textEl.caretPos = document.selection.createRange().duplicate();
}
}

/**
* Caret Position object
*/
function caretPosition2()
{
var start = null;
var end = null;
}

/**
* Get the caret position in an textarea
*/
function getCaretPosition2(txtarea)
{
var caretPos = new caretPosition2();

// simple Gecko/Opera way
if(txtarea.selectionStart || txtarea.selectionStart == 0)
{
caretPos.start = txtarea.selectionStart;
caretPos.end = txtarea.selectionEnd;
}
// dirty and slow IE way
else if(document.selection)
{

// get current selection
var range = document.selection.createRange();

// a new selection of the whole textarea
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtarea);

// calculate selection start point by moving beginning of range_all to beginning of range
var sel_start;
for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++)
{
range_all.moveStart('character', 1);
}

txtarea.sel_start = sel_start;

// we ignore the end value for IE, this is already dirty enough and we don't need it
caretPos.start = txtarea.sel_start;
caretPos.end = txtarea.sel_start;
}

return caretPos;
}
// ]]>
</script>
<!-- ENDIF -->[/code]

Locked

Return to “[3.0.x] MOD Database Releases”