Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
499 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* @defgroup js_controllers_informationCenter | ||
*/ | ||
/** | ||
* @file js/controllers/informationCenter/HistoryHandler.js | ||
* | ||
* Copyright (c) 2000-2013 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @class HistoryHandler | ||
* @ingroup js_controllers_informationCenter | ||
* | ||
* @brief Information center "history" tab handler. | ||
*/ | ||
(function($) { | ||
|
||
/** @type {Object} */ | ||
$.pkp.controllers.informationCenter = | ||
$.pkp.controllers.informationCenter || { }; | ||
|
||
|
||
|
||
/** | ||
* @constructor | ||
* | ||
* @extends $.pkp.classes.Handler | ||
* | ||
* @param {jQueryObject} $historyDiv A wrapped HTML element that | ||
* represents the "history" interface element. | ||
* @param {Object} options Tabbed modal options. | ||
*/ | ||
$.pkp.controllers.informationCenter.HistoryHandler = | ||
function($historyDiv, options) { | ||
this.parent($historyDiv, options); | ||
|
||
// Store the list fetch URLs for later | ||
this.fetchHistoryUrl_ = options.fetchHistoryUrl; | ||
this.fetchPastHistoryUrl_ = options.fetchPastHistoryUrl; | ||
|
||
// Load a list of the current events. | ||
this.loadPastHistoryList_(); | ||
this.loadHistoryList_(); | ||
}; | ||
$.pkp.classes.Helper.inherits( | ||
$.pkp.controllers.informationCenter.HistoryHandler, | ||
$.pkp.classes.Handler | ||
); | ||
|
||
|
||
// | ||
// Private properties | ||
// | ||
/** | ||
* The URL to be called to fetch a list of events. | ||
* @private | ||
* @type {string} | ||
*/ | ||
$.pkp.controllers.informationCenter.HistoryHandler. | ||
prototype.fetchHistoryUrl_ = ''; | ||
|
||
|
||
/** | ||
* The URL to be called to fetch a list of prior events. | ||
* @private | ||
* @type {string} | ||
*/ | ||
$.pkp.controllers.informationCenter.HistoryHandler. | ||
prototype.fetchPastHistoryUrl_ = ''; | ||
|
||
|
||
// | ||
// Private methods | ||
// | ||
$.pkp.controllers.informationCenter.HistoryHandler.prototype. | ||
loadHistoryList_ = function() { | ||
|
||
$.get(this.fetchHistoryUrl_, | ||
this.callbackWrapper(this.setHistoryList_), 'json'); | ||
}; | ||
|
||
$.pkp.controllers.informationCenter.HistoryHandler.prototype. | ||
setHistoryList_ = function(formElement, jsonData) { | ||
|
||
var processedJsonData = this.handleJson(jsonData); | ||
$('#historyList').replaceWith(processedJsonData.content); | ||
// Initialize an accordion for the "past events" list, if it's | ||
// available (e.g. for a file information center). | ||
$('#historyAccordion').accordion({ clearStyle: true }); | ||
}; | ||
|
||
|
||
$.pkp.controllers.informationCenter.HistoryHandler.prototype. | ||
loadPastHistoryList_ = function() { | ||
|
||
// Only attempt to load the past history list if it's in the UI | ||
if ($('#pastHistoryList').length) { | ||
$.get(this.fetchPastHistoryUrl_, | ||
this.callbackWrapper(this.setPastHistoryList_), 'json'); | ||
} | ||
}; | ||
|
||
|
||
$.pkp.controllers.informationCenter.HistoryHandler.prototype. | ||
setPastHistoryList_ = function(formElement, jsonData) { | ||
|
||
var processedJsonData = this.handleJson(jsonData); | ||
$('#pastHistoryList').replaceWith(processedJsonData.content); | ||
}; | ||
|
||
|
||
/** @param {jQuery} $ jQuery closure. */ | ||
}(jQuery)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/** | ||
* @file js/controllers/informationCenter/NotesHandler.js | ||
* | ||
* Copyright (c) 2000-2013 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @class NotesHandler | ||
* @ingroup js_controllers_informationCenter | ||
* | ||
* @brief Information center "notes" tab handler. | ||
*/ | ||
(function($) { | ||
|
||
|
||
/** | ||
* @constructor | ||
* | ||
* @extends $.pkp.classes.Handler | ||
* | ||
* @param {jQueryObject} $notesDiv A wrapped HTML element that | ||
* represents the "notes" interface element. | ||
* @param {Object} options Tabbed modal options. | ||
*/ | ||
$.pkp.controllers.informationCenter.NotesHandler = | ||
function($notesDiv, options) { | ||
this.parent($notesDiv, options); | ||
|
||
// Store the list fetch URLs for later | ||
this.fetchNotesUrl_ = options.fetchNotesUrl; | ||
this.fetchPastNotesUrl_ = options.fetchPastNotesUrl; | ||
// Bind for changes in the note list (e.g. new note or delete) | ||
this.bind('formSubmitted', this.handleRefreshNoteList); | ||
|
||
// Load a list of the current notes. | ||
this.loadPastNoteList_(); | ||
this.loadNoteList_(); | ||
}; | ||
$.pkp.classes.Helper.inherits( | ||
$.pkp.controllers.informationCenter.NotesHandler, | ||
$.pkp.classes.Handler | ||
); | ||
|
||
|
||
// | ||
// Private properties | ||
// | ||
/** | ||
* The URL to be called to fetch a list of notes. | ||
* @private | ||
* @type {string} | ||
*/ | ||
$.pkp.controllers.informationCenter.NotesHandler. | ||
prototype.fetchNotesUrl_ = ''; | ||
|
||
|
||
/** | ||
* The URL to be called to fetch a list of prior notes. | ||
* @private | ||
* @type {string} | ||
*/ | ||
$.pkp.controllers.informationCenter.NotesHandler. | ||
prototype.fetchPastNotesUrl_ = ''; | ||
|
||
|
||
// | ||
// Public methods | ||
// | ||
/** | ||
* Handle the "note added" event triggered by the | ||
* note form whenever a new note is added. | ||
* | ||
* @param {$.pkp.controllers.form.AjaxFormHandler} callingForm The form | ||
* that triggered the event. | ||
* @param {Event} event The upload event. | ||
*/ | ||
$.pkp.controllers.informationCenter.NotesHandler. | ||
prototype.handleRefreshNoteList = function(callingForm, event) { | ||
$(callingForm).find('[id^="newNote"]').val(''); | ||
this.loadNoteList_(); | ||
}; | ||
|
||
|
||
// | ||
// Private methods | ||
// | ||
$.pkp.controllers.informationCenter.NotesHandler.prototype. | ||
loadNoteList_ = function() { | ||
|
||
$.get(this.fetchNotesUrl_, this.callbackWrapper(this.setNoteList_), 'json'); | ||
}; | ||
|
||
$.pkp.controllers.informationCenter.NotesHandler.prototype. | ||
setNoteList_ = function(formElement, jsonData) { | ||
|
||
var processedJsonData = this.handleJson(jsonData); | ||
|
||
$('#notesList').replaceWith(processedJsonData.content); | ||
this.getHtmlElement().find('.showMore, .showLess'). | ||
bind('click', this.switchViz); | ||
|
||
// Initialize an accordion for the "past notes" list, if it's | ||
// available (e.g. for a file information center). | ||
if (!$('#notesAccordion').hasClass('ui-accordion')) { | ||
$('#notesAccordion').accordion({ clearStyle: true }); | ||
} else { | ||
// this is a refresh. Since the accordion exists, we must destroy | ||
// and then recreate it or the content looks unstyled. | ||
$('#notesAccordion').accordion('destroy').accordion({ clearStyle: true }); | ||
} | ||
}; | ||
|
||
|
||
$.pkp.controllers.informationCenter.NotesHandler.prototype. | ||
loadPastNoteList_ = function() { | ||
|
||
// Only attempt to load the past note list if it's in the UI | ||
if ($('#pastNotesList').length) { | ||
$.get(this.fetchPastNotesUrl_, | ||
this.callbackWrapper(this.setPastNoteList_), 'json'); | ||
} | ||
}; | ||
|
||
|
||
$.pkp.controllers.informationCenter.NotesHandler.prototype. | ||
setPastNoteList_ = function(formElement, jsonData) { | ||
|
||
var processedJsonData = this.handleJson(jsonData); | ||
$('#pastNotesList').replaceWith(jsonData.content); | ||
}; | ||
|
||
|
||
/** @param {jQuery} $ jQuery closure. */ | ||
}(jQuery)); |
149 changes: 149 additions & 0 deletions
149
js/controllers/informationCenter/SignoffNotesHandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/** | ||
* @file js/controllers/informationCenter/SignoffNotesHandler.js | ||
* | ||
* Copyright (c) 2000-2013 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @class SignoffNotesHandler | ||
* @ingroup js_controllers_informationCenter | ||
* | ||
* @brief Signoff information center "notes" handler. | ||
*/ | ||
(function($) { | ||
|
||
|
||
/** | ||
* @constructor | ||
* | ||
* @extends $.pkp.classes.Handler | ||
* | ||
* @param {jQueryObject} $notesDiv A wrapped HTML element that | ||
* represents the "notes" interface element. | ||
* @param {Object} options Notes options. | ||
*/ | ||
$.pkp.controllers.informationCenter.SignoffNotesHandler = | ||
function($notesDiv, options) { | ||
this.parent($notesDiv, options); | ||
|
||
// Store the signoff notes form fetch URL. | ||
this.signoffNotesFormUrl_ = options.signoffNotesFormUrl; | ||
|
||
// Bind for select signoff event, triggered by the drop down | ||
// element inside this widget. | ||
this.bind('selectSignoff', this.handleRefreshNotesForm_); | ||
|
||
// Check if we can automatically load the notes form after | ||
// the dropdown finished loading its options. | ||
this.bind('dropDownOptionSet', this.handleDropDownOptionSet_); | ||
|
||
// Load the notes form. | ||
var signoffId = null; | ||
if (options.signoffId) { | ||
signoffId = options.signoffId; | ||
} | ||
this.loadNoteForm_(signoffId); | ||
|
||
}; | ||
$.pkp.classes.Helper.inherits( | ||
$.pkp.controllers.informationCenter.SignoffNotesHandler, | ||
$.pkp.classes.Handler | ||
); | ||
|
||
|
||
// | ||
// Private properties | ||
// | ||
/** | ||
* The URL to be called to fetch the signoff notes form. | ||
* @private | ||
* @type {string} | ||
*/ | ||
$.pkp.controllers.informationCenter.SignoffNotesHandler. | ||
prototype.signoffNotesFormUrl_ = ''; | ||
|
||
|
||
// | ||
// Private methods. | ||
// | ||
/** | ||
* Handle the "note added" event triggered by the | ||
* note form whenever a new note is added. | ||
* | ||
* @param {$.pkp.controllers.form.AjaxFormHandler} callingForm The widget | ||
* that triggered the event. | ||
* @param {Event} event The upload event. | ||
* @param {number} signoffId The signoff ID. | ||
* @private | ||
*/ | ||
$.pkp.controllers.informationCenter.SignoffNotesHandler. | ||
prototype.handleRefreshNotesForm_ = | ||
function(callingForm, event, signoffId) { | ||
if (signoffId !== 0) { | ||
// Fetch the form | ||
this.loadNoteForm_(signoffId); | ||
} else { | ||
// Else it was the placeholder; blank out the form | ||
var $notesFormContainer = $('#signoffNotesFormContainer'); | ||
$notesFormContainer.children().remove(); | ||
} | ||
}; | ||
|
||
|
||
/** | ||
* Automatically loads the note form if drop down have only | ||
* one signoff id as option. | ||
* @param {HTMLElement} dropdown The element that called the event. | ||
* @param {Event} event The upload event. | ||
* @private | ||
*/ | ||
$.pkp.controllers.informationCenter.SignoffNotesHandler. | ||
prototype.handleDropDownOptionSet_ = function(dropdown, event) { | ||
var $dropDown = $('#signoffSelect', this.getHtmlElement()), | ||
$options = $('option', $dropDown), | ||
signoffId; | ||
|
||
if ($options.length == 2) { | ||
signoffId = /** @type {string} */ $('option', $dropDown).next().val(); | ||
$dropDown.val(signoffId); | ||
|
||
this.loadNoteForm_(signoffId); | ||
} | ||
}; | ||
|
||
|
||
/** | ||
* Send a request to load the signoff notes form. | ||
* @param {number|string} signoffId The signoff id. | ||
* @private | ||
*/ | ||
$.pkp.controllers.informationCenter.SignoffNotesHandler.prototype. | ||
loadNoteForm_ = function(signoffId) { | ||
if (signoffId !== undefined && signoffId) { | ||
$.get(this.signoffNotesFormUrl_, { signoffId: signoffId }, | ||
this.callbackWrapper(this.showFetchedNoteForm_), 'json'); | ||
} | ||
}; | ||
|
||
|
||
/** | ||
* Show the fetched note form. | ||
* @param {Object} ajaxContext The AJAX request context. | ||
* @param {Object} jsonData A parsed JSON response object. | ||
* @private | ||
*/ | ||
$.pkp.controllers.informationCenter.SignoffNotesHandler.prototype. | ||
showFetchedNoteForm_ = function(ajaxContext, jsonData) { | ||
|
||
var processedJsonData = this.handleJson(jsonData), | ||
// Find the container and remove all children. | ||
$notesFormContainer = $('#signoffNotesFormContainer'); | ||
|
||
$notesFormContainer.children().remove(); | ||
|
||
// Replace it with the form content. | ||
$notesFormContainer.append(processedJsonData.content); | ||
}; | ||
|
||
|
||
/** @param {jQuery} $ jQuery closure. */ | ||
}(jQuery)); |
Oops, something went wrong.