Skip to content

Commit

Permalink
Review and annotate MapDiscussionController
Browse files Browse the repository at this point in the history
  • Loading branch information
sethlu committed Sep 9, 2017
1 parent acd3912 commit 17928d5
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions scripts/map/MapDiscussionController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

/**
* MapDiscussionController
* Concrete view controller to display a Discussion.
* @constructor
*/
const MapDiscussionController = DiscussionController.createComponent("MapDiscussionController");

MapDiscussionController.createViewFragment = function () {
Expand All @@ -7,29 +12,40 @@ MapDiscussionController.createViewFragment = function () {

// View

MapDiscussionController.defineMethod("initView", function initView() {
if (!this.view) return;
(function (MapDiscussionController) {

this.view.addEventListener("click", function (e) {
e.stopPropagation();
}.bind(this.view));
MapDiscussionController.defineMethod("initView", function initView() {
if (!this.view) return;

});
this.view.addEventListener("click", viewOnClick);

MapDiscussionController.defineMethod("updateView", function updateView() {
if (!this.view) return;
});

this.view.querySelectorAll("[data-ica-discussion-predicate]").forEach(function (element) {
let predicate = getElementProperty(element, "discussion-predicate");
if (isEmpty(this.discussion[predicate])) {
element.style.display = "none";
} else {
element.style.display = "";
}
}.bind(this));
MapDiscussionController.defineMethod("updateView", function updateView() {
if (!this.view) return;

this.view.querySelectorAll("[data-ica-discussion]").forEach(function (element) {
element.textContent = this.discussion[getElementProperty(element, "discussion")]["0"];
}.bind(this));
this.view.querySelectorAll("[data-ica-discussion-predicate]").forEach(function (element) {
let predicate = getElementProperty(element, "discussion-predicate");
element.style.display = isEmpty(this.discussion[predicate]) ? "none" : "";
}.bind(this));

});
this.view.querySelectorAll("[data-ica-discussion]").forEach(function (element) {
element.textContent = this.discussion[getElementProperty(element, "discussion")]["0"];
}.bind(this));

});

MapDiscussionController.defineMethod("uninitView", function uninitView() {
if (!this.view) return;

this.view.removeEventListener("click", viewOnClick);

});

// Shared functions

function viewOnClick(event) {
event.stopPropagation();
}

})(MapDiscussionController);

0 comments on commit 17928d5

Please sign in to comment.