Remove anonymous function creation in "trigger"

Move common code to a private function, in main scope, where it will be compiled and reused in Crafty.trigger. This removes code repetition and (hopefully) increases performance by removing the creation of anon function when 2 or more entities are found.