@litejs/ui 22.12.0 → 23.3.1

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,9 @@
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
+
603
102
  /* litejs.com/MIT-LICENSE.txt */
604
103
 
605
104
 
@@ -620,7 +119,7 @@
620
119
  // In earlier versions, the expression "\v" === "v" returns true.
621
120
  // In Internet Explorer 9 standards mode, Internet Explorer 10 standards mode,
622
121
  // and win8_appname_long apps, the expression returns false.
623
- , ie6_7 = !+"\v1" && (document.documentMode | 0) < 8
122
+ , ie67 = !+"\v1" && (document.documentMode | 0) < 8 // jshint ignore:line
624
123
 
625
124
  function getUrl(_loc) {
626
125
  return (
@@ -696,18 +195,18 @@
696
195
  window.onpopstate = checkUrl
697
196
  } else
698
197
  /**/
699
- if ("onhashchange" in window && !ie6_7) {
198
+ if ("onhashchange" in window && !ie67) {
700
199
  // There are onhashchange in IE7 but its not get emitted
701
200
  //
702
201
  // Basic support:
703
202
  // Chrome 5.0, Firefox 3.6, IE 8, Opera 10.6, Safari 5.0
704
203
  window.onhashchange = checkUrl
705
204
  } else {
706
- if (ie6_7 && !iframe) {
205
+ if (ie67 && !iframe) {
707
206
  // IE<9 encounters the Mixed Content warning when the URI javascript: is used.
708
207
  // IE5/6 additionally encounters the Mixed Content warning when the URI about:blank is used.
709
208
  // src="//:"
710
- iframe = document.body.appendChild(document.createElement('<iframe style="display:none" tabindex="-1">')).contentWindow
209
+ iframe = document.body.appendChild(document.createElement("<iframe tabindex=-1 style=display:none>")).contentWindow
711
210
  }
712
211
  clearInterval(tick)
713
212
  tick = setInterval(function(){
@@ -715,17 +214,24 @@
715
214
  if (iframe && last === cur) cur = getUrl(iframe.location)
716
215
  if (last !== cur) {
717
216
  last = cur
718
- iframe ? setUrl(cur) : checkUrl()
217
+ if (iframe) setUrl(cur)
218
+ else checkUrl()
719
219
  }
720
220
  }, 60)
721
221
  }
722
222
  checkUrl()
723
223
  }
724
- }(this, document, history, location)
224
+ }(this, document, history, location) // jshint ignore:line
225
+
226
+
227
+
228
+
229
+
725
230
  /* litejs.com/MIT-LICENSE.txt */
726
231
 
727
232
 
728
233
 
234
+ /* global El, xhr */
729
235
  !function(exports) {
730
236
  var fn, lastView, lastStr, lastUrl, syncResume
731
237
  , isArray = Array.isArray
@@ -796,8 +302,8 @@
796
302
  View.prototype = {
797
303
  show: function(_params) {
798
304
  var parent
799
- , params = lastParams = _params || {}
800
- , view = lastView = this
305
+ , params = lastParams = _params || {} // jshint ignore:line
306
+ , view = lastView = this // jshint ignore:line
801
307
  , tmp = params._v || view
802
308
  , close = view.isOpen && view
803
309
 
@@ -808,7 +314,7 @@
808
314
  emit(syncResume = params._v = tmp, "ping", params, View)
809
315
  syncResume = null
810
316
  if (lastParams !== params) return
811
- if (parent = tmp.parent) {
317
+ if ((parent = tmp.parent)) {
812
318
  if (parent.child && parent.child !== tmp) {
813
319
  close = parent.child
814
320
  }
@@ -836,7 +342,7 @@
836
342
  if (view !== close) emit(view, "change", close)
837
343
 
838
344
  for (tmp in params) if (tmp.charAt(0) !== "_") {
839
- if (syncResume = hasOwn.call(paramCb, tmp) && paramCb[tmp] || paramCb["*"]) {
345
+ if ((syncResume = hasOwn.call(paramCb, tmp) && paramCb[tmp] || paramCb["*"])) {
840
346
  syncResume.call(view, params[tmp], tmp, params)
841
347
  syncResume = null
842
348
  }
@@ -878,10 +384,10 @@
878
384
  if (view.kb) El.addKb(view.kb)
879
385
  close = null
880
386
  }
881
- if (params._d = params._v = view.child) {
387
+ if ((params._d = params._v = view.child)) {
882
388
  bubbleDown(params, close)
883
389
  }
884
- if (lastView === view) {
390
+ if ((lastView === view)) {
885
391
  emit(view, "show", params)
886
392
  blur()
887
393
  }
@@ -935,20 +441,21 @@
935
441
  }
936
442
  }
937
443
 
938
- View.param = function(name, cb, re) {
444
+ View.param = function(name, cb) {
939
445
  ;(isArray(name) ? name : name.split(/\s+/)).forEach(function(n) {
940
446
  paramCb[n] = cb
941
447
  })
942
448
  }
943
449
 
944
450
  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
- })
451
+ for (var match, re = /(\S+) (\S+)/g; (match = re.exec(str)); ) {
452
+ match[1].split(",").map(def)
453
+ }
454
+ function def(view) {
455
+ view = View(expand(view, lastStr))
456
+ view.file = (view.file ? view.file + "," : "") +
457
+ match[2].split(",").map(function(file) {
458
+ return views[file] ? views[file].file : expand(file, lastStr)
952
459
  })
953
460
  }
954
461
  }
@@ -976,10 +483,14 @@
976
483
  )
977
484
  }
978
485
 
979
- }(this)
486
+ }(this) // jshint ignore:line
487
+
488
+
489
+
980
490
  /* litejs.com/MIT-LICENSE.txt */
981
491
 
982
492
 
493
+ /* global View, xhr */
983
494
  !function(window, document, Object, Event, P) {
984
495
  var UNDEF, styleNode
985
496
  , BIND_ATTR = "data-bind"
@@ -992,9 +503,9 @@
992
503
  , body = document.body
993
504
  , root = document.documentElement
994
505
  , 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
506
+ , templateRe = /([ \t]*)(%?)((?:("|')(?:\\\4|.)*?\4|[-\w:.#[\]]=?)*)[ \t]*([>^;@|\\\/]|!?=|)(([\])}]?).*?([[({]?))(?=\x1f|\n|$)+/g
507
+ , renderRe = /[;\s]*(\w+)(?:(::?| )((?:(["'\/])(?:\\\3|.)*?\3|[^;])*))?/g
508
+ , selectorRe = /([.#:[])([-\w]+)(?:\(((?:[^()]|\([^)]+\))+?)\)|([~^$*|]?)=(("|')(?:\\.|[^\\])*?\6|[-\w]+))?]?/g
998
509
  , splitRe = /[,\s]+/
999
510
  , camelRe = /\-([a-z])/g
1000
511
  , bindings = El.bindings = {
@@ -1054,7 +565,7 @@
1054
565
  /*** ie8 ***/
1055
566
 
1056
567
  // JScript engine in IE<9 does not recognize vertical tabulation character
1057
- , ie678 = !+"\v1"
568
+ , ie678 = !+"\v1" // jshint ignore:line
1058
569
  , ie67 = ie678 && (document.documentMode | 0) < 8
1059
570
 
1060
571
  El.matches = function(el, sel) {
@@ -1180,7 +691,7 @@
1180
691
  /*** ie8 ***/
1181
692
  // istanbul ignore next: IE fix
1182
693
  if (ie67 && (key === "id" || key === "name" || key === "checked")) {
1183
- el.mergeAttributes(document.createElement('<INPUT ' + key + '="' + val + '">'), false)
694
+ el.mergeAttributes(document.createElement("<INPUT " + key + "='" + val + "'>"), false)
1184
695
  } else
1185
696
  /**/
1186
697
  if (key === "class") {
@@ -1211,7 +722,7 @@
1211
722
  //
1212
723
  // Read-only checkboxes can be changed by the user
1213
724
 
1214
- for (opts = {}; input = el.elements[i++]; ) if (!input.disabled && (key = input.name || input.id)) {
725
+ for (opts = {}; (input = el.elements[i++]); ) if (!input.disabled && (key = input.name || input.id)) {
1215
726
  value = valFn(input)
1216
727
  if (value !== UNDEF) {
1217
728
  step = opts
@@ -1226,20 +737,22 @@
1226
737
  if (arguments.length > 1) {
1227
738
  if (opts) {
1228
739
  value = (isArray(val) ? val : [ val ]).map(String)
1229
- for (; input = opts[i++]; ) {
740
+ for (; (input = opts[i++]); ) {
1230
741
  input.selected = value.indexOf(input.value) > -1
1231
742
  }
1232
743
  } else if (el.val) {
1233
744
  el.val(val)
745
+ } else if (checkbox) {
746
+ el.checked = !!val
1234
747
  } else {
1235
- checkbox ? (el.checked = !!val) : (el.value = val)
748
+ el.value = val
1236
749
  }
1237
750
  return
1238
751
  }
1239
752
 
1240
753
  if (opts) {
1241
754
  if (type === "select-multiple") {
1242
- for (val = []; input = opts[i++]; ) {
755
+ for (val = []; (input = opts[i++]); ) {
1243
756
  if (input.selected && !input.disabled) {
1244
757
  val.push(input.valObject || input.value)
1245
758
  }
@@ -1282,7 +795,7 @@
1282
795
 
1283
796
  if (child.nodeType) {
1284
797
  tmp = el.insertBefore ? el : el[el.length - 1]
1285
- if (i = getAttr(tmp, "data-child")) {
798
+ if ((i = getAttr(tmp, "data-child"))) {
1286
799
  before = findCom(tmp, i) || tmp
1287
800
  tmp = before.parentNode
1288
801
  // TODO:2016-07-05:lauri:handle numeric befores
@@ -1322,6 +835,7 @@
1322
835
  })
1323
836
  return
1324
837
  }
838
+ var i
1325
839
  if (isObject(name)) {
1326
840
  for (i in name) {
1327
841
  if (hasOwn.call(name, i)) f(el, i, name[i], val)
@@ -1329,8 +843,8 @@
1329
843
  return
1330
844
  }
1331
845
  var names = isArray(name) ? name : name.split(splitRe)
1332
- , i = 0
1333
846
  , len = names.length
847
+ i = 0
1334
848
 
1335
849
  if (arguments.length < 3) {
1336
850
  if (getter) return getter(el, name)
@@ -1400,7 +914,7 @@
1400
914
  , prefix = window[addEv] ? "" : (addEv = "attachEvent", remEv = "detachEvent", "on")
1401
915
  , fixEv = Event.fixEv || (Event.fixEv = {})
1402
916
  , fixFn = Event.fixFn || (Event.fixFn = {})
1403
- , emitter = new Event.Emitter
917
+ , emitter = new Event.Emitter()
1404
918
 
1405
919
  if (iOS) {
1406
920
  // iOS doesn't support beforeunload, use pagehide instead
@@ -1497,12 +1011,12 @@
1497
1011
  return el
1498
1012
  }
1499
1013
 
1500
- El.emit = function(el, ev) {
1014
+ El.emit = function(el) {
1501
1015
  emitter.emit.apply(el, slice.call(arguments, 1))
1502
1016
  }
1503
1017
 
1504
1018
  function empty(el) {
1505
- for (var node; node = el.firstChild; kill(node));
1019
+ for (var node; (node = el.firstChild); kill(node));
1506
1020
  return el
1507
1021
  }
1508
1022
 
@@ -1545,7 +1059,7 @@
1545
1059
  }
1546
1060
 
1547
1061
  function closestScope(node) {
1548
- for (; node = node.parentNode; ) {
1062
+ for (; (node = node.parentNode); ) {
1549
1063
  if (node._scope) return elScope[node._scope]
1550
1064
  }
1551
1065
  }
@@ -1557,33 +1071,33 @@
1557
1071
  , i = 0
1558
1072
 
1559
1073
  if (node.nodeType != 1) {
1560
- node.render ? node.render(scope) : node
1074
+ if (node.render) node.render(scope)
1561
1075
  return
1562
1076
  }
1563
1077
 
1564
- if (bind = getAttr(node, BIND_ATTR)) {
1078
+ if ((bind = getAttr(node, BIND_ATTR))) {
1565
1079
  scope._m = bindMatch
1566
1080
  scope._t = bind
1567
1081
  // i18n(bind, lang).format(scope)
1568
1082
  // document.documentElement.lang
1569
1083
  // document.getElementsByTagName('html')[0].getAttribute('lang')
1570
1084
 
1571
- fn = "data b s B r->data&&(" + bind.replace(renderRe, function(match, name, op, args) {
1085
+ fn = "data&&(" + bind.replace(renderRe, function(match, name, op, args) {
1572
1086
  scope._m[i] = match
1573
1087
  match = bindings[name]
1574
1088
  return (
1575
1089
  (op === "::" || match && hasOwn.call(match, "once")) ?
1576
- "s(this,B,data._t=data._t.replace(data._m[" + (i++)+ "],''))||" :
1090
+ "s(n,B,data._t=data._t.replace(data._m[" + (i++)+ "],''))||" :
1577
1091
  ""
1578
1092
  ) + (
1579
1093
  match ?
1580
- "b['" + name + "'].call(data,this" + (match.raw ? ",'" + args + "'" : args ? "," + args : "") :
1581
- "s(this,'" + name + "'," + args
1094
+ "b['" + name + "'].call(data,n" + (match.raw ? ",'" + args + "'" : args ? "," + args : "") :
1095
+ "s(n,'" + name + "'," + args
1582
1096
  ) + ")||"
1583
1097
  }) + "r)"
1584
1098
 
1585
1099
  try {
1586
- if (Fn(fn, node, scope)(scope, bindings, setAttr, BIND_ATTR)) {
1100
+ if (Function("n,data,b,s,B,r", "with(data||{})return " + fn).call(node, node, scope, bindings, setAttr, BIND_ATTR)) {
1587
1101
  return
1588
1102
  }
1589
1103
  } catch (e) {
@@ -1612,7 +1126,9 @@
1612
1126
  El.kill = kill
1613
1127
  El.render = render
1614
1128
 
1615
- for (var key in El) !function(key) {
1129
+ for (var key in El) wrap(key)
1130
+
1131
+ function wrap(key) {
1616
1132
  wrapProto[key] = function wrap() {
1617
1133
  var i = 0
1618
1134
  , self = this
@@ -1625,7 +1141,7 @@
1625
1141
  }
1626
1142
  return self
1627
1143
  }
1628
- }(key)
1144
+ }
1629
1145
 
1630
1146
  wrapProto.append = function(el) {
1631
1147
  var elWrap = this
@@ -1659,6 +1175,7 @@
1659
1175
 
1660
1176
  for (q = indent.length; q <= stack[0]; ) {
1661
1177
  if (parent.plugin) {
1178
+ if (parent.plugin.content && !parent.plugin.el.childNodes[0]) break
1662
1179
  parent.plugin.done()
1663
1180
  }
1664
1181
  parent = parentStack.pop()
@@ -1693,8 +1210,8 @@
1693
1210
  text = text.replace(/(\w+):?/, "on:'$1',")
1694
1211
  } else if (op != ";" && op != "^") {
1695
1212
  text = (parent.tagName === "INPUT" ? "val" : "txt") + (
1696
- op === "=" ? ":" + text.replace(/'/g, "\\'") :
1697
- ":_('" + text.replace(/'/g, "\\'") + "', data)"
1213
+ op === "=" ? ":" + text.replace(/\\|'/g, "\\$&") :
1214
+ ":_('" + text.replace(/\\|'/g, "\\$&") + "',data)"
1698
1215
  )
1699
1216
  }
1700
1217
  appendBind(parent, text, ";", op)
@@ -1756,7 +1273,7 @@
1756
1273
  t.a = attr1
1757
1274
  }
1758
1275
 
1759
- js[P].done = Fn("Function(this.txt)()")
1276
+ js[P].done = Function("Function(this.txt)()")
1760
1277
 
1761
1278
  El.plugins = {
1762
1279
  binding: extend(js, {
@@ -1774,10 +1291,10 @@
1774
1291
  }
1775
1292
  }),
1776
1293
  css: extend(js, {
1777
- done: Fn("xhr.css(this.txt)")
1294
+ done: Function("xhr.css(this.txt)")
1778
1295
  }),
1779
1296
  def: extend(js, {
1780
- done: Fn("View.def(this.params||this.txt)")
1297
+ done: Function("View.def(this.params||this.txt)")
1781
1298
  }),
1782
1299
  each: extend(js, {
1783
1300
  done: function() {
@@ -1789,7 +1306,9 @@
1789
1306
  })
1790
1307
  }
1791
1308
  }),
1792
- el: plugin,
1309
+ el: extend(plugin, {
1310
+ content: 1,
1311
+ }),
1793
1312
  js: js,
1794
1313
  map: extend(js, {
1795
1314
  done: function() {
@@ -1802,8 +1321,8 @@
1802
1321
  )
1803
1322
  }
1804
1323
  }),
1805
- template: plugin,
1806
- view: extend(plugin,{
1324
+ view: extend(plugin, {
1325
+ content: 1,
1807
1326
  done: function() {
1808
1327
  var fn
1809
1328
  , t = this
@@ -1818,7 +1337,7 @@
1818
1337
  "=" + args
1819
1338
  ) + "),"
1820
1339
  }) + "1"
1821
- Fn(fn, view, scopeData)()
1340
+ Function(fn).call(view)
1822
1341
  }
1823
1342
  }
1824
1343
  }),
@@ -1882,7 +1401,8 @@
1882
1401
  map.bubble
1883
1402
  ););
1884
1403
  if (fn) {
1885
- isString(fn) ? View.emit(fn, e, chr, el) : fn(e, chr, el)
1404
+ if (isString(fn)) View.emit(fn, e, chr, el)
1405
+ else fn(e, chr, el)
1886
1406
  }
1887
1407
  }
1888
1408
 
@@ -1936,15 +1456,13 @@
1936
1456
  md: 601,
1937
1457
  lg: 1025
1938
1458
  }
1939
- , setBreakpointsRated = function() {
1940
- setBreakpoints()
1941
- }.rate(100, true)
1459
+ , setBreakpointsRated = rate(setBreakpoints, 100)
1942
1460
 
1943
1461
  function setBreakpoints(_breakpoints) {
1944
1462
  // document.documentElement.clientWidth is 0 in IE5
1945
1463
  var key, next
1946
1464
  , width = root.offsetWidth
1947
- , map = breakpoints = _breakpoints || breakpoints
1465
+ , map = breakpoints = _breakpoints || breakpoints // jshint ignore:line
1948
1466
 
1949
1467
  for (key in map) {
1950
1468
  if (map[key] > width) break
@@ -1963,7 +1481,7 @@
1963
1481
  cls(root, lastOrient = next)
1964
1482
  }
1965
1483
 
1966
- if (next = window.View) next.emit("resize")
1484
+ if ((next = window.View)) next.emit("resize")
1967
1485
  }
1968
1486
  El.setBreakpoints = setBreakpoints
1969
1487
 
@@ -1984,6 +1502,31 @@
1984
1502
  return wrapper
1985
1503
  }
1986
1504
 
1505
+ El.rate = rate
1506
+ // Maximum call rate for Function
1507
+ // leading edge, trailing edge
1508
+ function rate(fn, ms) {
1509
+ var tick
1510
+ , next = 0
1511
+ return function() {
1512
+ var now = Date.now()
1513
+ clearTimeout(tick)
1514
+ if (now >= next) {
1515
+ next = now + ms
1516
+ fn()
1517
+ } else {
1518
+ tick = setTimeout(fn, next - now)
1519
+ }
1520
+ }
1521
+ }
1522
+ El.step = step
1523
+ function step(num, factor, mid) {
1524
+ var x = ("" + factor).split(".")
1525
+ , steps = num / factor
1526
+ , n = ~~(steps + ((steps < 0 ? -1 : 1) * (mid == UNDEF ? 0.5 : mid === 1 && steps == (steps|0) ? 0 : +mid))) * factor
1527
+ return "" + (1 in x ? n.toFixed(x[1].length) : n)
1528
+ }
1529
+
1987
1530
  function isNumber(num) {
1988
1531
  return typeof num === "number"
1989
1532
  }
@@ -1995,4 +1538,5 @@
1995
1538
  function isString(str) {
1996
1539
  return typeof str === "string"
1997
1540
  }
1998
- }(window, document, Object, Event, "prototype")
1541
+ }(window, document, Object, Event, "prototype") // jshint ignore:line
1542
+