/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/yui/build/node/node-screen.js

  • Committer: Colin Watson
  • Date: 2020-06-08 09:55:03 UTC
  • mfrom: (498.2.2 jquery)
  • Revision ID: cjwatson@canonical.com-20200608095503-n387xggxud2khqsw
[r=cjwatson] Port loggerhead from YUI to jQuery.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
3
 
Code licensed under the BSD License:
4
 
http://developer.yahoo.net/yui/license.txt
5
 
version: 3.0.0pr2
6
 
*/
7
 
YUI.add('node-screen', function(Y) {
8
 
 
9
 
/**
10
 
 * Extended Node interface for managing regions and screen positioning.
11
 
 * Adds support for positioning elements and normalizes window size and scroll detection. 
12
 
 * @module node
13
 
 * @submodule node-screen
14
 
 * @for Node
15
 
 */
16
 
 
17
 
    Y.each([
18
 
        /**
19
 
         * Returns the inner width of the viewport (exludes scrollbar). 
20
 
         * @property winWidth
21
 
         * @type {Int}
22
 
         */
23
 
        'winWidth',
24
 
 
25
 
        /**
26
 
         * Returns the inner height of the viewport (exludes scrollbar). 
27
 
         * @property winHeight
28
 
         * @type {Int}
29
 
         */
30
 
        'winHeight',
31
 
 
32
 
        /**
33
 
         * Document width 
34
 
         * @property winHeight
35
 
         * @type {Int}
36
 
         */
37
 
        'docWidth',
38
 
 
39
 
        /**
40
 
         * Document height 
41
 
         * @property docHeight
42
 
         * @type {Int}
43
 
         */
44
 
        'docHeight',
45
 
 
46
 
        /**
47
 
         * Amount page has been scroll vertically 
48
 
         * @property docScrollX
49
 
         * @type {Int}
50
 
         */
51
 
        'docScrollX',
52
 
 
53
 
        /**
54
 
         * Amount page has been scroll horizontally 
55
 
         * @property docScrollY
56
 
         * @type {Int}
57
 
         */
58
 
        'docScrollY'
59
 
        ],
60
 
        function(v, n) {
61
 
            Y.Node.getters[v] = Y.Node.wrapDOMMethod(v);
62
 
        }
63
 
    );
64
 
 
65
 
    Y.Node.addDOMMethods([
66
 
    /**
67
 
     * Gets the current position of the node in page coordinates. 
68
 
     * Nodes must be part of the DOM tree to have page coordinates
69
 
     * (display:none or nodes not appended return false).
70
 
     * @method getXY
71
 
     * @return {Array} The XY position of the node
72
 
    */
73
 
        'getXY',
74
 
 
75
 
    /**
76
 
     * Set the position of the node in page coordinates, regardless of how the node is positioned.
77
 
     * The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
78
 
     * @method setXY
79
 
     * @param {Array} xy Contains X & Y values for new position (coordinates are page-based)
80
 
     * @chainable
81
 
     */
82
 
        'setXY',
83
 
 
84
 
    /**
85
 
     * Gets the current position of the node in page coordinates. 
86
 
     * Nodes must be part of the DOM tree to have page coordinates
87
 
     * (display:none or nodes not appended return false).
88
 
     * @method getX
89
 
     * @return {Int} The X position of the node
90
 
    */
91
 
        'getX',
92
 
 
93
 
    /**
94
 
     * Set the position of the node in page coordinates, regardless of how the node is positioned.
95
 
     * The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
96
 
     * @method setX
97
 
     * @param {Int} x X value for new position (coordinates are page-based)
98
 
     * @chainable
99
 
     */
100
 
        'setX',
101
 
 
102
 
    /**
103
 
     * Gets the current position of the node in page coordinates. 
104
 
     * Nodes must be part of the DOM tree to have page coordinates
105
 
     * (display:none or nodes not appended return false).
106
 
     * @method getY
107
 
     * @return {Int} The Y position of the node
108
 
    */
109
 
        'getY',
110
 
 
111
 
    /**
112
 
     * Set the position of the node in page coordinates, regardless of how the node is positioned.
113
 
     * The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
114
 
     * @method setY
115
 
     * @param {Int} y Y value for new position (coordinates are page-based)
116
 
     * @chainable
117
 
     */
118
 
        'setY'
119
 
    ]);
120
 
/**
121
 
 * Extended Node interface for managing regions and screen positioning.
122
 
 * Adds support for positioning elements and normalizes window size and scroll detection. 
123
 
 * @module node
124
 
 * @submodule node-screen
125
 
 * @for Node
126
 
 */
127
 
Y.each([
128
 
        /**
129
 
         * Returns a region object for the node 
130
 
         * @property region
131
 
         * @type Node
132
 
         */
133
 
        'region',
134
 
        /**
135
 
         * Returns a region object for the node's viewport 
136
 
         * @property viewportRegion
137
 
         * @type Node
138
 
         */
139
 
        'viewportRegion'
140
 
    ],
141
 
 
142
 
    function(v, n) {
143
 
        Y.Node.getters[v] = Y.Node.wrapDOMMethod(v);
144
 
    }
145
 
);
146
 
 
147
 
Y.Node.addDOMMethods([
148
 
    /**
149
 
     * Determines whether or not the node is currently visible in the viewport. 
150
 
     * @method inViewportRegion         
151
 
     * @return {Boolean} Whether or not the node is currently positioned
152
 
     * within the viewport's region
153
 
     */
154
 
    'inViewportRegion'
155
 
]);
156
 
 
157
 
// these need special treatment to extract 2nd node arg
158
 
Y.Node.methods({
159
 
    /**
160
 
     * Compares the intersection of the node with another node or region 
161
 
     * @method intersect         
162
 
     * @param {Node|Object} node2 The node or region to compare with.
163
 
     * @param {Object} altRegion An alternate region to use (rather than this node's). 
164
 
     * @return {Object} An object representing the intersection of the regions. 
165
 
     */
166
 
    intersect: function(node1, node2, altRegion) {
167
 
        if (node2 instanceof Y.Node) { // might be a region object
168
 
            node2 = Y.Node.getDOMNode(node2);
169
 
        }
170
 
        return Y.DOM.intersect(node1, node2, altRegion); 
171
 
    },
172
 
 
173
 
    /**
174
 
     * Determines whether or not the node is within the giving region.
175
 
     * @method inRegion         
176
 
     * @param {Node|Object} node2 The node or region to compare with.
177
 
     * @param {Boolean} all Whether or not all of the node must be in the region. 
178
 
     * @param {Object} altRegion An alternate region to use (rather than this node's). 
179
 
     * @return {Object} An object representing the intersection of the regions. 
180
 
     */
181
 
    inRegion: function(node1, node2, all, altRegion) {
182
 
        if (node2 instanceof Y.Node) { // might be a region object
183
 
            node2 = Y.Node.getDOMNode(node2);
184
 
        }
185
 
        return Y.DOM.inRegion(node1, node2, all, altRegion); 
186
 
    }
187
 
});
188
 
 
189
 
 
190
 
 
191
 
}, '3.0.0pr2' ,{requires:['dom-screen']});