");
html.push(" | ");
html.push(" | ");
html.push(" | ");
html.push("");
html.push(" | ");
html.push(" ");
el.innerHTML = html.join('');
this._bodyCell = FIRSTCLASS.ui.Dom.getChildByClassName("fcWikiPageCell", el);
this._bodyEl = FIRSTCLASS.ui.Dom.getChildByClassName("fcWikiPageBody", el);
this._tocCell = FIRSTCLASS.ui.Dom.getChildByClassName("fcWikiTOCCell", el);
this._tocEl = FIRSTCLASS.ui.Dom.getChildByClassName("fcWikiTOC", el);
this._tocEl.setAttribute('fcid', 'wikitoc');
this._tocBtnEl = FIRSTCLASS.ui.Dom.getChildByClassName("fcWikiTOCBtn", el);
this._tocBtnEl.setAttribute('fcid', 'wikitocbtn');
this._tocSplitEl = FIRSTCLASS.ui.Dom.getChildByClassName("fcWikiPageSplit", el);
this._tocTitle = document.createElement("div");
YAHOO.util.Dom.addClass(this._tocTitle, 'fcWikiContentsTitle');
this._tocTitle.innerHTML = "" + FIRSTCLASS.locale.community.wiki.contents + " | | ";
this._offlineEl = document.createElement("div");
this._offlineEl.appendChild(this._tocTitle);
this._contentBase = this._bodyEl;
this.hideContents();
this._tocOrigin = 0;
this._nTocRows = 0;
this._TOC = [];
this._scrollToc = false;
};
// open the page
FIRSTCLASS.apps.Wiki.pageView.prototype.openPage = function(row, callback) {
var that = this;
var openCB = {
success: function(o) {
that.constructPage(row, o.responseText);
if (callback.success) {
callback.success(o);
}
},
failure: function(o) {
if (callback.failure) {
callback.failure(o);
}
}
};
var url = this._config.dataSource.getItemUrl(row);
var qm = "?";
if (url.indexOf(qm) < 0) {
url += "?";
} else {
url += "&";
}
url += "FormID=20501";
FIRSTCLASS.util.net.asyncRequest('GET', url, openCB);
};
// populate page view from passed-in row and body text
FIRSTCLASS.apps.Wiki.pageView.prototype.constructPage = function(row, pageText) {
if (this._config.dataSource && pageText) {
// swap the body out of the DOM
FIRSTCLASS.ui.Dom.reparentNode(this._bodyEl, this._offlineEl);
this._bodyEl.innerHTML = this._config.dataSource.expandContent(row, pageText);
FIRSTCLASS.ui.Dom.reparentNode(this._bodyEl, this._bodyCell);
this.processContentNodes();
this.updateContents();
this.hideContents();
}
};
FIRSTCLASS.apps.Wiki.pageView.prototype.setContentBaseNode = function(node) {
if (node) {
this._contentBase = node;
}
};
FIRSTCLASS.apps.Wiki.pageView.prototype.processContentNodes = function() {
/* if (this.howMany)
alert('wow');
else
this.howMany = true;
*/
// functions for various kinds of nodes
var wikiWidth = this._config.owner._domEl.clientWidth;
var processAnchor = function(node) {
if ((node.className === "fcwl") && (this._view !== 'edit')) {
node.setAttribute('fcid', 'fcwl');
}
};
var processDiv = function(node) {
if ((node.className === 'fcEmbed') && (this._view === 'edit')) {
node.innerHTML = " ";
}
};
var processImage = function(node) {
if (node.width && (node.width > 0)) {
if (node.width > wikiWidth) {
node.width = parseInt(wikiWidth * 0.80);
node.setAttribute("width", node.width + "px");
}
} else {
YAHOO.util.Event.addListener(node, "load", function(ev) {
if (node.width > wikiWidth) {
node.width = parseInt(wikiWidth * 0.90);
node.setAttribute("width", node.width + "px");
YAHOO.util.Event.stopEvent(ev);
}
});
}
};
var process = function(node) {
var c;
switch (node.tagName) {
case 'A':
processAnchor(node);
break;
case 'DIV':
processDiv(node);
break;
case 'IMG':
processImage(node);
break;
}
for (c = 0; c < node.childNodes.length; c++) {
process(node.childNodes[c]);
}
};
// find base node - FIX THIS TO CALL setContentBaseNode
var baseEl = this._contentBase;
if (this._config.owner._view === "edit") {
var editor = this._config.owner.editor;
if (editor && editor._editor && editor._editor._editor && editor._editor._editor._getDoc) {
var doc = editor._editor._editor._getDoc();
if (doc.body) {
baseEl = doc.body;
}
}
}
process(baseEl);
};
FIRSTCLASS.apps.Wiki.pageView.prototype.updateContents = function() {
// function to walk nodes and scrape headings
var addToTOC = function (node, list) {
var isH = true;
var level = false, c;
switch (node.tagName) {
case 'H1': level = 1; break;
case 'H2': level = 2; break;
case 'H3': level = 3; break;
case 'H4': level = 4; break;
case 'H5': level = 5; break;
case 'H6': level = 6; break;
default: isH = false;
}
if (isH) {
var e = {};
if (YAHOO.env.ua.ie) {
e.text = "" + node.innerText;
} else {
e.text = "" + node.textContent;
}
e.el = node;
e.level = level;
list.push(e);
}
for (c = 0; c < node.childNodes.length; c++) {
addToTOC(node.childNodes[c],list);
}
};
this._TOC = [];
// find base node
var w = this._config.owner;
var baseEl = this._bodyEl;
if (w._view === "edit") {
if (w._editor && w._editor._editor && w._editor._editor._editor && w._editor._editor._editor.document) {
baseEl = w._editor._editor._editor.document.getBody().$;
}
}
addToTOC(baseEl, this._TOC);
this.setTocBounds(this._tocCell.offsetHeight);
};
// insert the contents data into the contents pane, with optional scroller buttons
FIRSTCLASS.apps.Wiki.pageView.prototype.drawContents = function() {
var row = this._tocOrigin, end = row + this._nTocRows;
var text, title;
this._tocEl.innerHTML = "";
var html = [];
if (this._scrollToc) {
html.push("");
}
for (; row < end; row++) {
html.push(" 32) {
text = text.slice(0,29) + "...";
}
html.push(" id='fcWikiTOC" + row + "' fcid='wikitoc' title='" + title + "'>" + text + " ");
}
if (this._scrollToc) {
html.push("");
html.push("");
}
this._tocEl.innerHTML = html.join("");
// set up event handler keys
if (this._scrollToc) {
var that = this;
var btn = FIRSTCLASS.ui.Dom.getChildByIdName('fcWikiTocUp',this._tocEl);
btn.setAttribute('fcid','wikitocup');
btn = FIRSTCLASS.ui.Dom.getChildByIdName('fcWikiTocDown',this._tocEl);
btn.setAttribute('fcid','wikitocdown');
}
return;
};
// set the ordinal origin for the top TOC item
FIRSTCLASS.apps.Wiki.pageView.prototype.setTocOrigin = function(origin) {
if (this._scrollToc && this._TOC && this._TOC.length > 0) {
if (origin !== this._tocOrigin && this._scrollToc) {
this._tocOrigin = origin;
if (this._tocOrigin < 0) {
this._tocOrigin = 0;
}
if (this._tocOrigin > (this._TOC.length - this._nTocRows)) {
this._tocOrigin = this._TOC.length - this._nTocRows;
}
if (!this._tocHidden) {
this.drawContents();
}
}
} else {
this._tocOrigin = 0;
}
return;
};
// set TOC visible row count
FIRSTCLASS.apps.Wiki.pageView.prototype.setTocBounds = function(height) {
var yRow = 20, yTitle = 25, yScroll = 42;
var available = height - yTitle;
if ((available < (yRow * this._TOC.length)) && (this._TOC.length > 0)) {
this._scrollToc = true;
available -= yScroll;
if (available > yRow) {
this._nTocRows = Math.floor(available/yRow);
this._tocSlop = available - (this._nTocRows * yRow);
} else {
this._nTocRows = 1;
}
} else {
this._scrollToc = false;
this._nTocRows = this._TOC.length;
}
this.drawContents();
};
FIRSTCLASS.apps.Wiki.pageView.prototype.showContents = function() {
this._tocCell.setAttribute('width','15%');
this._bodyCell.setAttribute('width','85%');
YAHOO.util.Dom.removeClass(this._tocCell,'fcHidden');
YAHOO.util.Dom.removeClass(this._tocBtnEl, 'fcWikiOpenToc');
YAHOO.util.Dom.addClass(this._tocBtnEl, 'fcWikiCloseToc');
YAHOO.util.Dom.removeClass(this._tocSplitEl, 'fcWikiPageSplitClosed');
this._tocBtnEl.setAttribute('title',FIRSTCLASS.locale.community.wiki.tooltips.hidetoc);
FIRSTCLASS.ui.Dom.reparentNode(this._tocTitle,this._tocCell);
FIRSTCLASS.ui.Dom.reparentNode(this._tocEl,this._tocCell);
this._tocOrigin = 0;
this.setTocBounds(this._tocCell.offsetHeight);
this._tocHidden = false;
return;
};
FIRSTCLASS.apps.Wiki.pageView.prototype.hideContents = function() {
YAHOO.util.Dom.addClass(this._tocCell,'fcHidden');
YAHOO.util.Dom.removeClass(this._tocBtnEl, 'fcWikiCloseToc');
YAHOO.util.Dom.addClass(this._tocBtnEl, 'fcWikiOpenToc');
YAHOO.util.Dom.addClass(this._tocSplitEl, 'fcWikiPageSplitClosed');
this._tocBtnEl.setAttribute('title',FIRSTCLASS.locale.community.wiki.tooltips.showtoc);
this._tocHidden = true;
return;
};
FIRSTCLASS.apps.Wiki.pageView.prototype.scrollToContentsItem = function(target) {
if (target) {
var id = target.id;
var prefix = "fcWikiTOC";
id = id.slice(id.indexOf(prefix) + prefix.length);
var scroller = false;
var w = this._config.owner;
if (w._view === "edit") {
if (w._editor && w._editor._editor && w._editor._editor._editor && w._editor._editor._editor.document) {
scroller = w._editor._editor._editor.document.getBody().$.parentNode;
}
} else if (w._view === "page") {
scroller = this._bodyEl;
}
if (scroller) {
FIRSTCLASS.ui.scrollChildrenIntoView(scroller, this._TOC[id].el, this._TOC[id].el, true);
}
}
return;
};
FIRSTCLASS.apps.Wiki.pageView.prototype.eventHandlers = {
click: {
// table of contents items
wikitoc: function(that, fcevent) {
that.scrollToContentsItem(fcevent.target);
},
// body links
fcwl: function(that, fcevent, evt) {
return that._config.owner.openLinkedPage(evt);
},
// show/hide toc
wikitocbtn: function(that) {
if (that._tocHidden) {
that.showContents();
} else {
that.hideContents();
}
},
// scroll toc
wikitocup: function(that) {
that.setTocOrigin(that._tocOrigin - 1);
},
wikitocdown: function(that) {
that.setTocOrigin(that._tocOrigin + 1);
}
}
};
FIRSTCLASS.apps.Wiki.pageView.prototype.handleEvent = function(evt, fcevent) {
var rc = false;
if (!rc) {
var handlers = this.eventHandlers[evt.type];
if (handlers) {
var handler = handlers[fcevent.fcid];
if (handler) {
rc = handler(this, fcevent, evt);
if (typeof rc === "undefined") {
rc = true;
}
}
}
}
return rc;
};
FIRSTCLASS.apps.Wiki.pageView.prototype.setBottomBounds = function(pageBottom, paneBottom) {
var yTop = YAHOO.util.Dom.getY(this._bodyCell);
var pageHeight = pageBottom - yTop,
paneHeight = paneBottom - yTop;
YAHOO.util.Dom.setStyle(this._bodyEl, "overflow", "auto");
YAHOO.util.Dom.setStyle(this._bodyEl, "height", "auto");
if (!isNaN(pageHeight) && pageHeight >= 0) {
YAHOO.util.Dom.setStyle(this._bodyEl, "height", pageHeight+"px");
}
if (!isNaN(paneHeight) && paneHeight >= 0) {
YAHOO.util.Dom.setStyle(this._bodyCell, "height", paneHeight+"px");
if (!this._tocHidden) {
yTop = YAHOO.util.Dom.getY(this._tocCell);
paneHeight = paneBottom - yTop;
this.setTocBounds(paneHeight);
}
}
};
// ---- History component -----
//
// Config is:
// domEl - containing DOM element for all the history stuff
// owner - pointer back to owning Wiki
//
FIRSTCLASS.apps.Wiki.history = function(config) {
var html = false;
var that = this;
this._domEl = config.domEl;
this._wiki = config.owner;
// frame
this._header = document.createElement('div');
this._domEl.appendChild(this._header);
this._body = document.createElement('div');
this._domEl.appendChild(this._body);
// list components
this._listTitleEl = document.createElement('div');
YAHOO.util.Dom.addClass(this._listTitleEl, 'fcWikiHistTitle');
this._listTitleEl.innerHTML = FIRSTCLASS.locale.community.wiki.history;
this._listEl = document.createElement('div');
var listCfg = {
domElement: this._listEl,
dataSource: this._wiki._dataSource,
dsRow: this._wiki._currentRow,
scrolling: true,
toolbar: [
{ id: 'fcWikiHistShowVersion',
label: FIRSTCLASS.locale.toolbars.wiki.view,
fcid: 'histshowversion'
},
{ id: "fcWikiHistDiffPrev",
label: FIRSTCLASS.locale.toolbars.wiki.changes,
fcid: 'wikihistdiffprev',
condition: function() {
var allow = (that._list._selRow.typedef.objtype === FIRSTCLASS.objTypes.odocument);
if (allow) {
allow = (that._list._selRow.col8090 > 1) ? true : false;
}
return allow;
}
},
{ id: "fcWikiHistDiffLatest",
label: FIRSTCLASS.locale.toolbars.wiki.compare,
fcid: 'wikihistdifflatest',
condition: function() {
var allow = (that._list._selRow.typedef.objtype === FIRSTCLASS.objTypes.odocument);
if (allow) {
allow = that._list._selRow.status.backversion ? true : false;
}
return allow;
}
},
{ id: "fcWikiHistDelete",
label: FIRSTCLASS.locale.toolbars.documents.deletevers,
fcid: 'wikihistdel',
condition: function() {
var allow = (that._list._selRow.typedef.objtype === FIRSTCLASS.objTypes.odocument);
if (allow) {
allow = that._list._selRow.status.backversion ? true : false;
}
if (allow) {
var delown = FIRSTCLASS.permissions.hasPriv(that._list._selRow.acl, FIRSTCLASS.permissions.ACL.DELETEOWN);
var del = FIRSTCLASS.permissions.hasPriv(that._list._selRow.acl, FIRSTCLASS.permissions.ACL.DELETE);
if (del) {
return true;
} else if (delown && FIRSTCLASS.session.user.cid === that._list._selRow.creatorcid) {
return true;
}
}
return false;
}
}
]
};
this._list = new FIRSTCLASS.apps.history(listCfg);
// page components
this._pageViewEl = document.createElement("div");
YAHOO.util.Dom.addClass(this._pageViewEl,'fcWikiPageContainer');
this._pageView = new FIRSTCLASS.apps.Wiki.pageView({domEl:this._pageViewEl, dataSource: this._wiki._dataSource, owner: this});
this._pageDetails = document.createElement('div');
YAHOO.util.Dom.addClass(this._header, 'fcToolBar');
YAHOO.util.Dom.setStyle(this._header, 'padding','7px 0px 0px 3px');
// diff components
this._diffContainer = document.createElement('div');
html = [];
html.push("");
html.push(" ");
html.push(" | | ");
html.push(" | ");
html.push(" ");
this._diffContainer.innerHTML = html.join("");
this._leftHeaderCell = FIRSTCLASS.ui.Dom.getChildByClassName('fcWikiDiffHeaderLeft', this._diffContainer);
this._leftHeaderCell.setAttribute('align', 'center');
this._rightHeaderCell = FIRSTCLASS.ui.Dom.getChildByClassName('fcWikiDiffHeaderRight', this._diffContainer);
this._rightHeaderCell.setAttribute('align', 'center');
this._leftInfoCell = FIRSTCLASS.ui.Dom.getChildByClassName('fcWikiDiffInfoLeft', this._diffContainer);
this._rightInfoCell = FIRSTCLASS.ui.Dom.getChildByClassName('fcWikiDiffInfoRight', this._diffContainer);
this._diffCell = FIRSTCLASS.ui.Dom.getChildByClassName('fcWikiDiffCell', this._diffContainer);
this._diffTitleEl = document.createElement('span');
YAHOO.util.Dom.addClass(this._diffTitleEl, 'fcCommentGuide');
this._diffFixedHeader = document.createElement('div');
YAHOO.util.Dom.addClass(this._diffFixedHeader, 'fcWikiDiffHeader fcWikiDiffFixedHeader');
this._diffTBEl = document.createElement("div");
YAHOO.util.Dom.addClass(this._diffTBEl, 'fcWikiDiffHeader');
var diffTBCfg = {
domElement: this._diffTBEl,
buttons: [
{ id: "fcWikiDiffPrev",
label: FIRSTCLASS.locale.toolbars.wiki.prev,
fcid: 'wikidiffprevious'
},
{ id: "fcWikiDiffNext",
label: FIRSTCLASS.locale.toolbars.wiki.next,
fcid: 'wikidiffnext'
}
]
};
this._diffTB = new FIRSTCLASS.ui.toolBar(diffTBCfg);
// back-to-list button
this._listButton = document.createElement('span');
this._listButton.innerHTML =FIRSTCLASS.locale.toolbars.wiki.showhist;
this._listButton.setAttribute('fcid','wikihistshowlist');
this._listButton.setAttribute('fcid','wikihistshowlist');
YAHOO.util.Dom.setStyle(this._listButton, 'font-size','0.9em');
YAHOO.util.Dom.addClass(this._listButton, 'fcToolBarButton fcToolBarLastButton');
// view mapper
var viewMap = [
{ element: this._pageViewEl,
views: {
page: this._body
}
},
{ element: this._pageDetails,
views: {
page: this._header
}
},
{ element: this._listEl,
views: {
list: this._body
}
},
{ element: this._listTitleEl,
views: {
list: this._header
}
},
{ element: this._diffTitleEl,
views: {
diffprev: this._header,
difflatest: this._header
}
},
{ element: this._diffTBEl,
views: {
diffprev: this._rightHeaderCell,
difflatest: this._leftHeaderCell
}
},
{ element: this._diffFixedHeader,
views: {
diffprev: this._leftHeaderCell,
difflatest: this._rightHeaderCell
}
},
{ element: this._diffContainer,
views: {
diffprev: this._body,
difflatest: this._body
}
},
{ element: this._listButton,
views: {
page: this._header,
diffprev: this._header,
difflatest: this._header
}
}
];
this._viewMapper = new FIRSTCLASS.ui.viewMapper(viewMap);
this.setView('list');
};
FIRSTCLASS.apps.Wiki.history.prototype.setView = function(view) {
this._viewMapper.selectView(view);
};
FIRSTCLASS.apps.Wiki.history.prototype.showDifferences = function(baseRow, mode) {
// figure out which versions to compare
var row = false,
vers;
if (mode === 'prev') {
this._diffMode = 'prev';
this._newDiffRow = baseRow;
vers = baseRow.col8090 - 1;
while (vers >= 1) {
row = this._list.getRowByVersion(vers--);
if (row) {
break;
}
}
if (!row) { return; }
this._oldDiffRow = row;
this._diffTitleEl.innerHTML = FIRSTCLASS.locale.diff.changes;
this._diffFixedHeader.innerHTML = FIRSTCLASS.locale.diff.previous;
} else if (mode === 'latest') {
this._diffMode = 'latest';
this._newDiffRow = this._wiki._currentRow;
this._oldDiffRow = baseRow;
this._diffTitleEl.innerHTML = FIRSTCLASS.locale.diff.compare;
this._diffFixedHeader.innerHTML = FIRSTCLASS.locale.diff.latest;
}
// set page infos
this._wiki.setPageInfo(this._oldDiffRow, this._leftInfoCell);
this._wiki.setPageInfo(this._newDiffRow, this._rightInfoCell);
// fetch bodies, then generate the diff view
var bodiesIn = 0;
var that = this;
var gotBody = function(recRowObj, version) {
bodiesIn++;
if (version === that._oldDiffRow.col8090) {
that._oldDiffRow.body = recRowObj.body;
} else {
that._newDiffRow.body = recRowObj.body;
}
if (bodiesIn > 1) {
that.displayDifferences();
}
};
// fetch version bodies
if (this.getBody(this._oldDiffRow, gotBody)) {
// fetch previous version
this.getBody(this._newDiffRow, gotBody);
}
};
// return full row JS object with body
FIRSTCLASS.apps.Wiki.history.prototype.getBody = function(row, callback) {
var that = this;
var version = row.col8090;
// handle the response
var CB = {
success: function(o) {
try {
var rowObj = FIRSTCLASS.util.net._parseJSONResponse(o.responseText);
if (!rowObj) {
throw FIRSTCLASS.locale.diff.parsefail;
}
callback(rowObj, version);
} catch(x) {
return;
}
}
};
// get the row
if (row) {
var url = this._wiki._dataSource.getItemUrl(row);
if (url.indexOf('?') < 0) {
url += "?";
} else {
url += "&";
}
url += "Templates=JS&FormID=20501";
FIRSTCLASS.util.net.asyncRequest('GET', url, CB);
return true;
}
return false;
};
// after row bodies are received, generate the difference view
FIRSTCLASS.apps.Wiki.history.prototype.displayDifferences = function() {
var getTextContent = function(domEl) {
var text = false;
if (domEl.textContent) {
text = domEl.textContent;
} else if (domEl.innerText) {
text = domEl.innerText;
}
return text;
};
var splitIntoLines = function(domEl, result) {
var isLink = false,
isAnchor = false;
if (domEl.tagName === 'A') { // links and anchors
if (domEl.href) { // a link
isLink = true;
result.push('[Link:');
result.push('> url: ' + domEl.href);
} else if (domEl.name) {
isAnchor = true;
result.push('[Anchor:');
result.push('> name: ' + domEl.name);
}
if (isAnchor || isLink) {
if (domEl.target) {
result.push('> target: ' + domEl.target);
}
if (domEl.title) {
result.push('> title: ' + domEl.title);
}
if (isAnchor) {
result.push('end anchor]');
} else {
result.push('end link]');
}
}
} else if (domEl.tagName === 'IMG') { // images
result.push('[Image:');
if (domEl.src) {
result.push('> url: ' + domEl.src);
}
if (domEl.title) {
result.push('> title: ' + domEl.title);
}
result.push('end image]');
} else if (domEl.tagName === 'DIV' && (domEl.className.indexOf('fcEmbed') >= 0)) { // embeds
result.push('[Embed:');
if (domEl.title) {
result.push('> title: ' + domEl.title);
}
result.push('end embed]');
}
if (getTextContent(domEl)) {
if (domEl.childNodes.length > 0) {
var c;
for (c = 0; c < domEl.childNodes.length; c++) {
splitIntoLines(domEl.childNodes[c], result);
}
} else {
var text = getTextContent(domEl).split('\r'), l;
for (l in text) {
if (text[l].length > 0) {
result.push(text[l]);
}
}
}
}
if (isLink) {
result.push('end link]');
} else if (isAnchor) {
result.push('end anchor]');
}
};
// get the baseText and newText values from the two textboxes, and split them into lines
var diffWorkEl = document.createElement('div');
diffWorkEl.innerHTML = this._oldDiffRow.body;
var baselines = [];
splitIntoLines(diffWorkEl, baselines);
diffWorkEl.innerHTML = this._newDiffRow.body;
var newlines = [];
splitIntoLines(diffWorkEl, newlines);
// create a SequenceMatcher instance that diffs the two sets of lines
var sm = new difflib.SequenceMatcher(baselines, newlines);
// get the opcodes from the SequenceMatcher instance
var opcodes = sm.get_opcodes();
// build the diff view
this._diffCell.innerHTML = '';
this._diffCell.appendChild(
diffview.buildView( {
baseTextLines:baselines,
newTextLines:newlines,
opcodes:opcodes,
// set the display titles for each resource
baseTextName:"",
newTextName:"",
contextSize: null,
viewType: 0
})
);
// change the view
this.setView('diff' + this._diffMode);
};
FIRSTCLASS.apps.Wiki.history.prototype.showList = function() {
this.setView('list');
};
FIRSTCLASS.apps.Wiki.history.prototype.showVersion = function(row) {
var that = this;
if (row.status.unread) {
that._wiki._dataSource.toggleUnRead(row, false);
}
this._pageView.openPage(row, {
success: function(o) {
that._wiki.setPageInfo(row, that._pageDetails);
that.setView('page');
},
failure: function(o) {
alert(FIRSTCLASS.locale.diff.cantopen);
}
});
};
FIRSTCLASS.apps.Wiki.history.prototype.eventHandlers = {
click: {
// history button
wikihistshowlist: function(that, fcevent) {
that.showList();
},
// show/hide toc
wikitocbtn: function(that) {
if (that._pageView._tocHidden) {
that._pageView.showContents();
} else {
that._pageView.hideContents();
}
},
// scroll toc
wikitocup: function(that) {
that._pageView.setTocOrigin(that._pageView._tocOrigin - 1);
},
wikitocdown: function(that) {
that._pageView.setTocOrigin(that._pageView._tocOrigin + 1);
},
// show version
histshowversion: function(that, fcevent) {
var tg = that._list.rowFromEvent(fcevent);
if (tg) {
that.showVersion(tg.row);
}
},
// diffing commands
wikihistdiffprev: function(that, fcevent) {
var tg = that._list.rowFromEvent(fcevent);
if (tg) {
that.showDifferences(tg.row, 'prev');
}
},
wikihistdifflatest: function(that, fcevent) {
var tg = that._list.rowFromEvent(fcevent);
if (tg) {
that.showDifferences(tg.row, 'latest');
}
},
wikidiffprevious: function(that, fcevent) {
if (that._diffMode === 'prev') {
that.showDifferences(that._oldDiffRow, 'prev');
} else {
var prevRow = false,
prevVers = that._oldDiffRow.col8090 - 1;
while (prevVers >= 1) {
prevRow = that._list.getRowByVersion(prevVers--);
if (prevRow) {
that.showDifferences(prevRow, 'latest');
break;
}
}
}
},
wikidiffnext: function(that, fcevent) {
var nextRow = false,
nextVers,
maxVers;
if (that._diffMode === 'prev') {
nextVers = that._newDiffRow.col8090 + 1;
maxVers = that._wiki._currentRow.col8090;
} else {
nextVers = that._oldDiffRow.col8090 + 1;
maxVers = that._wiki._currentRow.col8090;
}
while (nextVers <= maxVers) {
nextRow = that._list.getRowByVersion(nextVers++);
if (nextRow) {
that.showDifferences(nextRow, that._diffMode);
break;
}
}
}
}
};
FIRSTCLASS.apps.Wiki.history.prototype.handleEvent = function(evt, fcevent) {
var rc = false;
if (this._list) {
rc = this._list.handleEvent(evt, fcevent);
}
if (!rc) {
var handlers = this.eventHandlers[evt.type];
if (handlers) {
var handler = handlers[fcevent.fcid];
if (handler) {
rc = handler(this, fcevent, evt);
if (typeof rc === "undefined") {
rc = true;
}
}
}
}
return rc;
};
FIRSTCLASS.apps.Wiki.history.prototype.dispose = function() {
YAHOO.util.Event.purgeElement(this._domEl, true);
this._domEl.innerHTML = "";
};
|