1/** 2 * @defgroup js_classes_linkAction 3 */ 4/** 5 * @file js/classes/linkAction/LinkActionRequest.js 6 * 7 * Copyright (c) 2013-2019 Simon Fraser University 8 * Copyright (c) 2000-2019 John Willinsky 9 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. 10 * 11 * @class LinkActionRequest 12 * @ingroup js_classes_linkAction 13 * 14 * @brief Base class for all link action requests. 15 */ 16(function($) { 17 18 /** @type {Object} */ 19 $.pkp.classes.linkAction = $.pkp.classes.linkAction || {}; 20 21 22 23 /** 24 * @constructor 25 * 26 * @extends $.pkp.classes.ObjectProxy 27 * 28 * @param {jQueryObject} $linkActionElement The element the link 29 * action was attached to. 30 * @param {Object} options Configuration of the link action 31 * request. 32 */ 33 $.pkp.classes.linkAction.LinkActionRequest = 34 function($linkActionElement, options) { 35 36 // Save the reference to the link action element. 37 this.$linkActionElement = $linkActionElement; 38 39 // Save the link action request options. 40 this.options = options; 41 42 // If the link action element is an actual link 43 // and we find a URL in the options then set the 44 // link of the link action for better documentation 45 // and easier debugging in the DOM and for other 46 // JS to easily access the target if required. 47 if ($linkActionElement.is('a') && options.url) { 48 $linkActionElement.attr('href', options.url); 49 } 50 }; 51 52 53 // 54 // Protected properties 55 // 56 /** 57 * The element the link action was attached to. 58 * @protected 59 * @type {Object} 60 */ 61 $.pkp.classes.linkAction.LinkActionRequest.prototype. 62 $linkActionElement = null; 63 64 65 /** 66 * The link action request options. 67 * @protected 68 * @type {Object} 69 */ 70 $.pkp.classes.linkAction.LinkActionRequest.prototype.options = null; 71 72 73 // 74 // Public methods 75 // 76 /** 77 * Callback that will be bound to the link action element. 78 * @param {HTMLElement} element The element that triggered the link 79 * action activation event. 80 * @param {Event} event The event that activated the link action. 81 * @return {boolean} Should return false to stop event propagation. 82 */ 83 /*jslint unparam: true*/ 84 $.pkp.classes.linkAction.LinkActionRequest.prototype.activate = 85 function(element, event) { 86 87 this.getLinkActionElement().trigger('actionStart'); 88 return false; 89 }; 90 /*jslint unparam: false*/ 91 92 93 /** 94 * Callback that will be bound to the 'action finished' event of the 95 * link action. 96 * 97 * @return {boolean} Should return false to stop event propagation. 98 */ 99 $.pkp.classes.linkAction.LinkActionRequest.prototype.finish = 100 function() { 101 102 // Execute the finish callback if there is one. 103 if (this.options.finishCallback) { 104 this.options.finishCallback(); 105 } 106 107 this.getLinkActionElement().trigger('actionStop'); 108 return false; 109 }; 110 111 112 /** 113 * Get the link action request url. 114 * @return {?string} The link action request url. 115 */ 116 $.pkp.classes.linkAction.LinkActionRequest.prototype.getUrl = 117 function() { 118 if (this.options.url) { 119 return this.options.url; 120 } 121 122 return null; 123 }; 124 125 126 // 127 // Protected methods 128 // 129 /** 130 * Retrieve the link action request options. 131 * @return {Object} The link action request options. 132 */ 133 $.pkp.classes.linkAction.LinkActionRequest.prototype.getOptions = function() { 134 return this.options; 135 }; 136 137 138 /** 139 * Retrieve the element the link action was attached to. 140 * @return {Object} The element the link action was attached to. 141 */ 142 $.pkp.classes.linkAction.LinkActionRequest.prototype. 143 getLinkActionElement = function() { 144 145 return this.$linkActionElement; 146 }; 147 148 149 /** @param {jQuery} $ jQuery closure. */ 150}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.