-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFramePanel.js
More file actions
90 lines (69 loc) · 4.13 KB
/
Copy pathFramePanel.js
File metadata and controls
90 lines (69 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// This file is part of DQX - (C) Copyright 2014, Paul Vauterin, Ben Jeffery, Alistair Miles <info@cggh.org>
// This program is free software licensed under the GNU Affero General Public License.
// You can find a copy of this license in LICENSE in the top directory of the source code or at <http://opensource.org/licenses/AGPL-3.0>
/************************************************************************************************************************************
*************************************************************************************************************************************
*************************************************************************************************************************************
*************************************************************************************************************************************/
define(["jquery", "DQX/DocEl", "DQX/Msg"],
function ($, DocEl, Msg) {
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Creates a FramePanel base class
// A frame panel is a GUI component that is placed as an endpoint in a frame (Framework.FrameFinal)
// Example GUI components that are derived from this:
// QueryTable.Panel, ChannelPlotter.Panel, GMaps.GMap, QueryBuilder.Panel, FrameList, FreameTree
//
// iParentRef can be a Framework.Frame object, or a string containing the id of the html div that will hold this panel
////////////////////////////////////////////////////////////////////////////////////////////////////////
return function (iParentRef) {
var that = {};
that.getID = function () { return this.myID; }
if (DQX.hasMember(iParentRef, 'getClientDivID')) {//assume that the parent reference is a Framework.Frame object
that.myParentFrame = iParentRef;
that.myDivID = iParentRef.getClientDivID();
iParentRef.setClientObject(that);
}
if (!that.myDivID)//assume that the parent reference is simply the ID of a div
that.myDivID = iParentRef;
if (that.myDivID.length == 0)
DQX.reportError("Invalid parent reference");
if ($('#' + that.myDivID).length == 0)
DQX.reportError("Invalid Gui component " + that.myDivID);
that.myID = that.myDivID;
that.setID = function (iid) {
this.myID = iid;
return this;
}
that.getDivID = function () { return this.myDivID; }
that.getSubId = function (ext) { return this.myDivID + ext; }
that.getRootElem = function () { return $('#' + that.myDivID); }
that.getScrollPosVert = function() {
return $('#'+that.myDivID).scrollTop();
}
that.setScrollPosVert = function(vl) {
return $('#'+that.myDivID).scrollTop(vl);
}
//Used internally by the framework
that.handleResize = function () {
if ('onResize' in that) {
if ((that.getRootElem().width() > 5) && (that.getRootElem().height() > 5)) {
if ((that._lastResizedSizeX != that.getRootElem().width()) || (that._lastResizedSizeY != that.getRootElem().height())) {
that.onResize();
that._lastResizedSizeX = that.getRootElem().width();
that._lastResizedSizeY = that.getRootElem().height();
}
}
}
}
//Used internally by the framework
that.execPostInitialise = function () {
if (this._onPostInitialise)
this._onPostInitialise();
}
//Call this function to provide a function that will be called the first time this panel appears, after the html has been created
that.setPostInitialiseHandler = function (handler) {
this._onPostInitialise = handler;
}
return that;
};
});