PageSourceSearch

https://clinpractice.ru/lib/pkp/js/classes/features/Feature.js

js clinpractice.ru collected 2026-10-02 17:42:49 UTC 4,833 bytes, 201 lines download raw bytes

1/**
2 * @defgroup js_classes_features
3 */
4/**
5 * @file js/classes/features/Feature.js
6 *
7 * Copyright (c) 2014-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	// Protected properties.
44	//
45	/**
46	 * The grid that this feature is attached to.
47	 * @protected
48	 * @type {$.pkp.controllers.grid.GridHandler}
49	 */
50	$.pkp.classes.features.Feature.prototype.gridHandler = null;
51
52
53	//
54	// Private properties.
55	//
56	/**
57	 * This feature configuration options.
58	 * @private
59	 * @type {Object}
60	 */
61	$.pkp.classes.features.Feature.prototype.options_ = null;
62
63
64	//
65	// Setters and getters.
66	//
67	/**
68	 * @param {Object} options The feature options.
69	 */
70	$.pkp.classes.features.Feature.prototype.setOptions =
71			function(options) {
72		this.options_ = options;
73	};
74
75
76	/**
77	 * @return {Object} The feature options.
78	 */
79	$.pkp.classes.features.Feature.prototype.getOptions =
80			function() {
81		return this.options_;
82	};
83
84
85	//
86	// Public template methods.
87	//
88	/**
89	 * Initialize this feature. Needs to be extended to implement
90	 * specific initialization. This method will always be called
91	 * by the components that this feature is attached to, in the
92	 * moment of the attachment.
93	 */
94	$.pkp.classes.features.Feature.prototype.init =
95			function() {
96		throw new Error('Abstract method!');
97	};
98
99
100	//
101	// Template methods (hooks into grid widgets).
102	//
103	/**
104	 * Hook into the add new element grid functionality.
105	 * @param {jQueryObject} $newElement The new element to be added.
106	 * @return {boolean} Always returns false.
107	 */
108	$.pkp.classes.features.Feature.prototype.addElement =
109			function($newElement) {
110		return false;
111	};
112
113
114	/**
115	 * Hook into the replace element content grid functionality.
116	 * @param {jQueryObject} $newContent The element new content to be shown.
117	 * @return {boolean} Always returns false.
118	 */
119	$.pkp.classes.features.Feature.prototype.replaceElement =
120			function($newContent) {
121		return false;
122	};
123
124
125	/**
126	 * Hook into the resequence rows grid functionality.
127	 * @param {Object} sequenceMap The grid rows sequence.
128	 * @return {boolean} Always returns false.
129	 */
130	$.pkp.classes.features.Feature.prototype.resequenceRows =
131			function(sequenceMap) {
132		return false;
133	};
134
135
136	/**
137	 * Hook into the refresh grid functionality. Called just before
138	 * the fetch (grid or row) call is done.
139	 * @param {number|Object=} opt_elementId
140	 * @return {boolean} Always returns false.
141	 */
142	$.pkp.classes.features.Feature.prototype.refreshGrid =
143			function(opt_elementId) {
144		return false;
145	};
146
147
148	/**
149	 * Hook into the replace element response handler. Called after the
150	 * response is handled.
151	 * @param {Object} handledJsonData Object with the response content handled
152	 * by the grid.
153	 * @return {boolean} Always returns false.
154	 */
155	$.pkp.classes.features.Feature.prototype.replaceElementResponseHandler =
156			function(handledJsonData) {
157		return false;
158	};
159
160
161	//
162	// Protected methods.
163	//
164	/**
165	 * Use the grid handler object and call the
166	 * callback wrapper method there.
167	 * @see $.pkp.classes.Handler.callbackWrapper()
168	 * @return {Function} Callback function.
169	 */
170	$.pkp.classes.features.Feature.prototype.callbackWrapper =
171			function(callback, opt_context) {
172		return this.gridHandler.callbackWrapper(callback, opt_context);
173	};
174
175
176	/**
177	 * Extend to add extra html elements in the component
178	 * that this feature is attached to.
179	 * @param {jQueryObject} $gridElement Grid element to add elements to.
180	 * @param {Object} options Feature options.
181	 */
182	$.pkp.classes.features.Feature.prototype.addFeatureHtml =
183			function($gridElement, options) {
184		// Default implementation does nothing.
185	};
186
187
188	/**
189	 * Get the html element of the grid that this feature
190	 * is attached to.
191	 *
192	 * @return {jQueryObject} Return the grid's HTML element.
193	 */
194	$.pkp.classes.features.Feature.prototype.getGridHtmlElement =
195			function() {
196		return this.gridHandler.getHtmlElement();
197	};
198
199
200/** @param {jQuery} $ jQuery closure. */
201}(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.