Needlworks / Textcube

Textcube : Brand yourself! / Personalized web publishing platform with multi-user support
http://www.textcube.org
Other
207 stars 55 forks source link

Javascript Plugin API #1732

Open achimnol opened 9 years ago

achimnol commented 9 years ago

1705 has exposed necessity of Javascript-side plugin events.

reCAPTCHA plugin needs to know the exact timings when the comment/guestbook forms are loaded on the page (either via AJAX or refresh) and covering all timings manually leaves potential bugs and poses extra burdens to the plugin developers.

I'm going to write a simple hash-based event system, which may look like Plugin.fireEvent('loadCommentForm', entryId); and Plugin.registerHandler('loadCommentForm', my_javascript_func). Calls to fireEvent will be inserted in the core codes (e.g., dress() functions in library/view files.) The use of return values and semantics of the passed arguments are specific to individual events, just like PHP-side plugin events.

achimnol commented 9 years ago

Tech demo for reCAPTCHA plugin in 1.10.1 Full implementation in 2.0.0