first commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @defgroup js_pages_authorDashboard
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file js/pages/authorDashboard/SubmissionEmailHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class SubmissionEmailHandler
|
||||
* @ingroup js_pages_authorDashboard
|
||||
*
|
||||
* @brief Handler for reading monograph emails within the author dashboard.
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
/** @type {Object} */
|
||||
$.pkp.pages.authorDashboard = $.pkp.pages.authorDashboard || {};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.controllers.linkAction.LinkActionHandler
|
||||
*
|
||||
* @param {jQueryObject} $submissionEmailContainer The container for
|
||||
* the monograph email link.
|
||||
* @param {Object} options Handler options.
|
||||
*/
|
||||
$.pkp.pages.authorDashboard.SubmissionEmailHandler =
|
||||
function($submissionEmailContainer, options) {
|
||||
|
||||
this.parent($submissionEmailContainer, options);
|
||||
|
||||
$submissionEmailContainer.find('a[id^="submissionEmail"]').click(
|
||||
this.callbackWrapper(this.activateAction));
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.pages.authorDashboard.SubmissionEmailHandler,
|
||||
$.pkp.controllers.linkAction.LinkActionHandler);
|
||||
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @file js/pages/header/HeaderHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class HeaderHandler
|
||||
* @ingroup js_pages_index
|
||||
*
|
||||
* @brief Handler for the site header.
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
/** @type {Object} */
|
||||
$.pkp.pages = $.pkp.pages || { header: { } };
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.classes.Handler
|
||||
*
|
||||
* @param {jQueryObject} $headerElement The HTML element encapsulating
|
||||
* the header.
|
||||
* @param {{requestedPage: string,
|
||||
* fetchUnreadNotificationsCountUrl: string}} options Handler options.
|
||||
*/
|
||||
$.pkp.pages.header.HeaderHandler =
|
||||
function($headerElement, options) {
|
||||
|
||||
this.options_ = options;
|
||||
this.parent($headerElement, options);
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.pages.header.HeaderHandler,
|
||||
$.pkp.classes.Handler);
|
||||
|
||||
|
||||
/**
|
||||
* Site handler options.
|
||||
* @private
|
||||
* @type {{requestedPage: string}?}
|
||||
*/
|
||||
$.pkp.pages.header.HeaderHandler.prototype.options_ = null;
|
||||
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* @file js/pages/header/TasksHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class TasksHandler
|
||||
* @ingroup js_pages_index
|
||||
*
|
||||
* @brief Handler for the site header.
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.classes.Handler
|
||||
*
|
||||
* @param {jQueryObject} $tasksElement The HTML element encapsulating
|
||||
* the tasks.
|
||||
* @param {{requestedPage: string,
|
||||
* fetchUnreadNotificationsCountUrl: string}} options Handler options.
|
||||
*/
|
||||
$.pkp.pages.header.TasksHandler =
|
||||
function($tasksElement, options) {
|
||||
|
||||
this.options_ = options;
|
||||
this.parent($tasksElement, options);
|
||||
|
||||
$('#notificationsToggle').click(this.callbackWrapper(
|
||||
this.appendToggleIndicator_));
|
||||
|
||||
this.bind('updateUnreadNotificationsCount',
|
||||
this.fetchUnreadNotificationsCountHandler_);
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.pages.header.TasksHandler,
|
||||
$.pkp.classes.Handler);
|
||||
|
||||
|
||||
/**
|
||||
* Tasks handler options.
|
||||
* @private
|
||||
* @type {{requestedPage: string}?}
|
||||
*/
|
||||
$.pkp.pages.header.TasksHandler.prototype.options_ = null;
|
||||
|
||||
|
||||
//
|
||||
// Private helper methods
|
||||
//
|
||||
/**
|
||||
* Toggle the notifications grid visibility
|
||||
*
|
||||
* @param {jQueryObject} callingElement The calling element.
|
||||
* that triggered the event.
|
||||
* @param {Event} event The event.
|
||||
* @private
|
||||
*/
|
||||
$.pkp.pages.header.TasksHandler.prototype.appendToggleIndicator_ =
|
||||
function(callingElement, event) {
|
||||
|
||||
var $header = this.getHtmlElement(),
|
||||
$popover = $header.find('#notificationsPopover'),
|
||||
$toggle = $header.find('#notificationsToggle');
|
||||
|
||||
$popover.toggle();
|
||||
$toggle.toggleClass('expandedIndicator');
|
||||
|
||||
if ($toggle.hasClass('expandedIndicator')) {
|
||||
this.trigger('callWhenClickOutside', [{
|
||||
container: $header,
|
||||
callback: this.callbackWrapper(this.appendToggleIndicator_)
|
||||
}]);
|
||||
setTimeout(this.callbackWrapper(this.setPopoverSize_), 500);
|
||||
} else {
|
||||
$popover.css('height', '').css('overflow-y', '');
|
||||
if (event) {
|
||||
this.trigger('callWhenClickOutside', [{
|
||||
container: $header,
|
||||
clear: true
|
||||
}]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Resize the popover if it is too big for the screen when opened
|
||||
* @private
|
||||
*/
|
||||
$.pkp.pages.header.TasksHandler.prototype.setPopoverSize_ = function() {
|
||||
|
||||
var $popover = this.getHtmlElement().find('#notificationsPopover'),
|
||||
maxHeight = $(window).height() - 60;
|
||||
|
||||
if (maxHeight < $popover.height()) {
|
||||
$popover.height(maxHeight).css('overflow-y', 'scroll');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler to kick off a request to update the unread notifications
|
||||
* count.
|
||||
* @param {Object} ajaxContext The AJAX request context.
|
||||
* @param {Object} jsonData A parsed JSON response object.
|
||||
* @private
|
||||
*/
|
||||
$.pkp.pages.header.TasksHandler.prototype.
|
||||
fetchUnreadNotificationsCountHandler_ = function(ajaxContext, jsonData) {
|
||||
|
||||
$.get(this.options_.fetchUnreadNotificationsCountUrl,
|
||||
this.callbackWrapper(
|
||||
this.updateUnreadNotificationsCountHandler_), 'json');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler to update the unread notifications count upon receipt of
|
||||
* an updated number.
|
||||
* event.
|
||||
* @param {Object} ajaxContext The AJAX request context.
|
||||
* @param {Object} jsonData A parsed JSON response object.
|
||||
* @private
|
||||
*/
|
||||
$.pkp.pages.header.TasksHandler.prototype.
|
||||
updateUnreadNotificationsCountHandler_ = function(ajaxContext, jsonData) {
|
||||
|
||||
var el = this.getHtmlElement().find('#unreadNotificationCount');
|
||||
el.html(jsonData.content);
|
||||
|
||||
if (jsonData.content == '0') {
|
||||
el.removeClass('hasTasks');
|
||||
} else {
|
||||
el.addClass('hasTasks');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @defgroup js_controllers_tab_catalogEntry
|
||||
*/
|
||||
/**
|
||||
* @file js/pages/reviewer/ReviewerTabHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class ReviewerTabHandler
|
||||
* @ingroup js_pages_reviewer
|
||||
*
|
||||
* @brief A subclass of TabHandler for handling the reviewer tabs.
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
/** @type {Object} */
|
||||
$.pkp.pages.reviewer =
|
||||
$.pkp.pages.reviewer || {};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.controllers.TabHandler
|
||||
*
|
||||
* @param {jQueryObject} $tabs A wrapped HTML element that
|
||||
* represents the tabbed interface.
|
||||
* @param {Object} options Handler options.
|
||||
*/
|
||||
$.pkp.pages.reviewer.ReviewerTabHandler =
|
||||
function($tabs, options) {
|
||||
|
||||
this.parent($tabs, options);
|
||||
|
||||
this.reviewStep_ = options.reviewStep;
|
||||
|
||||
// Attach the tabs grid refresh handler.
|
||||
this.bind('setStep', this.setStepHandler);
|
||||
|
||||
this.getHtmlElement().tabs('option', 'disabled',
|
||||
this.getDisabledSteps(this.reviewStep_));
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.pages.reviewer.ReviewerTabHandler,
|
||||
$.pkp.controllers.TabHandler);
|
||||
|
||||
|
||||
//
|
||||
// Private Properties
|
||||
//
|
||||
/**
|
||||
* Review steps completed so far (read-only).
|
||||
* @private
|
||||
* @type {number?}
|
||||
*/
|
||||
$.pkp.pages.reviewer.ReviewerTabHandler.
|
||||
prototype.reviewStep_ = null;
|
||||
|
||||
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
/**
|
||||
* This listens for events from the contained form. It moves to the
|
||||
* next tab.
|
||||
*
|
||||
* @param {HTMLElement} sourceElement The parent DIV element
|
||||
* which contains the tabs.
|
||||
* @param {Event} event The triggered event (gridRefreshRequested).
|
||||
* @param {number} stepNumber The new step number to view.
|
||||
*/
|
||||
$.pkp.pages.reviewer.ReviewerTabHandler.prototype.
|
||||
setStepHandler = function(sourceElement, event, stepNumber) {
|
||||
|
||||
this.getHtmlElement().tabs('option', 'disabled',
|
||||
this.getDisabledSteps(stepNumber));
|
||||
this.getHtmlElement().tabs('option', 'active', stepNumber - 1);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of permitted tab indexes for the given review step
|
||||
* number.
|
||||
* @param {number} stepNumber The review step number (1-based).
|
||||
* @return {Object} An array of permissible tab indexes (0-based).
|
||||
*/
|
||||
$.pkp.pages.reviewer.ReviewerTabHandler.prototype.
|
||||
getDisabledSteps = function(stepNumber) {
|
||||
|
||||
switch (stepNumber) {
|
||||
case 1: return [1, 2, 3];
|
||||
case 2: return [2, 3];
|
||||
case 3: return [3];
|
||||
case 4: return [];
|
||||
}
|
||||
throw new Error('Illegal review step number.');
|
||||
};
|
||||
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* @defgroup js_pages_workflow
|
||||
*/
|
||||
/**
|
||||
* @file js/pages/workflow/WorkflowHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class WorkflowHandler
|
||||
* @ingroup js_pages_workflow
|
||||
*
|
||||
* @brief Base handler for the workflow pages.
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
/** @type {Object} */
|
||||
$.pkp.pages.workflow = $.pkp.pages.workflow || {};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.classes.Handler
|
||||
*
|
||||
* @param {jQueryObject} $workflowElement The HTML element encapsulating
|
||||
* the production page.
|
||||
* @param {Object} options Handler options.
|
||||
*/
|
||||
$.pkp.pages.workflow.WorkflowHandler =
|
||||
function($workflowElement, options) {
|
||||
|
||||
this.parent($workflowElement, options);
|
||||
|
||||
this.bind('stageParticipantsChanged', this.handleStageParticipantsChanged_);
|
||||
this.bind('dataChanged', this.dataChangedHandler_);
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.pages.workflow.WorkflowHandler,
|
||||
$.pkp.classes.Handler);
|
||||
|
||||
|
||||
//
|
||||
// Private functions
|
||||
//
|
||||
/**
|
||||
* Potentially refresh workflow content on participant change.
|
||||
*
|
||||
* @param {jQueryObject} callingElement The calling element.
|
||||
* that triggered the event.
|
||||
* @param {Event} event The event.
|
||||
* @private
|
||||
*/
|
||||
$.pkp.pages.workflow.WorkflowHandler.prototype.handleStageParticipantsChanged_ =
|
||||
function(callingElement, event) {
|
||||
// Find and reload editor decision action and progress bar.
|
||||
var $elements, $stageTabs, matches, cssClass, stageId, sourceUrl,
|
||||
$editorDecisionActions = this.getHtmlElement()
|
||||
.find('.editorDecisionActions'),
|
||||
$progressBar = this.getHtmlElement().find('#submissionProgressBarDiv'),
|
||||
$stageTabContainer = this.getHtmlElement().find('#stageTabs');
|
||||
|
||||
$stageTabs = $stageTabContainer.find('li');
|
||||
$stageTabs.each(function(index) {
|
||||
if ($(this).hasClass('ui-state-active')) {
|
||||
cssClass = $(this).find('a').attr('class');
|
||||
matches = cssClass.match(/stageId(\d)/);
|
||||
if (matches) {
|
||||
stageId = matches[1];
|
||||
var handler = $.pkp.classes.Handler.getHandler($progressBar);
|
||||
sourceUrl = handler.getSourceUrl();
|
||||
handler.setSourceUrl(sourceUrl.replace(/stageId=\d/, 'stageId=' +
|
||||
stageId));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$elements = $editorDecisionActions.add($progressBar);
|
||||
|
||||
$elements.each(function() {
|
||||
var handler = $.pkp.classes.Handler.getHandler($(this));
|
||||
handler.reload();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Potentially refresh contained grid.
|
||||
*
|
||||
* @param {jQueryObject} callingElement The calling element.
|
||||
* that triggered the event.
|
||||
* @param {Event} event The event.
|
||||
* @param {Object} eventData Event data.
|
||||
* @private
|
||||
*/
|
||||
$.pkp.pages.workflow.WorkflowHandler.prototype.dataChangedHandler_ =
|
||||
function(callingElement, event, eventData) {
|
||||
|
||||
var $childAnchors = $(event.target, this.getHtmlElement()).children('a'),
|
||||
$formatsGrid;
|
||||
|
||||
if ($childAnchors.length &&
|
||||
$childAnchors.attr('id').match(/submissionEntry/)) {
|
||||
// Refresh the format grid on this page, if any.
|
||||
$formatsGrid = $('[id^="formatsGridContainer"]',
|
||||
this.getHtmlElement()).children('div');
|
||||
$formatsGrid.trigger('dataChanged', [eventData]);
|
||||
$formatsGrid.trigger('notifyUser', [$formatsGrid]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}(jQuery));
|
||||
Reference in New Issue
Block a user