Fix triggers on angular strap drop down menu items (#13)
Fix triggers on angular strap drop down menu items (#13)

* pass in raw DOM element reference instead of id to UserVoice.push()

UserVoice.push() may be passed in either the target element's id string
(in the `#id` format), or a raw DOM element reference (even though the
second style is not clearly described in the UserVoice documentation).

Passing in the id string has a limitation that it can only reference
elements that have already been attached to the main DOM (i.e. they
need to be accessible using the `document.getElementById()` call used
internally in UserVoice code), while passing in a raw DOM element
reference also allows applying UserVoice triggers on detached DOM
elements.

One place where this limitation makes a difference is where we want
to set up the trigger on a menu item in an angular-strap drop-down
menu which constructs its drop-down menu DOM detached from the main
one and attaches it only after it has been fully constructed.

* avoid JS error if UserVoice init fails and 'identify' param is specified

Previously, in such cases the uservoice-trigger directive would attempt
to call `null.push()`.

* remove UserVoice trigger if DOM element is destroyed

This is best-effort cleanup for cases like attaching the trigger to a
drop-down menu item which gets recreated every time the drop-down is
recreated, e.g. as when using the angular-strap drop-down.

chesleybrown/uservoice-trigger-directive