@litejs/ui 22.12.0 → 23.3.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/index.js CHANGED
@@ -1,509 +1,5 @@
1
- /*
2
- * @version 22.12.0
3
- * @author Lauri Rooden <lauri@rooden.ee>
4
- * @license MIT License
5
- */
6
-
7
-
8
-
9
- !function(Date, proto) {
10
- var Date$prototype = Date[proto]
11
- , String$prototype = String[proto]
12
- , Number$prototype = Number[proto]
13
- , maskRe = /(\[)((?:\\?.)*?)\]|([YMD])\3\3\3?|([YMDHhmsWSZ])(\4?)|[uUASwoQ]|(["\\\n\r\u2028\u2029])/g
14
- , dateRe = /(\d+)[-.\/](\d+)[-.\/](\d+)/
15
- , timeRe = /(\d+):(\d+)(?::(\d+))?(\.\d+)?(?:\s*(?:(a)|(p))\.?m\.?)?(\s*(?:Z|GMT|UTC)?(?:([-+]\d\d):?(\d\d)?)?)?/i
16
- , fns = Object.create(null)
17
- , aliases = {
18
- sec: "s",
19
- second: "s",
20
- seconds: "s",
21
- min: "m",
22
- minute: "m",
23
- minutes: "m",
24
- hr: "h",
25
- hour: "h",
26
- hours: "h",
27
- day: "D",
28
- days: "D",
29
- week: "W",
30
- weeks: "W",
31
- month: "M",
32
- months: "M",
33
- year: "Y",
34
- years: "Y"
35
- }
36
- , units = {
37
- S: 1,
38
- s: 1000,
39
- m: 60000,
40
- h: 3600000,
41
- D: 86400000,
42
- W: 604800000
43
- }
44
- , tmp1 = new Date()
45
- , tmp2 = new Date()
46
- , sinceFrom = new Date()
47
- , map = Date.fnMap = {
48
- w: "Day()||7",
49
- Y: "FullYear()%100",
50
- M: "Month()+1",
51
- D: "Date()",
52
- h: "Hours()",
53
- H: "Hours()%12||12",
54
- m: "Minutes()",
55
- s: "Seconds()",
56
- S: "Milliseconds()"
57
- }
58
- , locales = Date.locales = {
59
- en: {
60
- am: "AM",
61
- pm: "PM",
62
- names: "JanFebMarAprMayJunJulAugSepOctNovDecJanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecemberSunMonTueWedThuFriSatSundayMondayTuesdayWednesdayThursdayFridaySaturday".match(/.[a-z]+/g),
63
- masks: {
64
- LT: "hh:mm",
65
- LTS: "hh:mm:ss",
66
- L: "DD/MM/YYYY",
67
- LL: "D MMMM YYYY",
68
- LLL: "D MMMM YYYY hh:mm",
69
- LLLL: "DDDD, D MMMM YYYY hh:mm"
70
- }
71
- }
72
- }
73
- , masks = Date.masks = {
74
- "iso": "UTC:YYYY-MM-DD[T]hh:mm:ss[Z]"
75
- }
76
-
77
-
78
- Date.makeStr = makeStr
79
- function makeStr(mask, utc) {
80
- var get = "d.get" + (utc ? "UTC" : "")
81
- , setA = "a.setTime(+d+((4-(" + get + map.w + "))*864e5))"
82
- return (utc ? mask.slice(4) : mask).replace(maskRe, function(match, quote, text, MD, single, pad, esc) {
83
- var str = (
84
- esc ? escape(esc).replace(/%u/g, "\\u").replace(/%/g, "\\x") :
85
- quote ? text :
86
- MD == "Y" ? get + "FullYear()" :
87
- MD ? "l.names[" + get + (MD == "M" ? "Month" : "Day" ) + "()+" + (match == "DDD" ? 24 : MD == "D" ? 31 : match == "MMM" ? 0 : 12) + "]" :
88
- match == "u" ? "(d/1000)>>>0" :
89
- match == "U" ? "+d" :
90
- match == "Q" ? "((" + get + "Month()/3)|0)+1" :
91
- match == "A" ? "l[" + get + map.h + ">11?'pm':'am']" :
92
- match == "o" ? setA + ",a" + get.slice(1) + "FullYear()" :
93
- single == "Z" ? "(t=o)?(t<0?((t=-t),'-'):'+')+(t<600?'0':'')+(0|(t/60))" + (pad ? "" : "+':'") + "+((t%=60)>9?t:'0'+t):'Z'" :
94
- single == "W" ? "Math.ceil(((" + setA + "-a.s" + get.slice(3) + "Month(0,1))/864e5+1)/7)" :
95
- get + map[single || match]
96
- )
97
- return quote || esc ? str : '"+(' + (
98
- match == "SS" ? "(t=" + str + ")>9?t>99?t:'0'+t:'00'+t" :
99
- pad && single != "Z" ? "(t=" + str + ")>9?t:'0'+t" :
100
- str
101
- ) + ')+"'
102
- })
103
- }
104
-
105
- Date$prototype.date = function(_mask, _zone) {
106
- var offset, undef
107
- , date = this
108
- , locale = locales[date._locale || Date._locale || "en"] || locales.en
109
- , mask = locale.masks && locale.masks[_mask] || masks[_mask] || _mask || masks.iso
110
- , zone = _zone != undef ? _zone : date._tz != undef ? date._tz : Date._tz != undef ? Date._tz : undef
111
- , utc = mask.slice(0, 4) == "UTC:"
112
- if (zone != undef && !utc) {
113
- offset = 60 * zone
114
- tmp1.setTime(+date + offset * 6e4)
115
- utc = mask = "UTC:" + mask
116
- } else {
117
- offset = utc ? 0 : -date.getTimezoneOffset()
118
- tmp1.setTime(+date)
119
- }
120
- return isNaN(+date) ? "" + date : (
121
- fns[mask] || (fns[mask] = Function("d,a,o,l", 'var t;return "' + makeStr(mask, utc) + '"')))(
122
- tmp1,
123
- tmp2,
124
- offset,
125
- locale
126
- )
127
- }
128
-
129
- addFn("add", function(amount, _unit, mask) {
130
- var date = this
131
- , unit = aliases[_unit] || _unit
132
- if (unit == "M" || unit == "Y" && (amount *= 12)) {
133
- unit = date.getUTCDate()
134
- date.setUTCMonth(date.getUTCMonth() + amount)
135
- if (unit > (unit = date.getUTCDate())) {
136
- date.add(-unit, "D")
137
- }
138
- } else if (amount) {
139
- date.setTime(date.getTime() + (amount * (units[unit] || 1)))
140
- }
141
- return mask ? date.date(mask) : date
142
- })
143
-
144
- addFn("startOf", function(_unit, mask) {
145
- var ms
146
- , date = this
147
- , unit = aliases[_unit] || _unit
148
- , zone = date._tz != ms ? date._tz : Date._tz != ms ? Date._tz : ms
149
- if (unit == "Y") {
150
- if (zone === 0) date.setUTCMonth(0, 1)
151
- else date.setMonth(0, 1)
152
- unit = "D"
153
- } else if (unit == "M") {
154
- if (zone === 0) date.setUTCDate(1)
155
- else date.setDate(1)
156
- unit = "D"
157
- } else if (unit == "W") {
158
- ms = date.getDay()
159
- if (ms != 1) date.setHours(-24 * (ms ? ms - 1 : 6))
160
- unit = "D"
161
- }
162
- zone = zone < 36 ? 3600000 * zone : -date.getTimezoneOffset() * 60000
163
- ms = date.getTime() + zone
164
- date.setTime(
165
- ms -
166
- (ms % (units[unit] || 1)) -
167
- zone
168
- )
169
- return mask ? date.date(mask) : date
170
- })
171
-
172
- addFn("endOf", function(unit, mask) {
173
- return this.add(1, unit).startOf(unit).add(-1, "S", mask)
174
- })
175
-
176
- addFn("since", function(from, _unit) {
177
- var diff
178
- , date = this
179
- , unit = aliases[_unit] || _unit
180
- if (typeof from == "string") {
181
- from = aliases[from] ? (sinceFrom.setTime(+date), sinceFrom.tz(date._tz).startOf(from)) : from.date()
182
- }
183
- if (units[unit]) {
184
- diff = (date - from) / units[unit]
185
- } else {
186
- diff = date.since("month", "S") - from.since("month", "S")
187
- if (diff) {
188
- tmp1.setTime(+date)
189
- diff /= units.D * tmp1.endOf("M").getUTCDate()
190
- }
191
- diff += 12 * (date.getUTCFullYear() - from.getUTCFullYear()) + date.getUTCMonth() - from.getUTCMonth()
192
- if (unit == "Y") {
193
- diff /= 12
194
- }
195
- }
196
-
197
- return diff
198
- })
199
-
200
- //*/
201
-
1
+ /*! litejs.com/MIT-LICENSE.txt */
202
2
 
203
- /*
204
- * // In Chrome Date.parse("01.02.2001") is Jan
205
- * num = +date || Date.parse(date) || ""+date;
206
- */
207
-
208
- String$prototype.date = function(mask, zoneOut, zoneIn) {
209
- var undef, date, match, year, month
210
- , str = this
211
- if (isNaN(+str)) {
212
- if (match = str.match(dateRe)) {
213
- // Big endian date, starting with the year, eg. 2011-01-31
214
- // Middle endian date, starting with the month, eg. 01/31/2011
215
- // Little endian date, starting with the day, eg. 31.01.2011
216
- year = match[1] > 99 ? 1 : 3
217
- month = Date.middleEndian ? 4 - year : 2
218
- date = new Date(match[year], match[month] - 1, match[6 - month - year])
219
- } else {
220
- date = new Date()
221
- }
222
-
223
- // Time
224
- match = str.match(timeRe) || [0, 0, 0]
225
- date.setHours(
226
- match[6] && match[1] < 12 ? +match[1] + 12 :
227
- match[5] && match[1] == 12 ? 0 : match[1],
228
- match[2], match[3]|0, (1000 * match[4])|0
229
- )
230
-
231
- // Timezone
232
- if (match[7]) {
233
- zoneIn = (match[8]|0) + ((match[9]|0)/(match[8]<0?-60:60))
234
- }
235
-
236
- if (zoneIn != undef) {
237
- date.tz(zoneIn)
238
- date.setTime(date - (60 * zoneIn + date.getTimezoneOffset()) * 60000)
239
- }
240
- return mask ? date.date(mask, zoneOut) : date
241
- }
242
- return (+str).date(mask, zoneOut, zoneIn)
243
- }
244
-
245
- Number$prototype.date = function(mask, zoneOut, zoneIn) {
246
- var date
247
- , num = this
248
- if (num < 4294967296) num *= 1000
249
- date = new Date(
250
- zoneIn != date ?
251
- tmp1.setTime(num) - (60 * zoneIn + tmp1.getTimezoneOffset()) * 60000 :
252
- num
253
- )
254
-
255
- return mask ? date.date(mask, zoneOut) : date
256
- }
257
-
258
- function addFn(method, fn) {
259
- Date$prototype[method] = fn
260
- String$prototype[method] = Number$prototype[method] = function(a, b, c) {
261
- return this.date()[method](a, b, c)
262
- }
263
- }
264
-
265
- function makeSetter(method) {
266
- Date[method] = Date$prototype[method] = function(value, mask) {
267
- var date = this
268
- date["_" + method] = value
269
- return mask ? date.date(mask) : date
270
- }
271
- }
272
-
273
- makeSetter("tz")
274
- makeSetter("locale")
275
- }(Date, "prototype")
276
- !function(F, undef) {
277
- // Time to live - Run *onTimeout* if Function not called on time
278
- F.ttl = function(ms, onTimeout, scope) {
279
- var fn = this
280
- , tick = setTimeout(function() {
281
- ms = 0
282
- if (onTimeout) onTimeout.call(scope)
283
- }, ms)
284
-
285
- return function() {
286
- clearTimeout(tick)
287
- if (ms) fn.apply(scope === undef ? this : scope, arguments)
288
- }
289
- }
290
-
291
- // Run Function one time after last call
292
- F.once = function(ms, scope) {
293
- var tick, args
294
- , fn = this
295
- return function() {
296
- if (scope === undef) scope = this
297
- clearTimeout(tick)
298
- args = arguments
299
- tick = setTimeout(function() {
300
- fn.apply(scope, args)
301
- }, ms)
302
- }
303
- }
304
-
305
- // Maximum call rate for Function
306
- // leading edge, trailing edge
307
- F.rate = function(ms, last_call, scope) {
308
- var tick, args
309
- , fn = this
310
- , next = 0
311
- if (last_call && typeof last_call !== "function") last_call = fn
312
- return function() {
313
- if (scope === undef) scope = this
314
- var now = Date.now()
315
- clearTimeout(tick)
316
- if (now >= next) {
317
- next = now + ms
318
- fn.apply(scope, arguments)
319
- } else if (last_call) {
320
- args = arguments
321
- tick = setTimeout(function() {
322
- last_call.apply(scope, args)
323
- }, next - now)
324
- }
325
- }
326
- }
327
- }(Function.prototype)
328
- !function(exports, Object) {
329
- var undef
330
- , P = "prototype"
331
- , A = Array[P]
332
- , S = String[P]
333
- , N = Number[P]
334
- , slice = Function[P].call.bind(A.slice)
335
- , fns = {}
336
- , hasOwn = fns.hasOwnProperty
337
- , fnRe = /('|")(?:\\?.)*?\1|\/(?:\\?.)+?\/[gim]*|\b(?:false|in|new|null|this|true|typeof|void|function|var|if|else|return)\b|\.\w+|\w+:/g
338
- , formatRe = /{(?!\\)((?:("|')(?:\\?.)*?\2|\\}|[^}])*)}/g
339
- , numbersRe = /-?\d+\.?\d*/g
340
- , wordRe = /\b[a-z_$][\w$]*/ig
341
- , unescapeRe = /{\\/g
342
-
343
-
344
- exports.Fn = Fn
345
- Fn.hold = hold
346
- Fn.wait = wait
347
-
348
-
349
- // Non-standard
350
- Object.each = function(obj, fn, scope, key) {
351
- if (obj) for (key in obj) {
352
- hasOwn.call(obj, key) && fn.call(scope, obj[key], key, obj)
353
- }
354
- }
355
-
356
- // Non-standard
357
- // IE<9 bug: [1,2].splice(0).join("") == "" but should be "12"
358
- A.remove = arrayRemove
359
- function arrayRemove() {
360
- var arr = this
361
- , len = arr.length
362
- , o = slice(arguments)
363
- , lastId = -1
364
-
365
- for (; len--; ) if (~o.indexOf(arr[len])) {
366
- arr.splice(lastId = len, 1)
367
- }
368
- return lastId
369
- }
370
-
371
- A.each = A.forEach
372
- // uniq
373
- // first item preserved
374
- A.uniq = function() {
375
- for (var a = this, i = a.length; i--; ) {
376
- if (a.indexOf(a[i]) !== i) a.splice(i, 1)
377
- }
378
- return a
379
- }
380
-
381
- A.pushUniq = function(item) {
382
- return this.indexOf(item) < 0 && this.push(item)
383
- }
384
-
385
- A.pluck = function(name) {
386
- for (var arr = this, i = arr.length, out = []; i--; ) {
387
- out[i] = arr[i][name]
388
- }
389
- return out
390
- }
391
-
392
- // THANKS: Oliver Steele - Functional Javascript [http://www.osteele.com/sources/javascript/functional/]
393
- function Fn(expr /*, scope, mask1, ..maskN */) {
394
- var args = []
395
- , arr = expr.match(/[^"']+?->|[\s\S]+$/g)
396
- , scope = slice(arguments, 1)
397
- , key = scope.length + ":" + expr
398
- , fn = fns[key]
399
-
400
- if (!fn) {
401
- fn = expr.replace(fnRe, "").match(wordRe) || []
402
- for (; arr.length > 1; ) {
403
- expr = arr.pop()
404
- args = arr.pop().match(/\w+/g) || []
405
- arrayRemove.apply(fn, args)
406
- if (arr.length) {
407
- arr.push("function(" + args + "){return(" + expr + ")}" + (scope[0] ? ".bind(this)" : ""))
408
- }
409
- }
410
- expr = "return(" + expr + ")"
411
-
412
- if (scope[0]) {
413
- arr = Object.keys(scope).map(Fn("a->'__'+a"))
414
- arr[0] = "this"
415
- expr = (
416
- fn[0] ?
417
- "var " + fn.uniq().join("='',") + "='';" :
418
- ""
419
- ) + "with(" + arr.join(")with(") + "){" + expr + "}"
420
- args = arr.slice(1).concat(args)
421
- }
422
-
423
- fn = fns[key] = Function(args, expr)
424
- }
425
-
426
- return scope.length ? fn.bind.apply(fn, scope) : fn
427
- }
428
-
429
- S.format = function() {
430
- var args = A.slice.call(arguments)
431
- args.unshift(0)
432
- return this.replace(formatRe, function(_, arg) {
433
- args[0] = arg.replace(/\\}/g, "}")
434
- return Fn.apply(null, args)()
435
- }).replace(unescapeRe, "{")
436
- }
437
-
438
- N.format = function(data) {
439
- return "" + this
440
- }
441
-
442
- N.step = function(a, add) {
443
- var x = ("" + a).split(".")
444
- , steps = this / a
445
- , n = ~~(steps + ((steps < 0 ? -1 : 1) * (add == undef ? .5 : add === 1 && steps == (steps|0) ? 0 : +add))) * a
446
- return "" + (1 in x ? n.toFixed(x[1].length) : n)
447
- }
448
-
449
- S.step = function(a, add) {
450
- return this.replace(numbersRe, function(num) {
451
- return (+num).step(a, add)
452
- })
453
- }
454
-
455
- function wait(fn) {
456
- var pending = 1
457
- function resume() {
458
- if (!--pending && fn) fn.call(this)
459
- }
460
- resume.wait = function() {
461
- pending++
462
- return resume
463
- }
464
- return resume
465
- }
466
-
467
- function hold(ignore) {
468
- var k
469
- , obj = this
470
- , hooks = []
471
- , hooked = []
472
- , _resume = wait(resume)
473
- ignore = ignore || obj.syncMethods || []
474
-
475
- for (k in obj) if (typeof obj[k] == "function" && ignore.indexOf(k) < 0) !function(k) {
476
- hooked.push(k, hasOwn.call(obj, k) && obj[k])
477
- obj[k] = function() {
478
- if (hooks === null) obj[k].apply(this, arguments)
479
- else hooks.push(k, arguments)
480
- return obj
481
- }
482
- }(k)
483
-
484
- /**
485
- * `wait` is already in hooked array,
486
- * so override hooked method
487
- * that will be cleared on resume.
488
- */
489
- obj.wait = _resume.wait
490
-
491
- return _resume
492
-
493
- function resume() {
494
- for (var v, scope = obj, i = hooked.length; i--; i--) {
495
- if (hooked[i]) obj[hooked[i-1]] = hooked[i]
496
- else delete obj[hooked[i-1]]
497
- }
498
- // i == -1 from previous loop
499
- for (; v = hooks[++i]; ) {
500
- scope = scope[v].apply(scope, hooks[++i]) || scope
501
- }
502
- hooks = hooked = null
503
- }
504
- }
505
-
506
- }(this, Object)
507
3
  !function(exports) {
508
4
  var empty = []
509
5
  , Event = exports.Event || exports
@@ -571,7 +67,7 @@
571
67
  , arr = _e ? (_e[type] || empty).concat(_e["*"] || empty) : empty
572
68
  if ((_e = arr.length)) {
573
69
  for (i = _e - 1, args = arr.slice.call(arguments, 1); i > 1; i -= 3) {
574
- arr[i] && arr[i].apply(arr[i - 2] || emitter, args)
70
+ if (arr[i]) arr[i].apply(arr[i - 2] || emitter, args)
575
71
  }
576
72
  }
577
73
  return _e / 3
@@ -600,6 +96,10 @@
600
96
 
601
97
  // `this` refers to the `window` in browser and to the `exports` in Node.js.
602
98
  }(this) // jshint ignore:line
99
+
100
+
101
+ /*! litejs.com/MIT-LICENSE.txt */
102
+
603
103
  /* litejs.com/MIT-LICENSE.txt */
604
104
 
605
105
 
@@ -620,7 +120,7 @@
620
120
  // In earlier versions, the expression "\v" === "v" returns true.
621
121
  // In Internet Explorer 9 standards mode, Internet Explorer 10 standards mode,
622
122
  // and win8_appname_long apps, the expression returns false.
623
- , ie6_7 = !+"\v1" && (document.documentMode | 0) < 8
123
+ , ie67 = !+"\v1" && (document.documentMode | 0) < 8 // jshint ignore:line
624
124
 
625
125
  function getUrl(_loc) {
626
126
  return (
@@ -696,18 +196,18 @@
696
196
  window.onpopstate = checkUrl
697
197
  } else
698
198
  /**/
699
- if ("onhashchange" in window && !ie6_7) {
199
+ if ("onhashchange" in window && !ie67) {
700
200
  // There are onhashchange in IE7 but its not get emitted
701
201
  //
702
202
  // Basic support:
703
203
  // Chrome 5.0, Firefox 3.6, IE 8, Opera 10.6, Safari 5.0
704
204
  window.onhashchange = checkUrl
705
205
  } else {
706
- if (ie6_7 && !iframe) {
206
+ if (ie67 && !iframe) {
707
207
  // IE<9 encounters the Mixed Content warning when the URI javascript: is used.
708
208
  // IE5/6 additionally encounters the Mixed Content warning when the URI about:blank is used.
709
209
  // src="//:"
710
- iframe = document.body.appendChild(document.createElement('<iframe style="display:none" tabindex="-1">')).contentWindow
210
+ iframe = document.body.appendChild(document.createElement("<iframe tabindex=-1 style=display:none>")).contentWindow
711
211
  }
712
212
  clearInterval(tick)
713
213
  tick = setInterval(function(){
@@ -715,17 +215,25 @@
715
215
  if (iframe && last === cur) cur = getUrl(iframe.location)
716
216
  if (last !== cur) {
717
217
  last = cur
718
- iframe ? setUrl(cur) : checkUrl()
218
+ if (iframe) setUrl(cur)
219
+ else checkUrl()
719
220
  }
720
221
  }, 60)
721
222
  }
722
223
  checkUrl()
723
224
  }
724
- }(this, document, history, location)
225
+ }(this, document, history, location) // jshint ignore:line
226
+
227
+
228
+
229
+
230
+ /*! litejs.com/MIT-LICENSE.txt */
231
+
725
232
  /* litejs.com/MIT-LICENSE.txt */
726
233
 
727
234
 
728
235
 
236
+ /* global El, xhr */
729
237
  !function(exports) {
730
238
  var fn, lastView, lastStr, lastUrl, syncResume
731
239
  , isArray = Array.isArray
@@ -796,8 +304,8 @@
796
304
  View.prototype = {
797
305
  show: function(_params) {
798
306
  var parent
799
- , params = lastParams = _params || {}
800
- , view = lastView = this
307
+ , params = lastParams = _params || {} // jshint ignore:line
308
+ , view = lastView = this // jshint ignore:line
801
309
  , tmp = params._v || view
802
310
  , close = view.isOpen && view
803
311
 
@@ -808,7 +316,7 @@
808
316
  emit(syncResume = params._v = tmp, "ping", params, View)
809
317
  syncResume = null
810
318
  if (lastParams !== params) return
811
- if (parent = tmp.parent) {
319
+ if ((parent = tmp.parent)) {
812
320
  if (parent.child && parent.child !== tmp) {
813
321
  close = parent.child
814
322
  }
@@ -836,7 +344,7 @@
836
344
  if (view !== close) emit(view, "change", close)
837
345
 
838
346
  for (tmp in params) if (tmp.charAt(0) !== "_") {
839
- if (syncResume = hasOwn.call(paramCb, tmp) && paramCb[tmp] || paramCb["*"]) {
347
+ if ((syncResume = hasOwn.call(paramCb, tmp)) && paramCb[tmp] || paramCb["*"]) {
840
348
  syncResume.call(view, params[tmp], tmp, params)
841
349
  syncResume = null
842
350
  }
@@ -878,10 +386,10 @@
878
386
  if (view.kb) El.addKb(view.kb)
879
387
  close = null
880
388
  }
881
- if (params._d = params._v = view.child) {
389
+ if ((params._d = params._v = view.child)) {
882
390
  bubbleDown(params, close)
883
391
  }
884
- if (lastView === view) {
392
+ if ((lastView === view)) {
885
393
  emit(view, "show", params)
886
394
  blur()
887
395
  }
@@ -935,20 +443,21 @@
935
443
  }
936
444
  }
937
445
 
938
- View.param = function(name, cb, re) {
446
+ View.param = function(name, cb) {
939
447
  ;(isArray(name) ? name : name.split(/\s+/)).forEach(function(n) {
940
448
  paramCb[n] = cb
941
449
  })
942
450
  }
943
451
 
944
452
  View.def = function(str) {
945
- for (var match, re = /(\S+) (\S+)/g; match = re.exec(str);) {
946
- match[1].split(",").map(function(view) {
947
- view = View(expand(view, lastStr))
948
- view.file = (view.file ? view.file + "," : "") +
949
- match[2].split(",").map(function(file) {
950
- return views[file] ? views[file].file : expand(file, lastStr)
951
- })
453
+ for (var match, re = /(\S+) (\S+)/g; (match = re.exec(str)); ) {
454
+ match[1].split(",").map(def)
455
+ }
456
+ function def(view) {
457
+ view = View(expand(view, lastStr))
458
+ view.file = (view.file ? view.file + "," : "") +
459
+ match[2].split(",").map(function(file) {
460
+ return views[file] ? views[file].file : expand(file, lastStr)
952
461
  })
953
462
  }
954
463
  }
@@ -976,10 +485,15 @@
976
485
  )
977
486
  }
978
487
 
979
- }(this)
488
+ }(this) // jshint ignore:line
489
+
490
+
491
+ /*! litejs.com/MIT-LICENSE.txt */
492
+
980
493
  /* litejs.com/MIT-LICENSE.txt */
981
494
 
982
495
 
496
+ /* global View, xhr */
983
497
  !function(window, document, Object, Event, P) {
984
498
  var UNDEF, styleNode
985
499
  , BIND_ATTR = "data-bind"
@@ -992,9 +506,9 @@
992
506
  , body = document.body
993
507
  , root = document.documentElement
994
508
  , txtAttr = El.T = "textContent" in body ? "textContent" : "innerText"
995
- , templateRe = /([ \t]*)(%?)((?:("|')(?:\\?.)*?\4|[-\w:.#[\]]=?)*)[ \t]*([>^;@|\\\/]|!?=|)(([\])}]?).*?([[({]?))(?=\x1f+|\n+|$)/g
996
- , renderRe = /[;\s]*(\w+)(?:(::?| )((?:(["'\/])(?:\\?.)*?\3|[^;])*))?/g
997
- , selectorRe = /([.#:[])([-\w]+)(?:\((.+?)\)|([~^$*|]?)=(("|')(?:\\?.)*?\6|[-\w]+))?]?/g
509
+ , templateRe = /([ \t]*)(%?)((?:("|')(?:\\\4|.)*?\4|[-\w:.#[\]]=?)*)[ \t]*([>^;@|\\\/]|!?=|)(([\])}]?).*?([[({]?))(?=\x1f|\n|$)+/g
510
+ , renderRe = /[;\s]*(\w+)(?:(::?| )((?:(["'\/])(?:\\\3|.)*?\3|[^;])*))?/g
511
+ , selectorRe = /([.#:[])([-\w]+)(?:\(((?:[^()]|\([^)]+\))+?)\)|([~^$*|]?)=(("|')(?:\\.|[^\\])*?\6|[-\w]+))?]?/g
998
512
  , splitRe = /[,\s]+/
999
513
  , camelRe = /\-([a-z])/g
1000
514
  , bindings = El.bindings = {
@@ -1054,7 +568,7 @@
1054
568
  /*** ie8 ***/
1055
569
 
1056
570
  // JScript engine in IE<9 does not recognize vertical tabulation character
1057
- , ie678 = !+"\v1"
571
+ , ie678 = !+"\v1" // jshint ignore:line
1058
572
  , ie67 = ie678 && (document.documentMode | 0) < 8
1059
573
 
1060
574
  El.matches = function(el, sel) {
@@ -1180,7 +694,7 @@
1180
694
  /*** ie8 ***/
1181
695
  // istanbul ignore next: IE fix
1182
696
  if (ie67 && (key === "id" || key === "name" || key === "checked")) {
1183
- el.mergeAttributes(document.createElement('<INPUT ' + key + '="' + val + '">'), false)
697
+ el.mergeAttributes(document.createElement("<INPUT " + key + "='" + val + "'>"), false)
1184
698
  } else
1185
699
  /**/
1186
700
  if (key === "class") {
@@ -1211,7 +725,7 @@
1211
725
  //
1212
726
  // Read-only checkboxes can be changed by the user
1213
727
 
1214
- for (opts = {}; input = el.elements[i++]; ) if (!input.disabled && (key = input.name || input.id)) {
728
+ for (opts = {}; (input = el.elements[i++]); ) if (!input.disabled && (key = input.name || input.id)) {
1215
729
  value = valFn(input)
1216
730
  if (value !== UNDEF) {
1217
731
  step = opts
@@ -1226,20 +740,22 @@
1226
740
  if (arguments.length > 1) {
1227
741
  if (opts) {
1228
742
  value = (isArray(val) ? val : [ val ]).map(String)
1229
- for (; input = opts[i++]; ) {
743
+ for (; (input = opts[i++]); ) {
1230
744
  input.selected = value.indexOf(input.value) > -1
1231
745
  }
1232
746
  } else if (el.val) {
1233
747
  el.val(val)
748
+ } else if (checkbox) {
749
+ el.checked = !!val
1234
750
  } else {
1235
- checkbox ? (el.checked = !!val) : (el.value = val)
751
+ el.value = val
1236
752
  }
1237
753
  return
1238
754
  }
1239
755
 
1240
756
  if (opts) {
1241
757
  if (type === "select-multiple") {
1242
- for (val = []; input = opts[i++]; ) {
758
+ for (val = []; (input = opts[i++]); ) {
1243
759
  if (input.selected && !input.disabled) {
1244
760
  val.push(input.valObject || input.value)
1245
761
  }
@@ -1282,7 +798,7 @@
1282
798
 
1283
799
  if (child.nodeType) {
1284
800
  tmp = el.insertBefore ? el : el[el.length - 1]
1285
- if (i = getAttr(tmp, "data-child")) {
801
+ if ((i = getAttr(tmp, "data-child"))) {
1286
802
  before = findCom(tmp, i) || tmp
1287
803
  tmp = before.parentNode
1288
804
  // TODO:2016-07-05:lauri:handle numeric befores
@@ -1322,6 +838,7 @@
1322
838
  })
1323
839
  return
1324
840
  }
841
+ var i
1325
842
  if (isObject(name)) {
1326
843
  for (i in name) {
1327
844
  if (hasOwn.call(name, i)) f(el, i, name[i], val)
@@ -1329,8 +846,8 @@
1329
846
  return
1330
847
  }
1331
848
  var names = isArray(name) ? name : name.split(splitRe)
1332
- , i = 0
1333
849
  , len = names.length
850
+ i = 0
1334
851
 
1335
852
  if (arguments.length < 3) {
1336
853
  if (getter) return getter(el, name)
@@ -1400,7 +917,7 @@
1400
917
  , prefix = window[addEv] ? "" : (addEv = "attachEvent", remEv = "detachEvent", "on")
1401
918
  , fixEv = Event.fixEv || (Event.fixEv = {})
1402
919
  , fixFn = Event.fixFn || (Event.fixFn = {})
1403
- , emitter = new Event.Emitter
920
+ , emitter = new Event.Emitter()
1404
921
 
1405
922
  if (iOS) {
1406
923
  // iOS doesn't support beforeunload, use pagehide instead
@@ -1497,12 +1014,12 @@
1497
1014
  return el
1498
1015
  }
1499
1016
 
1500
- El.emit = function(el, ev) {
1017
+ El.emit = function(el) {
1501
1018
  emitter.emit.apply(el, slice.call(arguments, 1))
1502
1019
  }
1503
1020
 
1504
1021
  function empty(el) {
1505
- for (var node; node = el.firstChild; kill(node));
1022
+ for (var node; (node = el.firstChild); kill(node));
1506
1023
  return el
1507
1024
  }
1508
1025
 
@@ -1545,7 +1062,7 @@
1545
1062
  }
1546
1063
 
1547
1064
  function closestScope(node) {
1548
- for (; node = node.parentNode; ) {
1065
+ for (; (node = node.parentNode); ) {
1549
1066
  if (node._scope) return elScope[node._scope]
1550
1067
  }
1551
1068
  }
@@ -1557,33 +1074,33 @@
1557
1074
  , i = 0
1558
1075
 
1559
1076
  if (node.nodeType != 1) {
1560
- node.render ? node.render(scope) : node
1077
+ if (node.render) node.render(scope)
1561
1078
  return
1562
1079
  }
1563
1080
 
1564
- if (bind = getAttr(node, BIND_ATTR)) {
1081
+ if ((bind = getAttr(node, BIND_ATTR))) {
1565
1082
  scope._m = bindMatch
1566
1083
  scope._t = bind
1567
1084
  // i18n(bind, lang).format(scope)
1568
1085
  // document.documentElement.lang
1569
1086
  // document.getElementsByTagName('html')[0].getAttribute('lang')
1570
1087
 
1571
- fn = "data b s B r->data&&(" + bind.replace(renderRe, function(match, name, op, args) {
1088
+ fn = "data&&(" + bind.replace(renderRe, function(match, name, op, args) {
1572
1089
  scope._m[i] = match
1573
1090
  match = bindings[name]
1574
1091
  return (
1575
1092
  (op === "::" || match && hasOwn.call(match, "once")) ?
1576
- "s(this,B,data._t=data._t.replace(data._m[" + (i++)+ "],''))||" :
1093
+ "s(n,B,data._t=data._t.replace(data._m[" + (i++)+ "],''))||" :
1577
1094
  ""
1578
1095
  ) + (
1579
1096
  match ?
1580
- "b['" + name + "'].call(data,this" + (match.raw ? ",'" + args + "'" : args ? "," + args : "") :
1581
- "s(this,'" + name + "'," + args
1097
+ "b['" + name + "'].call(data,n" + (match.raw ? ",'" + args + "'" : args ? "," + args : "") :
1098
+ "s(n,'" + name + "'," + args
1582
1099
  ) + ")||"
1583
1100
  }) + "r)"
1584
1101
 
1585
1102
  try {
1586
- if (Fn(fn, node, scope)(scope, bindings, setAttr, BIND_ATTR)) {
1103
+ if (Function("n,data,b,s,B,r", "with(data||{})return " + fn).call(node, node, scope, bindings, setAttr, BIND_ATTR)) {
1587
1104
  return
1588
1105
  }
1589
1106
  } catch (e) {
@@ -1612,7 +1129,9 @@
1612
1129
  El.kill = kill
1613
1130
  El.render = render
1614
1131
 
1615
- for (var key in El) !function(key) {
1132
+ for (var key in El) wrap(key)
1133
+
1134
+ function wrap(key) {
1616
1135
  wrapProto[key] = function wrap() {
1617
1136
  var i = 0
1618
1137
  , self = this
@@ -1625,7 +1144,7 @@
1625
1144
  }
1626
1145
  return self
1627
1146
  }
1628
- }(key)
1147
+ }
1629
1148
 
1630
1149
  wrapProto.append = function(el) {
1631
1150
  var elWrap = this
@@ -1659,6 +1178,7 @@
1659
1178
 
1660
1179
  for (q = indent.length; q <= stack[0]; ) {
1661
1180
  if (parent.plugin) {
1181
+ if (parent.plugin.content && !parent.plugin.el.childNodes[0]) break
1662
1182
  parent.plugin.done()
1663
1183
  }
1664
1184
  parent = parentStack.pop()
@@ -1693,8 +1213,8 @@
1693
1213
  text = text.replace(/(\w+):?/, "on:'$1',")
1694
1214
  } else if (op != ";" && op != "^") {
1695
1215
  text = (parent.tagName === "INPUT" ? "val" : "txt") + (
1696
- op === "=" ? ":" + text.replace(/'/g, "\\'") :
1697
- ":_('" + text.replace(/'/g, "\\'") + "', data)"
1216
+ op === "=" ? ":" + text.replace(/\\|'/g, "\\$&") :
1217
+ ":_('" + text.replace(/\\|'/g, "\\$&") + "',data)"
1698
1218
  )
1699
1219
  }
1700
1220
  appendBind(parent, text, ";", op)
@@ -1756,7 +1276,7 @@
1756
1276
  t.a = attr1
1757
1277
  }
1758
1278
 
1759
- js[P].done = Fn("Function(this.txt)()")
1279
+ js[P].done = Function("Function(this.txt)()")
1760
1280
 
1761
1281
  El.plugins = {
1762
1282
  binding: extend(js, {
@@ -1774,10 +1294,10 @@
1774
1294
  }
1775
1295
  }),
1776
1296
  css: extend(js, {
1777
- done: Fn("xhr.css(this.txt)")
1297
+ done: Function("xhr.css(this.txt)")
1778
1298
  }),
1779
1299
  def: extend(js, {
1780
- done: Fn("View.def(this.params||this.txt)")
1300
+ done: Function("View.def(this.params||this.txt)")
1781
1301
  }),
1782
1302
  each: extend(js, {
1783
1303
  done: function() {
@@ -1789,7 +1309,9 @@
1789
1309
  })
1790
1310
  }
1791
1311
  }),
1792
- el: plugin,
1312
+ el: extend(plugin, {
1313
+ content: 1,
1314
+ }),
1793
1315
  js: js,
1794
1316
  map: extend(js, {
1795
1317
  done: function() {
@@ -1802,8 +1324,8 @@
1802
1324
  )
1803
1325
  }
1804
1326
  }),
1805
- template: plugin,
1806
- view: extend(plugin,{
1327
+ view: extend(plugin, {
1328
+ content: 1,
1807
1329
  done: function() {
1808
1330
  var fn
1809
1331
  , t = this
@@ -1818,7 +1340,7 @@
1818
1340
  "=" + args
1819
1341
  ) + "),"
1820
1342
  }) + "1"
1821
- Fn(fn, view, scopeData)()
1343
+ Function(fn).call(view)
1822
1344
  }
1823
1345
  }
1824
1346
  }),
@@ -1882,7 +1404,8 @@
1882
1404
  map.bubble
1883
1405
  ););
1884
1406
  if (fn) {
1885
- isString(fn) ? View.emit(fn, e, chr, el) : fn(e, chr, el)
1407
+ if (isString(fn)) View.emit(fn, e, chr, el)
1408
+ else fn(e, chr, el)
1886
1409
  }
1887
1410
  }
1888
1411
 
@@ -1936,15 +1459,13 @@
1936
1459
  md: 601,
1937
1460
  lg: 1025
1938
1461
  }
1939
- , setBreakpointsRated = function() {
1940
- setBreakpoints()
1941
- }.rate(100, true)
1462
+ , setBreakpointsRated = rate(setBreakpoints, 100)
1942
1463
 
1943
1464
  function setBreakpoints(_breakpoints) {
1944
1465
  // document.documentElement.clientWidth is 0 in IE5
1945
1466
  var key, next
1946
1467
  , width = root.offsetWidth
1947
- , map = breakpoints = _breakpoints || breakpoints
1468
+ , map = breakpoints = _breakpoints || breakpoints // jshint ignore:line
1948
1469
 
1949
1470
  for (key in map) {
1950
1471
  if (map[key] > width) break
@@ -1963,7 +1484,7 @@
1963
1484
  cls(root, lastOrient = next)
1964
1485
  }
1965
1486
 
1966
- if (next = window.View) next.emit("resize")
1487
+ if ((next = window.View)) next.emit("resize")
1967
1488
  }
1968
1489
  El.setBreakpoints = setBreakpoints
1969
1490
 
@@ -1984,6 +1505,31 @@
1984
1505
  return wrapper
1985
1506
  }
1986
1507
 
1508
+ El.rate = rate
1509
+ // Maximum call rate for Function
1510
+ // leading edge, trailing edge
1511
+ function rate(fn, ms) {
1512
+ var tick
1513
+ , next = 0
1514
+ return function() {
1515
+ var now = Date.now()
1516
+ clearTimeout(tick)
1517
+ if (now >= next) {
1518
+ next = now + ms
1519
+ fn()
1520
+ } else {
1521
+ tick = setTimeout(fn, next - now)
1522
+ }
1523
+ }
1524
+ }
1525
+ El.step = step
1526
+ function step(num, factor, mid) {
1527
+ var x = ("" + factor).split(".")
1528
+ , steps = num / factor
1529
+ , n = ~~(steps + ((steps < 0 ? -1 : 1) * (mid == UNDEF ? 0.5 : mid === 1 && steps == (steps|0) ? 0 : +mid))) * factor
1530
+ return "" + (1 in x ? n.toFixed(x[1].length) : n)
1531
+ }
1532
+
1987
1533
  function isNumber(num) {
1988
1534
  return typeof num === "number"
1989
1535
  }
@@ -1995,4 +1541,5 @@
1995
1541
  function isString(str) {
1996
1542
  return typeof str === "string"
1997
1543
  }
1998
- }(window, document, Object, Event, "prototype")
1544
+ }(window, document, Object, Event, "prototype") // jshint ignore:line
1545
+