2Elm.Native.Window.make = function(elm) {
4 elm.Native = elm.Native || {};
5 elm.Native.Window = elm.Native.Window || {};
6 if (elm.Native.Window.values) return elm.Native.Window.values;
8 var Signal = Elm.Signal.make(elm);
9 var NS = Elm.Native.Signal.make(elm);
10 var Tuple2 = Elm.Native.Utils.make(elm).Tuple2;
12 function getWidth() { return elm.node.clientWidth; }
13 function getHeight() {
14 if (elm.display === ElmRuntime.Display.FULLSCREEN) {
15 return window.innerHeight;
17 return elm.node.clientHeight;
20 var dimensions = NS.input(Tuple2(getWidth(), getHeight()));
21 dimensions.defaultNumberOfKids = 2;
23 // Do not move width and height into Elm. By setting the default number of kids,
24 // the resize listener can be detached.
25 var width = A2(Signal.lift, function(p){return p._0;}, dimensions);
26 width.defaultNumberOfKids = 0;
28 var height = A2(Signal.lift, function(p){return p._1;}, dimensions);
29 height.defaultNumberOfKids = 0;
31 function resizeIfNeeded() {
34 if (dimensions.value._0 === w && dimensions.value._1 === h) return;
35 elm.notify(dimensions.id, Tuple2(w,h));
37 elm.addListener([dimensions.id], window, 'resize', resizeIfNeeded);
39 return elm.Native.Window.values = {
40 dimensions:dimensions,
43 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