2Elm.Native.Window.make = function(elm) {
4 elm.Native = elm.Native || {};
5 if (elm.Native.Window) return elm.Native.Window;
7 var Signal = Elm.Signal.make(elm);
8 var Tuple2 = Elm.Native.Utils.make(elm).Tuple2;
10 function getWidth() { return elm.node.clientWidth; }
11 function getHeight() {
12 if (elm.display === ElmRuntime.Display.FULLSCREEN) {
13 return window.innerHeight;
15 return elm.node.clientHeight;
18 var dimensions = Signal.constant(Tuple2(getWidth(), getHeight()));
19 dimensions.defaultNumberOfKids = 2;
21 // Do not move width and height into Elm. By setting the default number of kids,
22 // the resize listener can be detached.
23 var width = A2(Signal.lift, function(p){return p._0;}, dimensions);
24 width.defaultNumberOfKids = 0;
26 var height = A2(Signal.lift, function(p){return p._1;}, dimensions);
27 height.defaultNumberOfKids = 0;
29 function resizeIfNeeded() {
32 if (dimensions.value._0 === w && dimensions.value._1 === h) return;
33 elm.notify(dimensions.id, Tuple2(w,h));
35 elm.addListener([dimensions.id], window, 'resize', resizeIfNeeded);
37 return elm.Native.Window = {
38 dimensions:dimensions,
41 resizeIfNeeded:resizeIfNeeded
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list