@litejs/ui 26.3.0 → 26.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,7 +16,8 @@ used on heavy-traffic websites since 2006.
16
16
  Works seamlessly in ESM projects too.
17
17
  - No transpiling/compiling/bundling headache, just write working code.
18
18
 
19
- Includes templates, view routing, data binding, i18n, keyboard shortcuts, and touch gestures.
19
+ Includes templates, view routing, data binding, i18n, keyboard shortcuts,
20
+ touch gestures, FLIP animations.
20
21
 
21
22
  For usage instructions, see [Quick-Start](https://github.com/litejs/litejs/wiki/Quick-Start) guide
22
23
  and [wiki](https://github.com/litejs/ui/wiki).
package/css/anim.css CHANGED
@@ -3,11 +3,23 @@
3
3
  .anim,
4
4
  .anim:after,
5
5
  .anim:before {
6
- transition: all .2s;
6
+ transition: all .35s;
7
7
 
8
8
  /* Trigger GPU acceleration. Remove first flicker on iphone. */
9
9
  transform: translate3d(0, 0, 0);
10
10
 
11
- perspective: 1000;
11
+ perspective: 1000px;
12
+ }
13
+
14
+ .flip {
15
+ transform-origin: 0 0;
16
+ transition: transform .4s, width .4s, height .4s, opacity .4s;
17
+ }
18
+ .is-lifted {
19
+ animation: .4s lift;
20
+ z-index: 3;
21
+ }
22
+ @keyframes lift {
23
+ 70% { scale: 1.06; box-shadow: 0 5px 20px rgba(0, 0, 0, .8); }
12
24
  }
13
25
 
package/css/global.css CHANGED
@@ -11,6 +11,11 @@
11
11
  min-height: 100%;
12
12
  }
13
13
 
14
+ .no,
15
+ .no-empty:empty,
16
+ .sm .no-sm,
17
+ .md .no-md,
18
+ .lg .no-lg,
14
19
  .sm .sm-hide,
15
20
  .md .md-hide,
16
21
  .lg .lg-hide,
@@ -19,6 +24,7 @@
19
24
  display: none !important;
20
25
  visibility: hidden;
21
26
  }
27
+ .op0,
22
28
  .transparent {
23
29
  opacity: 0 !important;
24
30
  filter: alpha(opacity=0) !important;
package/el/dialog.ui CHANGED
@@ -3,11 +3,10 @@
3
3
  .Modal {
4
4
  overflow: auto;
5
5
  overscroll-behavior: contain;
6
- z-index: 9;
6
+ z-index: 8;
7
7
  }
8
8
  .Modal-bg {
9
- background-color: rgba(0, 0, 0, .6);
10
- pointer-events: none;
9
+ background-color: rgba(0, 0, 0, .8);
11
10
  }
12
11
  .Modal-content {
13
12
  left: 0;
@@ -60,30 +59,26 @@
60
59
  // ]
61
60
  %js
62
61
  $ui.on("modal", function(title, opts) {
63
- var oldFocus = document.activeElement
62
+ var a
63
+ , i = 0
64
+ , doc = document
65
+ , oldFocus = doc.activeElement
64
66
  , modal = El("Modal")
65
- , el = El("Dialog.Modal-content.Modal--blur.abs")
66
- , scope = El.scope(el, el, typeof opts === "string" ? { body: opts } : opts)
67
+ , scope = El.scope(modal, opts && opts.modalContent || modal, typeof opts === "string" ? { body: opts } : opts)
68
+ , el = scope.modalContent || El("Dialog.Modal-content.Modal--blur.abs")
67
69
  , kbMap = {
68
70
  bubble: 1, input: 1,
69
- tab: function(e) {
70
- var items = $$("a[href],:is(button,input,select,textarea):not(:disabled),[tabindex]:not([tabindex='-1'])", modal)
71
- , last = items.length - 1
72
- if (document.activeElement === items[e.shiftKey ? 0 : last]) {
73
- items[e.shiftKey ? last : 0].focus()
74
- El.stop(e)
75
- }
76
- }
71
+ tab: setFocus,
77
72
  }
78
- , body = document.body
79
- , scrollEl = document.scrollingElement || document.documentElement
73
+ , body = doc.body
74
+ , scrollEl = doc.scrollingElement
80
75
  , vibrate = scope.vibrate && navigator.vibrate
81
76
  , sound = scope.sound && window.Audio && new Audio(scope.sound)
82
77
  scope.title = title
83
78
  if (!scope.actions) scope.actions = [
84
79
  { title: "Close", key: "esc" }
85
80
  ]
86
- for (var a, i = 0; (a = scope.actions[i++]); ) {
81
+ for (; (a = scope.actions[i++]); ) {
87
82
  if (typeof a === "string") a = scope.actions[i - 1] = { title: a, action: a }
88
83
  if (a.key) kbMap[a.key] = resolve.bind(el, a.action)
89
84
  }
@@ -92,28 +87,25 @@
92
87
  El.append(body, modal)
93
88
  El.render(modal)
94
89
  El.addKb(kbMap, modal)
95
- if (El.closest(document.activeElement, 'form') !== el) {
96
- el.focus()
90
+ if (El.closest(doc.activeElement, 'form') !== el) {
91
+ setFocus()
97
92
  }
98
- El.on(el, "click", function(e) {
99
- console.log("click1 resolve")
100
- resolve(El.get(e.target, "data-action"), e)
93
+ El.on(el, "click", function(e, btn) {
94
+ resolve(El.get(btn, "data-action"), e)
101
95
  }, "[data-action]")
102
96
  El.cls(el, "Modal--blur",!1,1)
103
97
  $ui.emit("modalOpen", scope)
104
98
  $ui.one("show", function() { resolve() })
105
- El.on(modal.firstChild, "click", function() {
106
- console.log("click resolve")
107
- resolve()
108
- })
99
+ El.on(modal.firstChild, "click", resolve)
109
100
  if (vibrate) vibrate(scope.vibrate)
110
101
  if (sound) sound.play()
111
102
  El.cls(scrollEl, "no-scroll")
112
103
  function resolve(action, e) {
113
104
  if (modal) {
114
105
  El.stop(e)
115
- El.cls(scrollEl, "no-scroll", 0)
106
+ if (scope.beforeKill) scope.beforeKill(modal)
116
107
  El.kill(modal, "transparent", 1)
108
+ El.cls(scrollEl, "no-scroll", 0)
117
109
  if (vibrate) vibrate(0)
118
110
  if (sound) sound.pause()
119
111
  modal = null
@@ -124,13 +116,27 @@
124
116
  if (oldFocus) oldFocus.focus()
125
117
  }
126
118
  }
119
+ function setFocus(e) {
120
+ El.stop(e)
121
+ var items = $$("a[href],button,input,select,textarea,[tabindex]", modal)
122
+ , len = items.length
123
+ , tries = len
124
+ , pos = items.indexOf(doc.activeElement)
125
+ for (; tries--; ) {
126
+ pos += e && e.shiftKey ? -1 : 1
127
+ if (pos < 0) pos = len - 1
128
+ else if (pos >= len) pos = 0
129
+ items[pos].focus()
130
+ if (doc.activeElement === items[pos]) return
131
+ }
132
+ }
127
133
  })
128
134
 
129
135
  %el Modal
130
- .Modal.fix.max.anim>.Modal-bg.abs.max
136
+ .Modal.fix.max.anim>.Modal-bg.abs.max.anim.op0;cls!'op0',0,1
131
137
 
132
138
  %el Dialog
133
- form.Dialog.grid.p2.anim[action="javascript:"][method=POST][tabindex='-1']
139
+ form.Dialog.grid.p2.anim[action="javascript:"][method=POST][role=dialog]
134
140
  .col>h1 ;txt title
135
141
  .col ;if body; d body
136
142
  %slot
@@ -144,13 +150,16 @@ form.Dialog.grid.p2.anim[action="javascript:"][method=POST][tabindex='-1']
144
150
 
145
151
  %el Dialog-input
146
152
  .col
147
- input.field[name=value][type=text][placeholder="Enter value"] ;focus
153
+ input[type=hidden][name=hi]
154
+ input.field[name=value][type=text][placeholder="Enter value"]
148
155
 
149
156
  %el Dialog-numpad
150
157
  .grid.p1.js-numpad
151
158
  @click function(e,b,n,v){$s.in.value=(v=$s.in.value,n=b[El.T])>-1?v+n:n=='DEL'?v.slice(0,-1):'',$s.in.focus()},'.btn'
152
- ;kb!{num:function(e,b,n){$s.in.value=(n)>-1?$s.in.value+n:''},del:function(e,b,n){$s.in.value=$s.in.value.slice(-1)}}
153
- .col>input[name=code] ;ref!'in';focus
159
+ ;kb!{num:function(e,b,n){$s.in.value=(n)>-1?$s.in.value+n:''},del:function(e,b,n){$s.in.value=$s.in.value.slice(0,-1)}}
160
+ .col
161
+ input[type=hidden][name=hi]
162
+ input[name=code] ;ref!'in';focus
154
163
  .col.w4
155
164
  ;each! "num",[1,2,3,4,5,6,7,8,9,"CLEAR",0,"DEL"]
156
165
  button.btn.w12[type=button]
package/el/gallery.ui ADDED
@@ -0,0 +1,187 @@
1
+
2
+ %css
3
+ .Gallery {
4
+ display: grid;
5
+ place-items: center;
6
+ }
7
+ .Gallery-img {
8
+ grid-area: 1 / 1;
9
+ max-width: 90%;
10
+ max-height: 90%;
11
+ object-fit: contain;
12
+ opacity: 0;
13
+ transition: opacity .3s;
14
+ }
15
+ .Gallery-img.is-active {
16
+ opacity: 1;
17
+ }
18
+ .Gallery-nav {
19
+ grid-area: 1 / 1;
20
+ position: relative;
21
+ width: 100%;
22
+ height: 100%;
23
+ z-index: 1;
24
+ }
25
+ .Gallery-nav > button {
26
+ position: absolute;
27
+ top: 50%;
28
+ transform: translateY(-50%);
29
+ background: none;
30
+ border: none;
31
+ color: #fff;
32
+ font-size: 2em;
33
+ cursor: pointer;
34
+ opacity: .5;
35
+ padding: .5em;
36
+ }
37
+ .Gallery-nav > button:hover {
38
+ opacity: 1;
39
+ }
40
+ .Gallery-nav--prev {
41
+ left: 0;
42
+ }
43
+ .Gallery-nav--next {
44
+ right: 0;
45
+ }
46
+ .Gallery-counter {
47
+ position: absolute;
48
+ bottom: 1em;
49
+ left: 50%;
50
+ transform: translateX(-50%);
51
+ color: #fff;
52
+ opacity: .7;
53
+ z-index: 2;
54
+ }
55
+ .Gallery-anim {
56
+ transition: transform .3s ease;
57
+ transform-origin: 0 0;
58
+ }
59
+ .ImageGrid {
60
+ display: grid;
61
+ grid-template-columns: 2fr 1fr;
62
+ grid-template-rows: repeat(3, 1fr);
63
+ gap: 2px;
64
+ cursor: pointer;
65
+ max-width: 600px;
66
+ }
67
+ .ImageGrid-frame {
68
+ overflow: hidden;
69
+ position: relative;
70
+ transform-origin: 0 0;
71
+ }
72
+ .ImageGrid-anim {
73
+ transform-origin: 0 0;
74
+ }
75
+ .ImageGrid-frame:first-child {
76
+ grid-row: 1 / -1;
77
+ }
78
+ .ImageGrid-frame>img {
79
+ width: 100%;
80
+ height: 100%;
81
+ object-fit: cover;
82
+ display: block;
83
+ }
84
+ .ImageGrid-count {
85
+ position: absolute;
86
+ bottom: 2px;
87
+ right: 2px;
88
+ background: rgba(0, 0, 0, .6);
89
+ color: #fff;
90
+ font-size: 1.5em;
91
+ font-weight: 700;
92
+ border-radius: 20px;
93
+ border: 1px solid #999;
94
+ z-index: 2;
95
+ }
96
+
97
+ %js
98
+ $d.initGalleryImages = function(el) {
99
+ for (var images = $$("img[src]", el), i = images.length, arr = []; i--; ) arr[i] = images[i].src
100
+ images.kill()
101
+ return arr
102
+ }
103
+ $ui.on("flipToFirst", function toFirst(ev, el) {
104
+ var parent = el.parentNode
105
+ , first = parent.firstChild
106
+ if (el !== first) {
107
+ El.stop(ev)
108
+ El.flip(parent, 0, function() {
109
+ El.append(parent, el, first)
110
+ }, {scale:1})
111
+ El.cls(el, "is-lifted", toFirst._prev, 1, -1)
112
+ toFirst._prev = el
113
+ }
114
+ })
115
+ $ui.on("gallery", function(ev, thumb) {
116
+ var preview = El.closest(thumb, ".ImageGrid")
117
+ if (!preview) return
118
+ var images = El.scope(preview).images
119
+ , current = +El.get(thumb, "data-index") || 0
120
+ , el = El("Gallery")
121
+ , img1 = el.querySelector(".Gallery-img")
122
+ , img2 = img1.nextSibling
123
+ , counter = el.querySelector(".Gallery-counter")
124
+ , activeImg = img1
125
+ , thumbImg = thumb.querySelector("img") || thumb
126
+ , scope = El.scope(el, el, {
127
+ images: images,
128
+ nav: function(e, btn) {
129
+ El.stop(e)
130
+ show(current + (El.matches(btn, ".Gallery-nav--prev") ? -1 : 1))
131
+ },
132
+ flipIn: function() {
133
+ El.morph(thumbImg, activeImg, { anim: "Gallery-anim", scale:1 })
134
+ },
135
+ beforeKill: function() {
136
+ var thumbs = $$("[data-index]", preview)
137
+ , target = thumbs[current] || thumbs.pop()
138
+ if (target) {
139
+ El.morph(activeImg, target, { scale:1 })
140
+ El.css(target, "z-index", 10, 0, -2)
141
+ El.kill(activeImg)
142
+ }
143
+ }
144
+ })
145
+ show(current, 1)
146
+ $ui.emit("modal", "", {
147
+ modalContent: el,
148
+ actions: [{ title: "Close", key: "esc" }]
149
+ })
150
+ activeImg.src = thumbImg.src
151
+ function show(idx, initial) {
152
+ current = scope.current = ((idx % images.length) + images.length) % images.length
153
+ var nextImg = activeImg === img1 ? img2 : img1
154
+ if (initial && activeImg.src === images[current]) return
155
+ nextImg.src = images[current]
156
+ nextImg.onload = function() {
157
+ El.cls(nextImg, "is-active", activeImg)
158
+ activeImg = nextImg
159
+ }
160
+ El.render(el)
161
+ }
162
+ })
163
+
164
+ %el Gallery
165
+ .Gallery.abs.max
166
+ img.Gallery-img
167
+ @load!flipIn
168
+ img.Gallery-img
169
+ .Gallery-nav
170
+ ;if images.length > 1
171
+ @tap nav,"button"
172
+ button.Gallery-nav--prev[aria-label=Previous] ;txt! "\u276E"
173
+ button.Gallery-nav--next[aria-label=Next] ;txt! "\u276F"
174
+ .Gallery-counter
175
+ ;txt (current+1)+" / "+images.length
176
+
177
+ %el ImageGrid
178
+ .ImageGrid.rel
179
+ ;$s!{images:initGalleryImages($el)}
180
+ .ImageGrid-frame[data-index=0]
181
+ img ;src!images[0]
182
+ .ImageGrid-frame
183
+ ;each! "src", images.slice(1, 4)
184
+ ;data-index!$i+1
185
+ img ;src!src
186
+ .ImageGrid-count.p02 ;if images.length > 4
187
+ ;txt '+' + (images.length - 4)
package/el/menu.ui CHANGED
@@ -93,9 +93,10 @@
93
93
  , html = document.documentElement
94
94
  El.near = near
95
95
  function near(source, target, x, y, margin) {
96
- var rect = target.getBoundingClientRect()
97
- , top = rect.top + El.scrollTop()
98
- , left = rect.left + El.scrollLeft()
96
+ var rect = El.rect(target)
97
+ , scroll = El.scroll()
98
+ , top = rect.top + scroll.y
99
+ , left = rect.left + scroll.x
99
100
  // svg elements dont have offsetWidth, IE8 does not have rect.width
100
101
  , width = rect.width || target.offsetWidth || 0
101
102
  , height = rect.height || target.offsetHeight || 0
@@ -122,7 +123,7 @@
122
123
  top += height + margin
123
124
  y = " -50%"
124
125
  setTimeout(function() {
125
- var overflow = top + source.offsetHeight - El.scrollTop() - html.offsetHeight
126
+ var overflow = top + source.offsetHeight - scroll.y - html.offsetHeight
126
127
  if (overflow > 0) scrollBy({ top: overflow, left: 0, behavior: "smooth" })
127
128
  }, 400)
128
129
  } else {
package/el/slider.ui CHANGED
@@ -160,17 +160,17 @@
160
160
  elOn(el, "pointerdown", function(e) {
161
161
  drag = true
162
162
  load()
163
- var tmp = el.getBoundingClientRect()
164
- offset = tmp.left + El.scrollLeft() + knobLen
165
- var next, i
163
+ var tmp = El.rect(el)
164
+ offset = tmp.left + El.scroll().x + knobLen
165
+ var next, i = 0
166
166
  , x = maxPx
167
167
  , diff = e.pageX - offset
168
- for (i = 0; i < fills.length; i++) {
168
+ for (; i < fills.length; i++) {
169
169
  next = diff - fills[i].offsetWidth + knobLen
170
- if (next < 0 ? -next <= x : next < x) {
170
+ if ((next < 0 ? next*=-1 : next) <= x) {
171
171
  idx = i
172
172
  fill = fills[i]
173
- x = next < 0 ? -next : next
173
+ x = next
174
174
  }
175
175
  }
176
176
  tmp = offset - e.pageX + (values[idx]-min||0)*px
@@ -185,9 +185,9 @@
185
185
  emit(e)
186
186
  return El.stop(e)
187
187
  }
188
- function stop(e) {
188
+ function stop() {
189
189
  if (drag) {
190
- drag = false
190
+ drag = 0
191
191
  listen(elOff)
192
192
  setVal(idx, values[idx])
193
193
  }
package/el/sortable.ui ADDED
@@ -0,0 +1,85 @@
1
+
2
+ %css
3
+ .sortable{margin:-8px}
4
+ .sortable:after{content:"";display:block;clear:both;}
5
+ .sortItem{padding:8px 12px;background:#f5f5f5;border:1px solid #ddd;border-radius:4px;}
6
+ .is-dragging{box-shadow:0 4px 12px rgba(0,0,0,.3);cursor:grabbing;z-index:2;position:relative;pointer-events:none;}
7
+ .grip{font-size:2em;cursor:grab;float:left;}
8
+ .is-active{outline:2px dashed #4a90d9;position:relative;z-index:1;perspective:1000px;}
9
+
10
+ %js
11
+ var closest = El.closest, cls = El.cls, css = El.css
12
+ $ui.on("dragSort", function(e0, handle, sel, cols) {
13
+ var mode = e0.mode
14
+ , el = e0.el
15
+ , item = closest(handle, sel)
16
+ if (!item) return
17
+ var items = El.flip(el, sel)
18
+ , fromIdx = items.indexOf(item)
19
+ , toIdx = fromIdx
20
+ , fromCol = cols && item.parentNode
21
+ , toCol = fromCol
22
+ , flipSel = cols ? sel + "," + cols : sel
23
+ e0.left = items[fromIdx + 1].left
24
+ e0.top = items[fromIdx + 1].top
25
+ cls(item, "is-dragging")
26
+ cls(el, "no-select")
27
+ cls(toCol, "is-active")
28
+ El.on(el, mode, move)
29
+ El.on(el, mode + "end", end)
30
+ function move(e) {
31
+ if (!item) return
32
+ El.stop(e)
33
+ var dist, dx, dy
34
+ , i = items.length
35
+ , idx = toIdx
36
+ , min = Infinity
37
+ , col = cols && closest(document.elementFromPoint(e.clientX, e.clientY), cols)
38
+ if (col && col !== toCol) {
39
+ cls(col, "is-active", toCol)
40
+ toCol = col
41
+ if (!$ui.$(sel, col)) idx = -1
42
+ }
43
+ if (idx > -1) for (; i > 0; i -= 2) {
44
+ if (cols && items[i - 2].parentNode !== (col || toCol)) continue
45
+ dx = e.ex - items[i - 1].left
46
+ dy = e.ey - items[i - 1].top
47
+ dist = dx * dx + dy * dy
48
+ if (dist < min) {
49
+ min = dist
50
+ idx = i - 2
51
+ }
52
+ }
53
+ dx = dy = 0
54
+ if (idx - toIdx) {
55
+ items = El.flip(el, flipSel, function() {
56
+ if (idx < 0) return col.appendChild(item)
57
+ var target = items[idx]
58
+ , rect = items[idx + 1]
59
+ , after = col && target.parentNode !== item.parentNode ? e.ey > rect.top : toIdx < idx
60
+ target.parentNode.insertBefore(item, after ? target.nextSibling : target)
61
+ }, { skip: item, height: 1 })
62
+ toIdx = items.indexOf(item)
63
+ dx = e0.left - items[toIdx + 1].left
64
+ dy = e0.top - items[toIdx + 1].top
65
+ e0.x0 -= dx
66
+ e0.y0 -= dy
67
+ e0.left -= dx
68
+ e0.top -= dy
69
+ }
70
+ css(item, "transform", "translate3d(" + (e.dx + dx) + "px," + (e.dy + dy) + "px,20px)")
71
+ }
72
+ function end() {
73
+ if (item) {
74
+ El.off(el, mode, move)
75
+ El.off(el, mode + "end", end)
76
+ cls(el, "no-select", 0)
77
+ cls(item, "anim,is-dragging", 1, 0, -1)
78
+ cls(toCol, "is-active", 0, 350)
79
+ css(item, "transform", "")
80
+ css(item, "box-shadow", "0 0 0 rgba(0,0,0,0)",0,-2)
81
+ if (fromIdx - toIdx || fromCol !== toCol) El.emit(el, "sorted")
82
+ item = null
83
+ }
84
+ }
85
+ })
package/load.js CHANGED
@@ -169,7 +169,7 @@
169
169
  )
170
170
  /*** ie9 ***/
171
171
  // ActiveXObject does not accept `null` for onreadystatechange
172
- req.onreadystatechange = next = nop
172
+ req.onreadystatechange = req.onabort = req.onerror = req.ontimeout = next = nop
173
173
  xhrs.push(req)
174
174
  /*/
175
175
  req.onreadystatechange = next = null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litejs/ui",
3
- "version": "26.3.0",
3
+ "version": "26.8.0",
4
4
  "description": "UI engine for LiteJS full-stack framework",
5
5
  "license": "MIT",
6
6
  "author": "Lauri Rooden <lauri@rooden.ee>",
@@ -27,6 +27,6 @@
27
27
  "test": "lj t test/index.js"
28
28
  },
29
29
  "devDependencies": {
30
- "@litejs/cli": "26.2.3"
30
+ "@litejs/cli": "26.6.0"
31
31
  }
32
32
  }
package/shim.js CHANGED
@@ -35,6 +35,7 @@
35
35
  /*** debug ***/
36
36
  , IS_NODE = !window.document
37
37
  , document = patch("document", {body:{},documentElement:{}})
38
+ , history = patch("history", {})
38
39
  , location = patch("location", {href:""})
39
40
  , navigator = patch("navigator", {})
40
41
  /*/
@@ -42,7 +43,6 @@
42
43
  , IS_NODE = false
43
44
  /**/
44
45
  , html = document.documentElement
45
- , body = document.body
46
46
  // JScript engine in IE<9 does not recognize vertical tabulation character
47
47
  // The documentMode is an IE only property, supported from IE8
48
48
  , a = document.documentMode | 0
@@ -52,7 +52,6 @@
52
52
  /* node:coverage ignore next 19 */
53
53
  , ie678 = !+"\v1" && a < 9 // jshint ignore:line
54
54
  , ie6789 = ie678 || a == 9
55
- , ie67 = ie678 && a < 8
56
55
  , EV = "Event"
57
56
  , Event = patch(
58
57
  EV,
@@ -103,8 +102,8 @@
103
102
  c: "touchcancel"
104
103
  }
105
104
 
106
- , lastHash
107
- , onhashchange = "onhashchange"
105
+ , lastHref
106
+ , onpopstate = "onpopstate"
108
107
 
109
108
 
110
109
  // Patch parameters support for setTimeout callback
@@ -120,13 +119,13 @@
120
119
  // window.msRequestAnimationFrame || // IE 10 PP2+
121
120
  patch("cancel" + a, "clearTimeout(a)")
122
121
 
123
-
124
122
  /* node:coverage ignore next 8 */
125
- if (!IS_NODE && !(onhashchange in window) || ie67) {
126
- patch(onhashchange, NULL)
123
+ if (!IS_NODE && !(onpopstate in window)) {
124
+ patch(onpopstate, NULL)
127
125
  setInterval(function() {
128
- if (lastHash !== (lastHash = location.href.split("#")[1]) && isFn(window[onhashchange])) {
129
- window[onhashchange]()
126
+ if (isFn(window[onpopstate]) && lastHref !== (lastHref = "" + location)) {
127
+ window[onpopstate]()
128
+ scroll(0, 0)
130
129
  }
131
130
  }, 60)
132
131
  }
@@ -335,8 +334,16 @@
335
334
  // Chrome7, FF4, IE9, Opera 11.60, Safari 5.1.4
336
335
  patch("bind", "b=S.call(A,1);c=function(){return t.apply(this instanceof c?this:a,b.concat(S.call(arguments)))};if(t[P])c[P]=t[P];return c")
337
336
 
337
+ O = history
338
+ a = "replace"
339
+ b = "State"
340
+ c = "location[X](c)"
341
+ patch(a + b, c, 0, a)
342
+ a = "assign"
343
+ patch("push" + b, c, 0, a)
344
+
338
345
  O = Object
339
- patch("assign", "for(var k,i=1,l=A.length;i<l;)if(t=A[i++])for(k in t)if(o.call(t,k))a[k]=t[k];return a")
346
+ patch(a, "for(var k,i=1,l=A.length;i<l;)if(t=A[i++])for(k in t)if(o.call(t,k))a[k]=t[k];return a")
340
347
  patch("create", "X[P]=a||Y;return new X", 0, nop, {
341
348
  // oKeys is undefined at this point
342
349
  constructor: oKeys,
@@ -424,6 +431,9 @@
424
431
  return false
425
432
  })
426
433
 
434
+ O = document
435
+ var scrollEl = patch("scrollingElement", (document.compatMode === "CSS1Compat" ? html : document.body))
436
+
427
437
  // The HTML5 document.head DOM tree accessor
428
438
  // patch("head", document.getElementsByTagName("head")[0])
429
439
  // HTMLElement (IE9) -> Element (IE8)
@@ -433,12 +443,12 @@
433
443
  , selectorLastRe = /([\s>+~]*)(?:("|')(?:\\.|[^\\])*?\2|\((?:[^()]|\([^()]+\))+?\)|~=|[^'"()\s>+~])+$/
434
444
  , selectorSplitRe = /\s*,\s*(?=(?:[^'"()]|"(?:\\.|[^\\"])*?"|'(?:\\.|[^\\'])*?'|\((?:[^()]|\([^()]+\))+?\))+$)/
435
445
  , selectorMap = {
436
- "empty": "!_.lastChild",
437
- "enabled": "!m(_,':disabled')",
446
+ empty: "!_.lastChild",
447
+ enabled: "!m(_,':disabled')",
438
448
  "first-child": "(a=_.parentNode)&&a.firstChild==_",
439
- "lang": "m(c(_,'[lang]'),'[lang|='+v+']')",
449
+ lang: "m(c(_,'[lang]'),'[lang|='+v+']')",
440
450
  "last-child": "(a=_.parentNode)&&a.lastChild==_",
441
- "link": "m(_,'a[href]')",
451
+ link: "m(_,'a[href]')",
442
452
  "only-child": "(a=_.parentNode)&&a.firstChild==a.lastChild",
443
453
  ".": "~_.className.split(/\\s+/).indexOf(a)",
444
454
  "#": "_.id==a",
@@ -455,11 +465,11 @@
455
465
  , matches = patch("matches", "return!!X(a)(t)", 0, selectorFn)
456
466
 
457
467
  /* node:coverage ignore next 13 */
468
+ b = "removeEventListener"
458
469
  try {
459
470
  O[a = "addEventListener"]("t", NULL, Object.defineProperties({}, {
460
471
  capture: { get: function() { canCapture = 1 } }
461
472
  }))
462
- b = "removeEventListener"
463
473
  c = "O.call(t,a,b,X(c)?!!c.capture:!!c)"
464
474
  if (!canCapture) {
465
475
  patch("c:" + a, c, 1, isObj)
@@ -474,8 +484,8 @@
474
484
  return function() {
475
485
  var e = new Event(ev)
476
486
  if (e.clientX !== UNDEF) {
477
- e.pageX = e.clientX + (window.pageXOffset || html.scrollLeft || body.scrollLeft || 0)
478
- e.pageY = e.clientY + (window.pageYOffset || html.scrollTop || body.scrollTop || 0)
487
+ e.pageX = e.clientX + (window.pageXOffset || scrollEl.scrollLeft)
488
+ e.pageY = e.clientY + (window.pageYOffset || scrollEl.scrollTop)
479
489
  }
480
490
  fn.call(el, e)
481
491
  }