フォーラムモジュール

ForumViewThreadModule.js

WIKIDOT.modules.ForumViewThreadModule = {};
WIKIDOT.modules.ForumViewThreadModule.vars = {};
WIKIDOT.modules.ForumViewThreadModule.listeners = {
  togglePostFold: function (c, a) {
    fDiv = $("post-" + a);
    var b = new fx.Opacity(fDiv, {
      duration: 100,
      onComplete: function () {
        if (fDiv.className.indexOf(" folded") >= 0) {
          fDiv.className = fDiv.className.replace(/ folded/, "")
        } else {
          fDiv.className += " folded"
        }
        var d = new fx.Opacity(fDiv, {
          duration: 100
        });
        d.setOpacity(0);
        d.custom(0, 1)
      }
    });
    b.custom(1, 0)
  },
  togglePostOptions: function (h, a) {
    var d = $("post-options-" + a);
    if (d.style.display != "block") {
      var c = $("post-options-template").innerHTML;
      c = c.replace(/%POST_ID%/g, a);
      $j(d).html(c);
      var g = d.getElementsByTagName("a");
      for (var f = 0; f < g.length; f++) {
        if (g[f].innerHTML == "permalink") {
          g[f].href = $("post-options-permalink-template").innerHTML + a
        }
      }
      var b = new fx.Opacity(d.id, {
        duration: 200
      });
      b.setOpacity(0);
      d.style.display = "block";
      b.custom(0, 1)
    } else {
      var b = new fx.Opacity(d.id, {
        duration: 200
      });
      b.custom(1, 0);
      setTimeout('document.getElementById("post-options-' + a + '").style.display="none"', 300)
    }
  },
  toggleThreadOptions: function (d) {
    var c = $("thread-options-2");
    var a = new fx.Opacity(c, {
      duration: 200
    });
    var b = YAHOO.util.Event.getTarget(d);
    if (c.style.display == "none") {
      a.setOpacity(0);
      c.style.display = "block";
      a.custom(0, 1);
      b.innerHTML = "- Less Options"
    } else {
      a.custom(1, 0);
      b.innerHTML = "+ More Options";
      setTimeout('$("thread-options-2").style.display="none"', 200)
    }
  },
  showPermalink: function (d, b) {
    var a = new OZONE.dialogs.InfoDialog();
    a.style = {
      width: "60em"
    };
    var c = window.location.href.replace(/#.*$/, "").replace(/\/$/, "");
    if (!WIKIREQUEST.info.requestPageName.match(/^forum:thread$/)) {
      if (!c.match(/comments\/show/)) {
        c += "/comments/show"
      }
    }
    c += "#post-" + b;
    a.content = "<h1>Permanent link</h1><p>Permanent link for this post is:</p><p><strong>" + c + "</strong></p>";
    a.show()
  },
  newPost: function (f, b) {
    if (WIKIDOT.Editor.editElementId) {
      if ($("np-text") && $("np-text").value != "") {
        var a = new OZONE.dialogs.ErrorDialog();
        a.content = 'You have an active editor somewhere already and it is not possible to edit multiple elements at once.<br/><br/>(<a href="javascript:;" onclick="OZONE.visuals.scrollTo(\'' + WIKIDOT.Editor.editElementId + "');OZONE.dialog.cleanAll()\">scroll to active editor</a>)";
        a.show();
        return
      } else {
        var c = $("new-post-form-container");
        if (c) {
          c.parentNode.removeChild(c);
          $("new-post-button").style.display = "";
          WIKIDOT.Editor.shutDown()
        }
      }
    }
    var d = new Object();
    d.postId = b;
    d.threadId = WIKIDOT.forumThreadId;
    OZONE.ajax.requestModule("forum/sub/ForumNewPostFormModule", d, WIKIDOT.modules.ForumViewThreadModule.callbacks.newPost)
  },
  editPost: function (f, b) {
    if (WIKIDOT.Editor.editElementId) {
      if ($("np-text") && $("np-text").value != "") {
        var a = new OZONE.dialogs.ErrorDialog();
        a.content = 'You have an active editor somewhere already and it is not possible to edit multiple elements at once.<br/><br/>(<a href="javascript:;" onclick="OZONE.visuals.scrollTo(\'' + WIKIDOT.Editor.editElementId + "');OZONE.dialog.cleanAll()\">scroll to active editor</a>)";
        a.show();
        return
      } else {
        var c = $("new-post-form-container");
        c.parentNode.removeChild(c);
        $("new-post-button").style.display = "";
        WIKIDOT.Editor.shutDown()
      }
    }
    var d = new Object();
    d.postId = b;
    d.threadId = WIKIDOT.forumThreadId;
    OZONE.ajax.requestModule("forum/sub/ForumEditPostFormModule", d, WIKIDOT.modules.ForumViewThreadModule.callbacks.editPost)
  },
  deletePost: function (b, a) {
    OZONE.ajax.requestModule("forum/sub/ForumDeletePostModule", {
      postId: a
    }, WIKIDOT.modules.ForumViewThreadModule.callbacks.deletePost)
  },
  foldAll: function (c) {
    var b = YAHOO.util.Dom.getElementsByClassName("post", "div");
    for (var a = 0; a < b.length; a++) {
      YAHOO.util.Dom.addClass(b[a], "folded")
    }
  },
  unfoldAll: function (c) {
    var b = YAHOO.util.Dom.getElementsByClassName("post", "div");
    for (var a = 0; a < b.length; a++) {
      YAHOO.util.Dom.removeClass(b[a], "folded")
    }
  },
  showHistory: function (c, a) {
    var b = new Object();
    b.postId = a;
    OZONE.ajax.requestModule("forum/sub/ForumPostRevisionsModule", b, WIKIDOT.modules.ForumViewThreadModule.callbacks.showHistory)
  },
  hideHistory: function (f, a) {
    var d = $("post-" + a);
    var c = YAHOO.util.Dom.getElementsByClassName("revisions", "div", d)[0];
    var b = YAHOO.util.Dom.getElementsByClassName("changes", "div", d)[0];
    b.style.display = "block";
    c.style.display = "none"
  },
  showRevision: function (g, a) {
    var f = new Object();
    f.revisionId = a;
    OZONE.ajax.requestModule("forum/sub/ForumPostRevisionModule", f, WIKIDOT.modules.ForumViewThreadModule.callbacks.showRevision);
    var b = YAHOO.util.Event.getTarget(g);
    var d = b.parentNode;
    while (!d.tagName || d.tagName.toLowerCase() != "table") {
      d = d.parentNode
    }
    var c = YAHOO.util.Dom.getElementsByClassName("active", "tr", d)[0];
    YAHOO.util.Dom.removeClass(c, "active");
    while (!b.tagName || b.tagName.toLowerCase() != "tr") {
      b = b.parentNode
    }
    YAHOO.util.Dom.addClass(b, "active")
  },
  editThreadMeta: function (b) {
    var a = new Object();
    a.threadId = WIKIDOT.forumThreadId;
    OZONE.ajax.requestModule("forum/sub/ForumEditThreadMetaModule", a, WIKIDOT.modules.ForumViewThreadModule.callbacks.editThreadMeta)
  },
  editThreadStickiness: function (b) {
    var a = new Object();
    a.threadId = WIKIDOT.forumThreadId;
    OZONE.ajax.requestModule("forum/sub/ForumEditThreadStickinessModule", a, WIKIDOT.modules.ForumViewThreadModule.callbacks.editThreadStickiness)
  },
  editThreadBlock: function (b) {
    var a = new Object();
    a.threadId = WIKIDOT.forumThreadId;
    OZONE.ajax.requestModule("forum/sub/ForumEditThreadBlockModule", a, WIKIDOT.modules.ForumViewThreadModule.callbacks.editThreadBlock)
  },
  moveThread: function (b) {
    var a = new Object();
    a.threadId = WIKIDOT.forumThreadId;
    OZONE.ajax.requestModule("forum/sub/ForumThreadMoveModule", a, WIKIDOT.modules.ForumViewThreadModule.callbacks.moveThread)
  },
  watchThread: function (b) {
    var a = new Object();
    a.threadId = WIKIDOT.forumThreadId;
    a.action = "WatchAction";
    a.event = "watchThread";
    OZONE.ajax.requestModule(null, a, WIKIDOT.modules.ForumViewThreadModule.callbacks.watchThread)
  }
};
WIKIDOT.modules.ForumViewThreadModule.callbacks = {
  newPost: function (c) {
    if (WIKIDOT.modules.ForumViewThreadModule.vars.initHack && c.status != "ok") {
      WIKIDOT.modules.ForumViewThreadModule.vars.initHack = false;
      return
    } else {
      if (!WIKIDOT.utils.handleError(c)) {
        return
      }
    }
    var f = c.parentId;
    var a = document.createElement("div");
    a.id = "new-post-form-container";
    $j(a).html(c.body);
    if (f == null) {
      var e = $("thread-container");
      if ($j(e).hasClass("reverse")) {
        $j(e).prepend($j(a))
      } else {
        e.appendChild(a)
      }
      $("new-post-button").style.display = "none"
    } else {
      var d = $("fpc-" + f);
      var b = $("post-" + f);
      if (c.parentChanged == true) {
        d.appendChild(a)
      } else {
        OZONE.dom.insertAfter(d, a, b)
      }
    }
    WIKIDOT.Editor.init("np-text", "np-editor-panel", WIKIDOT.modules.ForumViewThreadModule.vars.initHack);
    if (WIKIDOT.modules.ForumViewThreadModule.vars.initHack) {
      WIKIDOT.modules.ForumViewThreadModule.vars.initHack = false
    } else {
      setTimeout('OZONE.visuals.scrollTo("new-post-form-container")', 300)
    }
  },
  editPost: function (c) {
    if (!WIKIDOT.utils.handleError(c)) {
      return
    }
    var a = document.createElement("div");
    a.id = "edit-post-form-container";
    $j(a).html(c.body);
    var d = $("fpc-" + c.postId);
    var b = $("post-" + c.postId);
    OZONE.dom.insertAfter(d, a, b);
    WIKIDOT.Editor.init("np-text", "np-editor-panel");
    setTimeout('OZONE.visuals.scrollTo("edit-post-form-container")', 300)
  },
  showHistory: function (d) {
    if (!WIKIDOT.utils.handleError(d)) {
      return
    }
    var c = $("post-" + d.postId);
    var b = YAHOO.util.Dom.getElementsByClassName("revisions", "div", c)[0];
    var a = YAHOO.util.Dom.getElementsByClassName("changes", "div", c)[0];
    a.style.display = "none";
    $j(b).html(d.body);
    b.style.display = "block"
  },
  showRevision: function (b) {
    if (!WIKIDOT.utils.handleError(b)) {
      return
    }
    var a = b.postId;
    $j("#post-content-" + a).html(b.content);
    $j("#post-title-" + a).html(b.title)
  },
  deletePost: function (a) {
    if (!WIKIDOT.utils.handleError(a)) {
      return
    }
    var b = $("fpc-" + a.postId);
    YAHOO.util.Dom.addClass(b, "fordelete");
    var c = "delete-post-" + a.postId;
    if ($(c)) {
      $(c).parentNode.removeChild($(c))
    }
    $j(b).find("#new-post-form-container").remove();
    $j("#post-" + a.postId).append(a.body);
    OZONE.visuals.scrollTo(c)
  },
  editThreadMeta: function (c) {
    if (!WIKIDOT.utils.handleError(c)) {
      return
    }
    var b = $("thread-action-area");
    b.style.display = "block";
    $j(b).html(c.body);
    var a = new OZONE.forms.lengthLimiter("thread-description", "desc-charleft", 1000)
  },
  editThreadStickiness: function (b) {
    if (!WIKIDOT.utils.handleError(b)) {
      return
    }
    var a = $("thread-action-area");
    a.style.display = "block";
    $j(a).html(b.body)
  },
  editThreadBlock: function (b) {
    if (!WIKIDOT.utils.handleError(b)) {
      return
    }
    var a = $("thread-action-area");
    a.style.display = "block";
    $j(a).html(b.body)
  },
  moveThread: function (b) {
    if (!WIKIDOT.utils.handleError(b)) {
      return
    }
    var a = $("thread-action-area");
    a.style.display = "block";
    $j(a).html(b.body)
  },
  watchThread: function (b) {
    if (!WIKIDOT.utils.handleError(b)) {
      return
    }
    var a = new OZONE.dialogs.SuccessBox();
    a.content = "Thread added to watched.";
    a.show()
  }
};
togglePostOptions = function (b, a) {
  WIKIDOT.modules.ForumViewThreadModule.listeners.togglePostOptions(b, a)
};
togglePostFold = function (b, a) {
  WIKIDOT.modules.ForumViewThreadModule.listeners.togglePostFold(b, a)
};
postReply = function (b, a) {
  WIKIDOT.modules.ForumViewThreadModule.listeners.newPost(b, a)
};
$j(function () {
  var a = function () {
    if (WIKIDOT.modules.ForumViewThreadPostsModule) {
      WIKIDOT.modules.ForumViewThreadPostsModule.initOnce()
    } else {
      setTimeout(a, 100)
    }
  };
  a()
});

ForumViewThreadPostsModule.js

WIKIDOT.modules.ForumViewThreadPostsModule = {};
WIKIDOT.modules.ForumViewThreadPostsModule.listeners = {
  updateList: function (a) {
    OZONE.ajax.requestModule("forum/ForumViewThreadPostsModule", {
      pageNo: a,
      t: WIKIDOT.forumThreadId,
      order: ($j("#thread-container").hasClass("reverse")) ? "reverse" : ""
    }, function (b) {
      if (!WIKIDOT.utils.handleError(b)) {
        return
      }
      $j("#thread-container-posts").html(b.body);
      OZONE.visuals.scrollTo("thread-container")
    })
  }
};
WIKIDOT.modules.ForumViewThreadPostsModule.initOnce = function () {
  var b = $j;
  if (location.hash.search("#post-") == 0 && b("#thread-container-posts > .pager").length) {
    var a = location.hash.replace("#post-", "");
    OZONE.ajax.requestModule("forum/ForumViewThreadPostsModule", {
      postId: a,
      t: WIKIDOT.forumThreadId,
      order: ($j("#thread-container").hasClass("reverse")) ? "reverse" : ""
    }, function (c) {
      b("#thread-container-posts").show();
      if (c.status == "no_post" || !WIKIDOT.utils.handleError(c)) {
        return
      }
      b("#thread-container-posts").html(c.body);
      OZONE.visuals.scrollTo("post-" + a)
    }, null, {
      ignoreCodeZero: true
    })
  } else {
    b("#thread-container-posts").show()
  }
};
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License