[TYPO3] Prototype and Mootools (accordion vs ratings)

Dmitry Dulepov [typo3] dmitry at typo3.org
Tue Feb 19 14:34:54 CET 2008


Hi!

Georg Ringer wrote:
> IMO ratings just uses ajax to send 1 ajax request and nothing more. so 
> this could be made with mootools too
> 
> Dmitry, could you tell me where to look closer?

Sure! JavaScript is in typo3conf/ratings/res/ratings.js. Here is the code:

==========================
function tx_ratings_submit(id, rating, ajaxData, check) {
	$('tx-ratings-display-' + id).style.visibility = 'hidden';
	$('tx-ratings-wait-' + id).style.visibility = 'visible';
	new Ajax.Updater('tx-ratings-' + id, 'index.php?eID=tx_ratings_ajax', {
		asynchronous: true,
		method: 'post',
		parameters: 'ref=' + id + '&rating=' + rating + '&data=' + ajaxData + '&check=' + check
	});
}

==========================

But I guess you need to know where prototype is included, right? Take a look to typo3conf/ratings/res/ratings.html:

==========================
<!-- ###HEADER_PARTS### -->
<link rel="stylesheet" href="###SITE_REL_PATH###res/styles.css" />
<script type="text/javascript" src="###SITE_REL_PATH###res/rating.js"></script>
<script type="text/javascript" src="typo3/contrib/prototype/prototype.js"></script>
<!-- ###ADDITIONAL_CSS### begin -->
<link rel="stylesheet" href="###CSS_FILE###" />
<!-- ###ADDITIONAL_CSS### end -->
<!-- ###HEADER_PARTS### -->
==========================

I know that many people like mootools but I used prototype because it comes with TYPO3 as official ajax library. I have no preference to prototype over mootools because I do not know any of them well (I am a big fun of ExtJS but it is too fat for having single ajax request).

Next paragraph assumes that mootools is compatible with prototype in Ajax.Updater definition.

I think a new TS configuration key is needed (say, "ajaxLibraryPath"), which will point by default to prototype inside TYPO3 but may point as well to EXT:mootools/whatever. Template file should have a marker instead of hard-coded path, which will be replaced by configuration value. The only requirement is that libraries should be compatible in syntax.

If mootools and prototype are not ompatible, it should be easy to make a custom template to use with mootools. I am willing to add such template to ratings extension and mention author in docs ;) 

-- 
Dmitry Dulepov
TYPO3 core team
Web: http://typo3bloke.net/
Skype: callto:liels_bugs
"Nothing is impossible. There are only limits to our knowledge"


More information about the TYPO3-english mailing list