PageSourceSearch

https://jomped.org/lib/pkp/js/classes/features/Feature.js

js jomped.org collected 2026-10-08 10:55:37 UTC 3,672 bytes, 148 lines download raw bytes

1/**
2 * @defgroup js_classes_features
3 */
4/**
5 * @file js/classes/features/Feature.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 Feature
12 * @ingroup js_classes_features
13 *
14 * @brief Base grid feature class.
15 * @see lib/pkp/classes/controllers/grid/feature/GridFeature.inc.php
16 *
17 * We use the features concept of the ext js framework:
18 * http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.feature.Feature
19 */
20(function($) {
21
22	/** @type {Object} */
23	$.pkp.classes.features = $.pkp.classes.features || {};
24
25
26
27	/**
28	 * @constructor
29	 * @extends $.pkp.classes.ObjectProxy
30	 * @param {$.pkp.controllers.grid.GridHandler} gridHandler The grid
31	 *  handler object.
32	 * @param {Array} options Associated options.
33	 */
34	$.pkp.classes.features.Feature =
35			function(gridHandler, options) {
36		this.gridHandler_ = gridHandler;
37		this.options_ = options;
38		this.addFeatureHtml(this.getGridHtmlElement(), options);
39	};
40
41
42	//
43	// Private properties.
44	//
45	/**
46	 * The grid that this feature is attached to.
47	 * @private
48	 * @type {$.pkp.controllers.grid.GridHandler}
49	 */
50	$.pkp.classes.features.Feature.prototype.gridHandler_ = null;
51
52
53	/**
54	 * This feature configuration options.
55	 * @private
56	 * @type {Object}
57	 */
58	$.pkp.classes.features.Feature.prototype.options_ = null;
59
60
61	//
62	// Public template methods.
63	//
64	/**
65	 * Initialize this feature. Needs to be extended to implement
66	 * specific initialization. This method will always be called
67	 * by the components that this feature is attached to, in the
68	 * moment of the attachment.
69	 */
70	$.pkp.classes.features.Feature.prototype.init =
71			function() {
72		throw new Error('Abstract method!');
73	};
74
75
76	//
77	// Template methods (hooks into grid widgets).
78	//
79	/**
80	 * Hook into the append new element grid functionality.
81	 * @param {jQueryObject} $newElement The new element to be appended.
82	 * @return {boolean} Always returns false.
83	 */
84	/*jslint unparam: true*/
85	$.pkp.classes.features.Feature.prototype.appendElement =
86			function($newElement) {
87		return false;
88	};
89	/*jslint unparam: false*/
90
91
92	/**
93	 * Hook into the replace element content grid functionality.
94	 * @param {jQueryObject} $newContent The element new content to be shown.
95	 * @return {boolean} Always returns false.
96	 */
97	/*jslint unparam: true*/
98	$.pkp.classes.features.Feature.prototype.replaceElement =
99			function($newContent) {
100		return false;
101	};
102	/*jslint unparam: false*/
103
104
105	//
106	// Protected methods.
107	//
108	/**
109	 * Use the grid handler object and call the
110	 * callback wrapper method there.
111	 * @see $.pkp.classes.Handler.callbackWrapper()
112	 * @return {Function} Callback function.
113	 */
114	$.pkp.classes.features.Feature.prototype.callbackWrapper =
115			function(callback, opt_context) {
116		return this.gridHandler_.callbackWrapper(callback, opt_context);
117	};
118
119
120	/**
121	 * Extend to add extra html elements in the component
122	 * that this feature is attached to.
123	 * @param {jQueryObject} $gridElement Grid element to add elements to.
124	 * @param {Object} options Feature options.
125	 */
126	/*jslint unparam: true*/
127	$.pkp.classes.features.Feature.prototype.addFeatureHtml =
128			function($gridElement, options) {
129		// Default implementation does nothing.
130		return;
131	};
132	/*jslint unparam: false*/
133
134
135	/**
136	 * Get the html element of the grid that this feature
137	 * is attached to.
138	 *
139	 * @return {jQueryObject} Return the grid's HTML element.
140	 */
141	$.pkp.classes.features.Feature.prototype.getGridHtmlElement =
142			function() {
143		return this.gridHandler_.getHtmlElement();
144	};
145
146
147/** @param {jQuery} $ jQuery closure. */
148}(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.