Created
March 20, 2012 14:03
-
-
Save kane-thornwyrd/2135947 to your computer and use it in GitHub Desktop.
Easy function decorator in Coffeescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extendStart = (func)-> | |
func ?= ()-> | |
Function::extendEnd = (args...)=> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
* Exemple de "décoration" de fonction d'autocompletion de Drupal 7 | |
* /!\ C'est comme les galipeurs, j'ai pas testé, c'est pas garanti de marcher, | |
* mais en théorie ça le devrait ! | |
* | |
* Pour ceux qui ne lisent pas le Coffeescript -> http://jashkenas.github.com/coffee-script/#try:%23%23%23%0A*%20Exemple%20de%20%22d%C3%A9coration%22%20de%20fonction%20d%27autocompletion%20de%20Drupal%207%0A%23%23%23%0A%28%28%24%29-%3E%0A%0A%20%20extendStart%20%3D%20%28func%29-%3E%0A%20%20%20%20func%20%3F%3D%20%28%29-%3E%0A%0A%20%20Function%3A%3AextendEnd%20%3D%20%28args...%29%3D%3E%0A%0A%20%20original_autocomplete%20%3D%20extendStart%20Drupal.behaviors.autocomplete.attach%0A%0A%20%20Drupal.behaviors.autocomplete.attach%20%3D%20%28context%2C%20settings%29-%3E%0A%20%20%20%20%23%20Traitement%20ici%0A%20%20%20%20original_autocomplete.extendEnd%20context%2C%20settings%0A%20%0A%0A%29.call%20window%2C%20jQuery | |
### | |
(($)-> | |
extendStart = (func)-> | |
func ?= ()-> | |
Function::extendEnd = (args...)=> | |
original_autocomplete = extendStart Drupal.behaviors.autocomplete.attach | |
Drupal.behaviors.autocomplete.attach = (context, settings)-> | |
# Traitement ici | |
original_autocomplete.extendEnd context, settings | |
).call window, jQuery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does not work anymore 😢