fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-10-11 11:21 am

[dw-free] Initialize poll handlers on the contents of a dynamically loaded cut tag.

[commit: http://hg.dwscoalition.org/dw-free/rev/b14e0868a33d]
http://bugs.dwscoalition.org/show_bug.cgi?id=3119

Initialize poll handlers on the contents of a dynamically loaded cut tag.

Patch by [personal profile] fu.

Files modified:
  • htdocs/js/cuttag-ajax.js
  • htdocs/js/livejournal.js
--------------------------------------------------------------------------------
diff -r f70f277d3918 -r b14e0868a33d htdocs/js/cuttag-ajax.js
--- a/htdocs/js/cuttag-ajax.js	Mon Oct 11 18:57:46 2010 +0800
+++ b/htdocs/js/cuttag-ajax.js	Mon Oct 11 19:21:28 2010 +0800
@@ -79,6 +79,7 @@ CutTagHandler = new Class(Object, {
         $("img-" + this.identifier).src= Site.imgprefix + "/expand.gif";
         CutTagHandler.initLinks(replaceDiv);
         LiveJournal.initPlaceholders(replaceDiv);
+        LiveJournal.initPolls(replaceDiv);
       }
     }
   });
diff -r f70f277d3918 -r b14e0868a33d htdocs/js/livejournal.js
--- a/htdocs/js/livejournal.js	Mon Oct 11 18:57:46 2010 +0800
+++ b/htdocs/js/livejournal.js	Mon Oct 11 19:21:28 2010 +0800
@@ -193,22 +193,23 @@ var PollPages = {
     "hourglass": null
 };
 
-LiveJournal.initPolls = function () {
-    var pollLinks = DOM.getElementsByTagAndClassName(document, 'a', "LJ_PollAnswerLink") || [];
+LiveJournal.initPolls = function (element) {
+    var ele = element || document;
+    var pollLinks = DOM.getElementsByTagAndClassName(ele, 'a', "LJ_PollAnswerLink") || [];
 
     // attach click handlers to each answer link
     Array.prototype.forEach.call(pollLinks, function (pollLink) {
         DOM.addEventListener(pollLink, "click", LiveJournal.pollAnswerLinkClicked.bindEventListener(pollLink));
     });
 
-    var pollButtons = DOM.getElementsByTagAndClassName(document, 'input', "LJ_PollSubmit") || []; 
+    var pollButtons = DOM.getElementsByTagAndClassName(ele, 'input', "LJ_PollSubmit") || []; 
     
     // attaches a click handler to all poll submit buttons
     Array.prototype.forEach.call(pollButtons, function (pollButton) {
         DOM.addEventListener(pollButton, "click", LiveJournal.pollButtonClicked.bindEventListener(pollButton));
     });
     
-    var pollForms = DOM.getElementsByTagAndClassName(document, 'form', "LJ_PollForm") || []; 
+    var pollForms = DOM.getElementsByTagAndClassName(ele, 'form', "LJ_PollForm") || []; 
     
     // attach submit handlers to each poll form
     Array.prototype.forEach.call(pollForms, function (pollForm) {
--------------------------------------------------------------------------------