All files / ima/window Window.js

100% Statements 2/2
0% Branches 0/2
16.67% Functions 4/24
100% Lines 2/2
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247    11x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     11x  
import ns from '../namespace';
 
ns.namespace('ima.window');
 
/**
 * The {@codelink Window} interface defines various utility API for easier
 * cross-environment usage of various low-level client-side JavaScript APIs
 * available through various global objects.
 *
 * @interface
 */
export default class Window {
  /**
	 * Returns {@code true} if invoked at the client side.
	 *
	 * @return {boolean} {@code true} if invoked at the client side.
	 */
  isClient() {}
 
  /**
	 * Returns {@code true} if the cookies are set and processed with every
	 * HTTP request and response automatically by the environment.
	 *
	 * @return {boolean} {@code true} if cookies are handled automatically by
	 *         the environment.
	 */
  isCookieEnabled() {}
 
  /**
	 * Returns {@code true} if the session storage is supported.
	 *
	 * @return {boolean} {@code true} if the session storage is supported.
	 */
  hasSessionStorage() {}
 
  /**
	 * Sets the new page title of the document.
	 *
	 * @param {string} title The new page title.
	 */
  setTitle(title) {}
 
  /**
	 * Returns the current {@code WebSocket} implementation to use.
	 *
	 * @deprecated All browsers currently supported by IMA.js support web
	 *             sockets, but when used at the server-side, this method
	 *             should fail unless web sockets are polyfilled by a 3rd party
	 *             library.
	 * @return {function(new: WebSocket)} The current {@code WebSocket}
	 *         implementation.
	 */
  getWebSocket() {}
 
  /**
	 * Returns the native {@code window} object representing the global context
	 * at the client-side. The method returns {@code undefined} if used at the
	 * server-side.
	 *
	 * @return {(undefined|Window)} The {@code window} object at the
	 *         client-side, or {@code undefined} at the server-side.
	 */
  getWindow() {}
 
  /**
	 * Returns the native {@code document} object representing any web page loaded
	 * in the browser and serves as an entry point into the web page's content
	 * which is the DOM tree at the client-side. The method returns {@code undefined}
	 * if used at the server-side.
	 *
	 * @return {(undefined|Document)} The {@code document} object at the
	 *         client-side, or {@code undefined} at the server-side.
	 */
  getDocument() {}
 
  /**
	 * Returns the number of pixels the viewport is scrolled horizontally.
	 *
	 * @return {number} The number of pixels the viewport is scrolled
	 *         horizontally.
	 */
  getScrollX() {}
 
  /**
	 * Returns the number of pixels the document is scrolled vertically.
	 *
	 * @return {number} The number of pixels the document is scrolled
	 *         vertically.
	 */
  getScrollY() {}
 
  /**
	 * Scrolls the viewport to the specified location (if possible).
	 *
	 * @param {number} x Horizontal scroll offset in pixels.
	 * @param {number} y Vertical scroll offset in pixels.
	 */
  scrollTo(x, y) {}
 
  /**
	 * Returns the domain of the current document's URL as
	 * {@code `${protocol}://${host}`}.
	 *
	 * @return {string} The current domain.
	 */
  getDomain() {}
 
  /**
	 * Returns the application's host.
	 *
	 * @return {string} The current host.
	 */
  getHost() {}
 
  /**
	 * Returns the path part of the current URL, including the query string.
	 *
	 * @return {string} The path and query string parts of the current URL.
	 */
  getPath() {}
 
  /**
	 * Returns the current document's URL.
	 *
	 * @return {string} The current document's URL.
	 */
  getUrl() {}
 
  /**
	 * Returns the document's body element. The method returns
	 * {@code undefined} if invoked at the server-side.
	 *
	 * @return {(undefined|HTMLBodyElement)} The document's body element, or
	 *         {@code undefined} if invoked at the server side.
	 */
  getBody() {}
 
  /**
	 * Returns the HTML element with the specified {@code id} attribute value.
	 *
	 * @param {string} id The value of the {@code id} attribute to look for.
	 * @return {?HTMLElement} The element with the specified id, or
	 *         {@code null} if no such element exists.
	 */
  getElementById(id) {}
 
  /**
	 * Returns the first element matching the specified CSS 3 selector.
	 *
	 * @param {string} selector The CSS selector.
	 * @return {?HTMLElement} The first element matching the CSS selector or
	 *         {@code null} if no such element exists.
	 */
  querySelector(selector) {}
 
  /**
	 * Returns a node list of all elements matching the specified CSS 3
	 * selector.
	 *
	 * @param {string} selector The CSS selector.
	 * @return {NodeList} A node list containing all elements matching the
	 *         specified CSS selector.
	 */
  querySelectorAll(selector) {}
 
  /**
	 * Performs a hard redirect (discarding the current JavaScript state) to
	 * the specified URL.
	 *
	 * @param {string} url The URL to which the browser will be redirected.
	 */
  redirect(url) {}
 
  /**
	 * Pushes a new state to the browser history. The method has no effect if
	 * the current browser does not support the history API (IE9).
	 *
	 * @param {Object<string, *>} state A state object associated with the
	 *        history item, preferably representing the page state.
	 * @param {string} title The page title related to the state. Note that
	 *        this parameter is ignored by some browsers.
	 * @param {string} url The new URL at which the state is available.
	 */
  pushState(state, title, url) {}
 
  /**
	 * Replaces the current history entry. The method has no effect if the
	 * current browser does not support the history API (IE9).
	 *
	 * @param {Object<string, *>} state A state object associated with the
	 *        history item, preferably representing the page state.
	 * @param {string} title The page title related to the state. Note that
	 *        this parameter is ignored by some browsers.
	 * @param {string} url The new URL at which the state is available.
	 */
  replaceState(state, title, url) {}
 
  /**
	 * Create new instance of CustomEvent of the specified name and using the
	 * provided options.
	 *
	 * @param {string} name Custom event's name (sometimes referred to as the
	 *        event's type).
	 * @param {Object<string, *>} options The custom event's options.
	 * @return {CustomEvent} The created custom event.
	 * @see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
	 */
  createCustomEvent(name, options) {}
 
  /**
	 * Registers the provided event listener to be executed when the specified
	 * event occurs on the specified event target.
	 *
	 * Registering the same event listener for the same event on the same event
	 * target with the same {@code useCapture} flag value repeatedly has no
	 * effect.
	 *
	 * @param {EventTarget} eventTarget The event target.
	 * @param {string} event The name of the event.
	 * @param {function(Event)} listener The event listener.
	 * @param {boolean=} [useCapture=false] If true, the method initiates event
	 *        capture. After initiating capture, all events of the specified
	 *        type will be dispatched to the registered listener before being
	 *        dispatched to any EventTarget beneath it in the DOM tree. Events
	 *        which are bubbling upward through the tree will not trigger a
	 *        listener designated to use capture.
	 */
  bindEventListener(eventTarget, event, listener, useCapture = false) {}
 
  /**
	 * Deregisters the provided event listener, so it will no longer we
	 * executed when the specified event occurs on the specified event target.
	 *
	 * The method has no effect if the provided event listener is not
	 * registered to be executed at the specified event.
	 *
	 * @param {EventTarget} eventTarget The event target.
	 * @param {string} event The name of the event.
	 * @param {function(Event)} listener The event listener.
	 * @param {boolean=} [useCapture=false] The {@code useCapture} flag value
	 *        that was used when the listener was registered.
	 */
  unbindEventListener(eventTarget, event, listener, useCapture = false) {}
}
 
ns.ima.window.Window = Window;