/** * This extension displays polls. */ (function () { function poll() { return [{ type: 'lang', filter: function(text) { return text.replace(/^\[poll id=([a-f\d]+)\]\s*$/gm, function(match, id) { var string; if (window['pollCache-' + id]) { string = window['pollCache-' + id]; string = string.replace(/fr-poll(-preview)?="(.*?)"/g, ''); string = string.replace(/ng-/g, 'not-ng-'); string = string.replace(/ngIf/g, 'not-ngIf'); string = string.replace(/ngRepeat/g, 'not-ngRepeat'); string = string.replace(/\s+/g, ' '); } else { string = '
'; } return string; }); } }]; } angular.module('footyroom').directive("frPollPreview", [function() { return { require: 'frPoll', link: function(scope, el, attrs, ctrl) { // Prevent clicks on the poll. el.prepend('
'); scope.$watch( function() { return ctrl.poll; }, function(newValue) { if (newValue) { // Show prestine poll condition. delete ctrl.showPollResult; delete ctrl.selectedChoice; // Cache poll's html. setTimeout(function() { window['pollCache-' + ctrl.frPoll] = el[0].outerHTML; }, 0); } } ); } }; }]); if (window && window.showdown) { window.showdown.extensions.poll = poll; } if (typeof module !== 'undefined') { module.exports = poll; } })();