[TYPO3] Mootools JavaScript for netcraft ratings

Christopher Schnell christopher.schnell at mda.ch
Fri Feb 29 12:14:59 CET 2008


Hi Dimitry,

with the mootools manual back online, it was pretty easy to rewrite  
the js for use with mootools.

Since I am no mootools expert, I didn't do all the t3mootools stuff  
(maybe georg can help out :-) ) and only enclose the js-fragment here.

Would really be cool, if ratings would be able to be run both with  
prototype and mootools.

The JS Code for Mootools:

----------

var myAjax = new Ajax("index.php?eID=tx_ratings_ajax", {
		method: 'post',
		data: 'ref=' + id + '&rating=' + rating + '&data=' + ajaxData +  
'&check=' + check,
		update: 'tx-ratings-' + id
	});
myAjax.request();

----------

Regards,
Christopher

Am 27.02.2008 um 11:24 schrieb Christopher Schnell:

> Hello,
>
> has anybody jet had the possibility to look into this one?
>
> The changing of the header was no problem, but I don't know how to
> rewrite the JS function tx_ratings_submit. If I simply launch it with
> mootools, I get the following error:
>
> "Ajax.Updater is not a constructor"
>
> And the script stops. Any idea on how to invoke the script with the
> correct mootools syntax? Unfortunately the whole mootools page
> (http://www.mootools.net) with the documentation seems to be down.
>
> Best regards,
> Christopher.
>
>
>
>> 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"
>
> --------------------------------
> christopher.schnell at mda.ch
>
> Christopher Schnell
> MdA Business Communications AG
> Unterer Rheinweg 86
> 4057 Basel
> Schweiz
>
> Phone: +41 61 273 44 69
>
>
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english



More information about the TYPO3-english mailing list